2012-01-16 Pedro Alves <palves@redhat.com>
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / pending.exp
1 # Copyright 2003-2005, 2007-2012 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
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.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 # This file was created by Jeff Johnston. (jjohnstn@redhat.com)
17
18 #
19 # test running programs
20 #
21
22 if {[skip_shlib_tests]} {
23 return 0
24 }
25
26 set testfile "pending"
27 set libfile "pendshr"
28 set srcfile $testfile.c
29 set libsrc $srcdir/$subdir/$libfile.c
30 set binfile $objdir/$subdir/$testfile
31 set lib_sl $objdir/$subdir/$libfile.sl
32
33 set lib_opts debug
34 set exec_opts [list debug shlib=$lib_sl]
35
36 if [get_compiler_info ${binfile}] {
37 return -1
38 }
39
40 if { [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
44 }
45
46 # Start with a fresh gdb.
47
48 gdb_exit
49 gdb_start
50 gdb_reinitialize_dir $srcdir/$subdir
51
52 gdb_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
58 gdb_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
63 gdb_load ${binfile}
64 gdb_load_shlibs $lib_sl
65
66 set pendfunc1_loc [gdb_get_line_number "y = x + 4" ${libfile}.c]
67
68 gdb_run_cmd
69
70 gdb_test "" \
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
76 gdb_exit
77 gdb_start
78 gdb_reinitialize_dir $srcdir/$subdir
79
80 gdb_load ${binfile}
81 gdb_load_shlibs $lib_sl
82
83 #
84 # Test setting, querying, and modifying pending breakpoints
85 #
86
87 gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
88 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
89 gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint"
90 }
91 }
92
93 gdb_test "info break" \
94 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
95 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*" \
96 "single pending breakpoint info"
97
98 #
99 # Test breaking at existing function
100 #
101
102 set mainline [gdb_get_line_number "break main here"]
103
104 gdb_test "break main" \
105 "Breakpoint.*at.* file .*$srcfile, line $mainline.*" \
106 "breakpoint function"
107
108 gdb_test "info break" \
109 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
110 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*
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 #
118 gdb_test "break pendfunc2" \
119 "" \
120 "Don't set pending breakpoint" \
121 ".*Make breakpoint pending.*y or \\\[n\\\]. $" \
122 "n"
123
124 #
125 # Add condition to pending breakpoint
126 #
127
128 gdb_test_no_output "condition 1 k == 1"
129
130 gdb_test "info break" \
131 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
132 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*
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
141 gdb_test_no_output "disable 1"
142
143 gdb_test "info break" \
144 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
145 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
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 #
153 gdb_test "commands 1\nprint k\nend" "" \
154 "Set commands for pending breakpoint"
155
156 gdb_test "info break" \
157 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
158 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
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
168 set bp2_loc [gdb_get_line_number "y = x + 4" ${libfile}.c]
169 gdb_test_multiple "break pendshr.c:$bp2_loc if x > 3" "Set pending breakpoint 2" {
170 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
171 gdb_test "y" "Breakpoint.*pendshr.c:$bp2_loc.*pending." \
172 "Set pending breakpoint 2"
173 }
174 }
175
176 gdb_test "info break" \
177 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
178 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
179 \[\t \]+stop only if k == 1.*
180 \[\t \]+print k.*
181 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
182 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp2_loc if x > 3.*" \
183 "multiple pending breakpoints"
184
185
186 #
187 # Try a pending break for a line in a source file with ignore count:
188 #
189
190 set bp3_loc [gdb_get_line_number "printf" ${libfile}.c]
191 gdb_test_multiple "break pendshr.c:$bp3_loc" "Set pending breakpoint 3" {
192 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
193 gdb_test "y" "Breakpoint.*pendshr.c:$bp3_loc.*pending." \
194 "Set pending breakpoint 3"
195 }
196 }
197
198 gdb_test {ignore $bpnum 2} "Will ignore next 2 crossings of breakpoint .*" \
199 "set ignore count on pending breakpoint 3"
200
201 gdb_test "info break" \
202 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
203 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
204 \[\t \]+stop only if k == 1.*
205 \[\t \]+print k.*
206 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
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.*" \
209 "multiple pending breakpoints 2"
210
211 #
212 # Run to main which should resolve a pending breakpoint
213 #
214
215 gdb_run_cmd
216 gdb_test "" \
217 ".*Breakpoint.*, main.*$mainline.*" \
218 "running to main"
219
220 #
221 # Re-enable the first pending breakpoint which should resolve
222 #
223
224 gdb_test_no_output "enable 1" \
225 "re-enabling pending breakpoint that can resolve instantly"
226
227 #
228 # Continue to verify conditionals and commands for breakpoints are honored
229 #
230
231 gdb_test "continue" \
232 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*4;" \
233 "continue to resolved breakpoint 2"
234
235 gdb_test "continue" \
236 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*
237 \[$\]1 = 1." \
238 "continue to resolved breakpoint 1"
239
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
246 gdb_test "disable 7" "" "Disable other breakpoints"
247 gdb_test "disable 5" "" "Disable other breakpoints"
248
249 gdb_test "continue" \
250 ".*Breakpoint.*pendfunc1.*\\\(x=3\\\) at.*pendshr.c:$bp3_loc.*printf.*;" \
251 "continue to resolved breakpoint 3"
252
253 delete_breakpoints
254
255 gdb_breakpoint "main"
256
257 #
258 # Set non-existent pending breakpoint
259 #
260 gdb_test_multiple "break imaginary" "set imaginary pending breakpoint" {
261 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
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
272 rerun_to_main
273
274 gdb_test "info break" \
275 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
276 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
277 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*imaginary.*" \
278 "verify pending breakpoint after restart"
This page took 0.036834 seconds and 5 git commands to generate.