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