Commit | Line | Data |
---|---|---|
1bf404ef AC |
1 | # This testcase is part of GDB, the GNU debugger. |
2 | ||
9b254dd1 | 3 | # Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008 |
6aba47ca | 4 | # Free Software Foundation, Inc. |
c906108c SS |
5 | |
6 | # This program is free software; you can redistribute it and/or modify | |
7 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 8 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 9 | # (at your option) any later version. |
e22f8b7c | 10 | # |
c906108c SS |
11 | # This program is distributed in the hope that it will be useful, |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. | |
e22f8b7c | 15 | # |
c906108c | 16 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c SS |
18 | |
19 | # use this to debug: | |
20 | # | |
21 | #log_user 1 | |
22 | ||
23 | # ending-run.exp -- Expect script to test ending a test run in gdb | |
24 | ||
25 | if $tracelevel then { | |
26 | strace $tracelevel | |
27 | } | |
28 | ||
29 | set testfile ending-run | |
30 | set srcfile ${testfile}.c | |
31 | set binfile ${objdir}/${subdir}/${testfile} | |
32 | ||
33 | remote_exec build "rm -f ${binfile}" | |
34 | remote_exec build "rm -f core" | |
35 | ||
36 | ||
37 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { | |
b60f0898 JB |
38 | untested ending-run.exp |
39 | return -1 | |
c906108c SS |
40 | } |
41 | ||
42 | ||
43 | ||
44 | gdb_exit | |
45 | gdb_start | |
46 | gdb_reinitialize_dir $srcdir/$subdir | |
47 | gdb_load ${binfile} | |
48 | ||
49 | # CHFts23469: Test that you can "clear" a bp set at | |
50 | # a line _before_ the routine (which will default to the | |
51 | # first line in the routine, which turns out to correspond | |
52 | # to the prolog--that's another bug...) | |
53 | # | |
b84b7669 MS |
54 | |
55 | gdb_test "b ending-run.c:1" ".*Breakpoint.*ending-run.c, line 1.*" \ | |
56 | "bpt at line before routine" | |
57 | ||
58 | gdb_test "b ending-run.c:13" \ | |
7dbd117d MC |
59 | ".*Note.*also.*Breakpoint 2.*ending-run.c, line 13.*" \ |
60 | "b ending-run.c:13, one" | |
c906108c SS |
61 | |
62 | # Set up to go to the next-to-last line of the program | |
63 | # | |
b84b7669 | 64 | gdb_test "b ending-run.c:31" ".*Breakpoint 3.*ending-run.c, line 31.*" |
c906108c SS |
65 | |
66 | # Expect to hit the bp at line "1", but symbolize this | |
085dd6e6 | 67 | # as line "13". Then try to clear it--this should work. |
c906108c | 68 | # |
b741e217 DJ |
69 | gdb_run_cmd |
70 | gdb_test "" ".*Breakpoint.*1.*callee.*13.*" "run" | |
71 | ||
d6e956e5 | 72 | gdb_test "cle" ".*Deleted breakpoints 1 2.*" "clear worked" |
c906108c SS |
73 | send_gdb "i b\n" |
74 | gdb_expect { | |
ed4c619a | 75 | -re ".* breakpoint .* breakpoint .*$gdb_prompt $" { |
cb9a9d3e MS |
76 | fail "cleared bp at line before routine" |
77 | } | |
78 | -re ".*3.*main.*31.*$gdb_prompt $" { | |
79 | pass "cleared bp at line before routine" | |
80 | } | |
81 | -re ".*$gdb_prompt $" { | |
82 | fail "cleared bp at line before routine (info b)" | |
83 | } | |
c906108c SS |
84 | } |
85 | ||
86 | # Test some other "clear" combinations | |
87 | # | |
b84b7669 | 88 | gdb_test "b ending-run.c:1" ".*Breakpoint.*4.*" |
7dbd117d | 89 | gdb_test "b ending-run.c:13" ".*Note.*also.*Breakpoint.*5.*" "b ending-run.c:13, two" |
b84b7669 MS |
90 | gdb_test "cle ending-run.c:13" \ |
91 | ".*Deleted breakpoint 5.*" "Only cleared 1 by line" | |
c906108c | 92 | |
b84b7669 | 93 | send_gdb "inf line ending-run.c:13\n" |
c906108c SS |
94 | gdb_expect { |
95 | -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" { | |
96 | set line_eight $expect_out(1,string) | |
a0b3c4fd | 97 | gdb_test "b 13" ".*Breakpoint.*6.*" |
d6e956e5 | 98 | gdb_test "cle *$line_eight" ".*Deleted breakpoints 4 6.*" "Clear 2 by address" |
c906108c SS |
99 | } |
100 | -re ".*$gdb_prompt $" { | |
101 | fail "need to fix test for new compile outcome" | |
102 | } | |
103 | } | |
104 | ||
b84b7669 | 105 | send_gdb "inf line ending-run.c:14\n" |
c906108c SS |
106 | gdb_expect { |
107 | -re ".*address (0x\[0-9a-fA-F]*).*$gdb_prompt $" { | |
108 | set line_nine $expect_out(1,string) | |
b84b7669 | 109 | gdb_test "b ending-run.c:14" ".*Breakpoint 7.*ending-run.c, line 14.*" |
1bf404ef | 110 | gdb_test "b *$line_nine" ".*Note.*also.*Breakpoint 8.*" "Breakpoint 7 at *ending-run.c:14" |
a0b3c4fd | 111 | gdb_test "c" ".*Breakpoint.*7.*callee.*14.*" |
d6e956e5 | 112 | gdb_test "cle" ".*Deleted breakpoints 7 8.*" "Clear 2 by default" |
c906108c SS |
113 | } |
114 | -re ".*$gdb_prompt $" { | |
115 | fail "need to fix test for new compile outcome" | |
116 | } | |
117 | } | |
118 | ||
119 | send_gdb "i b\n" | |
120 | gdb_expect { | |
ed4c619a | 121 | -re ".* breakpoint .* breakpoint .*$gdb_prompt $" { |
cb9a9d3e | 122 | fail "all set to continue (didn't clear bps)" |
c906108c | 123 | } |
085dd6e6 | 124 | -re ".*3.*main.*31.*$gdb_prompt $" { |
c906108c SS |
125 | pass "all set to continue" |
126 | } | |
127 | -re ".*$gdb_prompt $" { | |
cb9a9d3e | 128 | fail "all set to continue (missing bp at end)" |
c906108c SS |
129 | } |
130 | } | |
131 | ||
132 | ||
133 | # See if we can step out with control. The "1 2 3" stuff | |
134 | # is output from the program. | |
135 | # | |
004af6c7 DJ |
136 | if ![gdb_skip_stdio_test "cont"] { |
137 | gdb_test "cont" ".*1 2 7 14 23 34 47 62 79.*Breakpoint.*31.*" | |
138 | } else { | |
139 | gdb_test "cont" ".*Breakpoint.*31.*" | |
140 | } | |
13a5e3b8 MS |
141 | |
142 | if ![gdb_skip_stdio_test "Step to return"] { | |
808a31f5 | 143 | gdb_test "next" ".*Goodbye!.*32.*" \ |
13a5e3b8 MS |
144 | "Step to return" |
145 | } else { | |
146 | gdb_test "next" "" "" | |
147 | } | |
c906108c SS |
148 | |
149 | set old_timeout $timeout | |
150 | set timeout 50 | |
2b1a1355 | 151 | set program_exited 0 |
c906108c | 152 | send_gdb "next\n" |
697bc68d | 153 | set nexted 0 |
c906108c | 154 | gdb_expect { |
085dd6e6 | 155 | -re "33.*$gdb_prompt $" { |
c906108c | 156 | # sometimes we stop at the closing brace, if so, do another next |
697bc68d NS |
157 | if { $nexted } { |
158 | fail "step out of main" | |
159 | } else { | |
160 | set nexted 1 | |
161 | send_gdb "next\n" | |
162 | exp_continue | |
c906108c SS |
163 | } |
164 | } | |
165 | -re ".*Unable to find return pc for this frame.*$gdb_prompt $" { | |
697bc68d NS |
166 | fail "step out of main" |
167 | gdb_test "n" ".*" "" | |
c906108c SS |
168 | } |
169 | -re ".*in.*start.*$gdb_prompt $" { | |
697bc68d NS |
170 | pass "step out of main" |
171 | } | |
172 | -re ".*in.*bsp_trap.*$gdb_prompt $" { | |
173 | pass "step out of main" | |
c906108c | 174 | } |
697bc68d NS |
175 | -re ".*in.*init.*$gdb_prompt $" { |
176 | # This is what happens on sparc64-elf ultra. | |
177 | pass "step out of main" | |
178 | } | |
179 | -re ".*in.*dll_crt0_1.*$gdb_prompt $" { | |
180 | # This is what happens on Cygwin. | |
181 | pass "step out of main" | |
085dd6e6 | 182 | } |
2b1a1355 MS |
183 | -re ".*Program exited normally.*$gdb_prompt $" { |
184 | # This is what happens on Linux i86 (and I would expect others) | |
185 | set program_exited 1 | |
186 | pass "step out of main" | |
187 | } | |
697bc68d NS |
188 | -re ".*in .nope ().*$gdb_prompt $" { |
189 | # This is what happens on Solaris currently -sts 1999-08-25 | |
190 | pass "step out of main" | |
191 | } | |
192 | -re ".*in _int_reset ().*$gdb_prompt $" { | |
193 | # This is what happens on Sanyo XStormy16 | |
194 | pass "step out of main" | |
195 | } | |
196 | -re ".*init ().*$gdb_prompt $" { | |
197 | # This is what happens on many Mips targets | |
198 | pass "step out of main" | |
199 | } | |
200 | -re ".*in ..change.mode ().*$gdb_prompt $" { | |
201 | # This is what happens on ARM in thumb mode -fn 2000-02-01 | |
202 | pass "step out of main" | |
203 | } | |
204 | -re ".*__rt_entry ().*$gdb_prompt $" { | |
205 | # This is what happens on the ARM RVDS runtime | |
206 | pass "step out of main" | |
207 | } | |
208 | -re ".*in.*\\\$START\\\$.*from.*dld.sl.*$gdb_prompt $" { | |
209 | pass "step out of main" | |
210 | } | |
211 | -re ".*in __wrap__?main ().*$gdb_prompt $" { | |
212 | pass "step out of main" | |
213 | } | |
214 | -re "__setup_argv_for_main (.*).*$gdb_prompt $" { | |
215 | # On sh, another wrapper function (start_l) exists, so | |
216 | # another `next' is necessary. | |
217 | gdb_test "next" ".*in start_l ().*" "step out of main" | |
218 | } | |
cce74817 | 219 | -re ".*in.*currently asm.*$gdb_prompt $" { |
697bc68d NS |
220 | pass "step out of main" |
221 | } | |
222 | -re "_*start\[0-9\]* \\(\[^)\]*\\).*$gdb_prompt $" { | |
223 | pass "step out of main" | |
cce74817 JM |
224 | } |
225 | -re ".*Program received signal SIGTRAP.*$gdb_prompt $" { | |
697bc68d | 226 | pass "step out of main" |
cce74817 | 227 | } |
697bc68d NS |
228 | -re ".*$gdb_prompt $" { fail "step out of main" } |
229 | timeout { fail "step out of main" } | |
c906108c SS |
230 | } |
231 | ||
0f815cdf JB |
232 | # When we're talking to a program running on a real stand-alone board, |
233 | # every BSP's exit function behaves differently, so there's no single | |
234 | # way to tell whether we've exited gracefully or not. So don't run | |
235 | # these tests when use_gdb_stub is set, or when we're running under Cygmon. | |
31e45dee FN |
236 | set program_exited_normally 0 |
237 | set program_not_exited 0 | |
238 | set program_in_exit 0 | |
0f815cdf JB |
239 | if {! [target_info exists use_gdb_stub] |
240 | && (! [target_info exists use_cygmon] || ! [target_info use_cygmon])} { | |
2b1a1355 MS |
241 | global program_exited; |
242 | if {[eval expr $program_exited == 0]} { | |
243 | send_gdb "n\n" | |
244 | gdb_expect { | |
245 | -re "Program exited normally.*$gdb_prompt $" { | |
246 | # If we actually have debug info for the start function, | |
247 | # then we won't get the "Single-stepping until function | |
248 | # exit" message. | |
36a22261 | 249 | pass "step to end of run" |
31e45dee | 250 | set program_exited_normally 1 |
2b1a1355 | 251 | } |
a283c5a1 | 252 | -re "Single.*EXIT code 0\r\n.*Program exited normally.*$gdb_prompt $" { |
cb9a9d3e | 253 | pass "step to end of run (status wrapper)" |
31e45dee | 254 | set program_exited_normally 1 |
cb9a9d3e | 255 | } |
afb5c968 CV |
256 | -re "Single.*EXIT code 0\r\n.*$gdb_prompt $" { |
257 | pass "step to end of run (status wrapper)" | |
258 | } | |
2b1a1355 | 259 | -re ".*Single.*Program exited.*$gdb_prompt $" { |
36a22261 | 260 | pass "step to end of run" |
31e45dee | 261 | set program_exited_normally 1 |
2b1a1355 MS |
262 | } |
263 | -re ".*Single.*in exit.*from.*dld.sl.*$gdb_prompt $" { | |
36a22261 | 264 | pass "step to end of run" |
31e45dee | 265 | set program_in_exit 1 |
2b1a1355 | 266 | } |
36a22261 CV |
267 | -re ".*Single.*_int_reset.*$gdb_prompt $" { |
268 | pass "step to end of run" | |
31e45dee FN |
269 | if {![istarget "xstormy16-*-*"]} { |
270 | set program_exited_normally 1 | |
271 | } | |
36a22261 | 272 | } |
2b1a1355 MS |
273 | -re ".*$gdb_prompt $" { |
274 | fail "step to end of run" | |
31e45dee | 275 | set program_not_exited 1 |
2b1a1355 MS |
276 | } |
277 | timeout { | |
278 | fail "(timeout) step to end of run" | |
31e45dee | 279 | set program_not_exited 1 |
2b1a1355 MS |
280 | } |
281 | } | |
282 | } | |
283 | ||
31e45dee FN |
284 | if {$program_in_exit} { |
285 | if {[gdb_test "c" ".*" "continue after exit"] == 0} { | |
286 | set program_exited_normally 1 | |
287 | } | |
288 | } else { | |
289 | unsupported "continue after exit" | |
290 | } | |
291 | ||
2b1a1355 MS |
292 | set timeout $old_timeout |
293 | ||
31e45dee FN |
294 | if {$program_exited_normally} { |
295 | gdb_test "n" ".*The program is not being run.*" "don't step after run" | |
296 | } elseif {$program_not_exited} { | |
297 | unresolved "don't step after run" | |
298 | } else { | |
299 | unsupported "don't step after run" | |
300 | } | |
2b1a1355 MS |
301 | |
302 | set exec_output [remote_exec host "ls core"] | |
303 | ||
304 | if [ regexp "core not found" $exec_output] { | |
305 | pass "No core dumped on quit" | |
7a292a7a | 306 | } else { |
2b1a1355 | 307 | if [ regexp "No such file or directory" $exec_output] { |
cb9a9d3e | 308 | pass "ls: core (No core dumped on quit)" |
2b1a1355 MS |
309 | } else { |
310 | remote_exec build "rm -f core" | |
cb9a9d3e | 311 | fail "ls: core (Core dumped on quit)" |
2b1a1355 | 312 | } |
7a292a7a | 313 | } |
c906108c SS |
314 | } |
315 | ||
316 | #remote_exec build "rm -f ${binfile}" | |
317 | return 0 | |
318 | ||
319 | ||
320 | ||
321 |