Commit | Line | Data |
---|---|---|
b6ba6518 | 1 | # Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, |
82025e13 | 2 | # 2000, 2002, 2003 |
c906108c SS |
3 | # Free Software Foundation, Inc. |
4 | ||
5 | # This program is free software; you can redistribute it and/or modify | |
6 | # it under the terms of the GNU General Public License as published by | |
7 | # the Free Software Foundation; either version 2 of the License, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
16 | # along with this program; if not, write to the Free Software | |
17 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 | ||
19 | # Please email any bugs, comments, and/or additions to this file to: | |
20 | # bug-gdb@prep.ai.mit.edu | |
21 | ||
22 | # This file was written by Rob Savoye. (rob@cygnus.com) | |
23 | ||
24 | if $tracelevel then { | |
25 | strace $tracelevel | |
26 | } | |
27 | ||
28 | ||
29 | # | |
30 | # test running programs | |
31 | # | |
32 | set prms_id 0 | |
33 | set bug_id 0 | |
34 | ||
35 | set testfile "break" | |
36 | set srcfile ${testfile}.c | |
a1dea79a | 37 | set srcfile1 ${testfile}1.c |
c906108c SS |
38 | set binfile ${objdir}/${subdir}/${testfile} |
39 | ||
fc91c6c2 | 40 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } { |
a1dea79a FF |
41 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." |
42 | } | |
43 | ||
fc91c6c2 | 44 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } { |
a1dea79a FF |
45 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." |
46 | } | |
47 | ||
fc91c6c2 | 48 | if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } { |
a1dea79a | 49 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." |
c906108c SS |
50 | } |
51 | ||
085dd6e6 JM |
52 | if [get_compiler_info ${binfile}] { |
53 | return -1 | |
54 | } | |
55 | ||
c906108c SS |
56 | gdb_exit |
57 | gdb_start | |
58 | gdb_reinitialize_dir $srcdir/$subdir | |
59 | gdb_load ${binfile} | |
60 | ||
61 | if [target_info exists gdb_stub] { | |
62 | gdb_step_for_stub; | |
63 | } | |
64 | # | |
65 | # test simple breakpoint setting commands | |
66 | # | |
67 | ||
68 | # Test deleting all breakpoints when there are none installed, | |
69 | # GDB should not prompt for confirmation. | |
9d6f42e9 | 70 | # Note that lib/gdb.exp provides a "delete_breakpoints" proc |
c906108c SS |
71 | # for general use elsewhere. |
72 | ||
73 | send_gdb "delete breakpoints\n" | |
74 | gdb_expect { | |
75 | -re "Delete all breakpoints.*$" { | |
76 | send_gdb "y\n" | |
77 | gdb_expect { | |
78 | -re "$gdb_prompt $" { | |
79 | fail "Delete all breakpoints when none (unexpected prompt)" | |
80 | } | |
81 | timeout { fail "Delete all breakpoints when none (timeout after unexpected prompt)" } | |
82 | } | |
83 | } | |
84 | -re ".*$gdb_prompt $" { pass "Delete all breakpoints when none" } | |
85 | timeout { fail "Delete all breakpoints when none (timeout)" } | |
86 | } | |
87 | ||
88 | # | |
89 | # test break at function | |
90 | # | |
91 | gdb_test "break main" \ | |
92 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
93 | "breakpoint function" | |
94 | ||
df763c7f DJ |
95 | # |
96 | # test break at quoted function | |
97 | # | |
98 | gdb_test "break \"marker2\"" \ | |
a1dea79a | 99 | "Breakpoint.*at.* file .*$srcfile1, line.*" \ |
df763c7f DJ |
100 | "breakpoint quoted function" |
101 | ||
c906108c SS |
102 | # |
103 | # test break at function in file | |
104 | # | |
105 | gdb_test "break $srcfile:factorial" \ | |
106 | "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
107 | "breakpoint function in file" | |
108 | ||
a50d3602 EZ |
109 | set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] |
110 | ||
c906108c SS |
111 | # |
112 | # test break at line number | |
113 | # | |
e6f9e514 JB |
114 | # Note that the default source file is the last one whose source text |
115 | # was printed. For native debugging, before we've executed the | |
116 | # program, this is the file containing main, but for remote debugging, | |
117 | # it's wherever the processor was stopped when we connected to the | |
118 | # board. So, to be sure, we do a list command. | |
119 | # | |
120 | gdb_test "list main" \ | |
121 | ".*main \\(argc, argv, envp\\).*" \ | |
122 | "use `list' to establish default source file" | |
a50d3602 EZ |
123 | gdb_test "break $bp_location1" \ |
124 | "Breakpoint.*at.* file .*$srcfile, line $bp_location1\\." \ | |
c906108c SS |
125 | "breakpoint line number" |
126 | ||
127 | # | |
128 | # test duplicate breakpoint | |
129 | # | |
a50d3602 EZ |
130 | gdb_test "break $bp_location1" \ |
131 | "Note: breakpoint \[0-9\]+ also set at pc.*Breakpoint \[0-9\]+ at.* file .*$srcfile, line $bp_location1\\." \ | |
c906108c SS |
132 | "breakpoint duplicate" |
133 | ||
a50d3602 EZ |
134 | set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] |
135 | ||
c906108c SS |
136 | # |
137 | # test break at line number in file | |
138 | # | |
a50d3602 EZ |
139 | gdb_test "break $srcfile:$bp_location2" \ |
140 | "Breakpoint.*at.* file .*$srcfile, line $bp_location2\\." \ | |
c906108c SS |
141 | "breakpoint line number in file" |
142 | ||
a50d3602 EZ |
143 | set bp_location3 [gdb_get_line_number "set breakpoint 3 here"] |
144 | set bp_location4 [gdb_get_line_number "set breakpoint 4 here"] | |
c906108c | 145 | |
f286b2c3 JL |
146 | # |
147 | # Test putting a break at the start of a multi-line if conditional. | |
148 | # Verify the breakpoint was put at the start of the conditional. | |
149 | # | |
150 | gdb_test "break multi_line_if_conditional" \ | |
a50d3602 | 151 | "Breakpoint.*at.* file .*$srcfile, line $bp_location3\\." \ |
f286b2c3 JL |
152 | "breakpoint at start of multi line if conditional" |
153 | ||
154 | gdb_test "break multi_line_while_conditional" \ | |
a50d3602 | 155 | "Breakpoint.*at.* file .*$srcfile, line $bp_location4\\." \ |
f286b2c3 JL |
156 | "breakpoint at start of multi line while conditional" |
157 | ||
a50d3602 EZ |
158 | set bp_location5 [gdb_get_line_number "set breakpoint 5 here"] |
159 | set bp_location6 [gdb_get_line_number "set breakpoint 6 here"] | |
160 | ||
c906108c SS |
161 | # |
162 | # check to see what breakpoints are set | |
163 | # | |
164 | if [target_info exists gdb_stub] { | |
a50d3602 | 165 | set main_line $bp_location5 |
c906108c | 166 | } else { |
a50d3602 | 167 | set main_line $bp_location6 |
c906108c SS |
168 | } |
169 | ||
085dd6e6 JM |
170 | if {$hp_aCC_compiler} { |
171 | set proto "\\(int\\)" | |
172 | } else { | |
173 | set proto "" | |
174 | } | |
82025e13 | 175 | |
a50d3602 | 176 | set bp_location7 [gdb_get_line_number "set breakpoint 7 here"] |
a1dea79a FF |
177 | set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1] |
178 | set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1] | |
a50d3602 | 179 | |
c906108c SS |
180 | gdb_test "info break" \ |
181 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
182 | \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.* | |
a1dea79a | 183 | \[0-9\]+\[\t \]+breakpoint keep y.* in marker2 at .*$srcfile1:($bp_location8|$bp_location9).* |
a50d3602 EZ |
184 | \[0-9\]+\[\t \]+breakpoint keep y.* in factorial$proto at .*$srcfile:$bp_location7.* |
185 | \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.* | |
186 | \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.* | |
187 | \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location2.* | |
188 | \[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_if_conditional at .*$srcfile:$bp_location3.* | |
189 | \[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_while_conditional at .*$srcfile:$bp_location4" \ | |
c906108c SS |
190 | "breakpoint info" |
191 | ||
c906108c SS |
192 | # FIXME: The rest of this test doesn't work with anything that can't |
193 | # handle arguments. | |
194 | # Huh? There doesn't *appear* to be anything that passes arguments | |
195 | # below. | |
196 | if [istarget "mips-idt-*"] then { | |
197 | return | |
198 | } | |
199 | ||
200 | # | |
201 | # run until the breakpoint at main is hit. For non-stubs-using targets. | |
202 | # | |
203 | if ![target_info exists use_gdb_stub] { | |
204 | if [istarget "*-*-vxworks*"] then { | |
205 | send_gdb "run vxmain \"2\"\n" | |
206 | set timeout 120 | |
207 | verbose "Timeout is now $timeout seconds" 2 | |
208 | } else { | |
209 | send_gdb "run\n" | |
210 | } | |
211 | gdb_expect { | |
212 | -re "The program .* has been started already.*y or n. $" { | |
213 | send_gdb "y\n" | |
214 | exp_continue | |
215 | } | |
a50d3602 | 216 | -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\ |
c906108c SS |
217 | { pass "run until function breakpoint" } |
218 | -re ".*$gdb_prompt $" { fail "run until function breakpoint" } | |
219 | timeout { fail "run until function breakpoint (timeout)" } | |
220 | } | |
221 | } else { | |
222 | if ![target_info exists gdb_stub] { | |
a50d3602 | 223 | gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue" |
c906108c SS |
224 | } |
225 | } | |
226 | ||
227 | # | |
228 | # run until the breakpoint at a line number | |
229 | # | |
a50d3602 | 230 | gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location1.*$bp_location1\[\t \]+printf.*factorial.*" \ |
c906108c SS |
231 | "run until breakpoint set at a line number" |
232 | ||
233 | # | |
234 | # Run until the breakpoint set in a function in a file | |
235 | # | |
236 | for {set i 6} {$i >= 1} {incr i -1} { | |
a50d3602 | 237 | gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, factorial \\(value=$i\\) at .*$srcfile:$bp_location7.*$bp_location7\[\t \]+.*if .value > 1. \{.*" \ |
c906108c SS |
238 | "run until file:function($i) breakpoint" |
239 | } | |
240 | ||
df763c7f DJ |
241 | # |
242 | # Run until the breakpoint set at a quoted function | |
243 | # | |
a1dea79a | 244 | gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, (0x\[0-9a-f\]+ in )?marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*" \ |
df763c7f | 245 | "run until quoted breakpoint" |
c906108c SS |
246 | # |
247 | # run until the file:function breakpoint at a line number in a file | |
248 | # | |
a50d3602 | 249 | gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location2.*$bp_location2\[\t \]+argc = \\(argc == 12345\\);.*" \ |
c906108c SS |
250 | "run until file:linenum breakpoint" |
251 | ||
2acceee2 | 252 | # Test break at offset +1 |
a50d3602 | 253 | set bp_location10 [gdb_get_line_number "set breakpoint 10 here"] |
2acceee2 JM |
254 | |
255 | gdb_test "break +1" \ | |
a50d3602 | 256 | "Breakpoint.*at.* file .*$srcfile, line $bp_location10\\." \ |
2acceee2 JM |
257 | "breakpoint offset +1" |
258 | ||
259 | # Check to see if breakpoint is hit when stepped onto | |
260 | ||
261 | gdb_test "step" \ | |
a50d3602 | 262 | ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location10.*$bp_location10\[\t \]+return argc;.*breakpoint 10 here.*" \ |
2acceee2 JM |
263 | "step onto breakpoint" |
264 | ||
e1c2defa NS |
265 | # Check to see if breakpoint can be set on ending brace of function |
266 | set bp_location10a [gdb_get_line_number "set breakpoint 10a here"] | |
267 | ||
268 | gdb_test "break $bp_location10a" \ | |
269 | "Breakpoint.*at.* file .*$srcfile, line $bp_location10a\\." \ | |
270 | "setting breakpoint at }" | |
271 | ||
272 | gdb_test "continue" \ | |
273 | ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location10a.*$bp_location10a\[\t \]+}.*breakpoint 10a here.*" \ | |
274 | "continue to breakpoint at }" | |
275 | ||
c906108c SS |
276 | # |
277 | # delete all breakpoints so we can start over, course this can be a test too | |
278 | # | |
279 | delete_breakpoints | |
280 | ||
281 | # | |
282 | # test temporary breakpoint at function | |
283 | # | |
284 | ||
285 | gdb_test "tbreak main" "Breakpoint.*at.* file .*$srcfile, line.*" "Temporary breakpoint function" | |
286 | ||
287 | # | |
288 | # test break at function in file | |
289 | # | |
290 | ||
291 | gdb_test "tbreak $srcfile:factorial" "Breakpoint.*at.* file .*$srcfile, line.*" \ | |
292 | "Temporary breakpoint function in file" | |
293 | ||
294 | # | |
295 | # test break at line number | |
296 | # | |
a50d3602 | 297 | send_gdb "tbreak $bp_location1\n" |
c906108c | 298 | gdb_expect { |
a50d3602 | 299 | -re "Breakpoint.*at.* file .*$srcfile, line $bp_location1.*$gdb_prompt $" { pass "Temporary breakpoint line number #1" } |
c906108c SS |
300 | -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number #1" } |
301 | timeout { fail "breakpoint line number #1 (timeout)" } | |
302 | } | |
303 | ||
a50d3602 | 304 | gdb_test "tbreak $bp_location6" "Breakpoint.*at.* file .*$srcfile, line $bp_location6.*" "Temporary breakpoint line number #2" |
c906108c SS |
305 | |
306 | # | |
307 | # test break at line number in file | |
308 | # | |
a50d3602 | 309 | send_gdb "tbreak $srcfile:$bp_location2\n" |
c906108c | 310 | gdb_expect { |
a50d3602 | 311 | -re "Breakpoint.*at.* file .*$srcfile, line $bp_location2.*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" } |
c906108c SS |
312 | -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" } |
313 | timeout { fail "Temporary breakpoint line number in file #1 (timeout)" } | |
314 | } | |
315 | ||
a50d3602 EZ |
316 | set bp_location11 [gdb_get_line_number "set breakpoint 11 here"] |
317 | gdb_test "tbreak $srcfile:$bp_location11" "Breakpoint.*at.* file .*$srcfile, line $bp_location11.*" "Temporary breakpoint line number in file #2" | |
c906108c SS |
318 | |
319 | # | |
320 | # check to see what breakpoints are set (temporary this time) | |
321 | # | |
085dd6e6 JM |
322 | gdb_test "info break" "Num Type.*Disp Enb Address.*What.*\[\r\n\] |
323 | \[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$main_line.*\[\r\n\] | |
a50d3602 EZ |
324 | \[0-9\]+\[\t \]+breakpoint del.*y.*in factorial$proto at .*$srcfile:$bp_location7.*\[\r\n\] |
325 | \[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location1.*\[\r\n\] | |
326 | \[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location6.*\[\r\n\] | |
327 | \[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location2.*\[\r\n\] | |
328 | \[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location11.*" \ | |
085dd6e6 | 329 | "Temporary breakpoint info" |
c906108c SS |
330 | |
331 | ||
332 | #*********** | |
333 | ||
334 | # Verify that catchpoints for fork, vfork and exec don't trigger | |
335 | # inappropriately. (There are no calls to those system functions | |
336 | # in this test program.) | |
337 | # | |
338 | if ![runto_main] then { fail "break tests suppressed" } | |
339 | ||
340 | send_gdb "catch\n" | |
341 | gdb_expect { | |
342 | -re "Catch requires an event name.*$gdb_prompt $"\ | |
343 | {pass "catch requires an event name"} | |
344 | -re "$gdb_prompt $"\ | |
345 | {fail "catch requires an event name"} | |
346 | timeout {fail "(timeout) catch requires an event name"} | |
347 | } | |
348 | ||
349 | ||
350 | set name "set catch fork, never expected to trigger" | |
351 | send_gdb "catch fork\n" | |
352 | gdb_expect { | |
353 | -re "Catchpoint \[0-9\]* .fork..*$gdb_prompt $" | |
354 | {pass $name} | |
355 | -re "Catch of fork not yet implemented.*$gdb_prompt $" | |
356 | {pass $name} | |
357 | -re "$gdb_prompt $" | |
358 | {fail $name} | |
359 | timeout {fail "(timeout) $name"} | |
360 | } | |
361 | ||
362 | ||
363 | set name "set catch vfork, never expected to trigger" | |
364 | send_gdb "catch vfork\n" | |
365 | ||
366 | # If we are on HP-UX 10.20, we expect an error message to be | |
367 | # printed if we type "catch vfork" at the gdb gdb_prompt. This is | |
368 | # because on HP-UX 10.20, we cannot catch vfork events. | |
369 | ||
370 | if [istarget "hppa*-hp-hpux10.20"] then { | |
371 | gdb_expect { | |
372 | -re "Catch of vfork events not supported on HP-UX 10.20..*$gdb_prompt $" | |
373 | {pass $name} | |
374 | -re "$gdb_prompt $" | |
375 | {fail $name} | |
376 | timeout {fail "(timeout) $name"} | |
377 | } | |
378 | } else { | |
379 | gdb_expect { | |
380 | -re "Catchpoint \[0-9\]* .vfork..*$gdb_prompt $" | |
381 | {pass $name} | |
382 | -re "Catch of vfork not yet implemented.*$gdb_prompt $" | |
383 | {pass $name} | |
384 | -re "$gdb_prompt $" | |
385 | {fail $name} | |
386 | timeout {fail "(timeout) $name"} | |
387 | } | |
388 | } | |
389 | ||
390 | set name "set catch exec, never expected to trigger" | |
391 | send_gdb "catch exec\n" | |
392 | gdb_expect { | |
393 | -re "Catchpoint \[0-9\]* .exec..*$gdb_prompt $" | |
394 | {pass $name} | |
395 | -re "Catch of exec not yet implemented.*$gdb_prompt $" | |
396 | {pass $name} | |
397 | -re "$gdb_prompt $" {fail $name} | |
398 | timeout {fail "(timeout) $name"} | |
399 | } | |
400 | ||
c906108c SS |
401 | # Verify that GDB responds gracefully when asked to set a breakpoint |
402 | # on a nonexistent source line. | |
403 | # | |
404 | send_gdb "break 999\n" | |
405 | gdb_expect { | |
406 | -re "No line 999 in file .*$gdb_prompt $"\ | |
407 | {pass "break on non-existent source line"} | |
408 | -re "$gdb_prompt $"\ | |
409 | {fail "break on non-existent source line"} | |
410 | timeout {fail "(timeout) break on non-existent source line"} | |
411 | } | |
412 | ||
0fbc361c EZ |
413 | # Run to the desired default location. If not positioned here, the |
414 | # tests below don't work. | |
415 | # | |
a1dea79a | 416 | gdb_test "until $bp_location1" "main .* at .*:$bp_location1.*" "until bp_location1" |
0fbc361c EZ |
417 | |
418 | ||
c906108c SS |
419 | # Verify that GDB allows one to just say "break", which is treated |
420 | # as the "default" breakpoint. Note that GDB gets cute when printing | |
421 | # the informational message about other breakpoints at the same | |
422 | # location. We'll hit that bird with this stone too. | |
423 | # | |
424 | send_gdb "break\n" | |
425 | gdb_expect { | |
426 | -re "Breakpoint \[0-9\]*.*$gdb_prompt $"\ | |
427 | {pass "break on default location, 1st time"} | |
428 | -re "$gdb_prompt $"\ | |
429 | {fail "break on default location, 1st time"} | |
430 | timeout {fail "(timeout) break on default location, 1st time"} | |
431 | } | |
432 | ||
433 | send_gdb "break\n" | |
434 | gdb_expect { | |
435 | -re "Note: breakpoint \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\ | |
436 | {pass "break on default location, 2nd time"} | |
437 | -re "$gdb_prompt $"\ | |
438 | {fail "break on default location, 2nd time"} | |
439 | timeout {fail "(timeout) break on default location, 2nd time"} | |
440 | } | |
441 | ||
442 | send_gdb "break\n" | |
443 | gdb_expect { | |
444 | -re "Note: breakpoints \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\ | |
445 | {pass "break on default location, 3rd time"} | |
446 | -re "$gdb_prompt $"\ | |
447 | {fail "break on default location, 3rd time"} | |
448 | timeout {fail "(timeout) break on default location, 3rd time"} | |
449 | } | |
450 | ||
451 | send_gdb "break\n" | |
452 | gdb_expect { | |
453 | -re "Note: breakpoints \[0-9\]*, \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\ | |
454 | {pass "break on default location, 4th time"} | |
455 | -re "$gdb_prompt $"\ | |
456 | {fail "break on default location, 4th time"} | |
457 | timeout {fail "(timeout) break on default location, 4th time"} | |
458 | } | |
459 | ||
460 | # Verify that a "silent" breakpoint can be set, and that GDB is indeed | |
461 | # "silent" about its triggering. | |
462 | # | |
463 | if ![runto_main] then { fail "break tests suppressed" } | |
464 | ||
a50d3602 | 465 | send_gdb "break $bp_location1\n" |
c906108c | 466 | gdb_expect { |
a50d3602 | 467 | -re "Breakpoint (\[0-9\]*) at .*, line $bp_location1.*$gdb_prompt $"\ |
a1dea79a | 468 | {pass "set to-be-silent break bp_location1"} |
c906108c | 469 | -re "$gdb_prompt $"\ |
a1dea79a FF |
470 | {fail "set to-be-silent break bp_location1"} |
471 | timeout {fail "(timeout) set to-be-silent break bp_location1"} | |
c906108c SS |
472 | } |
473 | ||
474 | send_gdb "commands $expect_out(1,string)\n" | |
475 | send_gdb "silent\n" | |
476 | send_gdb "end\n" | |
477 | gdb_expect { | |
478 | -re ".*$gdb_prompt $"\ | |
a1dea79a FF |
479 | {pass "set silent break bp_location1"} |
480 | timeout {fail "(timeout) set silent break bp_location1"} | |
c906108c SS |
481 | } |
482 | ||
483 | send_gdb "info break $expect_out(1,string)\n" | |
484 | gdb_expect { | |
a50d3602 | 485 | -re "\[0-9\]*\[ \t\]*breakpoint.*:$bp_location1\r\n\[ \t\]*silent.*$gdb_prompt $"\ |
a1dea79a | 486 | {pass "info silent break bp_location1"} |
c906108c | 487 | -re "$gdb_prompt $"\ |
a1dea79a FF |
488 | {fail "info silent break bp_location1"} |
489 | timeout {fail "(timeout) info silent break bp_location1"} | |
c906108c SS |
490 | } |
491 | send_gdb "continue\n" | |
492 | gdb_expect { | |
493 | -re "Continuing.\r\n$gdb_prompt $"\ | |
a1dea79a | 494 | {pass "hit silent break bp_location1"} |
c906108c | 495 | -re "$gdb_prompt $"\ |
a1dea79a FF |
496 | {fail "hit silent break bp_location1"} |
497 | timeout {fail "(timeout) hit silent break bp_location1"} | |
c906108c SS |
498 | } |
499 | send_gdb "bt\n" | |
500 | gdb_expect { | |
a50d3602 | 501 | -re "#0 main .* at .*:$bp_location1.*$gdb_prompt $"\ |
a1dea79a | 502 | {pass "stopped for silent break bp_location1"} |
c906108c | 503 | -re "$gdb_prompt $"\ |
a1dea79a FF |
504 | {fail "stopped for silent break bp_location1"} |
505 | timeout {fail "(timeout) stopped for silent break bp_location1"} | |
c906108c SS |
506 | } |
507 | ||
508 | # Verify that GDB can at least parse a breakpoint with the | |
509 | # "thread" keyword. (We won't attempt to test here that a | |
510 | # thread-specific breakpoint really triggers appropriately. | |
511 | # The gdb.threads subdirectory contains tests for that.) | |
512 | # | |
a50d3602 EZ |
513 | set bp_location12 [gdb_get_line_number "set breakpoint 12 here"] |
514 | send_gdb "break $bp_location12 thread 999\n" | |
c906108c SS |
515 | gdb_expect { |
516 | -re "Unknown thread 999.*$gdb_prompt $"\ | |
517 | {pass "thread-specific breakpoint on non-existent thread disallowed"} | |
518 | -re "$gdb_prompt $"\ | |
519 | {fail "thread-specific breakpoint on non-existent thread disallowed"} | |
520 | timeout {fail "(timeout) thread-specific breakpoint on non-existent thread disallowed"} | |
521 | } | |
a50d3602 | 522 | send_gdb "break $bp_location12 thread foo\n" |
c906108c SS |
523 | gdb_expect { |
524 | -re "Junk after thread keyword..*$gdb_prompt $"\ | |
525 | {pass "thread-specific breakpoint on bogus thread ID disallowed"} | |
526 | -re "$gdb_prompt $"\ | |
527 | {fail "thread-specific breakpoint on bogus thread ID disallowed"} | |
528 | timeout {fail "(timeout) thread-specific breakpoint on bogus thread ID disallowed"} | |
529 | } | |
530 | ||
531 | # Verify that GDB responds gracefully to a breakpoint command with | |
532 | # trailing garbage. | |
533 | # | |
a50d3602 | 534 | send_gdb "break $bp_location12 foo\n" |
c906108c SS |
535 | gdb_expect { |
536 | -re "Junk at end of arguments..*$gdb_prompt $"\ | |
537 | {pass "breakpoint with trailing garbage disallowed"} | |
538 | -re "$gdb_prompt $"\ | |
539 | {fail "breakpoint with trailing garbage disallowed"} | |
540 | timeout {fail "(timeout) breakpoint with trailing garbage disallowed"} | |
541 | } | |
542 | ||
543 | # Verify that GDB responds gracefully to a "clear" command that has | |
544 | # no matching breakpoint. (First, get us off the current source line, | |
545 | # which we know has a breakpoint.) | |
546 | # | |
547 | send_gdb "next\n" | |
548 | gdb_expect { | |
549 | -re ".*$gdb_prompt $"\ | |
550 | {pass "step over breakpoint"} | |
551 | timeout {fail "(timeout) step over breakpoint"} | |
552 | } | |
085dd6e6 | 553 | send_gdb "clear 81\n" |
c906108c | 554 | gdb_expect { |
085dd6e6 | 555 | -re "No breakpoint at 81..*$gdb_prompt $"\ |
c906108c SS |
556 | {pass "clear line has no breakpoint disallowed"} |
557 | -re "$gdb_prompt $"\ | |
558 | {fail "clear line has no breakpoint disallowed"} | |
559 | timeout {fail "(timeout) clear line has no breakpoint disallowed"} | |
560 | } | |
561 | send_gdb "clear\n" | |
562 | gdb_expect { | |
563 | -re "No breakpoint at this line..*$gdb_prompt $"\ | |
564 | {pass "clear current line has no breakpoint disallowed"} | |
565 | -re "$gdb_prompt $"\ | |
566 | {fail "clear current line has no breakpoint disallowed"} | |
567 | timeout {fail "(timeout) clear current line has no breakpoint disallowed"} | |
568 | } | |
569 | ||
4a7bddb6 MC |
570 | # Verify that we can set and clear multiple breakpoints. |
571 | # | |
572 | # We don't test that it deletes the correct breakpoints. We do at | |
573 | # least test that it deletes more than one breakpoint. | |
574 | # | |
575 | gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #1" | |
576 | gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #2" | |
577 | gdb_test "clear marker3" {Deleted breakpoints [0-9]+ [0-9]+.*} | |
578 | ||
c906108c SS |
579 | # Verify that a breakpoint can be set via a convenience variable. |
580 | # | |
a50d3602 | 581 | send_gdb "set \$foo=$bp_location11\n" |
c906108c SS |
582 | gdb_expect { |
583 | -re "$gdb_prompt $"\ | |
a1dea79a FF |
584 | {pass "set convenience variable \$foo to bp_location11"} |
585 | timeout {fail "(timeout) set convenience variable \$foo to bp_location11"} | |
c906108c SS |
586 | } |
587 | send_gdb "break \$foo\n" | |
588 | gdb_expect { | |
a50d3602 | 589 | -re "Breakpoint (\[0-9\]*) at .*, line $bp_location11.*$gdb_prompt $"\ |
c906108c SS |
590 | {pass "set breakpoint via convenience variable"} |
591 | -re "$gdb_prompt $"\ | |
592 | {fail "set breakpoint via convenience variable"} | |
593 | timeout {fail "(timeout) set breakpoint via convenience variable"} | |
594 | } | |
595 | ||
596 | # Verify that GDB responds gracefully to an attempt to set a | |
597 | # breakpoint via a convenience variable whose type is not integer. | |
598 | # | |
085dd6e6 | 599 | send_gdb "set \$foo=81.5\n" |
c906108c SS |
600 | gdb_expect { |
601 | -re "$gdb_prompt $"\ | |
085dd6e6 JM |
602 | {pass "set convenience variable \$foo to 81.5"} |
603 | timeout {fail "(timeout) set convenience variable \$foo to 81.5"} | |
c906108c SS |
604 | } |
605 | send_gdb "break \$foo\n" | |
606 | gdb_expect { | |
607 | -re "Convenience variables used in line specs must have integer values..*$gdb_prompt $"\ | |
608 | {pass "set breakpoint via non-integer convenience variable disallowed"} | |
609 | -re "$gdb_prompt $"\ | |
610 | {fail "set breakpoint via non-integer convenience variable disallowed"} | |
611 | timeout {fail "(timeout) set breakpoint via non-integer convenience variable disallowed"} | |
612 | } | |
613 | ||
614 | # Verify that we can set and trigger a breakpoint in a user-called function. | |
615 | # | |
616 | send_gdb "break marker2\n" | |
617 | gdb_expect { | |
a50d3602 | 618 | -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location8|$bp_location9).*$gdb_prompt $"\ |
c906108c SS |
619 | {pass "set breakpoint on to-be-called function"} |
620 | -re "$gdb_prompt $"\ | |
621 | {fail "set breakpoint on to-be-called function"} | |
622 | timeout {fail "(timeout) set breakpoint on to-be-called function"} | |
623 | } | |
624 | send_gdb "print marker2(99)\n" | |
625 | gdb_expect { | |
085dd6e6 | 626 | -re "The program being debugged stopped while in a function called from GDB.\r\nWhen the function .marker2$proto. is done executing, GDB will silently\r\nstop .instead of continuing to evaluate the expression containing\r\nthe function call...*$gdb_prompt $"\ |
c906108c SS |
627 | {pass "hit breakpoint on called function"} |
628 | -re "$gdb_prompt $"\ | |
629 | {fail "hit breakpoint on called function"} | |
630 | timeout {fail "(timeout) hit breakpoint on called function"} | |
631 | } | |
632 | ||
633 | # As long as we're stopped (breakpointed) in a called function, | |
634 | # verify that we can successfully backtrace & such from here. | |
635 | # | |
30e87cd3 ND |
636 | # In this and the following test, the _sr4export check apparently is needed |
637 | # for hppa*-*-hpux. | |
638 | # | |
639 | send_gdb "bt\n" | |
640 | gdb_expect { | |
a50d3602 | 641 | -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*_sr4export.*$gdb_prompt $"\ |
c906108c | 642 | {pass "backtrace while in called function"} |
a50d3602 | 643 | -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*function called from gdb.*$gdb_prompt $"\ |
30e87cd3 | 644 | {pass "backtrace while in called function"} |
c906108c SS |
645 | -re "$gdb_prompt $"\ |
646 | {fail "backtrace while in called function"} | |
647 | timeout {fail "(timeout) backtrace while in called function"} | |
30e87cd3 ND |
648 | } |
649 | ||
650 | # Return from the called function. For remote targets, it's important to do | |
651 | # this before runto_main, which otherwise may silently stop on the dummy | |
652 | # breakpoint inserted by GDB at the program's entry point. | |
653 | # | |
654 | send_gdb "finish\n" | |
655 | gdb_expect { | |
a50d3602 | 656 | -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.* in _sr4export.*$gdb_prompt $"\ |
085dd6e6 | 657 | {pass "finish from called function"} |
a50d3602 | 658 | -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*function called from gdb.*$gdb_prompt $"\ |
c906108c | 659 | {pass "finish from called function"} |
a50d3602 | 660 | -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*Value returned.*$gdb_prompt $"\ |
104c1213 | 661 | {pass "finish from called function"} |
c906108c SS |
662 | -re "$gdb_prompt $"\ |
663 | {fail "finish from called function"} | |
664 | timeout {fail "(timeout) finish from called function"} | |
c906108c SS |
665 | } |
666 | ||
667 | # Verify that GDB responds gracefully to a "finish" command with | |
668 | # arguments. | |
669 | # | |
670 | if ![runto_main] then { fail "break tests suppressed" } | |
671 | ||
672 | send_gdb "finish 123\n" | |
673 | gdb_expect { | |
674 | -re "The \"finish\" command does not take any arguments.\r\n$gdb_prompt $"\ | |
675 | {pass "finish with arguments disallowed"} | |
676 | -re "$gdb_prompt $"\ | |
677 | {fail "finish with arguments disallowed"} | |
678 | timeout {fail "(timeout) finish with arguments disallowed"} | |
679 | } | |
680 | ||
681 | # Verify that GDB responds gracefully to a request to "finish" from | |
7a292a7a SS |
682 | # the outermost frame. On a stub that never exits, this will just |
683 | # run to the stubs routine, so we don't get this error... Thus the | |
684 | # second condition. | |
c906108c | 685 | # |
7a292a7a | 686 | |
c906108c SS |
687 | send_gdb "finish\n" |
688 | gdb_expect { | |
689 | -re "\"finish\" not meaningful in the outermost frame.\r\n$gdb_prompt $"\ | |
690 | {pass "finish from outermost frame disallowed"} | |
c4093a6a | 691 | -re "Run till exit from.*\r\n$gdb_prompt $" { |
7a292a7a SS |
692 | pass "finish from outermost frame disallowed" |
693 | } | |
c906108c SS |
694 | -re "$gdb_prompt $"\ |
695 | {fail "finish from outermost frame disallowed"} | |
696 | timeout {fail "(timeout) finish from outermost frame disallowed"} | |
697 | } | |
698 | ||
699 | # Verify that we can explicitly ask GDB to stop on all shared library | |
700 | # events, and that it does so. | |
701 | # | |
702 | if [istarget "hppa*-*-hpux*"] then { | |
703 | if ![runto_main] then { fail "break tests suppressed" } | |
704 | ||
705 | send_gdb "set stop-on-solib-events 1\n" | |
706 | gdb_expect { | |
707 | -re "$gdb_prompt $"\ | |
708 | {pass "set stop-on-solib-events"} | |
709 | timeout {fail "(timeout) set stop-on-solib-events"} | |
710 | } | |
711 | ||
712 | send_gdb "run\n" | |
713 | gdb_expect { | |
714 | -re ".*Start it from the beginning.*y or n. $"\ | |
715 | {send_gdb "y\n" | |
716 | gdb_expect { | |
717 | -re ".*Stopped due to shared library event.*$gdb_prompt $"\ | |
718 | {pass "triggered stop-on-solib-events"} | |
719 | -re "$gdb_prompt $"\ | |
720 | {fail "triggered stop-on-solib-events"} | |
721 | timeout {fail "(timeout) triggered stop-on-solib-events"} | |
722 | } | |
723 | } | |
724 | -re "$gdb_prompt $"\ | |
725 | {fail "rerun for stop-on-solib-events"} | |
726 | timeout {fail "(timeout) rerun for stop-on-solib-events"} | |
727 | } | |
728 | ||
729 | send_gdb "set stop-on-solib-events 0\n" | |
730 | gdb_expect { | |
731 | -re "$gdb_prompt $"\ | |
732 | {pass "reset stop-on-solib-events"} | |
733 | timeout {fail "(timeout) reset stop-on-solib-events"} | |
734 | } | |
735 | } | |
736 | ||
737 | # Hardware breakpoints are unsupported on HP-UX. Verify that GDB | |
738 | # gracefully responds to requests to create them. | |
739 | # | |
740 | if [istarget "hppa*-*-hpux*"] then { | |
741 | if ![runto_main] then { fail "break tests suppressed" } | |
742 | ||
743 | send_gdb "hbreak\n" | |
744 | gdb_expect { | |
745 | -re "No hardware breakpoint support in the target.*$gdb_prompt $"\ | |
746 | {pass "hw breaks disallowed"} | |
747 | -re "$gdb_prompt $"\ | |
748 | {fail "hw breaks disallowed"} | |
749 | timeout {fail "(timeout) hw breaks disallowed"} | |
750 | } | |
751 | ||
752 | send_gdb "thbreak\n" | |
753 | gdb_expect { | |
754 | -re "No hardware breakpoint support in the target.*$gdb_prompt $"\ | |
755 | {pass "temporary hw breaks disallowed"} | |
756 | -re "$gdb_prompt $"\ | |
757 | {fail "temporary hw breaks disallowed"} | |
758 | timeout {fail "(timeout) temporary hw breaks disallowed"} | |
759 | } | |
760 | } | |
761 | ||
762 | #******** | |
763 | ||
764 | ||
c906108c SS |
765 | # |
766 | # Test "next" over recursive function call. | |
767 | # | |
768 | ||
769 | proc test_next_with_recursion {} { | |
770 | global gdb_prompt | |
771 | global decimal | |
772 | global binfile | |
773 | ||
774 | if [target_info exists use_gdb_stub] { | |
775 | # Reload the program. | |
776 | delete_breakpoints | |
777 | gdb_load ${binfile}; | |
778 | } else { | |
779 | # FIXME: should be using runto | |
780 | gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y" | |
781 | ||
782 | delete_breakpoints | |
783 | } | |
784 | ||
785 | gdb_test "break factorial" "Breakpoint $decimal at .*" "break at factorial" | |
786 | ||
787 | # Run until we call factorial with 6 | |
788 | ||
789 | if [istarget "*-*-vxworks*"] then { | |
790 | send_gdb "run vxmain \"6\"\n" | |
791 | } else { | |
792 | gdb_run_cmd | |
793 | } | |
794 | gdb_expect { | |
795 | -re "Break.* factorial .value=6. .*$gdb_prompt $" {} | |
796 | -re ".*$gdb_prompt $" { | |
797 | fail "run to factorial(6)"; | |
798 | gdb_suppress_tests; | |
799 | } | |
800 | timeout { fail "run to factorial(6) (timeout)" ; gdb_suppress_tests } | |
801 | } | |
802 | ||
803 | # Continue until we call factorial recursively with 5. | |
804 | ||
805 | if [gdb_test "continue" \ | |
806 | "Continuing.*Break.* factorial .value=5. .*" \ | |
807 | "continue to factorial(5)"] then { gdb_suppress_tests } | |
808 | ||
809 | # Do a backtrace just to confirm how many levels deep we are. | |
810 | ||
811 | if [gdb_test "backtrace" \ | |
812 | "#0\[ \t\]+ factorial .value=5..*" \ | |
813 | "backtrace from factorial(5)"] then { gdb_suppress_tests } | |
814 | ||
815 | # Now a "next" should position us at the recursive call, which | |
816 | # we will be performing with 4. | |
817 | ||
818 | if [gdb_test "next" \ | |
819 | ".* factorial .value - 1.;.*" \ | |
820 | "next to recursive call"] then { gdb_suppress_tests } | |
821 | ||
822 | # Disable the breakpoint at the entry to factorial by deleting them all. | |
823 | # The "next" should run until we return to the next line from this | |
824 | # recursive call to factorial with 4. | |
825 | # Buggy versions of gdb will stop instead at the innermost frame on | |
826 | # the line where we are trying to "next" to. | |
827 | ||
828 | delete_breakpoints | |
829 | ||
830 | if [istarget "mips*tx39-*"] { | |
831 | set timeout 60 | |
c906108c | 832 | } |
7a345fb3 JB |
833 | # We used to set timeout here for all other targets as well. This |
834 | # is almost certainly wrong. The proper timeout depends on the | |
835 | # target system in use, and how we communicate with it, so there | |
836 | # is no single value appropriate for all targets. The timeout | |
837 | # should be established by the Dejagnu config file(s) for the | |
838 | # board, and respected by the test suite. | |
839 | # | |
840 | # For example, if I'm running GDB over an SSH tunnel talking to a | |
841 | # portmaster in California talking to an ancient 68k board running | |
842 | # a crummy ROM monitor (a situation I can only wish were | |
843 | # hypothetical), then I need a large timeout. But that's not the | |
844 | # kind of knowledge that belongs in this file. | |
c906108c SS |
845 | |
846 | gdb_test next "\[0-9\]*\[\t \]+return \\(value\\);.*" \ | |
847 | "next over recursive call" | |
848 | ||
849 | # OK, we should be back in the same stack frame we started from. | |
850 | # Do a backtrace just to confirm. | |
851 | ||
852 | set result [gdb_test "backtrace" \ | |
853 | "#0\[ \t\]+ factorial .value=120.*\r\n#1\[ \t\]+ \[0-9a-fx\]+ in factorial .value=6..*" \ | |
854 | "backtrace from factorial(5.1)"] | |
855 | if { $result != 0 } { gdb_suppress_tests } | |
856 | ||
857 | if [target_info exists gdb,noresults] { gdb_suppress_tests } | |
7a292a7a SS |
858 | gdb_continue_to_end "recursive next test" |
859 | gdb_stop_suppressing_tests; | |
c906108c SS |
860 | } |
861 | ||
c906108c SS |
862 | test_next_with_recursion |
863 | ||
c1790a9d JL |
864 | |
865 | #******** | |
866 | ||
867 | # build a new file with optimization enabled so that we can try breakpoints | |
868 | # on targets with optimized prologues | |
869 | ||
870 | set binfileo2 ${objdir}/${subdir}/${testfile}o2 | |
871 | ||
fc91c6c2 | 872 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}O0.o" object {debug nowarnings optimize=-O2}] != "" } { |
a1dea79a FF |
873 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." |
874 | } | |
875 | ||
fc91c6c2 | 876 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}O1.o" object {debug nowarnings optimize=-O2}] != "" } { |
a1dea79a FF |
877 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." |
878 | } | |
879 | ||
fc91c6c2 | 880 | if { [gdb_compile "${binfile}O0.o ${binfile}O1.o" "${binfileo2}" executable {debug nowarnings}] != "" } { |
a1dea79a | 881 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." |
c1790a9d JL |
882 | } |
883 | ||
884 | if [get_compiler_info ${binfileo2}] { | |
885 | return -1 | |
886 | } | |
887 | ||
888 | gdb_exit | |
889 | gdb_start | |
890 | gdb_reinitialize_dir $srcdir/$subdir | |
891 | gdb_load ${binfileo2} | |
892 | ||
893 | if [target_info exists gdb_stub] { | |
894 | gdb_step_for_stub; | |
895 | } | |
896 | ||
897 | # | |
898 | # test break at function | |
899 | # | |
900 | gdb_test "break main" \ | |
954de43b | 901 | "Breakpoint.*at.* file .*, line.*" \ |
c1790a9d JL |
902 | "breakpoint function, optimized file" |
903 | ||
904 | # | |
905 | # test break at function | |
906 | # | |
907 | gdb_test "break marker4" \ | |
a1dea79a | 908 | "Breakpoint.*at.* file .*$srcfile1, line.*" \ |
c1790a9d JL |
909 | "breakpoint small function, optimized file" |
910 | ||
911 | # | |
912 | # run until the breakpoint at main is hit. For non-stubs-using targets. | |
913 | # | |
914 | if ![target_info exists use_gdb_stub] { | |
915 | if [istarget "*-*-vxworks*"] then { | |
916 | send_gdb "run vxmain \"2\"\n" | |
917 | set timeout 120 | |
918 | verbose "Timeout is now $timeout seconds" 2 | |
919 | } else { | |
920 | send_gdb "run\n" | |
921 | } | |
922 | gdb_expect { | |
923 | -re "The program .* has been started already.*y or n. $" { | |
924 | send_gdb "y\n" | |
925 | exp_continue | |
926 | } | |
a50d3602 | 927 | -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\ |
c1790a9d | 928 | { pass "run until function breakpoint, optimized file" } |
e919ea79 MS |
929 | -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $"\ |
930 | { pass "run until function breakpoint, optimized file (code motion)" } | |
c1790a9d JL |
931 | -re ".*$gdb_prompt $" { fail "run until function breakpoint, optimized file" } |
932 | timeout { fail "run until function breakpoint, optimized file (timeout)" } | |
933 | } | |
934 | } else { | |
935 | if ![target_info exists gdb_stub] { | |
a50d3602 | 936 | gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue, optimized file" |
c1790a9d JL |
937 | } |
938 | } | |
939 | ||
940 | # | |
941 | # run until the breakpoint at a small function | |
942 | # | |
1a570b2f MS |
943 | |
944 | # | |
945 | # Add a second pass pattern. The behavior differs here between stabs | |
946 | # and dwarf for one-line functions. Stabs preserves two line symbols | |
947 | # (one before the prologue and one after) with the same line number, | |
948 | # but dwarf regards these as duplicates and discards one of them. | |
949 | # Therefore the address after the prologue (where the breakpoint is) | |
950 | # has no exactly matching line symbol, and GDB reports the breakpoint | |
951 | # as if it were in the middle of a line rather than at the beginning. | |
952 | ||
a1dea79a FF |
953 | set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1] |
954 | set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1] | |
1a570b2f MS |
955 | send_gdb "continue\n" |
956 | gdb_expect { | |
a1dea79a | 957 | -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" { |
1a570b2f MS |
958 | pass "run until breakpoint set at small function, optimized file" |
959 | } | |
a1dea79a | 960 | -re "Breakpoint $decimal, $hex in marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" { |
1a570b2f MS |
961 | pass "run until breakpoint set at small function, optimized file" |
962 | } | |
a1dea79a | 963 | -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location14\[\r\n\]+$bp_location14\[\t \]+void marker4.*" { |
f1f02ee4 | 964 | # marker4() is defined at line 46 when compiled with -DPROTOTYPES |
a1dea79a | 965 | pass "run until breakpoint set at small function, optimized file (line bp_location14)" |
f1f02ee4 | 966 | } |
1a570b2f MS |
967 | -re ".*$gdb_prompt " { |
968 | fail "run until breakpoint set at small function, optimized file" | |
969 | } | |
970 | timeout { | |
971 | fail "run until breakpoint set at small function, optimized file (timeout)" | |
972 | } | |
973 | } | |
c1790a9d JL |
974 | |
975 | ||
c906108c SS |
976 | # Reset the default arguments for VxWorks |
977 | if [istarget "*-*-vxworks*"] { | |
978 | set timeout 10 | |
979 | verbose "Timeout is now $timeout seconds" 2 | |
980 | send_gdb "set args main\n" | |
981 | gdb_expect -re ".*$gdb_prompt $" {} | |
982 | } |