Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2003-2020 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 | 22 | if {[skip_shlib_tests]} { |
18fe2033 JJ |
23 | return 0 |
24 | } | |
25 | ||
822bd149 | 26 | standard_testfile .c |
18fe2033 | 27 | set libfile "pendshr" |
3cbba3d1 | 28 | set libsrc $srcdir/$subdir/$libfile.c |
822bd149 | 29 | set lib_sl [standard_output_file $libfile.sl] |
3cbba3d1 PG |
30 | |
31 | set lib_opts debug | |
32 | set exec_opts [list debug shlib=$lib_sl] | |
18fe2033 | 33 | |
4c93b1db | 34 | if [get_compiler_info] { |
18fe2033 JJ |
35 | return -1 |
36 | } | |
37 | ||
3cbba3d1 PG |
38 | if { [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 | |
46 | gdb_exit | |
47 | gdb_start | |
48 | gdb_reinitialize_dir $srcdir/$subdir | |
b96e2927 PA |
49 | |
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)" | |
53 | } | |
54 | } | |
55 | ||
58ce7251 SDJ |
56 | # Complete the condition (PR 15413). |
57 | gdb_test "complete condition " "condition 1" | |
58 | ||
b96e2927 PA |
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)" | |
63 | ||
64 | gdb_load ${binfile} | |
d9019901 | 65 | gdb_load_shlib $lib_sl |
b96e2927 PA |
66 | |
67 | set pendfunc1_loc [gdb_get_line_number "y = x + 4" ${libfile}.c] | |
bdea3a92 NF |
68 | |
69 | gdb_run_cmd | |
70 | ||
71 | gdb_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 | ||
77 | gdb_exit | |
78 | gdb_start | |
79 | gdb_reinitialize_dir $srcdir/$subdir | |
80 | ||
18fe2033 | 81 | gdb_load ${binfile} |
d9019901 | 82 | gdb_load_shlib $lib_sl |
18fe2033 | 83 | |
18fe2033 JJ |
84 | # |
85 | # Test setting, querying, and modifying pending breakpoints | |
86 | # | |
87 | ||
88 | gdb_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 | ||
94 | gdb_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 | ||
103 | set mainline [gdb_get_line_number "break main here"] | |
104 | ||
105 | gdb_test "break main" \ | |
106 | "Breakpoint.*at.* file .*$srcfile, line $mainline.*" \ | |
107 | "breakpoint function" | |
108 | ||
109 | gdb_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 |
119 | gdb_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 | 129 | gdb_test_no_output "condition 1 k == 1" |
18fe2033 JJ |
130 | |
131 | gdb_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 | 142 | gdb_test_no_output "disable 1" |
18fe2033 JJ |
143 | |
144 | gdb_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 | # | |
154 | gdb_test "commands 1\nprint k\nend" "" \ | |
27d3a1a2 | 155 | "Set commands for pending breakpoint" |
18fe2033 JJ |
156 | |
157 | gdb_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 | 169 | set bp2_loc [gdb_get_line_number "y = x + 4" ${libfile}.c] |
de97fdd4 | 170 | gdb_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 | ||
177 | gdb_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 | 191 | set bp3_loc [gdb_get_line_number "printf" ${libfile}.c] |
de97fdd4 | 192 | gdb_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 | ||
199 | gdb_test {ignore $bpnum 2} "Will ignore next 2 crossings of breakpoint .*" \ | |
200 | "set ignore count on pending breakpoint 3" | |
201 | ||
202 | gdb_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 |
216 | gdb_run_cmd |
217 | gdb_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 | 225 | gdb_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 | ||
232 | gdb_test "continue" \ | |
b9c34f67 | 233 | ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*4;" \ |
18fe2033 JJ |
234 | "continue to resolved breakpoint 2" |
235 | ||
236 | gdb_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 |
247 | gdb_test "disable 7" "" "disable other breakpoints" |
248 | gdb_test "disable 5" "" "disable other breakpoints" | |
0a5e7efe JI |
249 | |
250 | gdb_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 |
254 | delete_breakpoints |
255 | ||
256 | gdb_breakpoint "main" | |
257 | ||
258 | # | |
259 | # Set non-existent pending breakpoint | |
260 | # | |
261 | gdb_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 | ||
273 | rerun_to_main | |
0a5e7efe | 274 | |
18fe2033 | 275 | gdb_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" |