1 # Copyright (C) 1997, 1998 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."
43 gdb_reinitialize_dir $srcdir/$subdir
46 if ![runto_main] then { fail "enable/disable break tests suppressed" }
48 # Verify that we can set a breakpoint (the location is irrelevant),
49 # then enable it (yes, it's already enabled by default), then hit it.
51 send_gdb "break marker1\n"
53 -re "Breakpoint (\[0-9\]*) at .*, line 41.*$gdb_prompt $"\
54 {pass "break marker1"}
56 {fail "break marker1"}
57 timeout {fail "(timeout) break marker1"}
60 send_gdb "enable $expect_out(1,string)\n"
63 {pass "enable break marker1"}
64 timeout {fail "(timeout) enable break marker1"}
67 send_gdb "info break $expect_out(1,string)\n"
69 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*$gdb_prompt $"\
70 {pass "info break marker1"}
72 {fail "info break marker1"}
73 timeout {fail "(timeout) info break marker1"}
78 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
79 {pass "continue to break marker1"}
81 {fail "continue to break marker1"}
82 timeout {fail "(timeout) continue to break marker1"}
85 send_gdb "delete $expect_out(1,string)\n"
88 {pass "delete break marker1"}
89 timeout {fail "(timeout) delete break marker1"}
92 # Verify that we can set a breakpoint to be self-disabling after
93 # the first time it triggers.
95 send_gdb "break marker2\n"
97 -re "Breakpoint (\[0-9\]*) at .*, line 42.*$gdb_prompt $"\
98 {pass "break marker2"}
100 {fail "break marker2"}
101 timeout {fail "(timeout) break marker2"}
104 send_gdb "enable once $expect_out(1,string)\n"
107 {pass "enable once break marker2"}
108 timeout {fail "(timeout) enable once break marker2"}
111 send_gdb "info break $expect_out(1,string)\n"
113 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+y.*$gdb_prompt $"\
114 {pass "info auto-disabled break marker2"}
116 {fail "info auto-disabled break marker2"}
117 timeout {fail "(timeout) info auto-disabled break marker2"}
120 send_gdb "continue\n"
122 -re "Breakpoint \[0-9\]*, marker2.*$gdb_prompt $"\
123 {pass "continue to auto-disabled break marker2"}
125 {fail "continue to auto-disabled break marker2"}
126 timeout {fail "(timeout) continue to auto-disabled break marker2"}
129 send_gdb "info break $expect_out(1,string)\n"
131 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+n.*$gdb_prompt $"\
132 {pass "info auto-disabled break marker2"}
134 {fail "info auto-disabled break marker2"}
135 timeout {fail "(timeout) info auto-disabled break marker2"}
138 # Verify that we don't stop at a disabled breakpoint.
140 send_gdb "continue\n"
142 -re ".*Program exited normally.*$gdb_prompt $"\
146 timeout {fail "(timeout) no stop"}
151 -re "Starting program.*$gdb_prompt $"\
152 {pass "rerun to main"}
154 {fail "rerun to main"}
155 timeout {fail "(timeout) rerun to main"}
158 send_gdb "continue\n"
160 -re ".*Program exited normally.*$gdb_prompt $"\
161 {pass "no stop at auto-disabled break marker2"}
163 {fail "no stop at auto-disabled break marker2"}
164 timeout {fail "(timeout) no stop at auto-disabled break marker2"}
167 # Verify that we can set a breakpoint to be self-deleting after
168 # the first time it triggers.
170 if ![runto_main] then { fail "enable/disable break tests suppressed" }
172 send_gdb "break marker3\n"
174 -re "Breakpoint (\[0-9\]*) at .*, line 43.*$gdb_prompt $"\
175 {pass "break marker3"}
177 {fail "break marker3"}
178 timeout {fail "(timeout) break marker3"}
181 send_gdb "enable del $expect_out(1,string)\n"
184 {pass "enable del break marker3"}
185 timeout {fail "(timeout) enable del break marker3"}
188 send_gdb "info break $expect_out(1,string)\n"
190 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*$gdb_prompt $"\
191 {pass "info auto-deleted break marker2"}
193 {fail "info auto-deleted break marker2"}
194 timeout {fail "(timeout) info auto-deleted break marker2"}
197 send_gdb "continue\n"
199 -re ".*marker3 .*:43.*$gdb_prompt $"\
200 {pass "continue to auto-deleted break marker3"}
201 -re "Breakpoint \[0-9\]*, marker3.*$gdb_prompt $"\
202 {fail "continue to auto-deleted break marker3"}
204 {fail "continue to auto-deleted break marker3"}
205 timeout {fail "(timeout) continue to break marker3"}
208 send_gdb "info break $expect_out(1,string)\n"
210 -re ".*No breakpoint or watchpoint number.*$gdb_prompt $"\
211 {pass "info auto-deleted break marker3"}
212 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\].*$gdb_prompt $"\
213 {fail "info auto-deleted break marker3"}
215 {fail "info auto-deleted break marker3"}
216 timeout {fail "(timeout) info auto-deleted break marker3"}
219 # Verify that we can set a breakpoint and manually disable it (we've
220 # already proven that disabled bp's don't trigger).
222 send_gdb "break marker4\n"
224 -re "Breakpoint (\[0-9\]*) at .*, line 44.*$gdb_prompt $"\
225 {pass "break marker4"}
227 {fail "break marker4"}
228 timeout {fail "(timeout) break marker4"}
231 send_gdb "disable $expect_out(1,string)\n"
234 {pass "disable break marker4"}
235 timeout {fail "(timeout) disable break marker4"}
238 send_gdb "info break $expect_out(1,string)\n"
240 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*$gdb_prompt $"\
241 {pass "info break marker4"}
243 {fail "info break marker4"}
244 timeout {fail "(timeout) info break marker4"}
247 # Verify that we can set a breakpoint with an ignore count N, which
248 # should cause the next N triggers of the bp to be ignored. (This is
249 # a flavor of enablement/disablement, after all.)
251 if ![runto_main] then { fail "enable/disable break tests suppressed" }
253 send_gdb "break marker1\n"
255 -re "Breakpoint (\[0-9\]*) at .*, line 41.*$gdb_prompt $"\
256 {pass "break marker1"}
258 {fail "break marker1"}
259 timeout {fail "(timeout) break marker1"}
262 # Verify that an ignore of a non-existent breakpoint is gracefully
265 send_gdb "ignore 999 2\n"
267 -re "No breakpoint number 999..*$gdb_prompt $"\
268 {pass "ignore non-existent break"}
270 {fail "ignore non-existent break"}
271 timeout {fail "(timeout) ignore non-existent break"}
274 # Verify that a missing ignore count is gracefully handled.
276 send_gdb "ignore $expect_out(1,string) \n"
278 -re "Second argument .specified ignore-count. is missing..*$gdb_prompt $"\
279 {pass "ignore break with missing ignore count"}
281 {fail "ignore break with missing ignore count"}
282 timeout {fail "(timeout) ignore break with missing ignore count"}
285 # Verify that a negative or zero ignore count is handled gracefully
286 # (they both are treated the same).
288 send_gdb "ignore $expect_out(1,string) -1\n"
290 -re "Will stop next time breakpoint \[0-9\]* is reached..*$gdb_prompt $"\
291 {pass "ignore break marker1 -1"}
293 {fail "ignore break marker1 -1"}
294 timeout {fail "(timeout) ignore break marker1 -1"}
297 send_gdb "ignore $expect_out(1,string) 0\n"
299 -re "Will stop next time breakpoint \[0-9\]* is reached..*$gdb_prompt $"\
300 {pass "ignore break marker1 0"}
302 {fail "ignore break marker1 0"}
303 timeout {fail "(timeout) ignore break marker1 0"}
306 send_gdb "ignore $expect_out(1,string) 1\n"
308 -re "Will ignore next crossing of breakpoint \[0-9\]*.*$gdb_prompt $"\
309 {pass "ignore break marker1"}
311 {fail "ignore break marker1"}
312 timeout {fail "(timeout) ignore break marker1"}
315 send_gdb "info break $expect_out(1,string)\n"
317 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*ignore next 1 hits.*$gdb_prompt $"\
318 {pass "info ignored break marker1"}
320 {fail "info ignored break marker1"}
321 timeout {fail "(timeout) info ignored break marker1"}
324 send_gdb "continue\n"
326 -re ".*Program exited normally.*$gdb_prompt $"\
327 {pass "no stop at ignored break marker1"}
329 {fail "no stop at ignored break marker1"}
330 timeout {fail "(timeout) no stop at ignored break marker1"}
335 -re "Starting program.*$gdb_prompt $"\
336 {pass "rerun to main"}
338 {fail "rerun to main"}
339 timeout {fail "(timeout) rerun to main"}
342 send_gdb "continue\n"
344 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
345 {pass "continue to break marker1"}
347 {fail "continue to break marker1"}
348 timeout {fail "(timeout) continue to break marker1"}
351 # Verify that we can specify both an ignore count and an auto-delete.
353 if ![runto_main] then { fail "enable/disable break tests suppressed" }
355 send_gdb "break marker1\n"
357 -re "Breakpoint (\[0-9\]*) at .*, line 41.*$gdb_prompt $"\
358 {pass "break marker1"}
360 {fail "break marker1"}
361 timeout {fail "(timeout) break marker1"}
364 send_gdb "ignore $expect_out(1,string) 1\n"
366 -re "Will ignore next crossing of breakpoint \[0-9\]*.*$gdb_prompt $"\
367 {pass "ignore break marker1"}
369 {fail "ignore break marker1"}
370 timeout {fail "(timeout) ignore break marker1"}
373 send_gdb "enable del $expect_out(1,string)\n"
376 {pass "enable del break marker1"}
377 timeout {fail "(timeout) enable del break marker1"}
380 send_gdb "info break $expect_out(1,string)\n"
382 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*ignore next 1 hits.*$gdb_prompt $"\
383 {pass "info break marker1"}
385 {fail "info break marker1"}
386 timeout {fail "(timeout) info break marker2"}
389 send_gdb "continue\n"
391 -re ".*Program exited normally.*$gdb_prompt $"\
392 {pass "no stop at ignored & auto-deleted break marker1"}
394 {fail "no stop at ignored & auto-deleted break marker1"}
395 timeout {fail "(timeout) no stop at ignored & auto-deleted break marker1"}
400 -re "Starting program.*$gdb_prompt $"\
401 {pass "rerun to main"}
403 {fail "rerun to main"}
404 timeout {fail "(timeout) rerun to main"}
407 send_gdb "continue\n"
409 -re ".*marker1 .*:41.*$gdb_prompt $"\
410 {pass "continue to ignored & auto-deleted break marker1"}
411 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
412 {fail "continue to ignored & auto-deleted break marker1"}
414 {fail "continue to ignored & auto-deleted break marker1"}
415 timeout {fail "(timeout) continue to ignored & auto-deleted break marker1"}
418 # Verify that a disabled breakpoint's ignore count isn't updated when
419 # the bp is encountered.
421 if ![runto_main] then { fail "enable/disable break tests suppressed" }
423 send_gdb "break marker1\n"
425 -re "Breakpoint (\[0-9\]*) at .*, line 41.*$gdb_prompt $"\
426 {pass "break marker1"}
428 {fail "break marker1"}
429 timeout {fail "(timeout) break marker1"}
432 send_gdb "ignore $expect_out(1,string) 10\n"
434 -re "Will ignore next 10 crossings of breakpoint \[0-9\]*.*$gdb_prompt $"\
435 {pass "ignore break marker1"}
437 {fail "ignore break marker1"}
438 timeout {fail "(timeout) ignore break marker1"}
441 send_gdb "disable $expect_out(1,string)\n"
444 {pass "disable break marker1"}
445 timeout {fail "(timeout) disable break marker1"}
448 send_gdb "continue\n"
450 -re ".*Program exited normally.*$gdb_prompt $"\
451 {pass "no stop at ignored & disabled break marker1"}
453 {fail "no stop at ignored & disabled break marker1"}
454 timeout {fail "(timeout) no stop at ignored & disabled break marker1"}
459 -re "Starting program.*$gdb_prompt $"\
460 {pass "rerun to main"}
462 {fail "rerun to main"}
463 timeout {fail "(timeout) rerun to main"}
466 send_gdb "info break $expect_out(1,string)\n"
468 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*ignore next 10 hits.*$gdb_prompt $"\
469 {pass "info ignored & disabled break marker1"}
471 {fail "info ignored & disabled break marker1"}
472 timeout {fail "(timeout) info ignored & disabled break marker1"}
475 # Verify that GDB correctly handles the "continue" command with an argument,
476 # which is an ignore count to set on the currently stopped-at breakpoint.
477 # (Also verify that GDB gracefully handles the case where the inferior
478 # isn't stopped at a breakpoint.)
480 if ![runto_main] then { fail "enable/disable break tests suppressed" }
482 send_gdb "break 64\n"
484 -re "Breakpoint \[0-9\]*.*, line 64.*$gdb_prompt $"\
485 {pass "prepare to continue with ignore count"}
487 {fail "prepare to continue with ignore count"}
488 timeout {fail "(timeout) prepare to continue with ignore count"}
490 send_gdb "continue 2\n"
492 -re "Will ignore next crossing of breakpoint \[0-9\]*. Continuing..*$gdb_prompt $"\
493 {pass "continue with ignore count"}
495 {fail "continue with ignore count"}
496 timeout {fail "(timeout) continue with ignore count"}
501 -re ".*66\[ \t\]*marker1.*$gdb_prompt $"\
502 {pass "step after continue with ignore count"}
504 {fail "step after continue with ignore count"}
505 timeout {fail "(timeout) step after continue with ignore count"}
508 # ??rehrauer: Huh. This appears to be an actual bug. (No big
509 # surprise, since this feature hasn't been tested...) Looks like
510 # GDB is currently trying to set the ignore count of bp # -1!
513 send_gdb "continue 2\n"
515 -re "Not stopped at any breakpoint; argument ignored..*$gdb_prompt $"\
516 {pass "continue with ignore count, not stopped at bpt"}
517 -re "No breakpoint number -1.*$gdb_prompt $"\
518 {xfail "(DTS'd) continue with ignore count, not stopped at bpt"}
520 {fail "continue with ignore count, not stopped at bpt"}
521 timeout {fail "(timeout) step after continue with ignore count, not stopped at bpt"}