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