1 # Copyright
2003-2019 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
]} {
28 set libsrc $srcdir
/$subdir
/$libfile.c
29 set lib_sl
[standard_output_file $libfile.sl
]
32 set exec_opts
[list debug shlib
=$lib_sl
]
34 if [get_compiler_info
] {
38 if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts
] != ""
39 ||
[gdb_compile $srcdir
/$subdir
/$srcfile $binfile executable $exec_opts
] != ""} {
40 untested
"failed to compile"
44 # Start with a fresh gdb.
48 gdb_reinitialize_dir $srcdir
/$subdir
50 gdb_test_multiple
"break pendfunc1" "set pending breakpoint" {
51 -re
".*Make breakpoint pending.*y or \\\[n\\\]. $" {
52 gdb_test
"y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint (without symbols)"
56 # Complete the condition
(PR
15413).
57 gdb_test
"complete condition " "condition 1"
59 gdb_test
"info break" \
60 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
61 \
[0-9\
]+\
[\t \
]+breakpoint keep y.
*PENDING.
*pendfunc1.
*" \
62 "single pending breakpoint info (without symbols)"
65 gdb_load_shlib $lib_sl
67 set pendfunc1_loc
[gdb_get_line_number
"y = x + 4" ${libfile}.c]
72 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$pendfunc1_loc.*y = x \\+ 4.*" \
73 "run to resolved breakpoint 1 (without symbols)"
75 # Restart with a fresh gdb.
79 gdb_reinitialize_dir $srcdir
/$subdir
82 gdb_load_shlib $lib_sl
85 # Test setting
, querying
, and modifying pending breakpoints
88 gdb_test_multiple
"break pendfunc1" "set pending breakpoint" {
89 -re
".*Make breakpoint pending.*y or \\\[n\\\]. $" {
90 gdb_test
"y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint"
94 gdb_test
"info break" \
95 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
96 \
[0-9\
]+\
[\t \
]+breakpoint keep y.
*PENDING.
*pendfunc1.
*" \
97 "single pending breakpoint info"
100 # Test breaking at existing function
103 set mainline
[gdb_get_line_number
"break main here"]
105 gdb_test
"break main" \
106 "Breakpoint.*at.* file .*$srcfile, line $mainline.*" \
107 "breakpoint function"
109 gdb_test
"info break" \
110 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
111 \
[0-9\
]+\
[\t \
]+breakpoint keep y.
*PENDING.
*pendfunc1.
*
112 \
[0-9\
]+\
[\t \
]+breakpoint keep y.
* in main at .
*$srcfile
:$mainline
" \
113 "pending plus real breakpoint info"
117 # Test not setting a pending breakpoint
119 gdb_test
"break pendfunc2" \
121 "Don't set pending breakpoint" \
122 ".*Make breakpoint pending.*y or \\\[n\\\]. $" \
126 # Add condition to pending breakpoint
129 gdb_test_no_output
"condition 1 k == 1"
131 gdb_test
"info break" \
132 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
133 \
[0-9\
]+\
[\t \
]+breakpoint keep y.
*PENDING.
*pendfunc1.
*
134 \
[\t \
]+stop only
if k
== 1.
*
135 \
[0-9\
]+\
[\t \
]+breakpoint keep y.
* in main at .
*$srcfile
:$mainline
" \
136 "pending plus condition"
139 # Disable pending breakpoint
142 gdb_test_no_output
"disable 1"
144 gdb_test
"info break" \
145 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
146 \
[0-9\
]+\
[\t \
]+breakpoint keep n.
*PENDING.
*pendfunc1.
*
147 \
[\t \
]+stop only
if k
== 1.
*
148 \
[0-9\
]+\
[\t \
]+breakpoint keep y.
* in main at .
*$srcfile
:$mainline
" \
152 # Add commands to pending breakpoint
154 gdb_test
"commands 1\nprint k\nend" "" \
155 "Set commands for pending breakpoint"
157 gdb_test
"info break" \
158 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
159 \
[0-9\
]+\
[\t \
]+breakpoint keep n.
*PENDING.
*pendfunc1.
*
160 \
[\t \
]+stop only
if k
== 1.
*
162 \
[0-9\
]+\
[\t \
]+breakpoint keep y.
* in main at .
*$srcfile
:$mainline
" \
163 "pending disabled plus commands"
166 # Try a pending
break for a line in a source file with a condition
169 set bp2_loc
[gdb_get_line_number
"y = x + 4" ${libfile}.c]
170 gdb_test_multiple
"break pendshr.c:$bp2_loc if x > 3" "set pending breakpoint 2" {
171 -re
".*Make breakpoint pending.*y or \\\[n\\\]. $" {
172 gdb_test
"y" "Breakpoint.*pendshr.c:$bp2_loc.*pending." \
173 "Set pending breakpoint 2"
177 gdb_test
"info break" \
178 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
179 \
[0-9\
]+\
[\t \
]+breakpoint keep n.
*PENDING.
*pendfunc1.
*
180 \
[\t \
]+stop only
if k
== 1.
*
182 \
[0-9\
]+\
[\t \
]+breakpoint keep y.
* in main at .
*$srcfile
:$mainline.
*
183 \
[0-9\
]+\
[\t \
]+breakpoint keep y.
*PENDING.
*pendshr.c
:$bp2_loc
if x
> 3.
*" \
184 "multiple pending breakpoints"
188 # Try a pending
break for a line in a source file with ignore
count:
191 set bp3_loc
[gdb_get_line_number
"printf" ${libfile}.c]
192 gdb_test_multiple
"break pendshr.c:$bp3_loc" "set pending breakpoint 3" {
193 -re
".*Make breakpoint pending.*y or \\\[n\\\]. $" {
194 gdb_test
"y" "Breakpoint.*pendshr.c:$bp3_loc.*pending." \
195 "Set pending breakpoint 3"
199 gdb_test
{ignore $bpnum
2} "Will ignore next 2 crossings of breakpoint .*" \
200 "set ignore count on pending breakpoint 3"
202 gdb_test
"info break" \
203 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
204 \
[0-9\
]+\
[\t \
]+breakpoint keep n.
*PENDING.
*pendfunc1.
*
205 \
[\t \
]+stop only
if k
== 1.
*
207 \
[0-9\
]+\
[\t \
]+breakpoint keep y.
* in main at .
*$srcfile
:$mainline.
*
208 \
[0-9\
]+\
[\t \
]+breakpoint keep y.
*PENDING.
*pendshr.c
:$bp2_loc
if x
> 3.
*
209 \
[0-9\
]+\
[\t \
]+breakpoint keep y.
*PENDING.
*pendshr.c
:$bp3_loc.
*ignore next
2 hits.
*" \
210 "multiple pending breakpoints 2"
213 # Run to main which should resolve a pending breakpoint
218 ".*Breakpoint.*, main.*$mainline.*" \
222 # Re
-enable the first pending breakpoint which should resolve
225 gdb_test_no_output
"enable 1" \
226 "re-enabling pending breakpoint that can resolve instantly"
229 #
Continue to verify conditionals and commands
for breakpoints are honored
232 gdb_test
"continue" \
233 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*4;" \
234 "continue to resolved breakpoint 2"
236 gdb_test
"continue" \
237 ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*
239 "continue to resolved breakpoint 1"
242 # Disable the other two breakpoints
, and
continue to the one with
243 # the ignore
count. Make sure you hit it the third time
, x should
247 gdb_test
"disable 7" "" "disable other breakpoints"
248 gdb_test
"disable 5" "" "disable other breakpoints"
250 gdb_test
"continue" \
251 ".*Breakpoint.*pendfunc1.*\\\(x=3\\\) at.*pendshr.c:$bp3_loc.*printf.*;" \
252 "continue to resolved breakpoint 3"
256 gdb_breakpoint
"main"
259 #
Set non
-existent pending breakpoint
261 gdb_test_multiple
"break imaginary" "set imaginary pending breakpoint" {
262 -re
".*Make breakpoint pending.*y or \\\[n\\\]. $" {
263 gdb_test
"y" "Breakpoint.*imaginary.*pending." \
264 "set imaginary pending breakpoint"
269 # rerun
program and make sure that
any pending breakpoint remains and no
270 # error messages are issued
for the missing function
275 gdb_test
"info break" \
276 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
277 \
[0-9\
]+\
[\t \
]+breakpoint keep y.
* in main at .
*$srcfile
:$mainline.
*
278 \
[0-9\
]+\
[\t \
]+breakpoint keep y.
*PENDING.
*imaginary.
*" \
279 "verify pending breakpoint after restart"