• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/gdb/gdb/testsuite/gdb.base/
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
18if $tracelevel then {
19    strace $tracelevel
20}
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
32set srcfile1 ${testfile}1.c
33set binfile ${objdir}/${subdir}/${testfile}
34
35if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } {
36     untested ena-dis-br.exp
37     return -1
38}
39
40if  { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } {
41     untested ena-dis-br.exp
42     return -1
43}
44
45if  { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } {
46     untested ena-dis-br.exp
47     return -1
48}
49
50gdb_exit
51gdb_start
52gdb_reinitialize_dir $srcdir/$subdir
53gdb_load ${binfile}
54
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
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.
70
71proc 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
86set bp [break_at "marker1" " line ($bp_location15|$bp_location16)"]
87
88gdb_test "enable $bp" "" "enable break marker1"
89
90gdb_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.
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    }
104}
105
106gdb_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.
110set bp [break_at "marker2" " line ($bp_location8|$bp_location9)"]
111
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    }
128}
129
130gdb_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.
135gdb_continue_to_end "no stop"
136rerun_to_main
137gdb_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.
141if ![runto_main] then {
142    fail "enable/disable break tests suppressed"
143}
144
145set bp [break_at "marker3" " line ($bp_location17|$bp_location18)"]
146
147gdb_test "enable del $bp" "" "enable del break marker3"
148
149gdb_test "info break $bp" \
150    "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*" \
151    "info auto-deleted break marker2"
152
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"
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
164set bp [break_at "marker4" " line ($bp_location14|$bp_location13).*"]
165
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"
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
176if ![runto_main] then {
177    fail "enable/disable break tests suppressed"
178}
179
180set 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
185gdb_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
191gdb_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
198gdb_test "ignore $bp -1" \
199    "Will stop next time breakpoint \[0-9\]* is reached..*" \
200    "ignore break marker1 -1"
201
202gdb_test "ignore $bp 0" \
203    "Will stop next time breakpoint \[0-9\]* is reached..*" \
204    "ignore break marker1 0"
205
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"
213
214gdb_continue_to_end "no stop at ignored break marker1"
215rerun_to_main
216
217# See the comments in condbreak.exp for "run until breakpoint at marker1"
218# for an explanation of the xfail below.
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    }
227}
228
229# Verify that we can specify both an ignore count and an auto-delete.
230
231if ![runto_main] then {
232    fail "enable/disable break tests suppressed"
233}
234
235set bp [break_at marker1 " line ($bp_location15|$bp_location16).*"]
236
237gdb_test "ignore $bp 1" \
238    "Will ignore next crossing of breakpoint \[0-9\]*.*" \
239    "ignore break marker1"
240
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"
246
247gdb_continue_to_end "no stop at ignored & auto-deleted break marker1"
248rerun_to_main
249
250gdb_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
257if ![runto_main] then {
258    fail "enable/disable break tests suppressed"
259}
260
261set bp [break_at marker1 " line ($bp_location15|$bp_location16)"]
262
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"
268
269gdb_continue_to_end "no stop at ignored & disabled break marker1"
270rerun_to_main
271
272gdb_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#
281if ![runto_main] then { fail "enable/disable break tests suppressed" }
282
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    }
302}
303
304gdb_exit
305return 0
306