import gdb-1999-11-08 snapshot
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / ena-dis-br.exp
CommitLineData
7a292a7a 1# Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
c906108c
SS
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
21if $tracelevel then {
22 strace $tracelevel
23 }
24
25global usestubs
26
27#
28# test running programs
29#
30set prms_id 0
31set bug_id 0
32
33set testfile "break"
34set srcfile ${testfile}.c
35set binfile ${objdir}/${subdir}/${testfile}
36
37if { [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
7a292a7a
SS
41proc 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
c906108c
SS
65gdb_exit
66gdb_start
67gdb_reinitialize_dir $srcdir/$subdir
68gdb_load ${binfile}
69
70if ![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#
75send_gdb "break marker1\n"
76gdb_expect {
085dd6e6 77 -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\
c906108c
SS
78 {pass "break marker1"}
79 -re "$gdb_prompt $"\
80 {fail "break marker1"}
81 timeout {fail "(timeout) break marker1"}
82}
83
84send_gdb "enable $expect_out(1,string)\n"
85gdb_expect {
86 -re "$gdb_prompt $"\
87 {pass "enable break marker1"}
88 timeout {fail "(timeout) enable break marker1"}
89}
90
91send_gdb "info break $expect_out(1,string)\n"
92gdb_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
11cf8741
JM
100# See the comments in condbreak.exp for "run until breakpoint at marker1"
101# for an explanation of the xfail below.
c906108c
SS
102send_gdb "continue\n"
103gdb_expect {
104 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
105 {pass "continue to break marker1"}
11cf8741
JM
106 -re "Breakpoint \[0-9\]*, $hex in marker1.*$gdb_prompt $"\
107 {xfail "continue to break marker1"}
c906108c
SS
108 -re "$gdb_prompt $"\
109 {fail "continue to break marker1"}
110 timeout {fail "(timeout) continue to break marker1"}
111}
112
113send_gdb "delete $expect_out(1,string)\n"
114gdb_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#
123send_gdb "break marker2\n"
124gdb_expect {
085dd6e6 125 -re "Breakpoint (\[0-9\]*) at .*, line 4\[49\].*$gdb_prompt $"\
c906108c
SS
126 {pass "break marker2"}
127 -re "$gdb_prompt $"\
128 {fail "break marker2"}
129 timeout {fail "(timeout) break marker2"}
130}
131
132send_gdb "enable once $expect_out(1,string)\n"
133gdb_expect {
134 -re "$gdb_prompt $"\
135 {pass "enable once break marker2"}
136 timeout {fail "(timeout) enable once break marker2"}
137}
138
139send_gdb "info break $expect_out(1,string)\n"
140gdb_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
11cf8741
JM
148# See the comments in condbreak.exp for "run until breakpoint at marker1"
149# for an explanation of the xfail below.
c906108c
SS
150send_gdb "continue\n"
151gdb_expect {
152 -re "Breakpoint \[0-9\]*, marker2.*$gdb_prompt $"\
153 {pass "continue to auto-disabled break marker2"}
11cf8741
JM
154 -re "Breakpoint \[0-9\]*, $hex in marker2.*$gdb_prompt $"\
155 {xfail "continue to auto-disabled break marker2"}
c906108c
SS
156 -re "$gdb_prompt $"\
157 {fail "continue to auto-disabled break marker2"}
158 timeout {fail "(timeout) continue to auto-disabled break marker2"}
159}
160
161send_gdb "info break $expect_out(1,string)\n"
162gdb_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#
7a292a7a
SS
172gdb_continue_to_end "no stop"
173rerun_to_main
174gdb_continue_to_end "no stop at auto-disabled break marker2"
c906108c
SS
175
176# Verify that we can set a breakpoint to be self-deleting after
177# the first time it triggers.
178#
179if ![runto_main] then { fail "enable/disable break tests suppressed" }
180
181send_gdb "break marker3\n"
182gdb_expect {
085dd6e6 183 -re "Breakpoint (\[0-9\]*) at .*, line (45|50).*$gdb_prompt $"\
c906108c
SS
184 {pass "break marker3"}
185 -re "$gdb_prompt $"\
186 {fail "break marker3"}
187 timeout {fail "(timeout) break marker3"}
188}
189
190send_gdb "enable del $expect_out(1,string)\n"
191gdb_expect {
192 -re "$gdb_prompt $"\
193 {pass "enable del break marker3"}
194 timeout {fail "(timeout) enable del break marker3"}
195}
196
197send_gdb "info break $expect_out(1,string)\n"
198gdb_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
206send_gdb "continue\n"
207gdb_expect {
085dd6e6 208 -re ".*marker3 .*:(45|50).*$gdb_prompt $"\
c906108c
SS
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
217send_gdb "info break $expect_out(1,string)\n"
218gdb_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#
231send_gdb "break marker4\n"
232gdb_expect {
085dd6e6 233 -re "Breakpoint (\[0-9\]*) at .*, line (46|51).*$gdb_prompt $"\
c906108c
SS
234 {pass "break marker4"}
235 -re "$gdb_prompt $"\
236 {fail "break marker4"}
237 timeout {fail "(timeout) break marker4"}
238}
239
240send_gdb "disable $expect_out(1,string)\n"
241gdb_expect {
242 -re "$gdb_prompt $"\
243 {pass "disable break marker4"}
244 timeout {fail "(timeout) disable break marker4"}
245}
246
247send_gdb "info break $expect_out(1,string)\n"
248gdb_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#
260if ![runto_main] then { fail "enable/disable break tests suppressed" }
261
262send_gdb "break marker1\n"
263gdb_expect {
085dd6e6 264 -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\
c906108c
SS
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#
274send_gdb "ignore 999 2\n"
275gdb_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#
285send_gdb "ignore $expect_out(1,string) \n"
286gdb_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#
297send_gdb "ignore $expect_out(1,string) -1\n"
298gdb_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
306send_gdb "ignore $expect_out(1,string) 0\n"
307gdb_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
315send_gdb "ignore $expect_out(1,string) 1\n"
316gdb_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
324send_gdb "info break $expect_out(1,string)\n"
325gdb_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
7a292a7a
SS
333gdb_continue_to_end "no stop at ignored break marker1"
334rerun_to_main
c906108c 335
11cf8741
JM
336# See the comments in condbreak.exp for "run until breakpoint at marker1"
337# for an explanation of the xfail below.
c906108c
SS
338send_gdb "continue\n"
339gdb_expect {
340 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
11cf8741
JM
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"}
c906108c 344 -re "$gdb_prompt $"\
11cf8741
JM
345 {fail "continue to break marker1, 2nd time"}
346 timeout {fail "(timeout) continue to break marker1, 2nd time"}
c906108c
SS
347}
348
349# Verify that we can specify both an ignore count and an auto-delete.
350#
351if ![runto_main] then { fail "enable/disable break tests suppressed" }
352
353send_gdb "break marker1\n"
354gdb_expect {
085dd6e6 355 -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\
c906108c
SS
356 {pass "break marker1"}
357 -re "$gdb_prompt $"\
358 {fail "break marker1"}
359 timeout {fail "(timeout) break marker1"}
360}
361
362send_gdb "ignore $expect_out(1,string) 1\n"
363gdb_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
371send_gdb "enable del $expect_out(1,string)\n"
372gdb_expect {
373 -re "$gdb_prompt $"\
374 {pass "enable del break marker1"}
375 timeout {fail "(timeout) enable del break marker1"}
376}
377
378send_gdb "info break $expect_out(1,string)\n"
379gdb_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
7a292a7a
SS
387gdb_continue_to_end "no stop at ignored & auto-deleted break marker1"
388rerun_to_main
c906108c
SS
389
390send_gdb "continue\n"
391gdb_expect {
085dd6e6 392 -re ".*marker1 .*:4\[38\].*$gdb_prompt $"\
c906108c
SS
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#
404if ![runto_main] then { fail "enable/disable break tests suppressed" }
405
406send_gdb "break marker1\n"
407gdb_expect {
085dd6e6 408 -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\
c906108c
SS
409 {pass "break marker1"}
410 -re "$gdb_prompt $"\
411 {fail "break marker1"}
412 timeout {fail "(timeout) break marker1"}
413}
414
415send_gdb "ignore $expect_out(1,string) 10\n"
416gdb_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
424send_gdb "disable $expect_out(1,string)\n"
425gdb_expect {
426 -re "$gdb_prompt $"\
427 {pass "disable break marker1"}
428 timeout {fail "(timeout) disable break marker1"}
429}
430
7a292a7a
SS
431gdb_continue_to_end "no stop at ignored & disabled break marker1"
432rerun_to_main
c906108c
SS
433
434send_gdb "info break $expect_out(1,string)\n"
435gdb_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#
448if ![runto_main] then { fail "enable/disable break tests suppressed" }
449
085dd6e6 450send_gdb "break 79\n"
c906108c 451gdb_expect {
085dd6e6 452 -re "Breakpoint \[0-9\]*.*, line 79.*$gdb_prompt $"\
c906108c
SS
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}
458send_gdb "continue 2\n"
459gdb_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
467send_gdb "next\n"
468gdb_expect {
085dd6e6 469 -re ".*81\[ \t\]*marker1.*$gdb_prompt $"\
c906108c
SS
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#
480setup_xfail hppa_*_*
481send_gdb "continue 2\n"
482gdb_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
492gdb_exit
493return 0
This page took 0.069039 seconds and 4 git commands to generate.