This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/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 send_gdb "continue\n"
101 gdb_expect {
102 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
103 {pass "continue to break marker1"}
104 -re "$gdb_prompt $"\
105 {fail "continue to break marker1"}
106 timeout {fail "(timeout) continue to break marker1"}
107 }
108
109 send_gdb "delete $expect_out(1,string)\n"
110 gdb_expect {
111 -re "$gdb_prompt $"\
112 {pass "delete break marker1"}
113 timeout {fail "(timeout) delete break marker1"}
114 }
115
116 # Verify that we can set a breakpoint to be self-disabling after
117 # the first time it triggers.
118 #
119 send_gdb "break marker2\n"
120 gdb_expect {
121 -re "Breakpoint (\[0-9\]*) at .*, line 4\[49\].*$gdb_prompt $"\
122 {pass "break marker2"}
123 -re "$gdb_prompt $"\
124 {fail "break marker2"}
125 timeout {fail "(timeout) break marker2"}
126 }
127
128 send_gdb "enable once $expect_out(1,string)\n"
129 gdb_expect {
130 -re "$gdb_prompt $"\
131 {pass "enable once break marker2"}
132 timeout {fail "(timeout) enable once break marker2"}
133 }
134
135 send_gdb "info break $expect_out(1,string)\n"
136 gdb_expect {
137 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+y.*$gdb_prompt $"\
138 {pass "info auto-disabled break marker2"}
139 -re "$gdb_prompt $"\
140 {fail "info auto-disabled break marker2"}
141 timeout {fail "(timeout) info auto-disabled break marker2"}
142 }
143
144 send_gdb "continue\n"
145 gdb_expect {
146 -re "Breakpoint \[0-9\]*, marker2.*$gdb_prompt $"\
147 {pass "continue to auto-disabled break marker2"}
148 -re "$gdb_prompt $"\
149 {fail "continue to auto-disabled break marker2"}
150 timeout {fail "(timeout) continue to auto-disabled break marker2"}
151 }
152
153 send_gdb "info break $expect_out(1,string)\n"
154 gdb_expect {
155 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+n.*$gdb_prompt $"\
156 {pass "info auto-disabled break marker2"}
157 -re "$gdb_prompt $"\
158 {fail "info auto-disabled break marker2"}
159 timeout {fail "(timeout) info auto-disabled break marker2"}
160 }
161
162 # Verify that we don't stop at a disabled breakpoint.
163 #
164 gdb_continue_to_end "no stop"
165 rerun_to_main
166 gdb_continue_to_end "no stop at auto-disabled break marker2"
167
168 # Verify that we can set a breakpoint to be self-deleting after
169 # the first time it triggers.
170 #
171 if ![runto_main] then { fail "enable/disable break tests suppressed" }
172
173 send_gdb "break marker3\n"
174 gdb_expect {
175 -re "Breakpoint (\[0-9\]*) at .*, line (45|50).*$gdb_prompt $"\
176 {pass "break marker3"}
177 -re "$gdb_prompt $"\
178 {fail "break marker3"}
179 timeout {fail "(timeout) break marker3"}
180 }
181
182 send_gdb "enable del $expect_out(1,string)\n"
183 gdb_expect {
184 -re "$gdb_prompt $"\
185 {pass "enable del break marker3"}
186 timeout {fail "(timeout) enable del break marker3"}
187 }
188
189 send_gdb "info break $expect_out(1,string)\n"
190 gdb_expect {
191 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*$gdb_prompt $"\
192 {pass "info auto-deleted break marker2"}
193 -re "$gdb_prompt $"\
194 {fail "info auto-deleted break marker2"}
195 timeout {fail "(timeout) info auto-deleted break marker2"}
196 }
197
198 send_gdb "continue\n"
199 gdb_expect {
200 -re ".*marker3 .*:(45|50).*$gdb_prompt $"\
201 {pass "continue to auto-deleted break marker3"}
202 -re "Breakpoint \[0-9\]*, marker3.*$gdb_prompt $"\
203 {fail "continue to auto-deleted break marker3"}
204 -re "$gdb_prompt $"\
205 {fail "continue to auto-deleted break marker3"}
206 timeout {fail "(timeout) continue to break marker3"}
207 }
208
209 send_gdb "info break $expect_out(1,string)\n"
210 gdb_expect {
211 -re ".*No breakpoint or watchpoint number.*$gdb_prompt $"\
212 {pass "info auto-deleted break marker3"}
213 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\].*$gdb_prompt $"\
214 {fail "info auto-deleted break marker3"}
215 -re "$gdb_prompt $"\
216 {fail "info auto-deleted break marker3"}
217 timeout {fail "(timeout) info auto-deleted break marker3"}
218 }
219
220 # Verify that we can set a breakpoint and manually disable it (we've
221 # already proven that disabled bp's don't trigger).
222 #
223 send_gdb "break marker4\n"
224 gdb_expect {
225 -re "Breakpoint (\[0-9\]*) at .*, line (46|51).*$gdb_prompt $"\
226 {pass "break marker4"}
227 -re "$gdb_prompt $"\
228 {fail "break marker4"}
229 timeout {fail "(timeout) break marker4"}
230 }
231
232 send_gdb "disable $expect_out(1,string)\n"
233 gdb_expect {
234 -re "$gdb_prompt $"\
235 {pass "disable break marker4"}
236 timeout {fail "(timeout) disable break marker4"}
237 }
238
239 send_gdb "info break $expect_out(1,string)\n"
240 gdb_expect {
241 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*$gdb_prompt $"\
242 {pass "info break marker4"}
243 -re "$gdb_prompt $"\
244 {fail "info break marker4"}
245 timeout {fail "(timeout) info break marker4"}
246 }
247
248 # Verify that we can set a breakpoint with an ignore count N, which
249 # should cause the next N triggers of the bp to be ignored. (This is
250 # a flavor of enablement/disablement, after all.)
251 #
252 if ![runto_main] then { fail "enable/disable break tests suppressed" }
253
254 send_gdb "break marker1\n"
255 gdb_expect {
256 -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\
257 {pass "break marker1"}
258 -re "$gdb_prompt $"\
259 {fail "break marker1"}
260 timeout {fail "(timeout) break marker1"}
261 }
262
263 # Verify that an ignore of a non-existent breakpoint is gracefully
264 # handled.
265 #
266 send_gdb "ignore 999 2\n"
267 gdb_expect {
268 -re "No breakpoint number 999..*$gdb_prompt $"\
269 {pass "ignore non-existent break"}
270 -re "$gdb_prompt $"\
271 {fail "ignore non-existent break"}
272 timeout {fail "(timeout) ignore non-existent break"}
273 }
274
275 # Verify that a missing ignore count is gracefully handled.
276 #
277 send_gdb "ignore $expect_out(1,string) \n"
278 gdb_expect {
279 -re "Second argument .specified ignore-count. is missing..*$gdb_prompt $"\
280 {pass "ignore break with missing ignore count"}
281 -re "$gdb_prompt $"\
282 {fail "ignore break with missing ignore count"}
283 timeout {fail "(timeout) ignore break with missing ignore count"}
284 }
285
286 # Verify that a negative or zero ignore count is handled gracefully
287 # (they both are treated the same).
288 #
289 send_gdb "ignore $expect_out(1,string) -1\n"
290 gdb_expect {
291 -re "Will stop next time breakpoint \[0-9\]* is reached..*$gdb_prompt $"\
292 {pass "ignore break marker1 -1"}
293 -re "$gdb_prompt $"\
294 {fail "ignore break marker1 -1"}
295 timeout {fail "(timeout) ignore break marker1 -1"}
296 }
297
298 send_gdb "ignore $expect_out(1,string) 0\n"
299 gdb_expect {
300 -re "Will stop next time breakpoint \[0-9\]* is reached..*$gdb_prompt $"\
301 {pass "ignore break marker1 0"}
302 -re "$gdb_prompt $"\
303 {fail "ignore break marker1 0"}
304 timeout {fail "(timeout) ignore break marker1 0"}
305 }
306
307 send_gdb "ignore $expect_out(1,string) 1\n"
308 gdb_expect {
309 -re "Will ignore next crossing of breakpoint \[0-9\]*.*$gdb_prompt $"\
310 {pass "ignore break marker1"}
311 -re "$gdb_prompt $"\
312 {fail "ignore break marker1"}
313 timeout {fail "(timeout) ignore break marker1"}
314 }
315
316 send_gdb "info break $expect_out(1,string)\n"
317 gdb_expect {
318 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*ignore next 1 hits.*$gdb_prompt $"\
319 {pass "info ignored break marker1"}
320 -re "$gdb_prompt $"\
321 {fail "info ignored break marker1"}
322 timeout {fail "(timeout) info ignored break marker1"}
323 }
324
325 gdb_continue_to_end "no stop at ignored break marker1"
326 rerun_to_main
327
328 send_gdb "continue\n"
329 gdb_expect {
330 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
331 {pass "continue to break marker1"}
332 -re "$gdb_prompt $"\
333 {fail "continue to break marker1"}
334 timeout {fail "(timeout) continue to break marker1"}
335 }
336
337 # Verify that we can specify both an ignore count and an auto-delete.
338 #
339 if ![runto_main] then { fail "enable/disable break tests suppressed" }
340
341 send_gdb "break marker1\n"
342 gdb_expect {
343 -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\
344 {pass "break marker1"}
345 -re "$gdb_prompt $"\
346 {fail "break marker1"}
347 timeout {fail "(timeout) break marker1"}
348 }
349
350 send_gdb "ignore $expect_out(1,string) 1\n"
351 gdb_expect {
352 -re "Will ignore next crossing of breakpoint \[0-9\]*.*$gdb_prompt $"\
353 {pass "ignore break marker1"}
354 -re "$gdb_prompt $"\
355 {fail "ignore break marker1"}
356 timeout {fail "(timeout) ignore break marker1"}
357 }
358
359 send_gdb "enable del $expect_out(1,string)\n"
360 gdb_expect {
361 -re "$gdb_prompt $"\
362 {pass "enable del break marker1"}
363 timeout {fail "(timeout) enable del break marker1"}
364 }
365
366 send_gdb "info break $expect_out(1,string)\n"
367 gdb_expect {
368 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*ignore next 1 hits.*$gdb_prompt $"\
369 {pass "info break marker1"}
370 -re "$gdb_prompt $"\
371 {fail "info break marker1"}
372 timeout {fail "(timeout) info break marker2"}
373 }
374
375 gdb_continue_to_end "no stop at ignored & auto-deleted break marker1"
376 rerun_to_main
377
378 send_gdb "continue\n"
379 gdb_expect {
380 -re ".*marker1 .*:4\[38\].*$gdb_prompt $"\
381 {pass "continue to ignored & auto-deleted break marker1"}
382 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
383 {fail "continue to ignored & auto-deleted break marker1"}
384 -re "$gdb_prompt $"\
385 {fail "continue to ignored & auto-deleted break marker1"}
386 timeout {fail "(timeout) continue to ignored & auto-deleted break marker1"}
387 }
388
389 # Verify that a disabled breakpoint's ignore count isn't updated when
390 # the bp is encountered.
391 #
392 if ![runto_main] then { fail "enable/disable break tests suppressed" }
393
394 send_gdb "break marker1\n"
395 gdb_expect {
396 -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\
397 {pass "break marker1"}
398 -re "$gdb_prompt $"\
399 {fail "break marker1"}
400 timeout {fail "(timeout) break marker1"}
401 }
402
403 send_gdb "ignore $expect_out(1,string) 10\n"
404 gdb_expect {
405 -re "Will ignore next 10 crossings of breakpoint \[0-9\]*.*$gdb_prompt $"\
406 {pass "ignore break marker1"}
407 -re "$gdb_prompt $"\
408 {fail "ignore break marker1"}
409 timeout {fail "(timeout) ignore break marker1"}
410 }
411
412 send_gdb "disable $expect_out(1,string)\n"
413 gdb_expect {
414 -re "$gdb_prompt $"\
415 {pass "disable break marker1"}
416 timeout {fail "(timeout) disable break marker1"}
417 }
418
419 gdb_continue_to_end "no stop at ignored & disabled break marker1"
420 rerun_to_main
421
422 send_gdb "info break $expect_out(1,string)\n"
423 gdb_expect {
424 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*ignore next 10 hits.*$gdb_prompt $"\
425 {pass "info ignored & disabled break marker1"}
426 -re "$gdb_prompt $"\
427 {fail "info ignored & disabled break marker1"}
428 timeout {fail "(timeout) info ignored & disabled break marker1"}
429 }
430
431 # Verify that GDB correctly handles the "continue" command with an argument,
432 # which is an ignore count to set on the currently stopped-at breakpoint.
433 # (Also verify that GDB gracefully handles the case where the inferior
434 # isn't stopped at a breakpoint.)
435 #
436 if ![runto_main] then { fail "enable/disable break tests suppressed" }
437
438 send_gdb "break 79\n"
439 gdb_expect {
440 -re "Breakpoint \[0-9\]*.*, line 79.*$gdb_prompt $"\
441 {pass "prepare to continue with ignore count"}
442 -re "$gdb_prompt $"\
443 {fail "prepare to continue with ignore count"}
444 timeout {fail "(timeout) prepare to continue with ignore count"}
445 }
446 send_gdb "continue 2\n"
447 gdb_expect {
448 -re "Will ignore next crossing of breakpoint \[0-9\]*. Continuing..*$gdb_prompt $"\
449 {pass "continue with ignore count"}
450 -re "$gdb_prompt $"\
451 {fail "continue with ignore count"}
452 timeout {fail "(timeout) continue with ignore count"}
453 }
454
455 send_gdb "next\n"
456 gdb_expect {
457 -re ".*81\[ \t\]*marker1.*$gdb_prompt $"\
458 {pass "step after continue with ignore count"}
459 -re "$gdb_prompt $"\
460 {fail "step after continue with ignore count"}
461 timeout {fail "(timeout) step after continue with ignore count"}
462 }
463
464 # ??rehrauer: Huh. This appears to be an actual bug. (No big
465 # surprise, since this feature hasn't been tested...) Looks like
466 # GDB is currently trying to set the ignore count of bp # -1!
467 #
468 setup_xfail hppa_*_*
469 send_gdb "continue 2\n"
470 gdb_expect {
471 -re "Not stopped at any breakpoint; argument ignored..*$gdb_prompt $"\
472 {pass "continue with ignore count, not stopped at bpt"}
473 -re "No breakpoint number -1.*$gdb_prompt $"\
474 {xfail "(DTS'd) continue with ignore count, not stopped at bpt"}
475 -re "$gdb_prompt $"\
476 {fail "continue with ignore count, not stopped at bpt"}
477 timeout {fail "(timeout) step after continue with ignore count, not stopped at bpt"}
478 }
479
480 gdb_exit
481 return 0
This page took 0.039776 seconds and 5 git commands to generate.