Commit | Line | Data |
---|---|---|
9c7bb332 AC |
1 | # This testcase is part of GDB, the GNU debugger. |
2 | ||
9b254dd1 DJ |
3 | # Copyright 1997, 1998, 1999, 2003, 2004, 2007, 2008 |
4 | # Free Software Foundation, Inc. | |
c906108c SS |
5 | |
6 | # This program is free software; you can redistribute it and/or modify | |
7 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 8 | # the Free Software Foundation; either version 3 of the License, or |
c906108c | 9 | # (at your option) any later version. |
e22f8b7c | 10 | # |
c906108c SS |
11 | # This program is distributed in the hope that it will be useful, |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. | |
e22f8b7c | 15 | # |
c906108c | 16 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
c906108c | 18 | |
c906108c | 19 | if $tracelevel then { |
9c7bb332 AC |
20 | strace $tracelevel |
21 | } | |
c906108c SS |
22 | |
23 | global usestubs | |
24 | ||
25 | # | |
26 | # test running programs | |
27 | # | |
28 | set prms_id 0 | |
29 | set bug_id 0 | |
30 | ||
31 | set testfile "break" | |
32 | set srcfile ${testfile}.c | |
a1dea79a | 33 | set srcfile1 ${testfile}1.c |
c906108c SS |
34 | set binfile ${objdir}/${subdir}/${testfile} |
35 | ||
fc91c6c2 | 36 | if { [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 | 41 | if { [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 | 46 | if { [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 | ||
51 | gdb_exit | |
52 | gdb_start | |
53 | gdb_reinitialize_dir $srcdir/$subdir | |
54 | gdb_load ${binfile} | |
55 | ||
a1dea79a FF |
56 | set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] |
57 | set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1] | |
58 | set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1] | |
59 | set bp_location11 [gdb_get_line_number "set breakpoint 11 here"] | |
60 | set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1] | |
61 | set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1] | |
62 | set bp_location15 [gdb_get_line_number "set breakpoint 15 here" $srcfile1] | |
63 | set bp_location16 [gdb_get_line_number "set breakpoint 16 here" $srcfile1] | |
64 | set bp_location17 [gdb_get_line_number "set breakpoint 17 here" $srcfile1] | |
65 | set bp_location18 [gdb_get_line_number "set breakpoint 18 here" $srcfile1] | |
66 | ||
c906108c SS |
67 | if ![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 |
72 | proc 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 | 87 | set bp [break_at "marker1" " line ($bp_location15|$bp_location16)"] |
c906108c | 88 | |
9c7bb332 | 89 | gdb_test "enable $bp" "" "enable break marker1" |
c906108c | 90 | |
9c7bb332 AC |
91 | gdb_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. | |
97 | set test "continue to break marker1" | |
98 | gdb_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 | 107 | gdb_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. | |
111 | set bp [break_at "marker2" " line ($bp_location8|$bp_location9)"] | |
c906108c | 112 | |
9c7bb332 AC |
113 | gdb_test "enable once $bp" "" "enable once break marker2" |
114 | ||
115 | gdb_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. | |
121 | set test "continue to auto-disabled break marker2" | |
122 | gdb_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 |
131 | gdb_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 |
136 | gdb_continue_to_end "no stop" |
137 | rerun_to_main | |
138 | gdb_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. | |
142 | if ![runto_main] then { | |
143 | fail "enable/disable break tests suppressed" | |
c906108c SS |
144 | } |
145 | ||
9c7bb332 | 146 | set bp [break_at "marker3" " line ($bp_location17|$bp_location18)"] |
c906108c | 147 | |
9c7bb332 | 148 | gdb_test "enable del $bp" "" "enable del break marker3" |
c906108c | 149 | |
9c7bb332 AC |
150 | gdb_test "info break $bp" \ |
151 | "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*" \ | |
152 | "info auto-deleted break marker2" | |
c906108c | 153 | |
9c7bb332 AC |
154 | gdb_test "continue" \ |
155 | ".*marker3 .*:($bp_location17|$bp_location18).*" \ | |
156 | "continue to auto-deleted break marker3" | |
157 | ||
158 | gdb_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 | 165 | set bp [break_at "marker4" " line ($bp_location14|$bp_location13).*"] |
c906108c | 166 | |
9c7bb332 AC |
167 | gdb_test "disable $bp" "" "disable break marker4" |
168 | ||
169 | gdb_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 |
177 | if ![runto_main] then { |
178 | fail "enable/disable break tests suppressed" | |
c906108c SS |
179 | } |
180 | ||
9c7bb332 AC |
181 | set 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 | |
186 | gdb_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 | |
192 | gdb_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 |
199 | gdb_test "ignore $bp -1" \ |
200 | "Will stop next time breakpoint \[0-9\]* is reached..*" \ | |
201 | "ignore break marker1 -1" | |
c906108c | 202 | |
9c7bb332 AC |
203 | gdb_test "ignore $bp 0" \ |
204 | "Will stop next time breakpoint \[0-9\]* is reached..*" \ | |
205 | "ignore break marker1 0" | |
c906108c | 206 | |
9c7bb332 AC |
207 | gdb_test "ignore $bp 1" \ |
208 | "Will ignore next crossing of breakpoint \[0-9\]*.*" \ | |
209 | "ignore break marker1" | |
210 | ||
211 | gdb_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 |
215 | gdb_continue_to_end "no stop at ignored break marker1" |
216 | rerun_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 |
220 | set test "continue to break marker1, 2nd time" |
221 | gdb_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 |
232 | if ![runto_main] then { |
233 | fail "enable/disable break tests suppressed" | |
c906108c SS |
234 | } |
235 | ||
9c7bb332 | 236 | set bp [break_at marker1 " line ($bp_location15|$bp_location16).*"] |
c906108c | 237 | |
9c7bb332 AC |
238 | gdb_test "ignore $bp 1" \ |
239 | "Will ignore next crossing of breakpoint \[0-9\]*.*" \ | |
240 | "ignore break marker1" | |
c906108c | 241 | |
9c7bb332 AC |
242 | gdb_test "enable del $bp" "" "enable del break marker1" |
243 | ||
244 | gdb_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 |
248 | gdb_continue_to_end "no stop at ignored & auto-deleted break marker1" |
249 | rerun_to_main | |
c906108c | 250 | |
9c7bb332 AC |
251 | gdb_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 |
258 | if ![runto_main] then { |
259 | fail "enable/disable break tests suppressed" | |
c906108c SS |
260 | } |
261 | ||
9c7bb332 | 262 | set bp [break_at marker1 " line ($bp_location15|$bp_location16)"] |
c906108c | 263 | |
9c7bb332 AC |
264 | gdb_test "ignore $bp 10" \ |
265 | "Will ignore next 10 crossings of breakpoint \[0-9\]*.*" \ | |
266 | "ignore break marker1" | |
267 | ||
268 | gdb_test "disable $bp" "" "disable break marker1" | |
c906108c | 269 | |
7a292a7a SS |
270 | gdb_continue_to_end "no stop at ignored & disabled break marker1" |
271 | rerun_to_main | |
c906108c | 272 | |
9c7bb332 AC |
273 | gdb_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 | # | |
282 | if ![runto_main] then { fail "enable/disable break tests suppressed" } | |
283 | ||
9c7bb332 AC |
284 | gdb_test "break $bp_location1" \ |
285 | "Breakpoint \[0-9\]*.*, line $bp_location1.*" \ | |
286 | "prepare to continue with ignore count" | |
287 | ||
288 | gdb_test "continue 2" \ | |
289 | "Will ignore next crossing of breakpoint \[0-9\]*. Continuing..*" \ | |
290 | "continue with ignore count" | |
291 | ||
292 | gdb_test "next" ".*$bp_location11\[ \t\]*marker1.*" \ | |
293 | step after continue with ignore count" | |
294 | ||
295 | set test "continue with ignore count, not stopped at bpt" | |
296 | gdb_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 | ||
305 | gdb_exit | |
306 | return 0 |