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