Commit | Line | Data |
---|---|---|
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 | 18 | if $tracelevel then { |
9c7bb332 AC |
19 | strace $tracelevel |
20 | } | |
c906108c SS |
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 | |
a1dea79a | 32 | set srcfile1 ${testfile}1.c |
c906108c SS |
33 | set binfile ${objdir}/${subdir}/${testfile} |
34 | ||
fc91c6c2 | 35 | if { [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 | 40 | if { [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 | 45 | if { [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 | ||
50 | gdb_exit | |
51 | gdb_start | |
52 | gdb_reinitialize_dir $srcdir/$subdir | |
53 | gdb_load ${binfile} | |
54 | ||
a1dea79a FF |
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 | ||
c906108c SS |
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. | |
c906108c | 70 | |
9c7bb332 AC |
71 | proc 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 | 86 | set bp [break_at "marker1" " line ($bp_location15|$bp_location16)"] |
c906108c | 87 | |
9c7bb332 | 88 | gdb_test "enable $bp" "" "enable break marker1" |
c906108c | 89 | |
9c7bb332 AC |
90 | gdb_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. | |
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 | } | |
c906108c SS |
104 | } |
105 | ||
9c7bb332 | 106 | gdb_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. | |
110 | set bp [break_at "marker2" " line ($bp_location8|$bp_location9)"] | |
c906108c | 111 | |
9c7bb332 AC |
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 | } | |
c906108c SS |
128 | } |
129 | ||
9c7bb332 AC |
130 | gdb_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 |
135 | gdb_continue_to_end "no stop" |
136 | rerun_to_main | |
137 | gdb_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. | |
141 | if ![runto_main] then { | |
142 | fail "enable/disable break tests suppressed" | |
c906108c SS |
143 | } |
144 | ||
9c7bb332 | 145 | set bp [break_at "marker3" " line ($bp_location17|$bp_location18)"] |
c906108c | 146 | |
9c7bb332 | 147 | gdb_test "enable del $bp" "" "enable del break marker3" |
c906108c | 148 | |
9c7bb332 AC |
149 | gdb_test "info break $bp" \ |
150 | "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*" \ | |
151 | "info auto-deleted break marker2" | |
c906108c | 152 | |
9c7bb332 AC |
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" | |
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 | 164 | set bp [break_at "marker4" " line ($bp_location14|$bp_location13).*"] |
c906108c | 165 | |
9c7bb332 AC |
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" | |
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 |
176 | if ![runto_main] then { |
177 | fail "enable/disable break tests suppressed" | |
c906108c SS |
178 | } |
179 | ||
9c7bb332 AC |
180 | set 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 | |
185 | gdb_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 | |
191 | gdb_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 |
198 | gdb_test "ignore $bp -1" \ |
199 | "Will stop next time breakpoint \[0-9\]* is reached..*" \ | |
200 | "ignore break marker1 -1" | |
c906108c | 201 | |
9c7bb332 AC |
202 | gdb_test "ignore $bp 0" \ |
203 | "Will stop next time breakpoint \[0-9\]* is reached..*" \ | |
204 | "ignore break marker1 0" | |
c906108c | 205 | |
9c7bb332 AC |
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" | |
c906108c | 213 | |
7a292a7a SS |
214 | gdb_continue_to_end "no stop at ignored break marker1" |
215 | rerun_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 |
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 | } | |
c906108c SS |
227 | } |
228 | ||
229 | # Verify that we can specify both an ignore count and an auto-delete. | |
c906108c | 230 | |
9c7bb332 AC |
231 | if ![runto_main] then { |
232 | fail "enable/disable break tests suppressed" | |
c906108c SS |
233 | } |
234 | ||
9c7bb332 | 235 | set bp [break_at marker1 " line ($bp_location15|$bp_location16).*"] |
c906108c | 236 | |
9c7bb332 AC |
237 | gdb_test "ignore $bp 1" \ |
238 | "Will ignore next crossing of breakpoint \[0-9\]*.*" \ | |
239 | "ignore break marker1" | |
c906108c | 240 | |
9c7bb332 AC |
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" | |
c906108c | 246 | |
7a292a7a SS |
247 | gdb_continue_to_end "no stop at ignored & auto-deleted break marker1" |
248 | rerun_to_main | |
c906108c | 249 | |
9c7bb332 AC |
250 | gdb_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 |
257 | if ![runto_main] then { |
258 | fail "enable/disable break tests suppressed" | |
c906108c SS |
259 | } |
260 | ||
9c7bb332 | 261 | set bp [break_at marker1 " line ($bp_location15|$bp_location16)"] |
c906108c | 262 | |
9c7bb332 AC |
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" | |
c906108c | 268 | |
7a292a7a SS |
269 | gdb_continue_to_end "no stop at ignored & disabled break marker1" |
270 | rerun_to_main | |
c906108c | 271 | |
9c7bb332 AC |
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" | |
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 | # | |
281 | if ![runto_main] then { fail "enable/disable break tests suppressed" } | |
282 | ||
9c7bb332 AC |
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 | } | |
c906108c SS |
302 | } |
303 | ||
304 | gdb_exit | |
305 | return 0 |