* auxv.exp: Intercept undefined command messages before
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / pending.exp
CommitLineData
3cbba3d1 1# Copyright 2003, 2004, 2005
18fe2033
JJ
2# Free Software Foundation, Inc.
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
18fe2033 18# This file was created by Jeff Johnston. (jjohnstn@redhat.com)
18fe2033
JJ
19
20if $tracelevel then {
21 strace $tracelevel
22}
23
24#
25# test running programs
26#
27set prms_id 0
28set bug_id 0
29
30# are we on a target board?
31if ![isnative] then {
32 return 0
33}
34
35set testfile "pending"
36set libfile "pendshr"
3cbba3d1
PG
37set srcfile $testfile.c
38set libsrc $srcdir/$subdir/$libfile.c
39set binfile $objdir/$subdir/$testfile
40set lib_sl $objdir/$subdir/$libfile.sl
41
42set lib_opts debug
43set exec_opts [list debug shlib=$lib_sl]
18fe2033
JJ
44
45if [get_compiler_info ${binfile}] {
46 return -1
47}
48
3cbba3d1
PG
49if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
50 || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""} {
51 untested "Could not compile either $libsrc or $srcdir/$subdir/$srcfile."
52 return -1
18fe2033
JJ
53}
54
3cbba3d1 55# Start with a fresh gdb.
18fe2033
JJ
56
57gdb_exit
58gdb_start
59gdb_reinitialize_dir $srcdir/$subdir
60gdb_load ${binfile}
61
62if [target_info exists gdb_stub] {
63 gdb_step_for_stub;
64}
65#
66# Test setting, querying, and modifying pending breakpoints
67#
68
69gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
9f27c604 70 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
18fe2033
JJ
71 gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint"
72 }
73}
74
75gdb_test "info break" \
76 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
77\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*" \
78"single pending breakpoint info"
79
80#
81# Test breaking at existing function
82#
83
84set mainline [gdb_get_line_number "break main here"]
85
86gdb_test "break main" \
87 "Breakpoint.*at.* file .*$srcfile, line $mainline.*" \
88 "breakpoint function"
89
90gdb_test "info break" \
91 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
92\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*
93\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
94"pending plus real breakpoint info"
95
96
97#
98# Test not setting a pending breakpoint
99#
100gdb_test_multiple "break pendfunc2" "Don't set pending breakpoint" {
9f27c604 101 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
18fe2033
JJ
102 gdb_test "n" "" "Don't set pending breakpoint"
103 }
104}
105
106#
107# Add condition to pending breakpoint
108#
109
d2dc51db 110gdb_test "condition 1 k == 1" ""
18fe2033
JJ
111
112gdb_test "info break" \
113 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
114\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*
115\[\t \]+stop only if k == 1.*
116\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
117"pending plus condition"
118
119#
120# Disable pending breakpoint
121#
122
d2dc51db 123gdb_test "disable 1" ""
18fe2033
JJ
124
125gdb_test "info break" \
126 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
127\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
128\[\t \]+stop only if k == 1.*
129\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
130"pending disabled"
131
132#
133# Add commands to pending breakpoint
134#
135gdb_test "commands 1\nprint k\nend" "" \
136 "Set commands for pending breakpoint"
137
138gdb_test "info break" \
139 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
140\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
141\[\t \]+stop only if k == 1.*
142\[\t \]+print k.*
143\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
144"pending disabled plus commands"
145
146#
147# Try a pending break for a line in a source file with a condition
148#
149
150gdb_test_multiple "break pendshr.c:26 if x > 3" "Set pending breakpoint 2" {
9f27c604 151 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
18fe2033
JJ
152 gdb_test "y" "Breakpoint.*pendshr.c:26.*pending." \
153 "Set pending breakpoint 2"
154 }
155}
156
157gdb_test "info break" \
158 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
159\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
160\[\t \]+stop only if k == 1.*
161\[\t \]+print k.*
162\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
163\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:26 if x > 3.*" \
164"multiple pending breakpoints"
165
0a5e7efe
JI
166
167#
168# Try a pending break for a line in a source file with ignore count:
169#
170
171gdb_test_multiple "break pendshr.c:27" "Set pending breakpoint 3" {
172 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
173 gdb_test "y" "Breakpoint.*pendshr.c:27.*pending." \
174 "Set pending breakpoint 3"
175 }
176}
177
178gdb_test {ignore $bpnum 2} "Will ignore next 2 crossings of breakpoint .*" \
179 "set ignore count on pending breakpoint 3"
180
181gdb_test "info break" \
182 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
183\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
184\[\t \]+stop only if k == 1.*
185\[\t \]+print k.*
186\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
187\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:26 if x > 3.*
188\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:27.*ignore next 2 hits.*" \
189"multiple pending breakpoints 2"
190
18fe2033
JJ
191#
192# Run to main which should resolve a pending breakpoint
193#
194
195gdb_test "run" \
196"Breakpoint.*at.*
197Pending breakpoint \"pendshr.c:26 if x > 3\" resolved.*
198Breakpoint.*, main.*$mainline.*" \
199"running to main"
200
201#
202# Re-enable the first pending breakpoint which should resolve
203#
204
205gdb_test "enable 1" \
206"Breakpoint.*at.*
207Pending breakpoint \"pendfunc1.* resolved.*" \
208"re-enabling pending breakpoint that can resolve instantly"
209
210#
211# Continue to verify conditionals and commands for breakpoints are honored
212#
213
214gdb_test "continue" \
215".*Breakpoint.*pendfunc1.*at.*pendshr.c:26.*4;" \
216"continue to resolved breakpoint 2"
217
218gdb_test "continue" \
219".*Breakpoint.*pendfunc1.*at.*pendshr.c:26.*
220\[$\]1 = 1." \
221"continue to resolved breakpoint 1"
222
0a5e7efe
JI
223#
224# Disable the other two breakpoints, and continue to the one with
225# the ignore count. Make sure you hit it the third time, x should
226# be 3 then.
227#
228
229gdb_test "disable 7" "" "Disable other breakpoints"
230gdb_test "disable 5" "" "Disable other breakpoints"
231
232gdb_test "continue" \
233 {.*Breakpoint.*pendfunc1.*\(x=3\) at.*pendshr.c:27.*printf.*;} \
234"continue to resolved breakpoint 3"
235
18fe2033
JJ
236delete_breakpoints
237
238gdb_breakpoint "main"
239
240#
241# Set non-existent pending breakpoint
242#
243gdb_test_multiple "break imaginary" "set imaginary pending breakpoint" {
9f27c604 244 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
18fe2033
JJ
245 gdb_test "y" "Breakpoint.*imaginary.*pending." \
246 "set imaginary pending breakpoint"
247 }
248}
249
250#
251# rerun program and make sure that any pending breakpoint remains and no
252# error messages are issued for the missing function
253#
254
255rerun_to_main
0a5e7efe 256
18fe2033
JJ
257gdb_test "info break" \
258 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
259\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
260\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*imaginary.*" \
261"verify pending breakpoint after restart"
This page took 0.412583 seconds and 4 git commands to generate.