Commit | Line | Data |
---|---|---|
9b254dd1 | 1 | # Copyright 1999, 2007, 2008 Free Software Foundation, Inc. |
104c1213 JM |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
104c1213 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
104c1213 JM |
8 | # This program is distributed in the hope that it will be useful, |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
e22f8b7c | 12 | # |
104c1213 | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
104c1213 JM |
15 | |
16 | # Please email any bugs, comments, and/or additions to this file to: | |
17 | # bug-gdb@prep.ai.mit.edu | |
18 | ||
19 | ||
20 | if $tracelevel then { | |
21 | strace $tracelevel | |
22 | } | |
23 | ||
24 | # | |
25 | # test running programs | |
26 | # | |
27 | set prms_id 0 | |
28 | set bug_id 0 | |
29 | ||
30 | set testfile "async" | |
31 | set srcfile ${testfile}.c | |
32 | set binfile ${objdir}/${subdir}/${testfile} | |
33 | ||
fc91c6c2 | 34 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { |
b60f0898 JB |
35 | untested async.exp |
36 | return -1 | |
104c1213 JM |
37 | } |
38 | ||
39 | if [get_compiler_info ${binfile}] { | |
40 | return -1 | |
41 | } | |
42 | ||
43 | ######################################## | |
44 | ## | |
45 | ## Don't do any of these tests until we reach consensus on this file. | |
46 | ## | |
47 | return 0 | |
48 | ######################################## | |
49 | ||
50 | set board [target_info name] | |
51 | set current_target [target_info gdb_protocol] | |
52 | if { $current_target == "remote" } { | |
53 | unset_board_info "gdb_protocol" | |
54 | set_board_info "gdb_protocol" "async" | |
55 | } else { | |
56 | return 0 | |
57 | } | |
58 | ||
59 | gdb_exit | |
60 | gdb_start | |
61 | gdb_reinitialize_dir $srcdir/$subdir | |
62 | gdb_load ${binfile} | |
63 | if [target_info exists gdb_stub] { | |
64 | gdb_step_for_stub; | |
65 | } | |
66 | ||
67 | # | |
68 | # set it up at a breakpoint so we can play with it | |
69 | # | |
70 | if ![runto_main] then { | |
71 | perror "couldn't run to breakpoint" | |
72 | continue | |
73 | } | |
74 | ||
75 | gdb_test "break baz" "" "" | |
76 | ||
77 | # | |
78 | # Make sure we get a 'completed' message when the target is done. | |
79 | # | |
80 | gdb_test "set display-exec-done on" "" "" | |
81 | ||
82 | ||
83 | send_gdb "next&\n" | |
84 | gdb_expect { | |
85 | -re "^next&\r\n$gdb_prompt.*z = 9.*completed\.\r\n" { pass "next &" } | |
86 | -re "$gdb_prompt.*completed\.$" { fail "next &" } | |
87 | timeout { fail "(timeout) next &" } | |
88 | } | |
89 | ||
90 | send_gdb "step&\n" | |
91 | gdb_expect { | |
92 | -re "^step&\r\n$gdb_prompt.*y = foo \\(\\).*completed\.\r\n" { pass "step &" } | |
93 | -re "$gdb_prompt.*completed\.$" { fail "step &" } | |
94 | timeout { fail "(timeout) step &" } | |
95 | } | |
96 | ||
97 | send_gdb "step&\n" | |
98 | gdb_expect { | |
99 | -re "^step&\r\n$gdb_prompt foo \\(\\) at .*async.c.*x = 5.*completed\.\r\n" \ | |
100 | { pass "step &" } | |
101 | -re "$gdb_prompt.*completed\.$" { fail "step &" } | |
102 | timeout { fail "(timeout) step &" } | |
103 | } | |
104 | ||
105 | send_gdb "stepi&\n" | |
106 | gdb_expect { | |
107 | -re "^stepi&\r\n$gdb_prompt.*$hex.*x = 5.*completed\.\r\n" { pass "stepi &" } | |
108 | -re "$gdb_prompt.*completed\.$" { fail "stepi &" } | |
109 | timeout { fail "(timeout) stepi &" } | |
110 | } | |
111 | ||
112 | send_gdb "nexti&\n" | |
113 | gdb_expect { | |
114 | -re "^nexti&\r\n$gdb_prompt.*y = 3.*completed\.\r\n" { pass "nexti &" } | |
115 | -re "$gdb_prompt.*completed\.$" { fail "nexti &" } | |
116 | timeout { fail "(timeout) nexti &" } | |
117 | } | |
118 | ||
119 | send_gdb "finish&\n" | |
120 | gdb_expect { | |
121 | -re "^finish&\r\nRun till exit from #0 foo \\(\\) at.*async.c.*\r\n$gdb_prompt.*$hex in main \\(\\) at.*async.c.*y = foo \\(\\).*Value returned is.*= 8.*completed\.\r\n" \ | |
122 | { pass "finish &" } | |
123 | -re "$gdb_prompt.*completed\.$" { fail "finish &" } | |
124 | timeout { fail "(timeout) finish &" } | |
125 | } | |
126 | ||
127 | send_gdb "jump 33&\n" | |
128 | gdb_expect { | |
129 | -re "^jump 33&.*Continuing at $hex.*$gdb_prompt.*Breakpoint 2, baz \\(\\) at.*async.c.*return 5.*completed\.\r\n" \ | |
130 | { pass "jump &" } | |
131 | -re ".*$gdb_prompt.*completed\.$" { fail "jump &" } | |
132 | timeout { fail "(timeout) jump &" } | |
133 | } | |
134 | ||
135 | send_gdb "until 35&\n" | |
136 | gdb_expect { | |
137 | -re "^until 35&.*$gdb_prompt.*$hex in main \\(\\) at.*async.c.*y = baz \\(\\).*completed\.\r\n" \ | |
138 | { pass "until &" } | |
139 | -re "$gdb_prompt.*completed\.$" { fail "until &" } | |
140 | timeout { fail "(timeout) until &" } | |
141 | } | |
142 | ||
143 | gdb_test "set display-exec-done off" "" "" | |
144 | ||
145 | unset_board_info "gdb_protocol" | |
146 | set_board_info "gdb_protocol" "remote" | |
147 | ||
148 | ||
149 | ||
150 | ||
151 | ||
152 |