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