Initial creation of sourceware repository
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / ena-dis-br.exp
CommitLineData
c906108c
SS
1# Copyright (C) 1997, 1998 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
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
41gdb_exit
42gdb_start
43gdb_reinitialize_dir $srcdir/$subdir
44gdb_load ${binfile}
45
46if ![runto_main] then { fail "enable/disable break tests suppressed" }
47
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.
50#
51send_gdb "break marker1\n"
52gdb_expect {
53 -re "Breakpoint (\[0-9\]*) at .*, line 41.*$gdb_prompt $"\
54 {pass "break marker1"}
55 -re "$gdb_prompt $"\
56 {fail "break marker1"}
57 timeout {fail "(timeout) break marker1"}
58}
59
60send_gdb "enable $expect_out(1,string)\n"
61gdb_expect {
62 -re "$gdb_prompt $"\
63 {pass "enable break marker1"}
64 timeout {fail "(timeout) enable break marker1"}
65}
66
67send_gdb "info break $expect_out(1,string)\n"
68gdb_expect {
69 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*$gdb_prompt $"\
70 {pass "info break marker1"}
71 -re "$gdb_prompt $"\
72 {fail "info break marker1"}
73 timeout {fail "(timeout) info break marker1"}
74}
75
76send_gdb "continue\n"
77gdb_expect {
78 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
79 {pass "continue to break marker1"}
80 -re "$gdb_prompt $"\
81 {fail "continue to break marker1"}
82 timeout {fail "(timeout) continue to break marker1"}
83}
84
85send_gdb "delete $expect_out(1,string)\n"
86gdb_expect {
87 -re "$gdb_prompt $"\
88 {pass "delete break marker1"}
89 timeout {fail "(timeout) delete break marker1"}
90}
91
92# Verify that we can set a breakpoint to be self-disabling after
93# the first time it triggers.
94#
95send_gdb "break marker2\n"
96gdb_expect {
97 -re "Breakpoint (\[0-9\]*) at .*, line 42.*$gdb_prompt $"\
98 {pass "break marker2"}
99 -re "$gdb_prompt $"\
100 {fail "break marker2"}
101 timeout {fail "(timeout) break marker2"}
102}
103
104send_gdb "enable once $expect_out(1,string)\n"
105gdb_expect {
106 -re "$gdb_prompt $"\
107 {pass "enable once break marker2"}
108 timeout {fail "(timeout) enable once break marker2"}
109}
110
111send_gdb "info break $expect_out(1,string)\n"
112gdb_expect {
113 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+y.*$gdb_prompt $"\
114 {pass "info auto-disabled break marker2"}
115 -re "$gdb_prompt $"\
116 {fail "info auto-disabled break marker2"}
117 timeout {fail "(timeout) info auto-disabled break marker2"}
118}
119
120send_gdb "continue\n"
121gdb_expect {
122 -re "Breakpoint \[0-9\]*, marker2.*$gdb_prompt $"\
123 {pass "continue to auto-disabled break marker2"}
124 -re "$gdb_prompt $"\
125 {fail "continue to auto-disabled break marker2"}
126 timeout {fail "(timeout) continue to auto-disabled break marker2"}
127}
128
129send_gdb "info break $expect_out(1,string)\n"
130gdb_expect {
131 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+n.*$gdb_prompt $"\
132 {pass "info auto-disabled break marker2"}
133 -re "$gdb_prompt $"\
134 {fail "info auto-disabled break marker2"}
135 timeout {fail "(timeout) info auto-disabled break marker2"}
136}
137
138# Verify that we don't stop at a disabled breakpoint.
139#
140send_gdb "continue\n"
141gdb_expect {
142 -re ".*Program exited normally.*$gdb_prompt $"\
143 {pass "no stop"}
144 -re "$gdb_prompt $"\
145 {fail "no stop"}
146 timeout {fail "(timeout) no stop"}
147}
148
149send_gdb "run\n"
150gdb_expect {
151 -re "Starting program.*$gdb_prompt $"\
152 {pass "rerun to main"}
153 -re "$gdb_prompt $"\
154 {fail "rerun to main"}
155 timeout {fail "(timeout) rerun to main"}
156}
157
158send_gdb "continue\n"
159gdb_expect {
160 -re ".*Program exited normally.*$gdb_prompt $"\
161 {pass "no stop at auto-disabled break marker2"}
162 -re "$gdb_prompt $"\
163 {fail "no stop at auto-disabled break marker2"}
164 timeout {fail "(timeout) no stop at auto-disabled break marker2"}
165}
166
167# Verify that we can set a breakpoint to be self-deleting after
168# the first time it triggers.
169#
170if ![runto_main] then { fail "enable/disable break tests suppressed" }
171
172send_gdb "break marker3\n"
173gdb_expect {
174 -re "Breakpoint (\[0-9\]*) at .*, line 43.*$gdb_prompt $"\
175 {pass "break marker3"}
176 -re "$gdb_prompt $"\
177 {fail "break marker3"}
178 timeout {fail "(timeout) break marker3"}
179}
180
181send_gdb "enable del $expect_out(1,string)\n"
182gdb_expect {
183 -re "$gdb_prompt $"\
184 {pass "enable del break marker3"}
185 timeout {fail "(timeout) enable del break marker3"}
186}
187
188send_gdb "info break $expect_out(1,string)\n"
189gdb_expect {
190 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*$gdb_prompt $"\
191 {pass "info auto-deleted break marker2"}
192 -re "$gdb_prompt $"\
193 {fail "info auto-deleted break marker2"}
194 timeout {fail "(timeout) info auto-deleted break marker2"}
195}
196
197send_gdb "continue\n"
198gdb_expect {
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"}
203 -re "$gdb_prompt $"\
204 {fail "continue to auto-deleted break marker3"}
205 timeout {fail "(timeout) continue to break marker3"}
206}
207
208send_gdb "info break $expect_out(1,string)\n"
209gdb_expect {
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"}
214 -re "$gdb_prompt $"\
215 {fail "info auto-deleted break marker3"}
216 timeout {fail "(timeout) info auto-deleted break marker3"}
217}
218
219# Verify that we can set a breakpoint and manually disable it (we've
220# already proven that disabled bp's don't trigger).
221#
222send_gdb "break marker4\n"
223gdb_expect {
224 -re "Breakpoint (\[0-9\]*) at .*, line 44.*$gdb_prompt $"\
225 {pass "break marker4"}
226 -re "$gdb_prompt $"\
227 {fail "break marker4"}
228 timeout {fail "(timeout) break marker4"}
229}
230
231send_gdb "disable $expect_out(1,string)\n"
232gdb_expect {
233 -re "$gdb_prompt $"\
234 {pass "disable break marker4"}
235 timeout {fail "(timeout) disable break marker4"}
236}
237
238send_gdb "info break $expect_out(1,string)\n"
239gdb_expect {
240 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*$gdb_prompt $"\
241 {pass "info break marker4"}
242 -re "$gdb_prompt $"\
243 {fail "info break marker4"}
244 timeout {fail "(timeout) info break marker4"}
245}
246
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.)
250#
251if ![runto_main] then { fail "enable/disable break tests suppressed" }
252
253send_gdb "break marker1\n"
254gdb_expect {
255 -re "Breakpoint (\[0-9\]*) at .*, line 41.*$gdb_prompt $"\
256 {pass "break marker1"}
257 -re "$gdb_prompt $"\
258 {fail "break marker1"}
259 timeout {fail "(timeout) break marker1"}
260}
261
262# Verify that an ignore of a non-existent breakpoint is gracefully
263# handled.
264#
265send_gdb "ignore 999 2\n"
266gdb_expect {
267 -re "No breakpoint number 999..*$gdb_prompt $"\
268 {pass "ignore non-existent break"}
269 -re "$gdb_prompt $"\
270 {fail "ignore non-existent break"}
271 timeout {fail "(timeout) ignore non-existent break"}
272}
273
274# Verify that a missing ignore count is gracefully handled.
275#
276send_gdb "ignore $expect_out(1,string) \n"
277gdb_expect {
278 -re "Second argument .specified ignore-count. is missing..*$gdb_prompt $"\
279 {pass "ignore break with missing ignore count"}
280 -re "$gdb_prompt $"\
281 {fail "ignore break with missing ignore count"}
282 timeout {fail "(timeout) ignore break with missing ignore count"}
283}
284
285# Verify that a negative or zero ignore count is handled gracefully
286# (they both are treated the same).
287#
288send_gdb "ignore $expect_out(1,string) -1\n"
289gdb_expect {
290 -re "Will stop next time breakpoint \[0-9\]* is reached..*$gdb_prompt $"\
291 {pass "ignore break marker1 -1"}
292 -re "$gdb_prompt $"\
293 {fail "ignore break marker1 -1"}
294 timeout {fail "(timeout) ignore break marker1 -1"}
295}
296
297send_gdb "ignore $expect_out(1,string) 0\n"
298gdb_expect {
299 -re "Will stop next time breakpoint \[0-9\]* is reached..*$gdb_prompt $"\
300 {pass "ignore break marker1 0"}
301 -re "$gdb_prompt $"\
302 {fail "ignore break marker1 0"}
303 timeout {fail "(timeout) ignore break marker1 0"}
304}
305
306send_gdb "ignore $expect_out(1,string) 1\n"
307gdb_expect {
308 -re "Will ignore next crossing of breakpoint \[0-9\]*.*$gdb_prompt $"\
309 {pass "ignore break marker1"}
310 -re "$gdb_prompt $"\
311 {fail "ignore break marker1"}
312 timeout {fail "(timeout) ignore break marker1"}
313}
314
315send_gdb "info break $expect_out(1,string)\n"
316gdb_expect {
317 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*ignore next 1 hits.*$gdb_prompt $"\
318 {pass "info ignored break marker1"}
319 -re "$gdb_prompt $"\
320 {fail "info ignored break marker1"}
321 timeout {fail "(timeout) info ignored break marker1"}
322}
323
324send_gdb "continue\n"
325gdb_expect {
326 -re ".*Program exited normally.*$gdb_prompt $"\
327 {pass "no stop at ignored break marker1"}
328 -re "$gdb_prompt $"\
329 {fail "no stop at ignored break marker1"}
330 timeout {fail "(timeout) no stop at ignored break marker1"}
331}
332
333send_gdb "run\n"
334gdb_expect {
335 -re "Starting program.*$gdb_prompt $"\
336 {pass "rerun to main"}
337 -re "$gdb_prompt $"\
338 {fail "rerun to main"}
339 timeout {fail "(timeout) rerun to main"}
340}
341
342send_gdb "continue\n"
343gdb_expect {
344 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
345 {pass "continue to break marker1"}
346 -re "$gdb_prompt $"\
347 {fail "continue to break marker1"}
348 timeout {fail "(timeout) continue to break marker1"}
349}
350
351# Verify that we can specify both an ignore count and an auto-delete.
352#
353if ![runto_main] then { fail "enable/disable break tests suppressed" }
354
355send_gdb "break marker1\n"
356gdb_expect {
357 -re "Breakpoint (\[0-9\]*) at .*, line 41.*$gdb_prompt $"\
358 {pass "break marker1"}
359 -re "$gdb_prompt $"\
360 {fail "break marker1"}
361 timeout {fail "(timeout) break marker1"}
362}
363
364send_gdb "ignore $expect_out(1,string) 1\n"
365gdb_expect {
366 -re "Will ignore next crossing of breakpoint \[0-9\]*.*$gdb_prompt $"\
367 {pass "ignore break marker1"}
368 -re "$gdb_prompt $"\
369 {fail "ignore break marker1"}
370 timeout {fail "(timeout) ignore break marker1"}
371}
372
373send_gdb "enable del $expect_out(1,string)\n"
374gdb_expect {
375 -re "$gdb_prompt $"\
376 {pass "enable del break marker1"}
377 timeout {fail "(timeout) enable del break marker1"}
378}
379
380send_gdb "info break $expect_out(1,string)\n"
381gdb_expect {
382 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*ignore next 1 hits.*$gdb_prompt $"\
383 {pass "info break marker1"}
384 -re "$gdb_prompt $"\
385 {fail "info break marker1"}
386 timeout {fail "(timeout) info break marker2"}
387}
388
389send_gdb "continue\n"
390gdb_expect {
391 -re ".*Program exited normally.*$gdb_prompt $"\
392 {pass "no stop at ignored & auto-deleted break marker1"}
393 -re "$gdb_prompt $"\
394 {fail "no stop at ignored & auto-deleted break marker1"}
395 timeout {fail "(timeout) no stop at ignored & auto-deleted break marker1"}
396}
397
398send_gdb "run\n"
399gdb_expect {
400 -re "Starting program.*$gdb_prompt $"\
401 {pass "rerun to main"}
402 -re "$gdb_prompt $"\
403 {fail "rerun to main"}
404 timeout {fail "(timeout) rerun to main"}
405}
406
407send_gdb "continue\n"
408gdb_expect {
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"}
413 -re "$gdb_prompt $"\
414 {fail "continue to ignored & auto-deleted break marker1"}
415 timeout {fail "(timeout) continue to ignored & auto-deleted break marker1"}
416}
417
418# Verify that a disabled breakpoint's ignore count isn't updated when
419# the bp is encountered.
420#
421if ![runto_main] then { fail "enable/disable break tests suppressed" }
422
423send_gdb "break marker1\n"
424gdb_expect {
425 -re "Breakpoint (\[0-9\]*) at .*, line 41.*$gdb_prompt $"\
426 {pass "break marker1"}
427 -re "$gdb_prompt $"\
428 {fail "break marker1"}
429 timeout {fail "(timeout) break marker1"}
430}
431
432send_gdb "ignore $expect_out(1,string) 10\n"
433gdb_expect {
434 -re "Will ignore next 10 crossings of breakpoint \[0-9\]*.*$gdb_prompt $"\
435 {pass "ignore break marker1"}
436 -re "$gdb_prompt $"\
437 {fail "ignore break marker1"}
438 timeout {fail "(timeout) ignore break marker1"}
439}
440
441send_gdb "disable $expect_out(1,string)\n"
442gdb_expect {
443 -re "$gdb_prompt $"\
444 {pass "disable break marker1"}
445 timeout {fail "(timeout) disable break marker1"}
446}
447
448send_gdb "continue\n"
449gdb_expect {
450 -re ".*Program exited normally.*$gdb_prompt $"\
451 {pass "no stop at ignored & disabled break marker1"}
452 -re "$gdb_prompt $"\
453 {fail "no stop at ignored & disabled break marker1"}
454 timeout {fail "(timeout) no stop at ignored & disabled break marker1"}
455}
456
457send_gdb "run\n"
458gdb_expect {
459 -re "Starting program.*$gdb_prompt $"\
460 {pass "rerun to main"}
461 -re "$gdb_prompt $"\
462 {fail "rerun to main"}
463 timeout {fail "(timeout) rerun to main"}
464}
465
466send_gdb "info break $expect_out(1,string)\n"
467gdb_expect {
468 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*ignore next 10 hits.*$gdb_prompt $"\
469 {pass "info ignored & disabled break marker1"}
470 -re "$gdb_prompt $"\
471 {fail "info ignored & disabled break marker1"}
472 timeout {fail "(timeout) info ignored & disabled break marker1"}
473}
474
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.)
479#
480if ![runto_main] then { fail "enable/disable break tests suppressed" }
481
482send_gdb "break 64\n"
483gdb_expect {
484 -re "Breakpoint \[0-9\]*.*, line 64.*$gdb_prompt $"\
485 {pass "prepare to continue with ignore count"}
486 -re "$gdb_prompt $"\
487 {fail "prepare to continue with ignore count"}
488 timeout {fail "(timeout) prepare to continue with ignore count"}
489}
490send_gdb "continue 2\n"
491gdb_expect {
492 -re "Will ignore next crossing of breakpoint \[0-9\]*. Continuing..*$gdb_prompt $"\
493 {pass "continue with ignore count"}
494 -re "$gdb_prompt $"\
495 {fail "continue with ignore count"}
496 timeout {fail "(timeout) continue with ignore count"}
497}
498
499send_gdb "next\n"
500gdb_expect {
501 -re ".*66\[ \t\]*marker1.*$gdb_prompt $"\
502 {pass "step after continue with ignore count"}
503 -re "$gdb_prompt $"\
504 {fail "step after continue with ignore count"}
505 timeout {fail "(timeout) step after continue with ignore count"}
506}
507
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!
511#
512setup_xfail hppa_*_*
513send_gdb "continue 2\n"
514gdb_expect {
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"}
519 -re "$gdb_prompt $"\
520 {fail "continue with ignore count, not stopped at bpt"}
521 timeout {fail "(timeout) step after continue with ignore count, not stopped at bpt"}
522}
523
524gdb_exit
525return 0
This page took 0.059924 seconds and 4 git commands to generate.