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