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