Commit | Line | Data |
---|---|---|
b6ba6518 | 1 | # Copyright 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 | ||
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 | gdb_exit | |
42 | gdb_start | |
43 | gdb_reinitialize_dir $srcdir/$subdir | |
44 | gdb_load ${binfile} | |
45 | ||
46 | if ![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 | # | |
51 | send_gdb "break marker1\n" | |
52 | gdb_expect { | |
085dd6e6 | 53 | -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\ |
c906108c SS |
54 | {pass "break marker1"} |
55 | -re "$gdb_prompt $"\ | |
56 | {fail "break marker1"} | |
57 | timeout {fail "(timeout) break marker1"} | |
58 | } | |
59 | ||
60 | send_gdb "enable $expect_out(1,string)\n" | |
61 | gdb_expect { | |
62 | -re "$gdb_prompt $"\ | |
63 | {pass "enable break marker1"} | |
64 | timeout {fail "(timeout) enable break marker1"} | |
65 | } | |
66 | ||
67 | send_gdb "info break $expect_out(1,string)\n" | |
68 | gdb_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 | ||
11cf8741 JM |
76 | # See the comments in condbreak.exp for "run until breakpoint at marker1" |
77 | # for an explanation of the xfail below. | |
c906108c SS |
78 | send_gdb "continue\n" |
79 | gdb_expect { | |
80 | -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\ | |
81 | {pass "continue to break marker1"} | |
11cf8741 JM |
82 | -re "Breakpoint \[0-9\]*, $hex in marker1.*$gdb_prompt $"\ |
83 | {xfail "continue to break marker1"} | |
c906108c SS |
84 | -re "$gdb_prompt $"\ |
85 | {fail "continue to break marker1"} | |
86 | timeout {fail "(timeout) continue to break marker1"} | |
87 | } | |
88 | ||
89 | send_gdb "delete $expect_out(1,string)\n" | |
90 | gdb_expect { | |
91 | -re "$gdb_prompt $"\ | |
92 | {pass "delete break marker1"} | |
93 | timeout {fail "(timeout) delete break marker1"} | |
94 | } | |
95 | ||
96 | # Verify that we can set a breakpoint to be self-disabling after | |
97 | # the first time it triggers. | |
98 | # | |
99 | send_gdb "break marker2\n" | |
100 | gdb_expect { | |
085dd6e6 | 101 | -re "Breakpoint (\[0-9\]*) at .*, line 4\[49\].*$gdb_prompt $"\ |
c906108c SS |
102 | {pass "break marker2"} |
103 | -re "$gdb_prompt $"\ | |
104 | {fail "break marker2"} | |
105 | timeout {fail "(timeout) break marker2"} | |
106 | } | |
107 | ||
108 | send_gdb "enable once $expect_out(1,string)\n" | |
109 | gdb_expect { | |
110 | -re "$gdb_prompt $"\ | |
111 | {pass "enable once break marker2"} | |
112 | timeout {fail "(timeout) enable once break marker2"} | |
113 | } | |
114 | ||
115 | send_gdb "info break $expect_out(1,string)\n" | |
116 | gdb_expect { | |
117 | -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+y.*$gdb_prompt $"\ | |
118 | {pass "info auto-disabled break marker2"} | |
119 | -re "$gdb_prompt $"\ | |
120 | {fail "info auto-disabled break marker2"} | |
121 | timeout {fail "(timeout) info auto-disabled break marker2"} | |
122 | } | |
123 | ||
11cf8741 JM |
124 | # See the comments in condbreak.exp for "run until breakpoint at marker1" |
125 | # for an explanation of the xfail below. | |
c906108c SS |
126 | send_gdb "continue\n" |
127 | gdb_expect { | |
128 | -re "Breakpoint \[0-9\]*, marker2.*$gdb_prompt $"\ | |
129 | {pass "continue to auto-disabled break marker2"} | |
11cf8741 JM |
130 | -re "Breakpoint \[0-9\]*, $hex in marker2.*$gdb_prompt $"\ |
131 | {xfail "continue to auto-disabled break marker2"} | |
c906108c SS |
132 | -re "$gdb_prompt $"\ |
133 | {fail "continue to auto-disabled break marker2"} | |
134 | timeout {fail "(timeout) continue to auto-disabled break marker2"} | |
135 | } | |
136 | ||
137 | send_gdb "info break $expect_out(1,string)\n" | |
138 | gdb_expect { | |
139 | -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+n.*$gdb_prompt $"\ | |
140 | {pass "info auto-disabled break marker2"} | |
141 | -re "$gdb_prompt $"\ | |
142 | {fail "info auto-disabled break marker2"} | |
143 | timeout {fail "(timeout) info auto-disabled break marker2"} | |
144 | } | |
145 | ||
146 | # Verify that we don't stop at a disabled breakpoint. | |
147 | # | |
7a292a7a SS |
148 | gdb_continue_to_end "no stop" |
149 | rerun_to_main | |
150 | gdb_continue_to_end "no stop at auto-disabled break marker2" | |
c906108c SS |
151 | |
152 | # Verify that we can set a breakpoint to be self-deleting after | |
153 | # the first time it triggers. | |
154 | # | |
155 | if ![runto_main] then { fail "enable/disable break tests suppressed" } | |
156 | ||
157 | send_gdb "break marker3\n" | |
158 | gdb_expect { | |
085dd6e6 | 159 | -re "Breakpoint (\[0-9\]*) at .*, line (45|50).*$gdb_prompt $"\ |
c906108c SS |
160 | {pass "break marker3"} |
161 | -re "$gdb_prompt $"\ | |
162 | {fail "break marker3"} | |
163 | timeout {fail "(timeout) break marker3"} | |
164 | } | |
165 | ||
166 | send_gdb "enable del $expect_out(1,string)\n" | |
167 | gdb_expect { | |
168 | -re "$gdb_prompt $"\ | |
169 | {pass "enable del break marker3"} | |
170 | timeout {fail "(timeout) enable del break marker3"} | |
171 | } | |
172 | ||
173 | send_gdb "info break $expect_out(1,string)\n" | |
174 | gdb_expect { | |
175 | -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*$gdb_prompt $"\ | |
176 | {pass "info auto-deleted break marker2"} | |
177 | -re "$gdb_prompt $"\ | |
178 | {fail "info auto-deleted break marker2"} | |
179 | timeout {fail "(timeout) info auto-deleted break marker2"} | |
180 | } | |
181 | ||
182 | send_gdb "continue\n" | |
183 | gdb_expect { | |
085dd6e6 | 184 | -re ".*marker3 .*:(45|50).*$gdb_prompt $"\ |
c906108c SS |
185 | {pass "continue to auto-deleted break marker3"} |
186 | -re "Breakpoint \[0-9\]*, marker3.*$gdb_prompt $"\ | |
187 | {fail "continue to auto-deleted break marker3"} | |
188 | -re "$gdb_prompt $"\ | |
189 | {fail "continue to auto-deleted break marker3"} | |
190 | timeout {fail "(timeout) continue to break marker3"} | |
191 | } | |
192 | ||
193 | send_gdb "info break $expect_out(1,string)\n" | |
194 | gdb_expect { | |
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"} | |
199 | -re "$gdb_prompt $"\ | |
200 | {fail "info auto-deleted break marker3"} | |
201 | timeout {fail "(timeout) info auto-deleted break marker3"} | |
202 | } | |
203 | ||
204 | # Verify that we can set a breakpoint and manually disable it (we've | |
205 | # already proven that disabled bp's don't trigger). | |
206 | # | |
207 | send_gdb "break marker4\n" | |
208 | gdb_expect { | |
085dd6e6 | 209 | -re "Breakpoint (\[0-9\]*) at .*, line (46|51).*$gdb_prompt $"\ |
c906108c SS |
210 | {pass "break marker4"} |
211 | -re "$gdb_prompt $"\ | |
212 | {fail "break marker4"} | |
213 | timeout {fail "(timeout) break marker4"} | |
214 | } | |
215 | ||
216 | send_gdb "disable $expect_out(1,string)\n" | |
217 | gdb_expect { | |
218 | -re "$gdb_prompt $"\ | |
219 | {pass "disable break marker4"} | |
220 | timeout {fail "(timeout) disable break marker4"} | |
221 | } | |
222 | ||
223 | send_gdb "info break $expect_out(1,string)\n" | |
224 | gdb_expect { | |
225 | -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*$gdb_prompt $"\ | |
226 | {pass "info break marker4"} | |
227 | -re "$gdb_prompt $"\ | |
228 | {fail "info break marker4"} | |
229 | timeout {fail "(timeout) info break marker4"} | |
230 | } | |
231 | ||
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.) | |
235 | # | |
236 | if ![runto_main] then { fail "enable/disable break tests suppressed" } | |
237 | ||
238 | send_gdb "break marker1\n" | |
239 | gdb_expect { | |
085dd6e6 | 240 | -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\ |
c906108c SS |
241 | {pass "break marker1"} |
242 | -re "$gdb_prompt $"\ | |
243 | {fail "break marker1"} | |
244 | timeout {fail "(timeout) break marker1"} | |
245 | } | |
246 | ||
247 | # Verify that an ignore of a non-existent breakpoint is gracefully | |
248 | # handled. | |
249 | # | |
250 | send_gdb "ignore 999 2\n" | |
251 | gdb_expect { | |
252 | -re "No breakpoint number 999..*$gdb_prompt $"\ | |
253 | {pass "ignore non-existent break"} | |
254 | -re "$gdb_prompt $"\ | |
255 | {fail "ignore non-existent break"} | |
256 | timeout {fail "(timeout) ignore non-existent break"} | |
257 | } | |
258 | ||
259 | # Verify that a missing ignore count is gracefully handled. | |
260 | # | |
261 | send_gdb "ignore $expect_out(1,string) \n" | |
262 | gdb_expect { | |
263 | -re "Second argument .specified ignore-count. is missing..*$gdb_prompt $"\ | |
264 | {pass "ignore break with missing ignore count"} | |
265 | -re "$gdb_prompt $"\ | |
266 | {fail "ignore break with missing ignore count"} | |
267 | timeout {fail "(timeout) ignore break with missing ignore count"} | |
268 | } | |
269 | ||
270 | # Verify that a negative or zero ignore count is handled gracefully | |
271 | # (they both are treated the same). | |
272 | # | |
273 | send_gdb "ignore $expect_out(1,string) -1\n" | |
274 | gdb_expect { | |
275 | -re "Will stop next time breakpoint \[0-9\]* is reached..*$gdb_prompt $"\ | |
276 | {pass "ignore break marker1 -1"} | |
277 | -re "$gdb_prompt $"\ | |
278 | {fail "ignore break marker1 -1"} | |
279 | timeout {fail "(timeout) ignore break marker1 -1"} | |
280 | } | |
281 | ||
282 | send_gdb "ignore $expect_out(1,string) 0\n" | |
283 | gdb_expect { | |
284 | -re "Will stop next time breakpoint \[0-9\]* is reached..*$gdb_prompt $"\ | |
285 | {pass "ignore break marker1 0"} | |
286 | -re "$gdb_prompt $"\ | |
287 | {fail "ignore break marker1 0"} | |
288 | timeout {fail "(timeout) ignore break marker1 0"} | |
289 | } | |
290 | ||
291 | send_gdb "ignore $expect_out(1,string) 1\n" | |
292 | gdb_expect { | |
293 | -re "Will ignore next crossing of breakpoint \[0-9\]*.*$gdb_prompt $"\ | |
294 | {pass "ignore break marker1"} | |
295 | -re "$gdb_prompt $"\ | |
296 | {fail "ignore break marker1"} | |
297 | timeout {fail "(timeout) ignore break marker1"} | |
298 | } | |
299 | ||
300 | send_gdb "info break $expect_out(1,string)\n" | |
301 | gdb_expect { | |
302 | -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*ignore next 1 hits.*$gdb_prompt $"\ | |
303 | {pass "info ignored break marker1"} | |
304 | -re "$gdb_prompt $"\ | |
305 | {fail "info ignored break marker1"} | |
306 | timeout {fail "(timeout) info ignored break marker1"} | |
307 | } | |
308 | ||
7a292a7a SS |
309 | gdb_continue_to_end "no stop at ignored break marker1" |
310 | rerun_to_main | |
c906108c | 311 | |
11cf8741 JM |
312 | # See the comments in condbreak.exp for "run until breakpoint at marker1" |
313 | # for an explanation of the xfail below. | |
c906108c SS |
314 | send_gdb "continue\n" |
315 | gdb_expect { | |
316 | -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\ | |
11cf8741 JM |
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"} | |
c906108c | 320 | -re "$gdb_prompt $"\ |
11cf8741 JM |
321 | {fail "continue to break marker1, 2nd time"} |
322 | timeout {fail "(timeout) continue to break marker1, 2nd time"} | |
c906108c SS |
323 | } |
324 | ||
325 | # Verify that we can specify both an ignore count and an auto-delete. | |
326 | # | |
327 | if ![runto_main] then { fail "enable/disable break tests suppressed" } | |
328 | ||
329 | send_gdb "break marker1\n" | |
330 | gdb_expect { | |
085dd6e6 | 331 | -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\ |
c906108c SS |
332 | {pass "break marker1"} |
333 | -re "$gdb_prompt $"\ | |
334 | {fail "break marker1"} | |
335 | timeout {fail "(timeout) break marker1"} | |
336 | } | |
337 | ||
338 | send_gdb "ignore $expect_out(1,string) 1\n" | |
339 | gdb_expect { | |
340 | -re "Will ignore next crossing of breakpoint \[0-9\]*.*$gdb_prompt $"\ | |
341 | {pass "ignore break marker1"} | |
342 | -re "$gdb_prompt $"\ | |
343 | {fail "ignore break marker1"} | |
344 | timeout {fail "(timeout) ignore break marker1"} | |
345 | } | |
346 | ||
347 | send_gdb "enable del $expect_out(1,string)\n" | |
348 | gdb_expect { | |
349 | -re "$gdb_prompt $"\ | |
350 | {pass "enable del break marker1"} | |
351 | timeout {fail "(timeout) enable del break marker1"} | |
352 | } | |
353 | ||
354 | send_gdb "info break $expect_out(1,string)\n" | |
355 | gdb_expect { | |
356 | -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*ignore next 1 hits.*$gdb_prompt $"\ | |
357 | {pass "info break marker1"} | |
358 | -re "$gdb_prompt $"\ | |
359 | {fail "info break marker1"} | |
360 | timeout {fail "(timeout) info break marker2"} | |
361 | } | |
362 | ||
7a292a7a SS |
363 | gdb_continue_to_end "no stop at ignored & auto-deleted break marker1" |
364 | rerun_to_main | |
c906108c SS |
365 | |
366 | send_gdb "continue\n" | |
367 | gdb_expect { | |
085dd6e6 | 368 | -re ".*marker1 .*:4\[38\].*$gdb_prompt $"\ |
c906108c SS |
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"} | |
372 | -re "$gdb_prompt $"\ | |
373 | {fail "continue to ignored & auto-deleted break marker1"} | |
374 | timeout {fail "(timeout) continue to ignored & auto-deleted break marker1"} | |
375 | } | |
376 | ||
377 | # Verify that a disabled breakpoint's ignore count isn't updated when | |
378 | # the bp is encountered. | |
379 | # | |
380 | if ![runto_main] then { fail "enable/disable break tests suppressed" } | |
381 | ||
382 | send_gdb "break marker1\n" | |
383 | gdb_expect { | |
085dd6e6 | 384 | -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\ |
c906108c SS |
385 | {pass "break marker1"} |
386 | -re "$gdb_prompt $"\ | |
387 | {fail "break marker1"} | |
388 | timeout {fail "(timeout) break marker1"} | |
389 | } | |
390 | ||
391 | send_gdb "ignore $expect_out(1,string) 10\n" | |
392 | gdb_expect { | |
393 | -re "Will ignore next 10 crossings of breakpoint \[0-9\]*.*$gdb_prompt $"\ | |
394 | {pass "ignore break marker1"} | |
395 | -re "$gdb_prompt $"\ | |
396 | {fail "ignore break marker1"} | |
397 | timeout {fail "(timeout) ignore break marker1"} | |
398 | } | |
399 | ||
400 | send_gdb "disable $expect_out(1,string)\n" | |
401 | gdb_expect { | |
402 | -re "$gdb_prompt $"\ | |
403 | {pass "disable break marker1"} | |
404 | timeout {fail "(timeout) disable break marker1"} | |
405 | } | |
406 | ||
7a292a7a SS |
407 | gdb_continue_to_end "no stop at ignored & disabled break marker1" |
408 | rerun_to_main | |
c906108c SS |
409 | |
410 | send_gdb "info break $expect_out(1,string)\n" | |
411 | gdb_expect { | |
412 | -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*ignore next 10 hits.*$gdb_prompt $"\ | |
413 | {pass "info ignored & disabled break marker1"} | |
414 | -re "$gdb_prompt $"\ | |
415 | {fail "info ignored & disabled break marker1"} | |
416 | timeout {fail "(timeout) info ignored & disabled break marker1"} | |
417 | } | |
418 | ||
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.) | |
423 | # | |
424 | if ![runto_main] then { fail "enable/disable break tests suppressed" } | |
425 | ||
085dd6e6 | 426 | send_gdb "break 79\n" |
c906108c | 427 | gdb_expect { |
085dd6e6 | 428 | -re "Breakpoint \[0-9\]*.*, line 79.*$gdb_prompt $"\ |
c906108c SS |
429 | {pass "prepare to continue with ignore count"} |
430 | -re "$gdb_prompt $"\ | |
431 | {fail "prepare to continue with ignore count"} | |
432 | timeout {fail "(timeout) prepare to continue with ignore count"} | |
433 | } | |
434 | send_gdb "continue 2\n" | |
435 | gdb_expect { | |
436 | -re "Will ignore next crossing of breakpoint \[0-9\]*. Continuing..*$gdb_prompt $"\ | |
437 | {pass "continue with ignore count"} | |
438 | -re "$gdb_prompt $"\ | |
439 | {fail "continue with ignore count"} | |
440 | timeout {fail "(timeout) continue with ignore count"} | |
441 | } | |
442 | ||
443 | send_gdb "next\n" | |
444 | gdb_expect { | |
085dd6e6 | 445 | -re ".*81\[ \t\]*marker1.*$gdb_prompt $"\ |
c906108c SS |
446 | {pass "step after continue with ignore count"} |
447 | -re "$gdb_prompt $"\ | |
448 | {fail "step after continue with ignore count"} | |
449 | timeout {fail "(timeout) step after continue with ignore count"} | |
450 | } | |
451 | ||
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! | |
455 | # | |
456 | setup_xfail hppa_*_* | |
457 | send_gdb "continue 2\n" | |
458 | gdb_expect { | |
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"} | |
463 | -re "$gdb_prompt $"\ | |
464 | {fail "continue with ignore count, not stopped at bpt"} | |
465 | timeout {fail "(timeout) step after continue with ignore count, not stopped at bpt"} | |
466 | } | |
467 | ||
468 | gdb_exit | |
469 | return 0 |