1 # Copyright 2003-2013 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file was created by Jeff Johnston. (jjohnstn@redhat.com)
19 # test running programs
22 if {[skip_shlib_tests]} {
26 set testfile "pending"
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
34 set exec_opts [list debug shlib=$lib_sl]
36 if [get_compiler_info] {
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."
46 # Start with a fresh gdb.
50 gdb_reinitialize_dir $srcdir/$subdir
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)"
58 # Complete the condition (PR 15413).
59 gdb_test "complete condition " "condition 1"
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)"
67 gdb_load_shlibs $lib_sl
69 set pendfunc1_loc [gdb_get_line_number "y = x + 4" ${libfile}.c]
74 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$pendfunc1_loc.*y = x \\+ 4.*" \
75 "run to resolved breakpoint 1 (without symbols)"
77 # Restart with a fresh gdb.
81 gdb_reinitialize_dir $srcdir/$subdir
84 gdb_load_shlibs $lib_sl
87 # Test setting, querying, and modifying pending breakpoints
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"
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"
102 # Test breaking at existing function
105 set mainline [gdb_get_line_number "break main here"]
107 gdb_test "break main" \
108 "Breakpoint.*at.* file .*$srcfile, line $mainline.*" \
109 "breakpoint function"
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"
119 # Test not setting a pending breakpoint
121 gdb_test "break pendfunc2" \
123 "Don't set pending breakpoint" \
124 ".*Make breakpoint pending.*y or \\\[n\\\]. $" \
128 # Add condition to pending breakpoint
131 gdb_test_no_output "condition 1 k == 1"
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"
141 # Disable pending breakpoint
144 gdb_test_no_output "disable 1"
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" \
154 # Add commands to pending breakpoint
156 gdb_test "commands 1\nprint k\nend" "" \
157 "Set commands for pending breakpoint"
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.*
164 \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
165 "pending disabled plus commands"
168 # Try a pending break for a line in a source file with a condition
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"
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.*
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"
190 # Try a pending break for a line in a source file with ignore count:
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"
201 gdb_test {ignore $bpnum 2} "Will ignore next 2 crossings of breakpoint .*" \
202 "set ignore count on pending breakpoint 3"
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.*
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"
215 # Run to main which should resolve a pending breakpoint
220 ".*Breakpoint.*, main.*$mainline.*" \
224 # Re-enable the first pending breakpoint which should resolve
227 gdb_test_no_output "enable 1" \
228 "re-enabling pending breakpoint that can resolve instantly"
231 # Continue to verify conditionals and commands for breakpoints are honored
234 gdb_test "continue" \
235 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*4;" \
236 "continue to resolved breakpoint 2"
238 gdb_test "continue" \
239 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*
241 "continue to resolved breakpoint 1"
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
249 gdb_test "disable 7" "" "Disable other breakpoints"
250 gdb_test "disable 5" "" "Disable other breakpoints"
252 gdb_test "continue" \
253 ".*Breakpoint.*pendfunc1.*\\\(x=3\\\) at.*pendshr.c:$bp3_loc.*printf.*;" \
254 "continue to resolved breakpoint 3"
258 gdb_breakpoint "main"
261 # Set non-existent pending breakpoint
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"
271 # rerun program and make sure that any pending breakpoint remains and no
272 # error messages are issued for the missing function
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"