1 # Copyright 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."
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 4\[38\].*$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"}
76 # See the comments in condbreak.exp for "run until breakpoint at marker1"
77 # for an explanation of the xfail below.
80 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
81 {pass "continue to break marker1"}
82 -re "Breakpoint \[0-9\]*, $hex in marker1.*$gdb_prompt $"\
83 {xfail "continue to break marker1"}
85 {fail "continue to break marker1"}
86 timeout {fail "(timeout) continue to break marker1"}
89 send_gdb "delete $expect_out(1,string)\n"
92 {pass "delete break marker1"}
93 timeout {fail "(timeout) delete break marker1"}
96 # Verify that we can set a breakpoint to be self-disabling after
97 # the first time it triggers.
99 send_gdb "break marker2\n"
101 -re "Breakpoint (\[0-9\]*) at .*, line 4\[49\].*$gdb_prompt $"\
102 {pass "break marker2"}
104 {fail "break marker2"}
105 timeout {fail "(timeout) break marker2"}
108 send_gdb "enable once $expect_out(1,string)\n"
111 {pass "enable once break marker2"}
112 timeout {fail "(timeout) enable once break marker2"}
115 send_gdb "info break $expect_out(1,string)\n"
117 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+y.*$gdb_prompt $"\
118 {pass "info auto-disabled break marker2"}
120 {fail "info auto-disabled break marker2"}
121 timeout {fail "(timeout) info auto-disabled break marker2"}
124 # See the comments in condbreak.exp for "run until breakpoint at marker1"
125 # for an explanation of the xfail below.
126 send_gdb "continue\n"
128 -re "Breakpoint \[0-9\]*, marker2.*$gdb_prompt $"\
129 {pass "continue to auto-disabled break marker2"}
130 -re "Breakpoint \[0-9\]*, $hex in marker2.*$gdb_prompt $"\
131 {xfail "continue to auto-disabled break marker2"}
133 {fail "continue to auto-disabled break marker2"}
134 timeout {fail "(timeout) continue to auto-disabled break marker2"}
137 send_gdb "info break $expect_out(1,string)\n"
139 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+n.*$gdb_prompt $"\
140 {pass "info auto-disabled break marker2"}
142 {fail "info auto-disabled break marker2"}
143 timeout {fail "(timeout) info auto-disabled break marker2"}
146 # Verify that we don't stop at a disabled breakpoint.
148 gdb_continue_to_end "no stop"
150 gdb_continue_to_end "no stop at auto-disabled break marker2"
152 # Verify that we can set a breakpoint to be self-deleting after
153 # the first time it triggers.
155 if ![runto_main] then { fail "enable/disable break tests suppressed" }
157 send_gdb "break marker3\n"
159 -re "Breakpoint (\[0-9\]*) at .*, line (45|50).*$gdb_prompt $"\
160 {pass "break marker3"}
162 {fail "break marker3"}
163 timeout {fail "(timeout) break marker3"}
166 send_gdb "enable del $expect_out(1,string)\n"
169 {pass "enable del break marker3"}
170 timeout {fail "(timeout) enable del break marker3"}
173 send_gdb "info break $expect_out(1,string)\n"
175 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*$gdb_prompt $"\
176 {pass "info auto-deleted break marker2"}
178 {fail "info auto-deleted break marker2"}
179 timeout {fail "(timeout) info auto-deleted break marker2"}
182 send_gdb "continue\n"
184 -re ".*marker3 .*:(45|50).*$gdb_prompt $"\
185 {pass "continue to auto-deleted break marker3"}
186 -re "Breakpoint \[0-9\]*, marker3.*$gdb_prompt $"\
187 {fail "continue to auto-deleted break marker3"}
189 {fail "continue to auto-deleted break marker3"}
190 timeout {fail "(timeout) continue to break marker3"}
193 send_gdb "info break $expect_out(1,string)\n"
195 -re ".*No breakpoint or watchpoint number.*$gdb_prompt $"\
196 {pass "info auto-deleted break marker3"}
197 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\].*$gdb_prompt $"\
198 {fail "info auto-deleted break marker3"}
200 {fail "info auto-deleted break marker3"}
201 timeout {fail "(timeout) info auto-deleted break marker3"}
204 # Verify that we can set a breakpoint and manually disable it (we've
205 # already proven that disabled bp's don't trigger).
207 send_gdb "break marker4\n"
209 -re "Breakpoint (\[0-9\]*) at .*, line (46|51).*$gdb_prompt $"\
210 {pass "break marker4"}
212 {fail "break marker4"}
213 timeout {fail "(timeout) break marker4"}
216 send_gdb "disable $expect_out(1,string)\n"
219 {pass "disable break marker4"}
220 timeout {fail "(timeout) disable break marker4"}
223 send_gdb "info break $expect_out(1,string)\n"
225 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*$gdb_prompt $"\
226 {pass "info break marker4"}
228 {fail "info break marker4"}
229 timeout {fail "(timeout) info break marker4"}
232 # Verify that we can set a breakpoint with an ignore count N, which
233 # should cause the next N triggers of the bp to be ignored. (This is
234 # a flavor of enablement/disablement, after all.)
236 if ![runto_main] then { fail "enable/disable break tests suppressed" }
238 send_gdb "break marker1\n"
240 -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\
241 {pass "break marker1"}
243 {fail "break marker1"}
244 timeout {fail "(timeout) break marker1"}
247 # Verify that an ignore of a non-existent breakpoint is gracefully
250 send_gdb "ignore 999 2\n"
252 -re "No breakpoint number 999..*$gdb_prompt $"\
253 {pass "ignore non-existent break"}
255 {fail "ignore non-existent break"}
256 timeout {fail "(timeout) ignore non-existent break"}
259 # Verify that a missing ignore count is gracefully handled.
261 send_gdb "ignore $expect_out(1,string) \n"
263 -re "Second argument .specified ignore-count. is missing..*$gdb_prompt $"\
264 {pass "ignore break with missing ignore count"}
266 {fail "ignore break with missing ignore count"}
267 timeout {fail "(timeout) ignore break with missing ignore count"}
270 # Verify that a negative or zero ignore count is handled gracefully
271 # (they both are treated the same).
273 send_gdb "ignore $expect_out(1,string) -1\n"
275 -re "Will stop next time breakpoint \[0-9\]* is reached..*$gdb_prompt $"\
276 {pass "ignore break marker1 -1"}
278 {fail "ignore break marker1 -1"}
279 timeout {fail "(timeout) ignore break marker1 -1"}
282 send_gdb "ignore $expect_out(1,string) 0\n"
284 -re "Will stop next time breakpoint \[0-9\]* is reached..*$gdb_prompt $"\
285 {pass "ignore break marker1 0"}
287 {fail "ignore break marker1 0"}
288 timeout {fail "(timeout) ignore break marker1 0"}
291 send_gdb "ignore $expect_out(1,string) 1\n"
293 -re "Will ignore next crossing of breakpoint \[0-9\]*.*$gdb_prompt $"\
294 {pass "ignore break marker1"}
296 {fail "ignore break marker1"}
297 timeout {fail "(timeout) ignore break marker1"}
300 send_gdb "info break $expect_out(1,string)\n"
302 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*ignore next 1 hits.*$gdb_prompt $"\
303 {pass "info ignored break marker1"}
305 {fail "info ignored break marker1"}
306 timeout {fail "(timeout) info ignored break marker1"}
309 gdb_continue_to_end "no stop at ignored break marker1"
312 # See the comments in condbreak.exp for "run until breakpoint at marker1"
313 # for an explanation of the xfail below.
314 send_gdb "continue\n"
316 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
317 {pass "continue to break marker1, 2nd time"}
318 -re "Breakpoint \[0-9\]*, $hex in marker1.*$gdb_prompt $"\
319 {xfail "continue to break marker1, 2nd time"}
321 {fail "continue to break marker1, 2nd time"}
322 timeout {fail "(timeout) continue to break marker1, 2nd time"}
325 # Verify that we can specify both an ignore count and an auto-delete.
327 if ![runto_main] then { fail "enable/disable break tests suppressed" }
329 send_gdb "break marker1\n"
331 -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\
332 {pass "break marker1"}
334 {fail "break marker1"}
335 timeout {fail "(timeout) break marker1"}
338 send_gdb "ignore $expect_out(1,string) 1\n"
340 -re "Will ignore next crossing of breakpoint \[0-9\]*.*$gdb_prompt $"\
341 {pass "ignore break marker1"}
343 {fail "ignore break marker1"}
344 timeout {fail "(timeout) ignore break marker1"}
347 send_gdb "enable del $expect_out(1,string)\n"
350 {pass "enable del break marker1"}
351 timeout {fail "(timeout) enable del break marker1"}
354 send_gdb "info break $expect_out(1,string)\n"
356 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*ignore next 1 hits.*$gdb_prompt $"\
357 {pass "info break marker1"}
359 {fail "info break marker1"}
360 timeout {fail "(timeout) info break marker2"}
363 gdb_continue_to_end "no stop at ignored & auto-deleted break marker1"
366 send_gdb "continue\n"
368 -re ".*marker1 .*:4\[38\].*$gdb_prompt $"\
369 {pass "continue to ignored & auto-deleted break marker1"}
370 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
371 {fail "continue to ignored & auto-deleted break marker1"}
373 {fail "continue to ignored & auto-deleted break marker1"}
374 timeout {fail "(timeout) continue to ignored & auto-deleted break marker1"}
377 # Verify that a disabled breakpoint's ignore count isn't updated when
378 # the bp is encountered.
380 if ![runto_main] then { fail "enable/disable break tests suppressed" }
382 send_gdb "break marker1\n"
384 -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\
385 {pass "break marker1"}
387 {fail "break marker1"}
388 timeout {fail "(timeout) break marker1"}
391 send_gdb "ignore $expect_out(1,string) 10\n"
393 -re "Will ignore next 10 crossings of breakpoint \[0-9\]*.*$gdb_prompt $"\
394 {pass "ignore break marker1"}
396 {fail "ignore break marker1"}
397 timeout {fail "(timeout) ignore break marker1"}
400 send_gdb "disable $expect_out(1,string)\n"
403 {pass "disable break marker1"}
404 timeout {fail "(timeout) disable break marker1"}
407 gdb_continue_to_end "no stop at ignored & disabled break marker1"
410 send_gdb "info break $expect_out(1,string)\n"
412 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*ignore next 10 hits.*$gdb_prompt $"\
413 {pass "info ignored & disabled break marker1"}
415 {fail "info ignored & disabled break marker1"}
416 timeout {fail "(timeout) info ignored & disabled break marker1"}
419 # Verify that GDB correctly handles the "continue" command with an argument,
420 # which is an ignore count to set on the currently stopped-at breakpoint.
421 # (Also verify that GDB gracefully handles the case where the inferior
422 # isn't stopped at a breakpoint.)
424 if ![runto_main] then { fail "enable/disable break tests suppressed" }
426 send_gdb "break 79\n"
428 -re "Breakpoint \[0-9\]*.*, line 79.*$gdb_prompt $"\
429 {pass "prepare to continue with ignore count"}
431 {fail "prepare to continue with ignore count"}
432 timeout {fail "(timeout) prepare to continue with ignore count"}
434 send_gdb "continue 2\n"
436 -re "Will ignore next crossing of breakpoint \[0-9\]*. Continuing..*$gdb_prompt $"\
437 {pass "continue with ignore count"}
439 {fail "continue with ignore count"}
440 timeout {fail "(timeout) continue with ignore count"}
445 -re ".*81\[ \t\]*marker1.*$gdb_prompt $"\
446 {pass "step after continue with ignore count"}
448 {fail "step after continue with ignore count"}
449 timeout {fail "(timeout) step after continue with ignore count"}
452 # ??rehrauer: Huh. This appears to be an actual bug. (No big
453 # surprise, since this feature hasn't been tested...) Looks like
454 # GDB is currently trying to set the ignore count of bp # -1!
457 send_gdb "continue 2\n"
459 -re "Not stopped at any breakpoint; argument ignored..*$gdb_prompt $"\
460 {pass "continue with ignore count, not stopped at bpt"}
461 -re "No breakpoint number -1.*$gdb_prompt $"\
462 {xfail "(DTS'd) continue with ignore count, not stopped at bpt"}
464 {fail "continue with ignore count, not stopped at bpt"}
465 timeout {fail "(timeout) step after continue with ignore count, not stopped at bpt"}