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