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