Remove unused support for target-based exception catching.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / ena-dis-br.exp
1 # This testcase is part of GDB, the GNU debugger.
2
3 # Copyright 1997, 1998, 1999, 2003, 2004, 2007 Free Software Foundation, Inc.
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 3 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, see <http://www.gnu.org/licenses/>.
17
18 if $tracelevel then {
19 strace $tracelevel
20 }
21
22 global usestubs
23
24 #
25 # test running programs
26 #
27 set prms_id 0
28 set bug_id 0
29
30 set testfile "break"
31 set srcfile ${testfile}.c
32 set srcfile1 ${testfile}1.c
33 set binfile ${objdir}/${subdir}/${testfile}
34
35 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
36 untested ena-dis-br.exp
37 return -1
38 }
39
40 if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
41 untested ena-dis-br.exp
42 return -1
43 }
44
45 if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
46 untested ena-dis-br.exp
47 return -1
48 }
49
50 gdb_exit
51 gdb_start
52 gdb_reinitialize_dir $srcdir/$subdir
53 gdb_load ${binfile}
54
55 set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
56 set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1]
57 set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1]
58 set bp_location11 [gdb_get_line_number "set breakpoint 11 here"]
59 set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1]
60 set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1]
61 set bp_location15 [gdb_get_line_number "set breakpoint 15 here" $srcfile1]
62 set bp_location16 [gdb_get_line_number "set breakpoint 16 here" $srcfile1]
63 set bp_location17 [gdb_get_line_number "set breakpoint 17 here" $srcfile1]
64 set bp_location18 [gdb_get_line_number "set breakpoint 18 here" $srcfile1]
65
66 if ![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.
70
71 proc break_at { breakpoint where } {
72 global gdb_prompt
73 global expect_out
74
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
84 }
85
86 set bp [break_at "marker1" " line ($bp_location15|$bp_location16)"]
87
88 gdb_test "enable $bp" "" "enable break marker1"
89
90 gdb_test "info break $bp" \
91 "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*" \
92 "info break marker1"
93
94 # See the comments in condbreak.exp for "run until breakpoint at
95 # marker1" for an explanation of the xfail below.
96 set test "continue to break marker1"
97 gdb_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 }
104 }
105
106 gdb_test "delete $bp" "" "delete break marker1"
107
108 # Verify that we can set a breakpoint to be self-disabling after the
109 # first time it triggers.
110 set bp [break_at "marker2" " line ($bp_location8|$bp_location9)"]
111
112 gdb_test "enable once $bp" "" "enable once break marker2"
113
114 gdb_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.
120 set test "continue to auto-disabled break marker2"
121 gdb_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 }
128 }
129
130 gdb_test "info break $bp" \
131 "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+n.*" \
132 "info auto-disabled break marker2"
133
134 # Verify that we don't stop at a disabled breakpoint.
135 gdb_continue_to_end "no stop"
136 rerun_to_main
137 gdb_continue_to_end "no stop at auto-disabled break marker2"
138
139 # Verify that we can set a breakpoint to be self-deleting after the
140 # first time it triggers.
141 if ![runto_main] then {
142 fail "enable/disable break tests suppressed"
143 }
144
145 set bp [break_at "marker3" " line ($bp_location17|$bp_location18)"]
146
147 gdb_test "enable del $bp" "" "enable del break marker3"
148
149 gdb_test "info break $bp" \
150 "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*" \
151 "info auto-deleted break marker2"
152
153 gdb_test "continue" \
154 ".*marker3 .*:($bp_location17|$bp_location18).*" \
155 "continue to auto-deleted break marker3"
156
157 gdb_test "info break $bp" \
158 ".*No breakpoint or watchpoint number.*" \
159 "info auto-deleted break marker3"
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).
163
164 set bp [break_at "marker4" " line ($bp_location14|$bp_location13).*"]
165
166 gdb_test "disable $bp" "" "disable break marker4"
167
168 gdb_test "info break $bp" \
169 "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*" \
170 "info break marker4"
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.)
175
176 if ![runto_main] then {
177 fail "enable/disable break tests suppressed"
178 }
179
180 set bp [break_at "marker1" " line ($bp_location15|$bp_location16).*"]
181
182 # Verify that an ignore of a non-existent breakpoint is gracefully
183 # handled.
184
185 gdb_test "ignore 999 2" \
186 "No breakpoint number 999..*" \
187 "ignore non-existent break"
188
189 # Verify that a missing ignore count is gracefully handled.
190
191 gdb_test "ignore $bp" \
192 "Second argument .specified ignore-count. is missing..*" \
193 "ignore break with missing ignore count"
194
195 # Verify that a negative or zero ignore count is handled gracefully
196 # (they both are treated the same).
197
198 gdb_test "ignore $bp -1" \
199 "Will stop next time breakpoint \[0-9\]* is reached..*" \
200 "ignore break marker1 -1"
201
202 gdb_test "ignore $bp 0" \
203 "Will stop next time breakpoint \[0-9\]* is reached..*" \
204 "ignore break marker1 0"
205
206 gdb_test "ignore $bp 1" \
207 "Will ignore next crossing of breakpoint \[0-9\]*.*" \
208 "ignore break marker1"
209
210 gdb_test "info break $bp" \
211 "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*ignore next 1 hits.*" \
212 "info ignored break marker1"
213
214 gdb_continue_to_end "no stop at ignored break marker1"
215 rerun_to_main
216
217 # See the comments in condbreak.exp for "run until breakpoint at marker1"
218 # for an explanation of the xfail below.
219 set test "continue to break marker1, 2nd time"
220 gdb_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 }
227 }
228
229 # Verify that we can specify both an ignore count and an auto-delete.
230
231 if ![runto_main] then {
232 fail "enable/disable break tests suppressed"
233 }
234
235 set bp [break_at marker1 " line ($bp_location15|$bp_location16).*"]
236
237 gdb_test "ignore $bp 1" \
238 "Will ignore next crossing of breakpoint \[0-9\]*.*" \
239 "ignore break marker1"
240
241 gdb_test "enable del $bp" "" "enable del break marker1"
242
243 gdb_test "info break $bp" \
244 "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*ignore next 1 hits.*" \
245 "info break marker1"
246
247 gdb_continue_to_end "no stop at ignored & auto-deleted break marker1"
248 rerun_to_main
249
250 gdb_test "continue" \
251 ".*marker1 .*:($bp_location15|$bp_location16).*" \
252 "continue to ignored & auto-deleted break marker1"
253
254 # Verify that a disabled breakpoint's ignore count isn't updated when
255 # the bp is encountered.
256
257 if ![runto_main] then {
258 fail "enable/disable break tests suppressed"
259 }
260
261 set bp [break_at marker1 " line ($bp_location15|$bp_location16)"]
262
263 gdb_test "ignore $bp 10" \
264 "Will ignore next 10 crossings of breakpoint \[0-9\]*.*" \
265 "ignore break marker1"
266
267 gdb_test "disable $bp" "" "disable break marker1"
268
269 gdb_continue_to_end "no stop at ignored & disabled break marker1"
270 rerun_to_main
271
272 gdb_test "info break $bp" \
273 "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+n.*ignore next 10 hits.*" \
274 "info ignored & disabled break marker1"
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 #
281 if ![runto_main] then { fail "enable/disable break tests suppressed" }
282
283 gdb_test "break $bp_location1" \
284 "Breakpoint \[0-9\]*.*, line $bp_location1.*" \
285 "prepare to continue with ignore count"
286
287 gdb_test "continue 2" \
288 "Will ignore next crossing of breakpoint \[0-9\]*. Continuing..*" \
289 "continue with ignore count"
290
291 gdb_test "next" ".*$bp_location11\[ \t\]*marker1.*" \
292 step after continue with ignore count"
293
294 set test "continue with ignore count, not stopped at bpt"
295 gdb_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 }
302 }
303
304 gdb_exit
305 return 0
This page took 0.036203 seconds and 4 git commands to generate.