1 # Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
28 # test running programs
34 set srcfile ${testfile}.c
35 set binfile ${objdir}/${subdir}/${testfile}
37 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
38 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
41 proc rerun_to_main {} {
44 if [target_info exists use_gdb_stub] {
47 -re ".*Breakpoint .*main .*$gdb_prompt $"\
48 {pass "rerun to main" ; return 0}
50 {fail "rerun to main" ; return 0}
51 timeout {fail "(timeout) rerun to main" ; return 0}
56 -re "Starting program.*$gdb_prompt $"\
57 {pass "rerun to main" ; return 0}
59 {fail "rerun to main" ; return 0}
60 timeout {fail "(timeout) rerun to main" ; return 0}
67 gdb_reinitialize_dir $srcdir/$subdir
70 if ![runto_main] then { fail "enable/disable break tests suppressed" }
72 # Verify that we can set a breakpoint (the location is irrelevant),
73 # then enable it (yes, it's already enabled by default), then hit it.
75 send_gdb "break marker1\n"
77 -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\
78 {pass "break marker1"}
80 {fail "break marker1"}
81 timeout {fail "(timeout) break marker1"}
84 send_gdb "enable $expect_out(1,string)\n"
87 {pass "enable break marker1"}
88 timeout {fail "(timeout) enable break marker1"}
91 send_gdb "info break $expect_out(1,string)\n"
93 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*$gdb_prompt $"\
94 {pass "info break marker1"}
96 {fail "info break marker1"}
97 timeout {fail "(timeout) info break marker1"}
100 # See the comments in condbreak.exp for "run until breakpoint at marker1"
101 # for an explanation of the xfail below.
102 send_gdb "continue\n"
104 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
105 {pass "continue to break marker1"}
106 -re "Breakpoint \[0-9\]*, $hex in marker1.*$gdb_prompt $"\
107 {xfail "continue to break marker1"}
109 {fail "continue to break marker1"}
110 timeout {fail "(timeout) continue to break marker1"}
113 send_gdb "delete $expect_out(1,string)\n"
116 {pass "delete break marker1"}
117 timeout {fail "(timeout) delete break marker1"}
120 # Verify that we can set a breakpoint to be self-disabling after
121 # the first time it triggers.
123 send_gdb "break marker2\n"
125 -re "Breakpoint (\[0-9\]*) at .*, line 4\[49\].*$gdb_prompt $"\
126 {pass "break marker2"}
128 {fail "break marker2"}
129 timeout {fail "(timeout) break marker2"}
132 send_gdb "enable once $expect_out(1,string)\n"
135 {pass "enable once break marker2"}
136 timeout {fail "(timeout) enable once break marker2"}
139 send_gdb "info break $expect_out(1,string)\n"
141 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+y.*$gdb_prompt $"\
142 {pass "info auto-disabled break marker2"}
144 {fail "info auto-disabled break marker2"}
145 timeout {fail "(timeout) info auto-disabled break marker2"}
148 # See the comments in condbreak.exp for "run until breakpoint at marker1"
149 # for an explanation of the xfail below.
150 send_gdb "continue\n"
152 -re "Breakpoint \[0-9\]*, marker2.*$gdb_prompt $"\
153 {pass "continue to auto-disabled break marker2"}
154 -re "Breakpoint \[0-9\]*, $hex in marker2.*$gdb_prompt $"\
155 {xfail "continue to auto-disabled break marker2"}
157 {fail "continue to auto-disabled break marker2"}
158 timeout {fail "(timeout) continue to auto-disabled break marker2"}
161 send_gdb "info break $expect_out(1,string)\n"
163 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+n.*$gdb_prompt $"\
164 {pass "info auto-disabled break marker2"}
166 {fail "info auto-disabled break marker2"}
167 timeout {fail "(timeout) info auto-disabled break marker2"}
170 # Verify that we don't stop at a disabled breakpoint.
172 gdb_continue_to_end "no stop"
174 gdb_continue_to_end "no stop at auto-disabled break marker2"
176 # Verify that we can set a breakpoint to be self-deleting after
177 # the first time it triggers.
179 if ![runto_main] then { fail "enable/disable break tests suppressed" }
181 send_gdb "break marker3\n"
183 -re "Breakpoint (\[0-9\]*) at .*, line (45|50).*$gdb_prompt $"\
184 {pass "break marker3"}
186 {fail "break marker3"}
187 timeout {fail "(timeout) break marker3"}
190 send_gdb "enable del $expect_out(1,string)\n"
193 {pass "enable del break marker3"}
194 timeout {fail "(timeout) enable del break marker3"}
197 send_gdb "info break $expect_out(1,string)\n"
199 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*$gdb_prompt $"\
200 {pass "info auto-deleted break marker2"}
202 {fail "info auto-deleted break marker2"}
203 timeout {fail "(timeout) info auto-deleted break marker2"}
206 send_gdb "continue\n"
208 -re ".*marker3 .*:(45|50).*$gdb_prompt $"\
209 {pass "continue to auto-deleted break marker3"}
210 -re "Breakpoint \[0-9\]*, marker3.*$gdb_prompt $"\
211 {fail "continue to auto-deleted break marker3"}
213 {fail "continue to auto-deleted break marker3"}
214 timeout {fail "(timeout) continue to break marker3"}
217 send_gdb "info break $expect_out(1,string)\n"
219 -re ".*No breakpoint or watchpoint number.*$gdb_prompt $"\
220 {pass "info auto-deleted break marker3"}
221 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\].*$gdb_prompt $"\
222 {fail "info auto-deleted break marker3"}
224 {fail "info auto-deleted break marker3"}
225 timeout {fail "(timeout) info auto-deleted break marker3"}
228 # Verify that we can set a breakpoint and manually disable it (we've
229 # already proven that disabled bp's don't trigger).
231 send_gdb "break marker4\n"
233 -re "Breakpoint (\[0-9\]*) at .*, line (46|51).*$gdb_prompt $"\
234 {pass "break marker4"}
236 {fail "break marker4"}
237 timeout {fail "(timeout) break marker4"}
240 send_gdb "disable $expect_out(1,string)\n"
243 {pass "disable break marker4"}
244 timeout {fail "(timeout) disable break marker4"}
247 send_gdb "info break $expect_out(1,string)\n"
249 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*$gdb_prompt $"\
250 {pass "info break marker4"}
252 {fail "info break marker4"}
253 timeout {fail "(timeout) info break marker4"}
256 # Verify that we can set a breakpoint with an ignore count N, which
257 # should cause the next N triggers of the bp to be ignored. (This is
258 # a flavor of enablement/disablement, after all.)
260 if ![runto_main] then { fail "enable/disable break tests suppressed" }
262 send_gdb "break marker1\n"
264 -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\
265 {pass "break marker1"}
267 {fail "break marker1"}
268 timeout {fail "(timeout) break marker1"}
271 # Verify that an ignore of a non-existent breakpoint is gracefully
274 send_gdb "ignore 999 2\n"
276 -re "No breakpoint number 999..*$gdb_prompt $"\
277 {pass "ignore non-existent break"}
279 {fail "ignore non-existent break"}
280 timeout {fail "(timeout) ignore non-existent break"}
283 # Verify that a missing ignore count is gracefully handled.
285 send_gdb "ignore $expect_out(1,string) \n"
287 -re "Second argument .specified ignore-count. is missing..*$gdb_prompt $"\
288 {pass "ignore break with missing ignore count"}
290 {fail "ignore break with missing ignore count"}
291 timeout {fail "(timeout) ignore break with missing ignore count"}
294 # Verify that a negative or zero ignore count is handled gracefully
295 # (they both are treated the same).
297 send_gdb "ignore $expect_out(1,string) -1\n"
299 -re "Will stop next time breakpoint \[0-9\]* is reached..*$gdb_prompt $"\
300 {pass "ignore break marker1 -1"}
302 {fail "ignore break marker1 -1"}
303 timeout {fail "(timeout) ignore break marker1 -1"}
306 send_gdb "ignore $expect_out(1,string) 0\n"
308 -re "Will stop next time breakpoint \[0-9\]* is reached..*$gdb_prompt $"\
309 {pass "ignore break marker1 0"}
311 {fail "ignore break marker1 0"}
312 timeout {fail "(timeout) ignore break marker1 0"}
315 send_gdb "ignore $expect_out(1,string) 1\n"
317 -re "Will ignore next crossing of breakpoint \[0-9\]*.*$gdb_prompt $"\
318 {pass "ignore break marker1"}
320 {fail "ignore break marker1"}
321 timeout {fail "(timeout) ignore break marker1"}
324 send_gdb "info break $expect_out(1,string)\n"
326 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*ignore next 1 hits.*$gdb_prompt $"\
327 {pass "info ignored break marker1"}
329 {fail "info ignored break marker1"}
330 timeout {fail "(timeout) info ignored break marker1"}
333 gdb_continue_to_end "no stop at ignored break marker1"
336 # See the comments in condbreak.exp for "run until breakpoint at marker1"
337 # for an explanation of the xfail below.
338 send_gdb "continue\n"
340 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
341 {pass "continue to break marker1, 2nd time"}
342 -re "Breakpoint \[0-9\]*, $hex in marker1.*$gdb_prompt $"\
343 {xfail "continue to break marker1, 2nd time"}
345 {fail "continue to break marker1, 2nd time"}
346 timeout {fail "(timeout) continue to break marker1, 2nd time"}
349 # Verify that we can specify both an ignore count and an auto-delete.
351 if ![runto_main] then { fail "enable/disable break tests suppressed" }
353 send_gdb "break marker1\n"
355 -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\
356 {pass "break marker1"}
358 {fail "break marker1"}
359 timeout {fail "(timeout) break marker1"}
362 send_gdb "ignore $expect_out(1,string) 1\n"
364 -re "Will ignore next crossing of breakpoint \[0-9\]*.*$gdb_prompt $"\
365 {pass "ignore break marker1"}
367 {fail "ignore break marker1"}
368 timeout {fail "(timeout) ignore break marker1"}
371 send_gdb "enable del $expect_out(1,string)\n"
374 {pass "enable del break marker1"}
375 timeout {fail "(timeout) enable del break marker1"}
378 send_gdb "info break $expect_out(1,string)\n"
380 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*ignore next 1 hits.*$gdb_prompt $"\
381 {pass "info break marker1"}
383 {fail "info break marker1"}
384 timeout {fail "(timeout) info break marker2"}
387 gdb_continue_to_end "no stop at ignored & auto-deleted break marker1"
390 send_gdb "continue\n"
392 -re ".*marker1 .*:4\[38\].*$gdb_prompt $"\
393 {pass "continue to ignored & auto-deleted break marker1"}
394 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
395 {fail "continue to ignored & auto-deleted break marker1"}
397 {fail "continue to ignored & auto-deleted break marker1"}
398 timeout {fail "(timeout) continue to ignored & auto-deleted break marker1"}
401 # Verify that a disabled breakpoint's ignore count isn't updated when
402 # the bp is encountered.
404 if ![runto_main] then { fail "enable/disable break tests suppressed" }
406 send_gdb "break marker1\n"
408 -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\
409 {pass "break marker1"}
411 {fail "break marker1"}
412 timeout {fail "(timeout) break marker1"}
415 send_gdb "ignore $expect_out(1,string) 10\n"
417 -re "Will ignore next 10 crossings of breakpoint \[0-9\]*.*$gdb_prompt $"\
418 {pass "ignore break marker1"}
420 {fail "ignore break marker1"}
421 timeout {fail "(timeout) ignore break marker1"}
424 send_gdb "disable $expect_out(1,string)\n"
427 {pass "disable break marker1"}
428 timeout {fail "(timeout) disable break marker1"}
431 gdb_continue_to_end "no stop at ignored & disabled break marker1"
434 send_gdb "info break $expect_out(1,string)\n"
436 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*ignore next 10 hits.*$gdb_prompt $"\
437 {pass "info ignored & disabled break marker1"}
439 {fail "info ignored & disabled break marker1"}
440 timeout {fail "(timeout) info ignored & disabled break marker1"}
443 # Verify that GDB correctly handles the "continue" command with an argument,
444 # which is an ignore count to set on the currently stopped-at breakpoint.
445 # (Also verify that GDB gracefully handles the case where the inferior
446 # isn't stopped at a breakpoint.)
448 if ![runto_main] then { fail "enable/disable break tests suppressed" }
450 send_gdb "break 79\n"
452 -re "Breakpoint \[0-9\]*.*, line 79.*$gdb_prompt $"\
453 {pass "prepare to continue with ignore count"}
455 {fail "prepare to continue with ignore count"}
456 timeout {fail "(timeout) prepare to continue with ignore count"}
458 send_gdb "continue 2\n"
460 -re "Will ignore next crossing of breakpoint \[0-9\]*. Continuing..*$gdb_prompt $"\
461 {pass "continue with ignore count"}
463 {fail "continue with ignore count"}
464 timeout {fail "(timeout) continue with ignore count"}
469 -re ".*81\[ \t\]*marker1.*$gdb_prompt $"\
470 {pass "step after continue with ignore count"}
472 {fail "step after continue with ignore count"}
473 timeout {fail "(timeout) step after continue with ignore count"}
476 # ??rehrauer: Huh. This appears to be an actual bug. (No big
477 # surprise, since this feature hasn't been tested...) Looks like
478 # GDB is currently trying to set the ignore count of bp # -1!
481 send_gdb "continue 2\n"
483 -re "Not stopped at any breakpoint; argument ignored..*$gdb_prompt $"\
484 {pass "continue with ignore count, not stopped at bpt"}
485 -re "No breakpoint number -1.*$gdb_prompt $"\
486 {xfail "(DTS'd) continue with ignore count, not stopped at bpt"}
488 {fail "continue with ignore count, not stopped at bpt"}
489 timeout {fail "(timeout) step after continue with ignore count, not stopped at bpt"}