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