]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame_incremental - 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
1# Copyright 2003-2018 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#
19# test running programs
20#
21
22if {[skip_shlib_tests]} {
23 return 0
24}
25
26standard_testfile .c
27set libfile "pendshr"
28set libsrc $srcdir/$subdir/$libfile.c
29set lib_sl [standard_output_file $libfile.sl]
30
31set lib_opts debug
32set exec_opts [list debug shlib=$lib_sl]
33
34if [get_compiler_info] {
35 return -1
36}
37
38if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
39 || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""} {
40 untested "failed to compile"
41 return -1
42}
43
44# Start with a fresh gdb.
45
46gdb_exit
47gdb_start
48gdb_reinitialize_dir $srcdir/$subdir
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
56# Complete the condition (PR 15413).
57gdb_test "complete condition " "condition 1"
58
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}
65gdb_load_shlib $lib_sl
66
67set pendfunc1_loc [gdb_get_line_number "y = x + 4" ${libfile}.c]
68
69gdb_run_cmd
70
71gdb_test "" \
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
81gdb_load ${binfile}
82gdb_load_shlib $lib_sl
83
84#
85# Test setting, querying, and modifying pending breakpoints
86#
87
88gdb_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"
91 }
92}
93
94gdb_test "info break" \
95 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
96\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*" \
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" \
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"
114
115
116#
117# Test not setting a pending breakpoint
118#
119gdb_test "break pendfunc2" \
120 "" \
121 "Don't set pending breakpoint" \
122 ".*Make breakpoint pending.*y or \\\[n\\\]. $" \
123 "n"
124
125#
126# Add condition to pending breakpoint
127#
128
129gdb_test_no_output "condition 1 k == 1"
130
131gdb_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"
137
138#
139# Disable pending breakpoint
140#
141
142gdb_test_no_output "disable 1"
143
144gdb_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" \
149"pending disabled"
150
151#
152# Add commands to pending breakpoint
153#
154gdb_test "commands 1\nprint k\nend" "" \
155 "Set commands for pending breakpoint"
156
157gdb_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.*
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
169set bp2_loc [gdb_get_line_number "y = x + 4" ${libfile}.c]
170gdb_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"
174 }
175}
176
177gdb_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.*
181\[\t \]+print k.*
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"
185
186
187#
188# Try a pending break for a line in a source file with ignore count:
189#
190
191set bp3_loc [gdb_get_line_number "printf" ${libfile}.c]
192gdb_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"
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" \
203 "Num Type\[ \]+Disp Enb Address\[ \]+What.*
204\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
205\[\t \]+stop only if k == 1.*
206\[\t \]+print k.*
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"
211
212#
213# Run to main which should resolve a pending breakpoint
214#
215
216gdb_run_cmd
217gdb_test "" \
218".*Breakpoint.*, main.*$mainline.*" \
219"running to main"
220
221#
222# Re-enable the first pending breakpoint which should resolve
223#
224
225gdb_test_no_output "enable 1" \
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" \
233".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*4;" \
234"continue to resolved breakpoint 2"
235
236gdb_test "continue" \
237".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*
238\[$\]1 = 1." \
239"continue to resolved breakpoint 1"
240
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
247gdb_test "disable 7" "" "disable other breakpoints"
248gdb_test "disable 5" "" "disable other breakpoints"
249
250gdb_test "continue" \
251 ".*Breakpoint.*pendfunc1.*\\\(x=3\\\) at.*pendshr.c:$bp3_loc.*printf.*;" \
252"continue to resolved breakpoint 3"
253
254delete_breakpoints
255
256gdb_breakpoint "main"
257
258#
259# Set non-existent pending breakpoint
260#
261gdb_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"
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
274
275gdb_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"