]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/ena-dis-br.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / ena-dis-br.exp
CommitLineData
9c7bb332
AC
1# This testcase is part of GDB, the GNU debugger.
2
6aba47ca 3# Copyright 1997, 1998, 1999, 2003, 2004, 2007 Free Software Foundation, Inc.
c906108c
SS
4
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
a1dea79a 17# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
c906108c 18
c906108c 19if $tracelevel then {
9c7bb332
AC
20 strace $tracelevel
21}
c906108c
SS
22
23global usestubs
24
25#
26# test running programs
27#
28set prms_id 0
29set bug_id 0
30
31set testfile "break"
32set srcfile ${testfile}.c
a1dea79a 33set srcfile1 ${testfile}1.c
c906108c
SS
34set binfile ${objdir}/${subdir}/${testfile}
35
fc91c6c2 36if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
b60f0898
JB
37 untested ena-dis-br.exp
38 return -1
a1dea79a
FF
39}
40
fc91c6c2 41if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
b60f0898
JB
42 untested ena-dis-br.exp
43 return -1
a1dea79a
FF
44}
45
fc91c6c2 46if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
b60f0898
JB
47 untested ena-dis-br.exp
48 return -1
c906108c
SS
49}
50
51gdb_exit
52gdb_start
53gdb_reinitialize_dir $srcdir/$subdir
54gdb_load ${binfile}
55
a1dea79a
FF
56set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
57set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1]
58set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1]
59set bp_location11 [gdb_get_line_number "set breakpoint 11 here"]
60set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1]
61set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1]
62set bp_location15 [gdb_get_line_number "set breakpoint 15 here" $srcfile1]
63set bp_location16 [gdb_get_line_number "set breakpoint 16 here" $srcfile1]
64set bp_location17 [gdb_get_line_number "set breakpoint 17 here" $srcfile1]
65set bp_location18 [gdb_get_line_number "set breakpoint 18 here" $srcfile1]
66
c906108c
SS
67if ![runto_main] then { fail "enable/disable break tests suppressed" }
68
69# Verify that we can set a breakpoint (the location is irrelevant),
70# then enable it (yes, it's already enabled by default), then hit it.
c906108c 71
9c7bb332
AC
72proc break_at { breakpoint where } {
73 global gdb_prompt
74 global expect_out
c906108c 75
9c7bb332
AC
76 set test "break $breakpoint"
77 set bp 0
78 gdb_test_multiple "$test" "$test" {
79 -re "Breakpoint (\[0-9\]*) at .*$where.*$gdb_prompt $" {
80 set bp $expect_out(1,string)
81 pass "$test"
82 }
83 }
84 return $bp
c906108c
SS
85}
86
9c7bb332 87set bp [break_at "marker1" " line ($bp_location15|$bp_location16)"]
c906108c 88
9c7bb332 89gdb_test "enable $bp" "" "enable break marker1"
c906108c 90
9c7bb332
AC
91gdb_test "info break $bp" \
92 "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*" \
93 "info break marker1"
c906108c 94
9c7bb332
AC
95# See the comments in condbreak.exp for "run until breakpoint at
96# marker1" for an explanation of the xfail below.
97set test "continue to break marker1"
98gdb_test_multiple "continue" "$test" {
99 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $" {
100 pass "$test"
101 }
102 -re "Breakpoint \[0-9\]*, $hex in marker1.*$gdb_prompt $" {
103 xfail "$test"
104 }
c906108c
SS
105}
106
9c7bb332 107gdb_test "delete $bp" "" "delete break marker1"
c906108c 108
9c7bb332
AC
109# Verify that we can set a breakpoint to be self-disabling after the
110# first time it triggers.
111set bp [break_at "marker2" " line ($bp_location8|$bp_location9)"]
c906108c 112
9c7bb332
AC
113gdb_test "enable once $bp" "" "enable once break marker2"
114
115gdb_test "info break $bp" \
116 "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+y.*" \
117 "info auto-disabled break marker2"
118
119# See the comments in condbreak.exp for "run until breakpoint at
120# marker1" for an explanation of the xfail below.
121set test "continue to auto-disabled break marker2"
122gdb_test_multiple "continue" "$test" {
123 -re "Breakpoint \[0-9\]*, marker2.*$gdb_prompt $" {
124 pass "$test"
125 }
126 -re "Breakpoint \[0-9\]*, $hex in marker2.*$gdb_prompt $" {
127 xfail "$test"
128 }
c906108c
SS
129}
130
9c7bb332
AC
131gdb_test "info break $bp" \
132 "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+n.*" \
133 "info auto-disabled break marker2"
134
c906108c 135# Verify that we don't stop at a disabled breakpoint.
7a292a7a
SS
136gdb_continue_to_end "no stop"
137rerun_to_main
138gdb_continue_to_end "no stop at auto-disabled break marker2"
c906108c 139
9c7bb332
AC
140# Verify that we can set a breakpoint to be self-deleting after the
141# first time it triggers.
142if ![runto_main] then {
143 fail "enable/disable break tests suppressed"
c906108c
SS
144}
145
9c7bb332 146set bp [break_at "marker3" " line ($bp_location17|$bp_location18)"]
c906108c 147
9c7bb332 148gdb_test "enable del $bp" "" "enable del break marker3"
c906108c 149
9c7bb332
AC
150gdb_test "info break $bp" \
151 "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*" \
152 "info auto-deleted break marker2"
c906108c 153
9c7bb332
AC
154gdb_test "continue" \
155 ".*marker3 .*:($bp_location17|$bp_location18).*" \
156 "continue to auto-deleted break marker3"
157
158gdb_test "info break $bp" \
159 ".*No breakpoint or watchpoint number.*" \
160 "info auto-deleted break marker3"
c906108c
SS
161
162# Verify that we can set a breakpoint and manually disable it (we've
163# already proven that disabled bp's don't trigger).
c906108c 164
9c7bb332 165set bp [break_at "marker4" " line ($bp_location14|$bp_location13).*"]
c906108c 166
9c7bb332
AC
167gdb_test "disable $bp" "" "disable break marker4"
168
169gdb_test "info break $bp" \
170 "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*" \
171 "info break marker4"
c906108c
SS
172
173# Verify that we can set a breakpoint with an ignore count N, which
174# should cause the next N triggers of the bp to be ignored. (This is
175# a flavor of enablement/disablement, after all.)
c906108c 176
9c7bb332
AC
177if ![runto_main] then {
178 fail "enable/disable break tests suppressed"
c906108c
SS
179}
180
9c7bb332
AC
181set bp [break_at "marker1" " line ($bp_location15|$bp_location16).*"]
182
c906108c
SS
183# Verify that an ignore of a non-existent breakpoint is gracefully
184# handled.
9c7bb332
AC
185
186gdb_test "ignore 999 2" \
187 "No breakpoint number 999..*" \
188 "ignore non-existent break"
c906108c
SS
189
190# Verify that a missing ignore count is gracefully handled.
9c7bb332
AC
191
192gdb_test "ignore $bp" \
193 "Second argument .specified ignore-count. is missing..*" \
194 "ignore break with missing ignore count"
c906108c
SS
195
196# Verify that a negative or zero ignore count is handled gracefully
197# (they both are treated the same).
c906108c 198
9c7bb332
AC
199gdb_test "ignore $bp -1" \
200 "Will stop next time breakpoint \[0-9\]* is reached..*" \
201 "ignore break marker1 -1"
c906108c 202
9c7bb332
AC
203gdb_test "ignore $bp 0" \
204 "Will stop next time breakpoint \[0-9\]* is reached..*" \
205 "ignore break marker1 0"
c906108c 206
9c7bb332
AC
207gdb_test "ignore $bp 1" \
208 "Will ignore next crossing of breakpoint \[0-9\]*.*" \
209 "ignore break marker1"
210
211gdb_test "info break $bp" \
212 "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*ignore next 1 hits.*" \
213 "info ignored break marker1"
c906108c 214
7a292a7a
SS
215gdb_continue_to_end "no stop at ignored break marker1"
216rerun_to_main
c906108c 217
11cf8741
JM
218# See the comments in condbreak.exp for "run until breakpoint at marker1"
219# for an explanation of the xfail below.
9c7bb332
AC
220set test "continue to break marker1, 2nd time"
221gdb_test_multiple "continue" "$test" {
222 -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $" {
223 pass "continue to break marker1, 2nd time"
224 }
225 -re "Breakpoint \[0-9\]*, $hex in marker1.*$gdb_prompt $" {
226 xfail "continue to break marker1, 2nd time"
227 }
c906108c
SS
228}
229
230# Verify that we can specify both an ignore count and an auto-delete.
c906108c 231
9c7bb332
AC
232if ![runto_main] then {
233 fail "enable/disable break tests suppressed"
c906108c
SS
234}
235
9c7bb332 236set bp [break_at marker1 " line ($bp_location15|$bp_location16).*"]
c906108c 237
9c7bb332
AC
238gdb_test "ignore $bp 1" \
239 "Will ignore next crossing of breakpoint \[0-9\]*.*" \
240 "ignore break marker1"
c906108c 241
9c7bb332
AC
242gdb_test "enable del $bp" "" "enable del break marker1"
243
244gdb_test "info break $bp" \
245 "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*ignore next 1 hits.*" \
246 "info break marker1"
c906108c 247
7a292a7a
SS
248gdb_continue_to_end "no stop at ignored & auto-deleted break marker1"
249rerun_to_main
c906108c 250
9c7bb332
AC
251gdb_test "continue" \
252 ".*marker1 .*:($bp_location15|$bp_location16).*" \
253 "continue to ignored & auto-deleted break marker1"
c906108c
SS
254
255# Verify that a disabled breakpoint's ignore count isn't updated when
256# the bp is encountered.
c906108c 257
9c7bb332
AC
258if ![runto_main] then {
259 fail "enable/disable break tests suppressed"
c906108c
SS
260}
261
9c7bb332 262set bp [break_at marker1 " line ($bp_location15|$bp_location16)"]
c906108c 263
9c7bb332
AC
264gdb_test "ignore $bp 10" \
265 "Will ignore next 10 crossings of breakpoint \[0-9\]*.*" \
266 "ignore break marker1"
267
268gdb_test "disable $bp" "" "disable break marker1"
c906108c 269
7a292a7a
SS
270gdb_continue_to_end "no stop at ignored & disabled break marker1"
271rerun_to_main
c906108c 272
9c7bb332
AC
273gdb_test "info break $bp" \
274 "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*ignore next 10 hits.*" \
275 "info ignored & disabled break marker1"
c906108c
SS
276
277# Verify that GDB correctly handles the "continue" command with an argument,
278# which is an ignore count to set on the currently stopped-at breakpoint.
279# (Also verify that GDB gracefully handles the case where the inferior
280# isn't stopped at a breakpoint.)
281#
282if ![runto_main] then { fail "enable/disable break tests suppressed" }
283
9c7bb332
AC
284gdb_test "break $bp_location1" \
285 "Breakpoint \[0-9\]*.*, line $bp_location1.*" \
286 "prepare to continue with ignore count"
287
288gdb_test "continue 2" \
289 "Will ignore next crossing of breakpoint \[0-9\]*. Continuing..*" \
290 "continue with ignore count"
291
292gdb_test "next" ".*$bp_location11\[ \t\]*marker1.*" \
293 step after continue with ignore count"
294
295set test "continue with ignore count, not stopped at bpt"
296gdb_test_multiple "continue 2" "$test" {
297 -re "Not stopped at any breakpoint; argument ignored.*$gdb_prompt $" {
298 pass "$test"
299 }
300 -re "No breakpoint number -1.*$gdb_prompt $" {
301 kfail gdb/1689 "$test"
302 }
c906108c
SS
303}
304
305gdb_exit
306return 0