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