pending.exp revision 1.11 1 1.11 christos # Copyright 2003-2024 Free Software Foundation, Inc.
2 1.1 christos
3 1.1 christos # This program is free software; you can redistribute it and/or modify
4 1.1 christos # it under the terms of the GNU General Public License as published by
5 1.1 christos # the Free Software Foundation; either version 3 of the License, or
6 1.1 christos # (at your option) any later version.
7 1.1 christos #
8 1.1 christos # This program is distributed in the hope that it will be useful,
9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 1.1 christos # GNU General Public License for more details.
12 1.1 christos #
13 1.1 christos # You should have received a copy of the GNU General Public License
14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 1.1 christos
16 1.1 christos # This file was created by Jeff Johnston. (jjohnstn (at) redhat.com)
17 1.1 christos
18 1.1 christos #
19 1.1 christos # test running programs
20 1.1 christos #
21 1.1 christos
22 1.11 christos require allow_shlib_tests
23 1.1 christos
24 1.1 christos standard_testfile .c
25 1.1 christos set libfile "pendshr"
26 1.1 christos set libsrc $srcdir/$subdir/$libfile.c
27 1.1 christos set lib_sl [standard_output_file $libfile.sl]
28 1.1 christos
29 1.1 christos set lib_opts debug
30 1.1 christos set exec_opts [list debug shlib=$lib_sl]
31 1.1 christos
32 1.1 christos if { [gdb_compile_shlib $libsrc $lib_sl $lib_opts] != ""
33 1.1 christos || [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != ""} {
34 1.7 christos untested "failed to compile"
35 1.1 christos return -1
36 1.1 christos }
37 1.1 christos
38 1.11 christos clean_restart
39 1.1 christos
40 1.1 christos gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
41 1.1 christos -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
42 1.1 christos gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint (without symbols)"
43 1.1 christos }
44 1.1 christos }
45 1.1 christos
46 1.1 christos # Complete the condition (PR 15413).
47 1.1 christos gdb_test "complete condition " "condition 1"
48 1.1 christos
49 1.1 christos gdb_test "info break" \
50 1.1 christos "Num Type\[ \]+Disp Enb Address\[ \]+What.*
51 1.1 christos \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*" \
52 1.1 christos "single pending breakpoint info (without symbols)"
53 1.1 christos
54 1.10 christos with_test_prefix "first load" {
55 1.10 christos gdb_load ${binfile}
56 1.10 christos gdb_load_shlib $lib_sl
57 1.10 christos }
58 1.1 christos
59 1.1 christos set pendfunc1_loc [gdb_get_line_number "y = x + 4" ${libfile}.c]
60 1.1 christos
61 1.1 christos gdb_run_cmd
62 1.1 christos
63 1.1 christos gdb_test "" \
64 1.1 christos ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$pendfunc1_loc.*y = x \\+ 4.*" \
65 1.1 christos "run to resolved breakpoint 1 (without symbols)"
66 1.1 christos
67 1.11 christos clean_restart
68 1.1 christos
69 1.10 christos with_test_prefix "second load" {
70 1.10 christos gdb_load ${binfile}
71 1.10 christos gdb_load_shlib $lib_sl
72 1.10 christos }
73 1.1 christos
74 1.1 christos #
75 1.1 christos # Test setting, querying, and modifying pending breakpoints
76 1.1 christos #
77 1.1 christos
78 1.1 christos gdb_test_multiple "break pendfunc1" "set pending breakpoint" {
79 1.1 christos -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
80 1.1 christos gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint"
81 1.1 christos }
82 1.1 christos }
83 1.1 christos
84 1.1 christos gdb_test "info break" \
85 1.1 christos "Num Type\[ \]+Disp Enb Address\[ \]+What.*
86 1.1 christos \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*" \
87 1.1 christos "single pending breakpoint info"
88 1.1 christos
89 1.1 christos #
90 1.1 christos # Test breaking at existing function
91 1.1 christos #
92 1.1 christos
93 1.1 christos set mainline [gdb_get_line_number "break main here"]
94 1.1 christos
95 1.10 christos gdb_test "break -q main" \
96 1.1 christos "Breakpoint.*at.* file .*$srcfile, line $mainline.*" \
97 1.1 christos "breakpoint function"
98 1.1 christos
99 1.1 christos gdb_test "info break" \
100 1.1 christos "Num Type\[ \]+Disp Enb Address\[ \]+What.*
101 1.1 christos \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*
102 1.1 christos \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
103 1.1 christos "pending plus real breakpoint info"
104 1.1 christos
105 1.1 christos
106 1.1 christos #
107 1.1 christos # Test not setting a pending breakpoint
108 1.1 christos #
109 1.1 christos gdb_test "break pendfunc2" \
110 1.1 christos "" \
111 1.1 christos "Don't set pending breakpoint" \
112 1.1 christos ".*Make breakpoint pending.*y or \\\[n\\\]. $" \
113 1.1 christos "n"
114 1.1 christos
115 1.1 christos #
116 1.1 christos # Add condition to pending breakpoint
117 1.1 christos #
118 1.1 christos
119 1.1 christos gdb_test_no_output "condition 1 k == 1"
120 1.1 christos
121 1.1 christos gdb_test "info break" \
122 1.1 christos "Num Type\[ \]+Disp Enb Address\[ \]+What.*
123 1.1 christos \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*
124 1.1 christos \[\t \]+stop only if k == 1.*
125 1.1 christos \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
126 1.1 christos "pending plus condition"
127 1.1 christos
128 1.1 christos #
129 1.1 christos # Disable pending breakpoint
130 1.1 christos #
131 1.1 christos
132 1.1 christos gdb_test_no_output "disable 1"
133 1.1 christos
134 1.1 christos gdb_test "info break" \
135 1.1 christos "Num Type\[ \]+Disp Enb Address\[ \]+What.*
136 1.1 christos \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
137 1.1 christos \[\t \]+stop only if k == 1.*
138 1.1 christos \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
139 1.1 christos "pending disabled"
140 1.1 christos
141 1.1 christos #
142 1.1 christos # Add commands to pending breakpoint
143 1.1 christos #
144 1.1 christos gdb_test "commands 1\nprint k\nend" "" \
145 1.1 christos "Set commands for pending breakpoint"
146 1.1 christos
147 1.1 christos gdb_test "info break" \
148 1.1 christos "Num Type\[ \]+Disp Enb Address\[ \]+What.*
149 1.1 christos \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
150 1.1 christos \[\t \]+stop only if k == 1.*
151 1.1 christos \[\t \]+print k.*
152 1.1 christos \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \
153 1.1 christos "pending disabled plus commands"
154 1.1 christos
155 1.1 christos #
156 1.1 christos # Try a pending break for a line in a source file with a condition
157 1.1 christos #
158 1.1 christos
159 1.1 christos set bp2_loc [gdb_get_line_number "y = x + 4" ${libfile}.c]
160 1.7 christos gdb_test_multiple "break pendshr.c:$bp2_loc if x > 3" "set pending breakpoint 2" {
161 1.1 christos -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
162 1.1 christos gdb_test "y" "Breakpoint.*pendshr.c:$bp2_loc.*pending." \
163 1.1 christos "Set pending breakpoint 2"
164 1.1 christos }
165 1.1 christos }
166 1.1 christos
167 1.1 christos gdb_test "info break" \
168 1.1 christos "Num Type\[ \]+Disp Enb Address\[ \]+What.*
169 1.1 christos \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
170 1.1 christos \[\t \]+stop only if k == 1.*
171 1.1 christos \[\t \]+print k.*
172 1.1 christos \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
173 1.1 christos \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp2_loc if x > 3.*" \
174 1.1 christos "multiple pending breakpoints"
175 1.1 christos
176 1.1 christos
177 1.1 christos #
178 1.1 christos # Try a pending break for a line in a source file with ignore count:
179 1.1 christos #
180 1.1 christos
181 1.1 christos set bp3_loc [gdb_get_line_number "printf" ${libfile}.c]
182 1.7 christos gdb_test_multiple "break pendshr.c:$bp3_loc" "set pending breakpoint 3" {
183 1.1 christos -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
184 1.1 christos gdb_test "y" "Breakpoint.*pendshr.c:$bp3_loc.*pending." \
185 1.1 christos "Set pending breakpoint 3"
186 1.1 christos }
187 1.1 christos }
188 1.1 christos
189 1.1 christos gdb_test {ignore $bpnum 2} "Will ignore next 2 crossings of breakpoint .*" \
190 1.1 christos "set ignore count on pending breakpoint 3"
191 1.1 christos
192 1.1 christos gdb_test "info break" \
193 1.1 christos "Num Type\[ \]+Disp Enb Address\[ \]+What.*
194 1.1 christos \[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.*
195 1.1 christos \[\t \]+stop only if k == 1.*
196 1.1 christos \[\t \]+print k.*
197 1.1 christos \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
198 1.1 christos \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp2_loc if x > 3.*
199 1.1 christos \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:$bp3_loc.*ignore next 2 hits.*" \
200 1.1 christos "multiple pending breakpoints 2"
201 1.1 christos
202 1.1 christos #
203 1.1 christos # Run to main which should resolve a pending breakpoint
204 1.1 christos #
205 1.1 christos
206 1.1 christos gdb_run_cmd
207 1.1 christos gdb_test "" \
208 1.1 christos ".*Breakpoint.*, main.*$mainline.*" \
209 1.1 christos "running to main"
210 1.1 christos
211 1.1 christos #
212 1.1 christos # Re-enable the first pending breakpoint which should resolve
213 1.1 christos #
214 1.1 christos
215 1.1 christos gdb_test_no_output "enable 1" \
216 1.1 christos "re-enabling pending breakpoint that can resolve instantly"
217 1.1 christos
218 1.1 christos #
219 1.1 christos # Continue to verify conditionals and commands for breakpoints are honored
220 1.1 christos #
221 1.1 christos
222 1.1 christos gdb_test "continue" \
223 1.1 christos ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*4;" \
224 1.1 christos "continue to resolved breakpoint 2"
225 1.1 christos
226 1.1 christos gdb_test "continue" \
227 1.1 christos ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*
228 1.11 christos \\\$1 = 1" \
229 1.1 christos "continue to resolved breakpoint 1"
230 1.1 christos
231 1.1 christos #
232 1.1 christos # Disable the other two breakpoints, and continue to the one with
233 1.1 christos # the ignore count. Make sure you hit it the third time, x should
234 1.1 christos # be 3 then.
235 1.1 christos #
236 1.1 christos
237 1.10 christos gdb_test "disable 7" "" "disable breakpoint 7"
238 1.10 christos gdb_test "disable 5" "" "disable breakpoint 5"
239 1.1 christos
240 1.1 christos gdb_test "continue" \
241 1.1 christos ".*Breakpoint.*pendfunc1.*\\\(x=3\\\) at.*pendshr.c:$bp3_loc.*printf.*;" \
242 1.1 christos "continue to resolved breakpoint 3"
243 1.1 christos
244 1.1 christos delete_breakpoints
245 1.1 christos
246 1.1 christos gdb_breakpoint "main"
247 1.1 christos
248 1.1 christos #
249 1.1 christos # Set non-existent pending breakpoint
250 1.1 christos #
251 1.1 christos gdb_test_multiple "break imaginary" "set imaginary pending breakpoint" {
252 1.1 christos -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" {
253 1.1 christos gdb_test "y" "Breakpoint.*imaginary.*pending." \
254 1.1 christos "set imaginary pending breakpoint"
255 1.1 christos }
256 1.1 christos }
257 1.1 christos
258 1.1 christos #
259 1.1 christos # rerun program and make sure that any pending breakpoint remains and no
260 1.1 christos # error messages are issued for the missing function
261 1.1 christos #
262 1.1 christos
263 1.1 christos rerun_to_main
264 1.1 christos
265 1.1 christos gdb_test "info break" \
266 1.1 christos "Num Type\[ \]+Disp Enb Address\[ \]+What.*
267 1.1 christos \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.*
268 1.1 christos \[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*imaginary.*" \
269 1.1 christos "verify pending breakpoint after restart"
270