gdb/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / pending.exp
1 # Copyright 2003-2013 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] {
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 # Complete the condition (PR 15413).
59 gdb_test "complete condition " "condition 1"
60
61 gdb_test "info break" \
62 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
63 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*" \
64 "single pending breakpoint info (without symbols)"
65
66 gdb_load ${binfile}
67 gdb_load_shlibs $lib_sl
68
69 set pendfunc1_loc [gdb_get_line_number "y = x + 4" ${libfile}.c]
70
71 gdb_run_cmd
72
73 gdb_test "" \
74 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$pendfunc1_loc.*y = x \\+ 4.*" \
75 "run to resolved breakpoint 1 (without symbols)"
76
77 # Restart with a fresh gdb.
78
79 gdb_exit
80 gdb_start
81 gdb_reinitialize_dir $srcdir/$subdir
82
83 gdb_load ${binfile}
84 gdb_load_shlibs $lib_sl
85
86 #
87 # Test setting, querying, and modifying pending breakpoints
88 #
89
90 gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
91 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
92 gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint"
93 }
94 }
95
96 gdb_test "info break" \
97 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
98 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*" \
99 "single pending breakpoint info"
100
101 #
102 # Test breaking at existing function
103 #
104
105 set mainline [gdb_get_line_number "break main here"]
106
107 gdb_test "break main" \
108 "Breakpoint.*at.* file .*$srcfile, line $mainline.*" \
109 "breakpoint function"
110
111 gdb_test "info break" \
112 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
113 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*
114 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
115 "pending plus real breakpoint info"
116
117
118 #
119 # Test not setting a pending breakpoint
120 #
121 gdb_test "break pendfunc2" \
122 "" \
123 "Don't set pending breakpoint" \
124 ".*Make breakpoint pending.*y or \\\[n\\\]. $" \
125 "n"
126
127 #
128 # Add condition to pending breakpoint
129 #
130
131 gdb_test_no_output "condition 1 k == 1"
132
133 gdb_test "info break" \
134 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
135 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*
136 \[\t \]+stop only if k == 1.*
137 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
138 "pending plus condition"
139
140 #
141 # Disable pending breakpoint
142 #
143
144 gdb_test_no_output "disable 1"
145
146 gdb_test "info break" \
147 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
148 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
149 \[\t \]+stop only if k == 1.*
150 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
151 "pending disabled"
152
153 #
154 # Add commands to pending breakpoint
155 #
156 gdb_test "commands 1\nprint k\nend" "" \
157 "Set commands for pending breakpoint"
158
159 gdb_test "info break" \
160 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
161 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
162 \[\t \]+stop only if k == 1.*
163 \[\t \]+print k.*
164 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
165 "pending disabled plus commands"
166
167 #
168 # Try a pending break for a line in a source file with a condition
169 #
170
171 set bp2_loc [gdb_get_line_number "y = x + 4" ${libfile}.c]
172 gdb_test_multiple "break pendshr.c:$bp2_loc if x > 3" "Set pending breakpoint 2" {
173 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
174 gdb_test "y" "Breakpoint.*pendshr.c:$bp2_loc.*pending." \
175 "Set pending breakpoint 2"
176 }
177 }
178
179 gdb_test "info break" \
180 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
181 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
182 \[\t \]+stop only if k == 1.*
183 \[\t \]+print k.*
184 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
185 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp2_loc if x > 3.*" \
186 "multiple pending breakpoints"
187
188
189 #
190 # Try a pending break for a line in a source file with ignore count:
191 #
192
193 set bp3_loc [gdb_get_line_number "printf" ${libfile}.c]
194 gdb_test_multiple "break pendshr.c:$bp3_loc" "Set pending breakpoint 3" {
195 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
196 gdb_test "y" "Breakpoint.*pendshr.c:$bp3_loc.*pending." \
197 "Set pending breakpoint 3"
198 }
199 }
200
201 gdb_test {ignore $bpnum 2} "Will ignore next 2 crossings of breakpoint .*" \
202 "set ignore count on pending breakpoint 3"
203
204 gdb_test "info break" \
205 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
206 \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
207 \[\t \]+stop only if k == 1.*
208 \[\t \]+print k.*
209 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
210 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp2_loc if x > 3.*
211 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp3_loc.*ignore next 2 hits.*" \
212 "multiple pending breakpoints 2"
213
214 #
215 # Run to main which should resolve a pending breakpoint
216 #
217
218 gdb_run_cmd
219 gdb_test "" \
220 ".*Breakpoint.*, main.*$mainline.*" \
221 "running to main"
222
223 #
224 # Re-enable the first pending breakpoint which should resolve
225 #
226
227 gdb_test_no_output "enable 1" \
228 "re-enabling pending breakpoint that can resolve instantly"
229
230 #
231 # Continue to verify conditionals and commands for breakpoints are honored
232 #
233
234 gdb_test "continue" \
235 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*4;" \
236 "continue to resolved breakpoint 2"
237
238 gdb_test "continue" \
239 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*
240 \[$\]1 = 1." \
241 "continue to resolved breakpoint 1"
242
243 #
244 # Disable the other two breakpoints, and continue to the one with
245 # the ignore count. Make sure you hit it the third time, x should
246 # be 3 then.
247 #
248
249 gdb_test "disable 7" "" "Disable other breakpoints"
250 gdb_test "disable 5" "" "Disable other breakpoints"
251
252 gdb_test "continue" \
253 ".*Breakpoint.*pendfunc1.*\\\(x=3\\\) at.*pendshr.c:$bp3_loc.*printf.*;" \
254 "continue to resolved breakpoint 3"
255
256 delete_breakpoints
257
258 gdb_breakpoint "main"
259
260 #
261 # Set non-existent pending breakpoint
262 #
263 gdb_test_multiple "break imaginary" "set imaginary pending breakpoint" {
264 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
265 gdb_test "y" "Breakpoint.*imaginary.*pending." \
266 "set imaginary pending breakpoint"
267 }
268 }
269
270 #
271 # rerun program and make sure that any pending breakpoint remains and no
272 # error messages are issued for the missing function
273 #
274
275 rerun_to_main
276
277 gdb_test "info break" \
278 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
279 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
280 \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*imaginary.*" \
281 "verify pending breakpoint after restart"
This page took 0.035949 seconds and 5 git commands to generate.