]>
Commit | Line | Data |
---|---|---|
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 | ||
22 | if {[skip_shlib_tests]} { | |
23 | return 0 | |
24 | } | |
25 | ||
26 | standard_testfile .c | |
27 | set libfile "pendshr" | |
28 | set libsrc $srcdir/$subdir/$libfile.c | |
29 | set lib_sl [standard_output_file $libfile.sl] | |
30 | ||
31 | set lib_opts debug | |
32 | set exec_opts [list debug shlib=$lib_sl] | |
33 | ||
34 | if [get_compiler_info] { | |
35 | return -1 | |
36 | } | |
37 | ||
38 | if { [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 | ||
46 | gdb_exit | |
47 | gdb_start | |
48 | gdb_reinitialize_dir $srcdir/$subdir | |
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 | ||
56 | # Complete the condition (PR 15413). | |
57 | gdb_test "complete condition " "condition 1" | |
58 | ||
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} | |
65 | gdb_load_shlib $lib_sl | |
66 | ||
67 | set pendfunc1_loc [gdb_get_line_number "y = x + 4" ${libfile}.c] | |
68 | ||
69 | gdb_run_cmd | |
70 | ||
71 | gdb_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 | ||
77 | gdb_exit | |
78 | gdb_start | |
79 | gdb_reinitialize_dir $srcdir/$subdir | |
80 | ||
81 | gdb_load ${binfile} | |
82 | gdb_load_shlib $lib_sl | |
83 | ||
84 | # | |
85 | # Test setting, querying, and modifying pending breakpoints | |
86 | # | |
87 | ||
88 | gdb_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 | ||
94 | gdb_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 | ||
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" \ | |
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 | # | |
119 | gdb_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 | ||
129 | gdb_test_no_output "condition 1 k == 1" | |
130 | ||
131 | gdb_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 | ||
142 | gdb_test_no_output "disable 1" | |
143 | ||
144 | gdb_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 | # | |
154 | gdb_test "commands 1\nprint k\nend" "" \ | |
155 | "Set commands for pending breakpoint" | |
156 | ||
157 | gdb_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 | ||
169 | set bp2_loc [gdb_get_line_number "y = x + 4" ${libfile}.c] | |
170 | gdb_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 | ||
177 | gdb_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 | ||
191 | set bp3_loc [gdb_get_line_number "printf" ${libfile}.c] | |
192 | gdb_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 | ||
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" \ | |
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 | ||
216 | gdb_run_cmd | |
217 | gdb_test "" \ | |
218 | ".*Breakpoint.*, main.*$mainline.*" \ | |
219 | "running to main" | |
220 | ||
221 | # | |
222 | # Re-enable the first pending breakpoint which should resolve | |
223 | # | |
224 | ||
225 | gdb_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 | ||
232 | gdb_test "continue" \ | |
233 | ".*Breakpoint.*pendfunc1.*at.*pendshr.c:$bp2_loc.*4;" \ | |
234 | "continue to resolved breakpoint 2" | |
235 | ||
236 | gdb_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 | ||
247 | gdb_test "disable 7" "" "disable other breakpoints" | |
248 | gdb_test "disable 5" "" "disable other breakpoints" | |
249 | ||
250 | gdb_test "continue" \ | |
251 | ".*Breakpoint.*pendfunc1.*\\\(x=3\\\) at.*pendshr.c:$bp3_loc.*printf.*;" \ | |
252 | "continue to resolved breakpoint 3" | |
253 | ||
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" { | |
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 | ||
273 | rerun_to_main | |
274 | ||
275 | gdb_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" |