]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/pending.exp
Update copyright year range in all GDB files
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / pending.exp
CommitLineData
e2882c85 1# Copyright 2003-2018 Free Software Foundation, Inc.
18fe2033
JJ
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
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
18fe2033 6# (at your option) any later version.
e22f8b7c 7#
18fe2033
JJ
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.
e22f8b7c 12#
18fe2033 13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
18fe2033 15
18fe2033 16# This file was created by Jeff Johnston. (jjohnstn@redhat.com)
18fe2033 17
18fe2033
JJ
18#
19# test running programs
20#
18fe2033 21
93f02886 22if {[skip_shlib_tests]} {
18fe2033
JJ
23 return 0
24}
25
822bd149 26standard_testfile .c
18fe2033 27set libfile "pendshr"
3cbba3d1 28set libsrc $srcdir/$subdir/$libfile.c
822bd149 29set lib_sl [standard_output_file $libfile.sl]
3cbba3d1
PG
30
31set lib_opts debug
32set exec_opts [list debug shlib=$lib_sl]
18fe2033 33
4c93b1db 34if [get_compiler_info] {
18fe2033
JJ
35 return -1
36}
37
3cbba3d1
PG
38if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
39 || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""} {
84c93cd5 40 untested "failed to compile"
3cbba3d1 41 return -1
18fe2033
JJ
42}
43
3cbba3d1 44# Start with a fresh gdb.
18fe2033
JJ
45
46gdb_exit
47gdb_start
48gdb_reinitialize_dir $srcdir/$subdir
b96e2927
PA
49
50gdb_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)"
53 }
54}
55
58ce7251
SDJ
56# Complete the condition (PR 15413).
57gdb_test "complete condition " "condition 1"
58
b96e2927
PA
59gdb_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)"
63
64gdb_load ${binfile}
d9019901 65gdb_load_shlib $lib_sl
b96e2927
PA
66
67set pendfunc1_loc [gdb_get_line_number "y = x + 4" ${libfile}.c]
bdea3a92
NF
68
69gdb_run_cmd
70
71gdb_test "" \
b96e2927
PA
72".*Breakpoint.*pendfunc1.*at.*pendshr.c:$pendfunc1_loc.*y = x \\+ 4.*" \
73"run to resolved breakpoint 1 (without symbols)"
74
75# Restart with a fresh gdb.
76
77gdb_exit
78gdb_start
79gdb_reinitialize_dir $srcdir/$subdir
80
18fe2033 81gdb_load ${binfile}
d9019901 82gdb_load_shlib $lib_sl
18fe2033 83
18fe2033
JJ
84#
85# Test setting, querying, and modifying pending breakpoints
86#
87
88gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
9f27c604 89 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
18fe2033
JJ
90 gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint"
91 }
92}
93
94gdb_test "info break" \
54e52265
VP
95 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
96\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*" \
18fe2033
JJ
97"single pending breakpoint info"
98
99#
100# Test breaking at existing function
101#
102
103set mainline [gdb_get_line_number "break main here"]
104
105gdb_test "break main" \
106 "Breakpoint.*at.* file .*$srcfile, line $mainline.*" \
107 "breakpoint function"
108
109gdb_test "info break" \
54e52265
VP
110 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
111\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*
18fe2033
JJ
112\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
113"pending plus real breakpoint info"
114
115
116#
117# Test not setting a pending breakpoint
118#
f7ae76b3
MS
119gdb_test "break pendfunc2" \
120 "" \
121 "Don't set pending breakpoint" \
122 ".*Make breakpoint pending.*y or \\\[n\\\]. $" \
123 "n"
18fe2033
JJ
124
125#
126# Add condition to pending breakpoint
127#
128
27d3a1a2 129gdb_test_no_output "condition 1 k == 1"
18fe2033
JJ
130
131gdb_test "info break" \
54e52265
VP
132 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
133\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*
18fe2033
JJ
134\[\t \]+stop only if k == 1.*
135\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
136"pending plus condition"
137
138#
139# Disable pending breakpoint
140#
141
27d3a1a2 142gdb_test_no_output "disable 1"
18fe2033
JJ
143
144gdb_test "info break" \
54e52265
VP
145 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
146\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
18fe2033
JJ
147\[\t \]+stop only if k == 1.*
148\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
149"pending disabled"
150
151#
152# Add commands to pending breakpoint
153#
154gdb_test "commands 1\nprint k\nend" "" \
27d3a1a2 155 "Set commands for pending breakpoint"
18fe2033
JJ
156
157gdb_test "info break" \
54e52265
VP
158 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
159\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
18fe2033
JJ
160\[\t \]+stop only if k == 1.*
161\[\t \]+print k.*
162\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
163"pending disabled plus commands"
164
165#
166# Try a pending break for a line in a source file with a condition
167#
168
b9c34f67 169set bp2_loc [gdb_get_line_number "y = x + 4" ${libfile}.c]
de97fdd4 170gdb_test_multiple "break pendshr.c:$bp2_loc if x > 3" "set pending breakpoint 2" {
9f27c604 171 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
b9c34f67 172 gdb_test "y" "Breakpoint.*pendshr.c:$bp2_loc.*pending." \
18fe2033
JJ
173 "Set pending breakpoint 2"
174 }
175}
176
177gdb_test "info break" \
54e52265
VP
178 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
179\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
18fe2033
JJ
180\[\t \]+stop only if k == 1.*
181\[\t \]+print k.*
182\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
54e52265 183\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp2_loc if x > 3.*" \
18fe2033
JJ
184"multiple pending breakpoints"
185
0a5e7efe
JI
186
187#
188# Try a pending break for a line in a source file with ignore count:
189#
190
b9c34f67 191set bp3_loc [gdb_get_line_number "printf" ${libfile}.c]
de97fdd4 192gdb_test_multiple "break pendshr.c:$bp3_loc" "set pending breakpoint 3" {
0a5e7efe 193 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
b9c34f67 194 gdb_test "y" "Breakpoint.*pendshr.c:$bp3_loc.*pending." \
0a5e7efe
JI
195 "Set pending breakpoint 3"
196 }
197}
198
199gdb_test {ignore $bpnum 2} "Will ignore next 2 crossings of breakpoint .*" \
200 "set ignore count on pending breakpoint 3"
201
202gdb_test "info break" \
54e52265
VP
203 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
204\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
0a5e7efe
JI
205\[\t \]+stop only if k == 1.*
206\[\t \]+print k.*
207\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
54e52265
VP
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.*" \
0a5e7efe
JI
210"multiple pending breakpoints 2"
211
18fe2033
JJ
212#
213# Run to main which should resolve a pending breakpoint
214#
215
b741e217
DJ
216gdb_run_cmd
217gdb_test "" \
fe3f5fa8 218".*Breakpoint.*, main.*$mainline.*" \
18fe2033
JJ
219"running to main"
220
221#
222# Re-enable the first pending breakpoint which should resolve
223#
224
27d3a1a2 225gdb_test_no_output "enable 1" \
18fe2033
JJ
226"re-enabling pending breakpoint that can resolve instantly"
227
228#
229# Continue to verify conditionals and commands for breakpoints are honored
230#
231
232gdb_test "continue" \
b9c34f67 233".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*4;" \
18fe2033
JJ
234"continue to resolved breakpoint 2"
235
236gdb_test "continue" \
b9c34f67 237".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*
18fe2033
JJ
238\[$\]1 = 1." \
239"continue to resolved breakpoint 1"
240
0a5e7efe
JI
241#
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
244# be 3 then.
245#
246
cdc7edd7
LM
247gdb_test "disable 7" "" "disable other breakpoints"
248gdb_test "disable 5" "" "disable other breakpoints"
0a5e7efe
JI
249
250gdb_test "continue" \
b9c34f67 251 ".*Breakpoint.*pendfunc1.*\\\(x=3\\\) at.*pendshr.c:$bp3_loc.*printf.*;" \
0a5e7efe
JI
252"continue to resolved breakpoint 3"
253
18fe2033
JJ
254delete_breakpoints
255
256gdb_breakpoint "main"
257
258#
259# Set non-existent pending breakpoint
260#
261gdb_test_multiple "break imaginary" "set imaginary pending breakpoint" {
9f27c604 262 -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
18fe2033
JJ
263 gdb_test "y" "Breakpoint.*imaginary.*pending." \
264 "set imaginary pending breakpoint"
265 }
266}
267
268#
269# rerun program and make sure that any pending breakpoint remains and no
270# error messages are issued for the missing function
271#
272
273rerun_to_main
0a5e7efe 274
18fe2033 275gdb_test "info break" \
54e52265 276 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
18fe2033 277\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
54e52265 278\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*imaginary.*" \
18fe2033 279"verify pending breakpoint after restart"