]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.base/ena-dis-br.exp
This commit was generated by cvs2svn to track changes on a CVS vendor
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / ena-dis-br.exp
1 # Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
2
3
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.
8 #
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.
13 #
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. */
17
18 # Please email any bugs, comments, and/or additions to this file to:
19 # bug-gdb@prep.ai.mit.edu
20
21 if $tracelevel then {
22 strace $tracelevel
23 }
24
25 global usestubs
26
27 #
28 # test running programs
29 #
30 set prms_id 0
31 set bug_id 0
32
33 set testfile "break"
34 set srcfile ${testfile}.c
35 set binfile ${objdir}/${subdir}/${testfile}
36
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."
39 }
40
41 proc rerun_to_main {} {
42 global gdb_prompt
43
44 if [target_info exists use_gdb_stub] {
45 gdb_run_cmd
46 gdb_expect {
47 -re ".*Breakpoint .*main .*$gdb_prompt $"\
48 {pass "rerun to main" ; return 0}
49 -re "$gdb_prompt $"\
50 {fail "rerun to main" ; return 0}
51 timeout {fail "(timeout) rerun to main" ; return 0}
52 }
53 } else {
54 send_gdb "run\n"
55 gdb_expect {
56 -re "Starting program.*$gdb_prompt $"\
57 {pass "rerun to main" ; return 0}
58 -re "$gdb_prompt $"\
59 {fail "rerun to main" ; return 0}
60 timeout {fail "(timeout) rerun to main" ; return 0}
61 }
62 }
63 }
64
65 gdb_exit
66 gdb_start
67 gdb_reinitialize_dir $srcdir/$subdir
68 gdb_load ${binfile}
69
70 if ![runto_main] then { fail "enable/disable break tests suppressed" }
71
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.
74 #
75 send_gdb "break marker1\n"
76 gdb_expect {
77 -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\
78 {pass "break marker1"}
79 -re "$gdb_prompt $"\
80 {fail "break marker1"}
81 timeout {fail "(timeout) break marker1"}
82 }
83
84 send_gdb "enable $expect_out(1,string)\n"
85 gdb_expect {
86 -re "$gdb_prompt $"\
87 {pass "enable break marker1"}
88 timeout {fail "(timeout) enable break marker1"}
89 }
90
91 send_gdb "info break $expect_out(1,string)\n"
92 gdb_expect {
93 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*$gdb_prompt $"\
94 {pass "info break marker1"}
95 -re "$gdb_prompt $"\
96 {fail "info break marker1"}
97 timeout {fail "(timeout) info break marker1"}
98 }
99
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"
103 gdb_expect {
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"}
108 -re "$gdb_prompt $"\
109 {fail "continue to break marker1"}
110 timeout {fail "(timeout) continue to break marker1"}
111 }
112
113 send_gdb "delete $expect_out(1,string)\n"
114 gdb_expect {
115 -re "$gdb_prompt $"\
116 {pass "delete break marker1"}
117 timeout {fail "(timeout) delete break marker1"}
118 }
119
120 # Verify that we can set a breakpoint to be self-disabling after
121 # the first time it triggers.
122 #
123 send_gdb "break marker2\n"
124 gdb_expect {
125 -re "Breakpoint (\[0-9\]*) at .*, line 4\[49\].*$gdb_prompt $"\
126 {pass "break marker2"}
127 -re "$gdb_prompt $"\
128 {fail "break marker2"}
129 timeout {fail "(timeout) break marker2"}
130 }
131
132 send_gdb "enable once $expect_out(1,string)\n"
133 gdb_expect {
134 -re "$gdb_prompt $"\
135 {pass "enable once break marker2"}
136 timeout {fail "(timeout) enable once break marker2"}
137 }
138
139 send_gdb "info break $expect_out(1,string)\n"
140 gdb_expect {
141 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+y.*$gdb_prompt $"\
142 {pass "info auto-disabled break marker2"}
143 -re "$gdb_prompt $"\
144 {fail "info auto-disabled break marker2"}
145 timeout {fail "(timeout) info auto-disabled break marker2"}
146 }
147
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"
151 gdb_expect {
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"}
156 -re "$gdb_prompt $"\
157 {fail "continue to auto-disabled break marker2"}
158 timeout {fail "(timeout) continue to auto-disabled break marker2"}
159 }
160
161 send_gdb "info break $expect_out(1,string)\n"
162 gdb_expect {
163 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+n.*$gdb_prompt $"\
164 {pass "info auto-disabled break marker2"}
165 -re "$gdb_prompt $"\
166 {fail "info auto-disabled break marker2"}
167 timeout {fail "(timeout) info auto-disabled break marker2"}
168 }
169
170 # Verify that we don't stop at a disabled breakpoint.
171 #
172 gdb_continue_to_end "no stop"
173 rerun_to_main
174 gdb_continue_to_end "no stop at auto-disabled break marker2"
175
176 # Verify that we can set a breakpoint to be self-deleting after
177 # the first time it triggers.
178 #
179 if ![runto_main] then { fail "enable/disable break tests suppressed" }
180
181 send_gdb "break marker3\n"
182 gdb_expect {
183 -re "Breakpoint (\[0-9\]*) at .*, line (45|50).*$gdb_prompt $"\
184 {pass "break marker3"}
185 -re "$gdb_prompt $"\
186 {fail "break marker3"}
187 timeout {fail "(timeout) break marker3"}
188 }
189
190 send_gdb "enable del $expect_out(1,string)\n"
191 gdb_expect {
192 -re "$gdb_prompt $"\
193 {pass "enable del break marker3"}
194 timeout {fail "(timeout) enable del break marker3"}
195 }
196
197 send_gdb "info break $expect_out(1,string)\n"
198 gdb_expect {
199 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*$gdb_prompt $"\
200 {pass "info auto-deleted break marker2"}
201 -re "$gdb_prompt $"\
202 {fail "info auto-deleted break marker2"}
203 timeout {fail "(timeout) info auto-deleted break marker2"}
204 }
205
206 send_gdb "continue\n"
207 gdb_expect {
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"}
212 -re "$gdb_prompt $"\
213 {fail "continue to auto-deleted break marker3"}
214 timeout {fail "(timeout) continue to break marker3"}
215 }
216
217 send_gdb "info break $expect_out(1,string)\n"
218 gdb_expect {
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"}
223 -re "$gdb_prompt $"\
224 {fail "info auto-deleted break marker3"}
225 timeout {fail "(timeout) info auto-deleted break marker3"}
226 }
227
228 # Verify that we can set a breakpoint and manually disable it (we've
229 # already proven that disabled bp's don't trigger).
230 #
231 send_gdb "break marker4\n"
232 gdb_expect {
233 -re "Breakpoint (\[0-9\]*) at .*, line (46|51).*$gdb_prompt $"\
234 {pass "break marker4"}
235 -re "$gdb_prompt $"\
236 {fail "break marker4"}
237 timeout {fail "(timeout) break marker4"}
238 }
239
240 send_gdb "disable $expect_out(1,string)\n"
241 gdb_expect {
242 -re "$gdb_prompt $"\
243 {pass "disable break marker4"}
244 timeout {fail "(timeout) disable break marker4"}
245 }
246
247 send_gdb "info break $expect_out(1,string)\n"
248 gdb_expect {
249 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*$gdb_prompt $"\
250 {pass "info break marker4"}
251 -re "$gdb_prompt $"\
252 {fail "info break marker4"}
253 timeout {fail "(timeout) info break marker4"}
254 }
255
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.)
259 #
260 if ![runto_main] then { fail "enable/disable break tests suppressed" }
261
262 send_gdb "break marker1\n"
263 gdb_expect {
264 -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\
265 {pass "break marker1"}
266 -re "$gdb_prompt $"\
267 {fail "break marker1"}
268 timeout {fail "(timeout) break marker1"}
269 }
270
271 # Verify that an ignore of a non-existent breakpoint is gracefully
272 # handled.
273 #
274 send_gdb "ignore 999 2\n"
275 gdb_expect {
276 -re "No breakpoint number 999..*$gdb_prompt $"\
277 {pass "ignore non-existent break"}
278 -re "$gdb_prompt $"\
279 {fail "ignore non-existent break"}
280 timeout {fail "(timeout) ignore non-existent break"}
281 }
282
283 # Verify that a missing ignore count is gracefully handled.
284 #
285 send_gdb "ignore $expect_out(1,string) \n"
286 gdb_expect {
287 -re "Second argument .specified ignore-count. is missing..*$gdb_prompt $"\
288 {pass "ignore break with missing ignore count"}
289 -re "$gdb_prompt $"\
290 {fail "ignore break with missing ignore count"}
291 timeout {fail "(timeout) ignore break with missing ignore count"}
292 }
293
294 # Verify that a negative or zero ignore count is handled gracefully
295 # (they both are treated the same).
296 #
297 send_gdb "ignore $expect_out(1,string) -1\n"
298 gdb_expect {
299 -re "Will stop next time breakpoint \[0-9\]* is reached..*$gdb_prompt $"\
300 {pass "ignore break marker1 -1"}
301 -re "$gdb_prompt $"\
302 {fail "ignore break marker1 -1"}
303 timeout {fail "(timeout) ignore break marker1 -1"}
304 }
305
306 send_gdb "ignore $expect_out(1,string) 0\n"
307 gdb_expect {
308 -re "Will stop next time breakpoint \[0-9\]* is reached..*$gdb_prompt $"\
309 {pass "ignore break marker1 0"}
310 -re "$gdb_prompt $"\
311 {fail "ignore break marker1 0"}
312 timeout {fail "(timeout) ignore break marker1 0"}
313 }
314
315 send_gdb "ignore $expect_out(1,string) 1\n"
316 gdb_expect {
317 -re "Will ignore next crossing of breakpoint \[0-9\]*.*$gdb_prompt $"\
318 {pass "ignore break marker1"}
319 -re "$gdb_prompt $"\
320 {fail "ignore break marker1"}
321 timeout {fail "(timeout) ignore break marker1"}
322 }
323
324 send_gdb "info break $expect_out(1,string)\n"
325 gdb_expect {
326 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*ignore next 1 hits.*$gdb_prompt $"\
327 {pass "info ignored break marker1"}
328 -re "$gdb_prompt $"\
329 {fail "info ignored break marker1"}
330 timeout {fail "(timeout) info ignored break marker1"}
331 }
332
333 gdb_continue_to_end "no stop at ignored break marker1"
334 rerun_to_main
335
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"
339 gdb_expect {
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"}
344 -re "$gdb_prompt $"\
345 {fail "continue to break marker1, 2nd time"}
346 timeout {fail "(timeout) continue to break marker1, 2nd time"}
347 }
348
349 # Verify that we can specify both an ignore count and an auto-delete.
350 #
351 if ![runto_main] then { fail "enable/disable break tests suppressed" }
352
353 send_gdb "break marker1\n"
354 gdb_expect {
355 -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\
356 {pass "break marker1"}
357 -re "$gdb_prompt $"\
358 {fail "break marker1"}
359 timeout {fail "(timeout) break marker1"}
360 }
361
362 send_gdb "ignore $expect_out(1,string) 1\n"
363 gdb_expect {
364 -re "Will ignore next crossing of breakpoint \[0-9\]*.*$gdb_prompt $"\
365 {pass "ignore break marker1"}
366 -re "$gdb_prompt $"\
367 {fail "ignore break marker1"}
368 timeout {fail "(timeout) ignore break marker1"}
369 }
370
371 send_gdb "enable del $expect_out(1,string)\n"
372 gdb_expect {
373 -re "$gdb_prompt $"\
374 {pass "enable del break marker1"}
375 timeout {fail "(timeout) enable del break marker1"}
376 }
377
378 send_gdb "info break $expect_out(1,string)\n"
379 gdb_expect {
380 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*ignore next 1 hits.*$gdb_prompt $"\
381 {pass "info break marker1"}
382 -re "$gdb_prompt $"\
383 {fail "info break marker1"}
384 timeout {fail "(timeout) info break marker2"}
385 }
386
387 gdb_continue_to_end "no stop at ignored & auto-deleted break marker1"
388 rerun_to_main
389
390 send_gdb "continue\n"
391 gdb_expect {
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"}
396 -re "$gdb_prompt $"\
397 {fail "continue to ignored & auto-deleted break marker1"}
398 timeout {fail "(timeout) continue to ignored & auto-deleted break marker1"}
399 }
400
401 # Verify that a disabled breakpoint's ignore count isn't updated when
402 # the bp is encountered.
403 #
404 if ![runto_main] then { fail "enable/disable break tests suppressed" }
405
406 send_gdb "break marker1\n"
407 gdb_expect {
408 -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\
409 {pass "break marker1"}
410 -re "$gdb_prompt $"\
411 {fail "break marker1"}
412 timeout {fail "(timeout) break marker1"}
413 }
414
415 send_gdb "ignore $expect_out(1,string) 10\n"
416 gdb_expect {
417 -re "Will ignore next 10 crossings of breakpoint \[0-9\]*.*$gdb_prompt $"\
418 {pass "ignore break marker1"}
419 -re "$gdb_prompt $"\
420 {fail "ignore break marker1"}
421 timeout {fail "(timeout) ignore break marker1"}
422 }
423
424 send_gdb "disable $expect_out(1,string)\n"
425 gdb_expect {
426 -re "$gdb_prompt $"\
427 {pass "disable break marker1"}
428 timeout {fail "(timeout) disable break marker1"}
429 }
430
431 gdb_continue_to_end "no stop at ignored & disabled break marker1"
432 rerun_to_main
433
434 send_gdb "info break $expect_out(1,string)\n"
435 gdb_expect {
436 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*ignore next 10 hits.*$gdb_prompt $"\
437 {pass "info ignored & disabled break marker1"}
438 -re "$gdb_prompt $"\
439 {fail "info ignored & disabled break marker1"}
440 timeout {fail "(timeout) info ignored & disabled break marker1"}
441 }
442
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.)
447 #
448 if ![runto_main] then { fail "enable/disable break tests suppressed" }
449
450 send_gdb "break 79\n"
451 gdb_expect {
452 -re "Breakpoint \[0-9\]*.*, line 79.*$gdb_prompt $"\
453 {pass "prepare to continue with ignore count"}
454 -re "$gdb_prompt $"\
455 {fail "prepare to continue with ignore count"}
456 timeout {fail "(timeout) prepare to continue with ignore count"}
457 }
458 send_gdb "continue 2\n"
459 gdb_expect {
460 -re "Will ignore next crossing of breakpoint \[0-9\]*. Continuing..*$gdb_prompt $"\
461 {pass "continue with ignore count"}
462 -re "$gdb_prompt $"\
463 {fail "continue with ignore count"}
464 timeout {fail "(timeout) continue with ignore count"}
465 }
466
467 send_gdb "next\n"
468 gdb_expect {
469 -re ".*81\[ \t\]*marker1.*$gdb_prompt $"\
470 {pass "step after continue with ignore count"}
471 -re "$gdb_prompt $"\
472 {fail "step after continue with ignore count"}
473 timeout {fail "(timeout) step after continue with ignore count"}
474 }
475
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!
479 #
480 setup_xfail hppa_*_*
481 send_gdb "continue 2\n"
482 gdb_expect {
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"}
487 -re "$gdb_prompt $"\
488 {fail "continue with ignore count, not stopped at bpt"}
489 timeout {fail "(timeout) step after continue with ignore count, not stopped at bpt"}
490 }
491
492 gdb_exit
493 return 0