(elf_sort_symbol): Restructure code to avoid bug in Solairs hosted versions of
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / ena-dis-br.exp
CommitLineData
a1dea79a 1# Copyright 1997, 1998, 1999, 2003 Free Software Foundation, Inc.
c906108c
SS
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
a1dea79a 15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
c906108c
SS
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20if $tracelevel then {
21 strace $tracelevel
22 }
23
24global usestubs
25
26#
27# test running programs
28#
29set prms_id 0
30set bug_id 0
31
32set testfile "break"
33set srcfile ${testfile}.c
a1dea79a 34set srcfile1 ${testfile}1.c
c906108c
SS
35set binfile ${objdir}/${subdir}/${testfile}
36
a1dea79a
FF
37if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } {
38 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
39}
40
41if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } {
42 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
43}
44
45if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } {
c906108c
SS
46 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
47}
48
49gdb_exit
50gdb_start
51gdb_reinitialize_dir $srcdir/$subdir
52gdb_load ${binfile}
53
a1dea79a
FF
54set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
55set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1]
56set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1]
57set bp_location11 [gdb_get_line_number "set breakpoint 11 here"]
58set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1]
59set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1]
60set bp_location15 [gdb_get_line_number "set breakpoint 15 here" $srcfile1]
61set bp_location16 [gdb_get_line_number "set breakpoint 16 here" $srcfile1]
62set bp_location17 [gdb_get_line_number "set breakpoint 17 here" $srcfile1]
63set bp_location18 [gdb_get_line_number "set breakpoint 18 here" $srcfile1]
64
c906108c
SS
65if ![runto_main] then { fail "enable/disable break tests suppressed" }
66
67# Verify that we can set a breakpoint (the location is irrelevant),
68# then enable it (yes, it's already enabled by default), then hit it.
69#
70send_gdb "break marker1\n"
71gdb_expect {
a1dea79a 72 -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location15|$bp_location16).*$gdb_prompt $"\
c906108c
SS
73 {pass "break marker1"}
74 -re "$gdb_prompt $"\
75 {fail "break marker1"}
76 timeout {fail "(timeout) break marker1"}
77}
78
79send_gdb "enable $expect_out(1,string)\n"
80gdb_expect {
81 -re "$gdb_prompt $"\
82 {pass "enable break marker1"}
83 timeout {fail "(timeout) enable break marker1"}
84}
85
86send_gdb "info break $expect_out(1,string)\n"
87gdb_expect {
88 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*$gdb_prompt $"\
89 {pass "info break marker1"}
90 -re "$gdb_prompt $"\
91 {fail "info break marker1"}
92 timeout {fail "(timeout) info break marker1"}
93}
94
11cf8741
JM
95# See the comments in condbreak.exp for "run until breakpoint at marker1"
96# for an explanation of the xfail below.
c906108c
SS
97send_gdb "continue\n"
98gdb_expect {
99 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
100 {pass "continue to break marker1"}
11cf8741
JM
101 -re "Breakpoint \[0-9\]*, $hex in marker1.*$gdb_prompt $"\
102 {xfail "continue to break marker1"}
c906108c
SS
103 -re "$gdb_prompt $"\
104 {fail "continue to break marker1"}
105 timeout {fail "(timeout) continue to break marker1"}
106}
107
108send_gdb "delete $expect_out(1,string)\n"
109gdb_expect {
110 -re "$gdb_prompt $"\
111 {pass "delete break marker1"}
112 timeout {fail "(timeout) delete break marker1"}
113}
114
115# Verify that we can set a breakpoint to be self-disabling after
116# the first time it triggers.
117#
118send_gdb "break marker2\n"
119gdb_expect {
a1dea79a 120 -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location8|$bp_location9).*$gdb_prompt $"\
c906108c
SS
121 {pass "break marker2"}
122 -re "$gdb_prompt $"\
123 {fail "break marker2"}
124 timeout {fail "(timeout) break marker2"}
125}
126
127send_gdb "enable once $expect_out(1,string)\n"
128gdb_expect {
129 -re "$gdb_prompt $"\
130 {pass "enable once break marker2"}
131 timeout {fail "(timeout) enable once break marker2"}
132}
133
134send_gdb "info break $expect_out(1,string)\n"
135gdb_expect {
136 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+y.*$gdb_prompt $"\
137 {pass "info auto-disabled break marker2"}
138 -re "$gdb_prompt $"\
139 {fail "info auto-disabled break marker2"}
140 timeout {fail "(timeout) info auto-disabled break marker2"}
141}
142
11cf8741
JM
143# See the comments in condbreak.exp for "run until breakpoint at marker1"
144# for an explanation of the xfail below.
c906108c
SS
145send_gdb "continue\n"
146gdb_expect {
147 -re "Breakpoint \[0-9\]*, marker2.*$gdb_prompt $"\
148 {pass "continue to auto-disabled break marker2"}
11cf8741
JM
149 -re "Breakpoint \[0-9\]*, $hex in marker2.*$gdb_prompt $"\
150 {xfail "continue to auto-disabled break marker2"}
c906108c
SS
151 -re "$gdb_prompt $"\
152 {fail "continue to auto-disabled break marker2"}
153 timeout {fail "(timeout) continue to auto-disabled break marker2"}
154}
155
156send_gdb "info break $expect_out(1,string)\n"
157gdb_expect {
158 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+n.*$gdb_prompt $"\
159 {pass "info auto-disabled break marker2"}
160 -re "$gdb_prompt $"\
161 {fail "info auto-disabled break marker2"}
162 timeout {fail "(timeout) info auto-disabled break marker2"}
163}
164
165# Verify that we don't stop at a disabled breakpoint.
166#
7a292a7a
SS
167gdb_continue_to_end "no stop"
168rerun_to_main
169gdb_continue_to_end "no stop at auto-disabled break marker2"
c906108c
SS
170
171# Verify that we can set a breakpoint to be self-deleting after
172# the first time it triggers.
173#
174if ![runto_main] then { fail "enable/disable break tests suppressed" }
175
176send_gdb "break marker3\n"
177gdb_expect {
a1dea79a 178 -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location17|$bp_location18).*$gdb_prompt $"\
c906108c
SS
179 {pass "break marker3"}
180 -re "$gdb_prompt $"\
181 {fail "break marker3"}
182 timeout {fail "(timeout) break marker3"}
183}
184
185send_gdb "enable del $expect_out(1,string)\n"
186gdb_expect {
187 -re "$gdb_prompt $"\
188 {pass "enable del break marker3"}
189 timeout {fail "(timeout) enable del break marker3"}
190}
191
192send_gdb "info break $expect_out(1,string)\n"
193gdb_expect {
194 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*$gdb_prompt $"\
195 {pass "info auto-deleted break marker2"}
196 -re "$gdb_prompt $"\
197 {fail "info auto-deleted break marker2"}
198 timeout {fail "(timeout) info auto-deleted break marker2"}
199}
200
201send_gdb "continue\n"
202gdb_expect {
a1dea79a 203 -re ".*marker3 .*:($bp_location17|$bp_location18).*$gdb_prompt $"\
c906108c
SS
204 {pass "continue to auto-deleted break marker3"}
205 -re "Breakpoint \[0-9\]*, marker3.*$gdb_prompt $"\
206 {fail "continue to auto-deleted break marker3"}
207 -re "$gdb_prompt $"\
208 {fail "continue to auto-deleted break marker3"}
209 timeout {fail "(timeout) continue to break marker3"}
210}
211
212send_gdb "info break $expect_out(1,string)\n"
213gdb_expect {
214 -re ".*No breakpoint or watchpoint number.*$gdb_prompt $"\
215 {pass "info auto-deleted break marker3"}
216 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\].*$gdb_prompt $"\
217 {fail "info auto-deleted break marker3"}
218 -re "$gdb_prompt $"\
219 {fail "info auto-deleted break marker3"}
220 timeout {fail "(timeout) info auto-deleted break marker3"}
221}
222
223# Verify that we can set a breakpoint and manually disable it (we've
224# already proven that disabled bp's don't trigger).
225#
226send_gdb "break marker4\n"
227gdb_expect {
a1dea79a 228 -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location14|$bp_location13).*$gdb_prompt $"\
c906108c
SS
229 {pass "break marker4"}
230 -re "$gdb_prompt $"\
231 {fail "break marker4"}
232 timeout {fail "(timeout) break marker4"}
233}
234
235send_gdb "disable $expect_out(1,string)\n"
236gdb_expect {
237 -re "$gdb_prompt $"\
238 {pass "disable break marker4"}
239 timeout {fail "(timeout) disable break marker4"}
240}
241
242send_gdb "info break $expect_out(1,string)\n"
243gdb_expect {
244 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*$gdb_prompt $"\
245 {pass "info break marker4"}
246 -re "$gdb_prompt $"\
247 {fail "info break marker4"}
248 timeout {fail "(timeout) info break marker4"}
249}
250
251# Verify that we can set a breakpoint with an ignore count N, which
252# should cause the next N triggers of the bp to be ignored. (This is
253# a flavor of enablement/disablement, after all.)
254#
255if ![runto_main] then { fail "enable/disable break tests suppressed" }
256
257send_gdb "break marker1\n"
258gdb_expect {
a1dea79a 259 -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location15|$bp_location16).*$gdb_prompt $"\
c906108c
SS
260 {pass "break marker1"}
261 -re "$gdb_prompt $"\
262 {fail "break marker1"}
263 timeout {fail "(timeout) break marker1"}
264}
265
266# Verify that an ignore of a non-existent breakpoint is gracefully
267# handled.
268#
269send_gdb "ignore 999 2\n"
270gdb_expect {
271 -re "No breakpoint number 999..*$gdb_prompt $"\
272 {pass "ignore non-existent break"}
273 -re "$gdb_prompt $"\
274 {fail "ignore non-existent break"}
275 timeout {fail "(timeout) ignore non-existent break"}
276}
277
278# Verify that a missing ignore count is gracefully handled.
279#
280send_gdb "ignore $expect_out(1,string) \n"
281gdb_expect {
282 -re "Second argument .specified ignore-count. is missing..*$gdb_prompt $"\
283 {pass "ignore break with missing ignore count"}
284 -re "$gdb_prompt $"\
285 {fail "ignore break with missing ignore count"}
286 timeout {fail "(timeout) ignore break with missing ignore count"}
287}
288
289# Verify that a negative or zero ignore count is handled gracefully
290# (they both are treated the same).
291#
292send_gdb "ignore $expect_out(1,string) -1\n"
293gdb_expect {
294 -re "Will stop next time breakpoint \[0-9\]* is reached..*$gdb_prompt $"\
295 {pass "ignore break marker1 -1"}
296 -re "$gdb_prompt $"\
297 {fail "ignore break marker1 -1"}
298 timeout {fail "(timeout) ignore break marker1 -1"}
299}
300
301send_gdb "ignore $expect_out(1,string) 0\n"
302gdb_expect {
303 -re "Will stop next time breakpoint \[0-9\]* is reached..*$gdb_prompt $"\
304 {pass "ignore break marker1 0"}
305 -re "$gdb_prompt $"\
306 {fail "ignore break marker1 0"}
307 timeout {fail "(timeout) ignore break marker1 0"}
308}
309
310send_gdb "ignore $expect_out(1,string) 1\n"
311gdb_expect {
312 -re "Will ignore next crossing of breakpoint \[0-9\]*.*$gdb_prompt $"\
313 {pass "ignore break marker1"}
314 -re "$gdb_prompt $"\
315 {fail "ignore break marker1"}
316 timeout {fail "(timeout) ignore break marker1"}
317}
318
319send_gdb "info break $expect_out(1,string)\n"
320gdb_expect {
321 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*ignore next 1 hits.*$gdb_prompt $"\
322 {pass "info ignored break marker1"}
323 -re "$gdb_prompt $"\
324 {fail "info ignored break marker1"}
325 timeout {fail "(timeout) info ignored break marker1"}
326}
327
7a292a7a
SS
328gdb_continue_to_end "no stop at ignored break marker1"
329rerun_to_main
c906108c 330
11cf8741
JM
331# See the comments in condbreak.exp for "run until breakpoint at marker1"
332# for an explanation of the xfail below.
c906108c
SS
333send_gdb "continue\n"
334gdb_expect {
335 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
11cf8741
JM
336 {pass "continue to break marker1, 2nd time"}
337 -re "Breakpoint \[0-9\]*, $hex in marker1.*$gdb_prompt $"\
338 {xfail "continue to break marker1, 2nd time"}
c906108c 339 -re "$gdb_prompt $"\
11cf8741
JM
340 {fail "continue to break marker1, 2nd time"}
341 timeout {fail "(timeout) continue to break marker1, 2nd time"}
c906108c
SS
342}
343
344# Verify that we can specify both an ignore count and an auto-delete.
345#
346if ![runto_main] then { fail "enable/disable break tests suppressed" }
347
348send_gdb "break marker1\n"
349gdb_expect {
a1dea79a 350 -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location15|$bp_location16).*$gdb_prompt $"\
c906108c
SS
351 {pass "break marker1"}
352 -re "$gdb_prompt $"\
353 {fail "break marker1"}
354 timeout {fail "(timeout) break marker1"}
355}
356
357send_gdb "ignore $expect_out(1,string) 1\n"
358gdb_expect {
359 -re "Will ignore next crossing of breakpoint \[0-9\]*.*$gdb_prompt $"\
360 {pass "ignore break marker1"}
361 -re "$gdb_prompt $"\
362 {fail "ignore break marker1"}
363 timeout {fail "(timeout) ignore break marker1"}
364}
365
366send_gdb "enable del $expect_out(1,string)\n"
367gdb_expect {
368 -re "$gdb_prompt $"\
369 {pass "enable del break marker1"}
370 timeout {fail "(timeout) enable del break marker1"}
371}
372
373send_gdb "info break $expect_out(1,string)\n"
374gdb_expect {
375 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*ignore next 1 hits.*$gdb_prompt $"\
376 {pass "info break marker1"}
377 -re "$gdb_prompt $"\
378 {fail "info break marker1"}
379 timeout {fail "(timeout) info break marker2"}
380}
381
7a292a7a
SS
382gdb_continue_to_end "no stop at ignored & auto-deleted break marker1"
383rerun_to_main
c906108c
SS
384
385send_gdb "continue\n"
386gdb_expect {
a1dea79a 387 -re ".*marker1 .*:($bp_location15|$bp_location16).*$gdb_prompt $"\
c906108c
SS
388 {pass "continue to ignored & auto-deleted break marker1"}
389 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\
390 {fail "continue to ignored & auto-deleted break marker1"}
391 -re "$gdb_prompt $"\
392 {fail "continue to ignored & auto-deleted break marker1"}
393 timeout {fail "(timeout) continue to ignored & auto-deleted break marker1"}
394}
395
396# Verify that a disabled breakpoint's ignore count isn't updated when
397# the bp is encountered.
398#
399if ![runto_main] then { fail "enable/disable break tests suppressed" }
400
401send_gdb "break marker1\n"
402gdb_expect {
a1dea79a 403 -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location15|$bp_location16).*$gdb_prompt $"\
c906108c
SS
404 {pass "break marker1"}
405 -re "$gdb_prompt $"\
406 {fail "break marker1"}
407 timeout {fail "(timeout) break marker1"}
408}
409
410send_gdb "ignore $expect_out(1,string) 10\n"
411gdb_expect {
412 -re "Will ignore next 10 crossings of breakpoint \[0-9\]*.*$gdb_prompt $"\
413 {pass "ignore break marker1"}
414 -re "$gdb_prompt $"\
415 {fail "ignore break marker1"}
416 timeout {fail "(timeout) ignore break marker1"}
417}
418
419send_gdb "disable $expect_out(1,string)\n"
420gdb_expect {
421 -re "$gdb_prompt $"\
422 {pass "disable break marker1"}
423 timeout {fail "(timeout) disable break marker1"}
424}
425
7a292a7a
SS
426gdb_continue_to_end "no stop at ignored & disabled break marker1"
427rerun_to_main
c906108c
SS
428
429send_gdb "info break $expect_out(1,string)\n"
430gdb_expect {
431 -re "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*ignore next 10 hits.*$gdb_prompt $"\
432 {pass "info ignored & disabled break marker1"}
433 -re "$gdb_prompt $"\
434 {fail "info ignored & disabled break marker1"}
435 timeout {fail "(timeout) info ignored & disabled break marker1"}
436}
437
438# Verify that GDB correctly handles the "continue" command with an argument,
439# which is an ignore count to set on the currently stopped-at breakpoint.
440# (Also verify that GDB gracefully handles the case where the inferior
441# isn't stopped at a breakpoint.)
442#
443if ![runto_main] then { fail "enable/disable break tests suppressed" }
444
a1dea79a 445send_gdb "break $bp_location1\n"
c906108c 446gdb_expect {
a1dea79a 447 -re "Breakpoint \[0-9\]*.*, line $bp_location1.*$gdb_prompt $"\
c906108c
SS
448 {pass "prepare to continue with ignore count"}
449 -re "$gdb_prompt $"\
450 {fail "prepare to continue with ignore count"}
451 timeout {fail "(timeout) prepare to continue with ignore count"}
452}
453send_gdb "continue 2\n"
454gdb_expect {
455 -re "Will ignore next crossing of breakpoint \[0-9\]*. Continuing..*$gdb_prompt $"\
456 {pass "continue with ignore count"}
457 -re "$gdb_prompt $"\
458 {fail "continue with ignore count"}
459 timeout {fail "(timeout) continue with ignore count"}
460}
461
462send_gdb "next\n"
463gdb_expect {
a1dea79a 464 -re ".*$bp_location11\[ \t\]*marker1.*$gdb_prompt $"\
c906108c
SS
465 {pass "step after continue with ignore count"}
466 -re "$gdb_prompt $"\
467 {fail "step after continue with ignore count"}
468 timeout {fail "(timeout) step after continue with ignore count"}
469}
470
471# ??rehrauer: Huh. This appears to be an actual bug. (No big
472# surprise, since this feature hasn't been tested...) Looks like
473# GDB is currently trying to set the ignore count of bp # -1!
474#
475setup_xfail hppa_*_*
476send_gdb "continue 2\n"
477gdb_expect {
478 -re "Not stopped at any breakpoint; argument ignored..*$gdb_prompt $"\
479 {pass "continue with ignore count, not stopped at bpt"}
480 -re "No breakpoint number -1.*$gdb_prompt $"\
481 {xfail "(DTS'd) continue with ignore count, not stopped at bpt"}
482 -re "$gdb_prompt $"\
483 {fail "continue with ignore count, not stopped at bpt"}
484 timeout {fail "(timeout) step after continue with ignore count, not stopped at bpt"}
485}
486
487gdb_exit
488return 0
This page took 0.472345 seconds and 4 git commands to generate.