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