]>
Commit | Line | Data |
---|---|---|
320b6f49 MR |
1 | # Copyright 1988, 1990-1992, 1994-2000, 2002-2003, 2007-2012 Free |
2 | # Software Foundation, Inc. | |
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 3 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, see <http://www.gnu.org/licenses/>. | |
16 | ||
17 | # Based on break.exp by Rob Savoye. (rob@cygnus.com) | |
18 | # Hardware breakpoint support by Maciej W. Rozycki and Daniel Jacobowitz. | |
19 | # Only one hardware breakpoint is set at a time as targets may limit | |
20 | # the number available. | |
21 | ||
22 | ||
23 | if { [prepare_for_testing hbreak2.exp "hbreak2" {break.c break1.c} {debug nowarnings}] } { | |
24 | return -1 | |
25 | } | |
26 | set srcfile break.c | |
27 | set srcfile1 break1.c | |
28 | ||
29 | if ![runto_main] then { fail "break tests suppressed" } | |
30 | delete_breakpoints | |
31 | ||
32 | # | |
33 | # Test whether the target supports hardware breakpoints at all. | |
34 | # | |
35 | gdb_test_multiple "hbreak main" "hardware breakpoint support" { | |
36 | -re "No hardware breakpoint support in the target.*$gdb_prompt $" { | |
37 | unsupported "hardware breakpoints" | |
38 | return | |
39 | } | |
40 | -re "Hardware breakpoints used exceeds limit.*$gdb_prompt $" { | |
41 | unsupported "hardware breakpoints" | |
42 | return | |
43 | } | |
44 | -re "Hardware assisted breakpoint.*at.* file .*$srcfile, line.*$gdb_prompt $" { | |
45 | pass "hardware breakpoint support" | |
46 | } | |
47 | } | |
48 | gdb_run_cmd | |
49 | gdb_test_multiple "" "hardware breakpoint insertion" { | |
50 | -re "Warning:\[\r\n\]+Cannot insert hardware breakpoint \[0-9\]+\.\[\r\n\]+Could not insert hardware breakpoints:\[\r\n\]+You may have requested too many hardware breakpoints/watchpoints\.\[\r\n\]+.*$gdb_prompt $" { | |
51 | unsupported "hardware breakpoint insertion" | |
52 | return | |
53 | } | |
54 | -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:.*\[\r\n\]+.*\[\t \]+if .argc.* \{.*$gdb_prompt $" { | |
55 | pass "hardware breakpoint insertion" | |
56 | } | |
57 | } | |
58 | delete_breakpoints | |
59 | ||
60 | # | |
61 | # Test simple hardware breakpoint setting commands. | |
62 | # | |
63 | ||
64 | # | |
65 | # Test break at function. | |
66 | # | |
67 | gdb_test "hbreak main" \ | |
68 | "Hardware assisted breakpoint.*at.* file .*$srcfile, line.*" \ | |
69 | "hardware breakpoint function" | |
70 | delete_breakpoints | |
71 | ||
72 | # | |
73 | # Test break at quoted function. | |
74 | # | |
75 | gdb_test "hbreak \"marker2\"" \ | |
76 | "Hardware assisted breakpoint.*at.* file .*$srcfile1, line.*" \ | |
77 | "hardware breakpoint quoted function" | |
78 | delete_breakpoints | |
79 | ||
80 | # | |
81 | # Test break at function in file. | |
82 | # | |
83 | gdb_test "hbreak $srcfile:factorial" \ | |
84 | "Hardware assisted breakpoint.*at.* file .*$srcfile, line.*" \ | |
85 | "hardware breakpoint function in file" | |
86 | delete_breakpoints | |
87 | ||
88 | set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] | |
89 | ||
90 | # | |
91 | # Test break at line number. | |
92 | # | |
93 | # Note that the default source file is the last one whose source text | |
94 | # was printed. For native debugging, before we've executed the | |
95 | # program, this is the file containing main, but for remote debugging, | |
96 | # it's wherever the processor was stopped when we connected to the | |
97 | # board. So, to be sure, we do a list command. | |
98 | # | |
99 | gdb_test "list main" \ | |
100 | ".*main \\(argc, argv, envp\\).*" \ | |
101 | "use `list' to establish default source file" | |
102 | gdb_test "hbreak $bp_location1" \ | |
103 | "Hardware assisted breakpoint.*at.* file .*$srcfile, line $bp_location1\\." \ | |
104 | "hardware breakpoint line number" | |
105 | delete_breakpoints | |
106 | ||
107 | set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] | |
108 | ||
109 | # | |
110 | # Test break at line number in file. | |
111 | # | |
112 | gdb_test "hbreak $srcfile:$bp_location2" \ | |
113 | "Hardware assisted breakpoint.*at.* file .*$srcfile, line $bp_location2\\." \ | |
114 | "hardware breakpoint line number in file" | |
115 | delete_breakpoints | |
116 | ||
117 | set bp_location3 [gdb_get_line_number "set breakpoint 3 here"] | |
118 | set bp_location4 [gdb_get_line_number "set breakpoint 4 here"] | |
119 | ||
120 | # | |
121 | # Test putting a break at the start of a multi-line if conditional. | |
122 | # Verify the breakpoint was put at the start of the conditional. | |
123 | # | |
124 | gdb_test "hbreak multi_line_if_conditional" \ | |
125 | "Hardware assisted breakpoint.*at.* file .*$srcfile, line $bp_location3\\." \ | |
126 | "hardware breakpoint at start of multi line if conditional" | |
127 | delete_breakpoints | |
128 | ||
129 | gdb_test "hbreak multi_line_while_conditional" \ | |
130 | "Hardware assisted breakpoint.*at.* file .*$srcfile, line $bp_location4\\." \ | |
131 | "hardware breakpoint at start of multi line while conditional" | |
132 | ||
133 | set bp_location5 [gdb_get_line_number "set breakpoint 5 here"] | |
134 | set bp_location6 [gdb_get_line_number "set breakpoint 6 here"] | |
135 | ||
136 | set main_line $bp_location6 | |
137 | ||
138 | if {$hp_aCC_compiler} { | |
139 | set proto "\\(int\\)" | |
140 | } else { | |
141 | set proto "" | |
142 | } | |
143 | ||
144 | set bp_location7 [gdb_get_line_number "set breakpoint 7 here"] | |
145 | set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1] | |
146 | set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1] | |
147 | ||
148 | gdb_test "info break" \ | |
149 | "Num Type\[ \]+Disp Enb Address\[ \]+What.* | |
150 | \[0-9\]+\[\t \]+hw breakpoint keep y.* in multi_line_while_conditional at .*$srcfile:$bp_location4" \ | |
151 | "hardware breakpoint info" | |
152 | delete_breakpoints | |
153 | ||
154 | # | |
155 | # Run until the breakpoint at main is hit. For non-stubs-using targets. | |
156 | # | |
157 | gdb_test "hbreak main" \ | |
158 | "Hardware assisted breakpoint.*at.* file .*$srcfile, line.*" \ | |
159 | "hardware breakpoint function (2)" | |
160 | gdb_run_cmd | |
161 | gdb_test "" \ | |
162 | "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*" \ | |
163 | "run until function breakpoint" | |
164 | delete_breakpoints | |
165 | ||
166 | # | |
167 | # Run until the breakpoint at a line number. | |
168 | # | |
169 | gdb_test "hbreak $bp_location1" \ | |
170 | "Hardware assisted breakpoint.*at.* file .*$srcfile, line $bp_location1\\." \ | |
171 | "hardware breakpoint line number (2)" | |
172 | gdb_test "continue" \ | |
173 | "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location1.*$bp_location1\[\t \]+printf.*factorial.*" \ | |
174 | "run until breakpoint set at a line number" | |
175 | delete_breakpoints | |
176 | ||
177 | # | |
178 | # Run until the breakpoint set in a function in a file. | |
179 | # | |
180 | gdb_test "hbreak $srcfile:factorial" \ | |
181 | "Hardware assisted breakpoint.*at.* file .*$srcfile, line.*" \ | |
182 | "hardware breakpoint function in file (2)" | |
183 | for {set i 6} {$i >= 1} {incr i -1} { | |
184 | gdb_test "continue" \ | |
185 | "Continuing\\..*Breakpoint \[0-9\]+, factorial \\(value=$i\\) at .*$srcfile:$bp_location7.*$bp_location7\[\t \]+.*if .value > 1. \{.*" \ | |
186 | "run until file:function($i) breakpoint" | |
187 | } | |
188 | delete_breakpoints | |
189 | ||
190 | # | |
191 | # Run until the breakpoint set at a quoted function. | |
192 | # | |
193 | gdb_test "hbreak \"marker2\"" \ | |
194 | "Hardware assisted breakpoint.*at.* file .*$srcfile1, line.*" \ | |
195 | "hardware breakpoint quoted function (2)" | |
196 | gdb_test "continue" \ | |
197 | "Continuing\\..*Breakpoint \[0-9\]+, (0x\[0-9a-f\]+ in )?marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*" \ | |
198 | "run until quoted breakpoint" | |
199 | delete_breakpoints | |
200 | # | |
201 | # Run until the file:function breakpoint at a line number in a file. | |
202 | # | |
203 | gdb_test "hbreak $srcfile:$bp_location2" \ | |
204 | "Hardware assisted breakpoint.*at.* file .*$srcfile, line $bp_location2\\." \ | |
205 | "hardware breakpoint line number in file (2)" | |
206 | gdb_test "continue" \ | |
207 | "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location2.*$bp_location2\[\t \]+argc = \\(argc == 12345\\);.*" \ | |
208 | "run until file:linenum breakpoint" | |
209 | delete_breakpoints | |
210 | ||
211 | # Test break at offset +1. | |
212 | set bp_location10 [gdb_get_line_number "set breakpoint 10 here"] | |
213 | ||
214 | gdb_test "hbreak +1" \ | |
215 | "Hardware assisted breakpoint.*at.* file .*$srcfile, line $bp_location10\\." \ | |
216 | "hardware breakpoint offset +1" | |
217 | ||
218 | # Check to see if breakpoint is hit when stepped onto. | |
219 | ||
220 | gdb_test "step" \ | |
221 | ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location10.*$bp_location10\[\t \]+return argc;.*breakpoint 10 here.*" \ | |
222 | "step onto hardware breakpoint" | |
223 | delete_breakpoints | |
224 | ||
225 | # Check to see if breakpoint can be set on ending brace of function. | |
226 | set bp_location10a [gdb_get_line_number "set breakpoint 10a here"] | |
227 | ||
228 | gdb_test "hbreak $bp_location10a" \ | |
229 | "Hardware assisted breakpoint.*at.* file .*$srcfile, line $bp_location10a\\." \ | |
230 | "setting hardware breakpoint at }" | |
231 | ||
232 | gdb_test "continue" \ | |
233 | ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location10a.*$bp_location10a\[\t \]+}.*breakpoint 10a here.*" \ | |
234 | "continue to hardware breakpoint at }" | |
235 | ||
236 | # | |
237 | # Delete all breakpoints so we can start over, course this can be a test too. | |
238 | # | |
239 | delete_breakpoints | |
240 | ||
241 | # | |
242 | # Test temporary breakpoint at function. | |
243 | # | |
244 | ||
245 | gdb_test "thbreak main" \ | |
246 | "Hardware assisted breakpoint.*at.* file .*$srcfile, line.*" \ | |
247 | "temporary hardware breakpoint function" | |
248 | delete_breakpoints | |
249 | ||
250 | # | |
251 | # Test break at function in file. | |
252 | # | |
253 | ||
254 | gdb_test "thbreak $srcfile:factorial" \ | |
255 | "Hardware assisted breakpoint.*at.* file .*$srcfile, line.*" \ | |
256 | "temporary hardware breakpoint function in file" | |
257 | delete_breakpoints | |
258 | ||
259 | # | |
260 | # Test break at line number. | |
261 | # | |
262 | gdb_test "thbreak $bp_location1" \ | |
263 | "Hardware assisted breakpoint.*at.* file .*$srcfile, line $bp_location1.*" \ | |
264 | "temporary hardware breakpoint line number #1" | |
265 | delete_breakpoints | |
266 | ||
267 | gdb_test "thbreak $bp_location6" \ | |
268 | "Hardware assisted breakpoint.*at.* file .*$srcfile, line $bp_location6.*" \ | |
269 | "temporary hardware breakpoint line number #2" | |
270 | delete_breakpoints | |
271 | ||
272 | # | |
273 | # Test break at line number in file. | |
274 | # | |
275 | gdb_test "thbreak $srcfile:$bp_location2" \ | |
276 | "Hardware assisted breakpoint.*at.* file .*$srcfile, line $bp_location2.*" \ | |
277 | "temporary hardware breakpoint line number in file #1" | |
278 | delete_breakpoints | |
279 | ||
280 | set bp_location11 [gdb_get_line_number "set breakpoint 11 here"] | |
281 | gdb_test "thbreak $srcfile:$bp_location11" \ | |
282 | "Hardware assisted breakpoint.*at.* file .*$srcfile, line $bp_location11.*" \ | |
283 | "temporary hardware breakpoint line number in file #2" | |
284 | ||
285 | # | |
286 | # Check to see what breakpoints are set (temporary this time). | |
287 | # | |
288 | gdb_test "info break" \ | |
289 | "Num Type.*Disp Enb Address.*What.*\[\r\n\] | |
290 | \[0-9\]+\[\t \]+hw breakpoint del.*y.*in main at .*$srcfile:$bp_location11.*" \ | |
291 | "temporary hardware breakpoint info" | |
292 | ||
293 | ||
294 | #*********** | |
295 | ||
296 | if ![runto_main] then { fail "break tests suppressed" } | |
297 | ||
298 | # Verify that GDB responds gracefully when asked to set a breakpoint | |
299 | # on a nonexistent source line. | |
300 | # | |
301 | gdb_test_no_output "set breakpoint pending off" | |
302 | gdb_test "hbreak 999" \ | |
303 | "No line 999 in the current file." \ | |
304 | "hardware break on non-existent source line" | |
305 | ||
306 | # Run to the desired default location. If not positioned here, the | |
307 | # tests below don't work. | |
308 | # | |
309 | gdb_test "until $bp_location1" "main .* at .*:$bp_location1.*" \ | |
310 | "until bp_location1" | |
311 | ||
312 | ||
313 | # Verify that GDB allows one to just say "hbreak", which is treated | |
314 | # as the "default" breakpoint. | |
315 | # | |
316 | gdb_test "hbreak" "Hardware assisted breakpoint \[0-9\]*.*" \ | |
317 | "hardware break on default location" | |
318 | ||
319 | # Verify that a "silent" breakpoint can be set, and that GDB is indeed | |
320 | # "silent" about its triggering. | |
321 | # | |
322 | if ![runto_main] then { fail "break tests suppressed" } | |
323 | ||
324 | gdb_test_multiple "hbreak $bp_location1" \ | |
325 | "set to-be-silent hardware break bp_location1" { | |
326 | -re "Hardware assisted breakpoint (\[0-9\]*) at .*, line $bp_location1.*$gdb_prompt $" { | |
327 | pass "set to-be-silent hardware break bp_location1" | |
328 | } | |
329 | } | |
330 | ||
331 | gdb_test "commands $expect_out(1,string)\nsilent\nend" ">end" "set silent break bp_location1" | |
332 | ||
333 | gdb_test "info break $expect_out(1,string)" \ | |
334 | "\[0-9\]*\[ \t\]*hw breakpoint.*:$bp_location1\r\n\[ \t\]*silent.*" \ | |
335 | "info silent hardware break bp_location1" | |
336 | ||
337 | gdb_test "continue" "Continuing." \ | |
338 | "hit silent hardware break bp_location1" | |
339 | ||
340 | gdb_test "bt" "#0 main .* at .*:$bp_location1.*" \ | |
341 | "stopped for silent hardware break bp_location1" | |
342 | ||
343 | # Verify that GDB can at least parse a breakpoint with the | |
344 | # "thread" keyword. (We won't attempt to test here that a | |
345 | # thread-specific breakpoint really triggers appropriately. | |
346 | # The gdb.threads subdirectory contains tests for that.) | |
347 | # | |
348 | set bp_location12 [gdb_get_line_number "set breakpoint 12 here"] | |
349 | gdb_test "hbreak $bp_location12 thread 999" "Unknown thread 999.*" \ | |
350 | "thread-specific hardware breakpoint on non-existent thread disallowed" | |
351 | ||
352 | gdb_test "hbreak $bp_location12 thread foo" \ | |
353 | "Junk after thread keyword.*" \ | |
354 | "thread-specific hardware breakpoint on bogus thread ID disallowed" | |
355 | ||
356 | # Verify that GDB responds gracefully to a breakpoint command with | |
357 | # trailing garbage. | |
358 | # | |
359 | gdb_test "hbreak $bp_location12 foo" \ | |
360 | "Junk at end of arguments.*" \ | |
361 | "hardware breakpoint with trailing garbage disallowed" | |
362 | ||
363 | # Verify that GDB responds gracefully to a "clear" command that has | |
364 | # no matching breakpoint. (First, get us off the current source line, | |
365 | # which we know has a breakpoint.) | |
366 | # | |
367 | gdb_test "next" "marker1.*" "step over hardware breakpoint" | |
368 | ||
369 | gdb_test "clear 81" "No breakpoint at 81.*" \ | |
370 | "clear line has no breakpoint disallowed" | |
371 | ||
372 | gdb_test "clear" "No breakpoint at this line.*" \ | |
373 | "clear current line has no breakpoint disallowed" | |
374 | delete_breakpoints | |
375 | ||
376 | # Verify that a breakpoint can be set via a convenience variable. | |
377 | # | |
378 | gdb_test_no_output "set \$foo=$bp_location11" \ | |
379 | "set convenience variable \$foo to bp_location11" | |
380 | ||
381 | gdb_test "hbreak \$foo" \ | |
382 | "Hardware assisted breakpoint (\[0-9\]*) at .*, line $bp_location11.*" \ | |
383 | "set hardware breakpoint via convenience variable" | |
384 | delete_breakpoints | |
385 | ||
386 | # Verify that GDB responds gracefully to an attempt to set a | |
387 | # breakpoint via a convenience variable whose type is not integer. | |
388 | # | |
389 | gdb_test_no_output "set \$foo=81.5" \ | |
390 | "set convenience variable \$foo to 81.5" | |
391 | ||
392 | gdb_test "hbreak \$foo" \ | |
393 | "Convenience variables used in line specs must have integer values.*" \ | |
394 | "set hardware breakpoint via non-integer convenience variable disallowed" | |
395 | ||
396 | # Verify that we can set and trigger a breakpoint in a user-called function. | |
397 | # | |
398 | gdb_test "hbreak marker2" \ | |
399 | "Hardware assisted breakpoint (\[0-9\]*) at .*, line ($bp_location8|$bp_location9).*" \ | |
400 | "set hardware breakpoint on to-be-called function" | |
401 | ||
402 | gdb_test "print marker2(99)" \ | |
403 | "The program being debugged stopped while in a function called from GDB.\r\nEvaluation of the expression containing the function\r\n.marker2$proto. will be abandoned.\r\nWhen the function is done executing, GDB will silently stop.*" \ | |
404 | "hit hardware breakpoint on called function" | |
405 | ||
406 | # As long as we're stopped (breakpointed) in a called function, | |
407 | # verify that we can successfully backtrace & such from here. | |
408 | # | |
409 | # In this and the following test, the _sr4export check apparently is needed | |
410 | # for hppa*-*-hpux. | |
411 | # | |
412 | gdb_test_multiple "bt" "backtrace while in called function" { | |
413 | -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*_sr4export.*$gdb_prompt $" { | |
414 | pass "backtrace while in called function" | |
415 | } | |
416 | -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*function called from gdb.*$gdb_prompt $" { | |
417 | pass "backtrace while in called function" | |
418 | } | |
419 | } | |
420 | ||
421 | # Return from the called function. For remote targets, it's important to do | |
422 | # this before runto_main, which otherwise may silently stop on the dummy | |
423 | # breakpoint inserted by GDB at the program's entry point. | |
424 | # | |
425 | gdb_test_multiple "finish" "finish from called function" { | |
426 | -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.* in _sr4export.*$gdb_prompt $" { | |
427 | pass "finish from called function" | |
428 | } | |
429 | -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*function called from gdb.*$gdb_prompt $" { | |
430 | pass "finish from called function" | |
431 | } | |
432 | -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*Value returned.*$gdb_prompt $" { | |
433 | pass "finish from called function" | |
434 | } | |
435 | } | |
436 | ||
437 | #******** | |
438 | ||
439 | ||
440 | # | |
441 | # Test "next" over recursive function call. | |
442 | # | |
443 | ||
444 | proc test_next_with_recursion {} { | |
445 | global gdb_prompt | |
446 | global decimal | |
447 | global binfile | |
448 | ||
449 | delete_breakpoints | |
450 | ||
451 | # Can't set a hardware breakpoint without a live target, so do it now | |
452 | # before it's killed below. | |
453 | gdb_test "hbreak factorial" \ | |
454 | "Hardware assisted breakpoint $decimal at .*" \ | |
455 | "hardware break at factorial" | |
456 | ||
457 | gdb_test "kill" "" "kill program" \ | |
458 | "Kill the program being debugged.*y or n. $" "y" | |
459 | ||
460 | # Run until we call factorial with 6 | |
461 | ||
462 | gdb_run_cmd | |
463 | if [gdb_test "" \ | |
464 | "Break.* factorial .value=6. .*" \ | |
465 | "run to factorial(6)"] then { gdb_suppress_tests } | |
466 | ||
467 | # Continue until we call factorial recursively with 5. | |
468 | ||
469 | if [gdb_test "continue" \ | |
470 | "Continuing.*Break.* factorial .value=5. .*" \ | |
471 | "continue to factorial(5)"] then { gdb_suppress_tests } | |
472 | ||
473 | # Do a backtrace just to confirm how many levels deep we are. | |
474 | ||
475 | if [gdb_test "backtrace" \ | |
476 | "#0\[ \t\]+ factorial .value=5..*" \ | |
477 | "backtrace from factorial(5)"] then { gdb_suppress_tests } | |
478 | ||
479 | # Now a "next" should position us at the recursive call, which | |
480 | # we will be performing with 4. | |
481 | ||
482 | if [gdb_test "next" \ | |
483 | ".* factorial .value - 1.;.*" \ | |
484 | "next to recursive call"] then { gdb_suppress_tests } | |
485 | ||
486 | # Disable the breakpoint at the entry to factorial by deleting them all. | |
487 | # The "next" should run until we return to the next line from this | |
488 | # recursive call to factorial with 4. | |
489 | # Buggy versions of gdb will stop instead at the innermost frame on | |
490 | # the line where we are trying to "next" to. | |
491 | ||
492 | delete_breakpoints | |
493 | ||
494 | if [istarget "mips*tx39-*"] { | |
495 | set timeout 60 | |
496 | } | |
497 | # We used to set timeout here for all other targets as well. This | |
498 | # is almost certainly wrong. The proper timeout depends on the | |
499 | # target system in use, and how we communicate with it, so there | |
500 | # is no single value appropriate for all targets. The timeout | |
501 | # should be established by the Dejagnu config file(s) for the | |
502 | # board, and respected by the test suite. | |
503 | # | |
504 | # For example, if I'm running GDB over an SSH tunnel talking to a | |
505 | # portmaster in California talking to an ancient 68k board running | |
506 | # a crummy ROM monitor (a situation I can only wish were | |
507 | # hypothetical), then I need a large timeout. But that's not the | |
508 | # kind of knowledge that belongs in this file. | |
509 | ||
510 | gdb_test next "\[0-9\]*\[\t \]+return \\(value\\);.*" \ | |
511 | "next over recursive call" | |
512 | ||
513 | # OK, we should be back in the same stack frame we started from. | |
514 | # Do a backtrace just to confirm. | |
515 | ||
516 | set result [gdb_test "backtrace" \ | |
517 | "#0\[ \t\]+ factorial .value=120.*\r\n#1\[ \t\]+ \[0-9a-fx\]+ in factorial .value=6..*" \ | |
518 | "backtrace from factorial(5.1)"] | |
519 | if { $result != 0 } { gdb_suppress_tests } | |
520 | ||
521 | if [target_info exists gdb,noresults] { gdb_suppress_tests } | |
522 | gdb_continue_to_end "recursive next test" | |
523 | gdb_stop_suppressing_tests; | |
524 | } | |
525 | ||
526 | test_next_with_recursion | |
527 | ||
528 | ||
529 | #******** | |
530 | ||
531 | # Build a new file with optimization enabled so that we can try breakpoints | |
532 | # on targets with optimized prologues. | |
533 | ||
534 | if { [prepare_for_testing hbreak2.exp "hbreak2o2" {break.c break1.c} {debug nowarnings optimize=-O2}] } { | |
535 | return -1 | |
536 | } | |
537 | ||
538 | if ![runto_main] then { fail "break tests suppressed" } | |
539 | delete_breakpoints | |
540 | ||
541 | # | |
542 | # Test break at function. | |
543 | # | |
544 | gdb_test "hbreak main" \ | |
545 | "Hardware assisted breakpoint.*at.* file .*, line.*" \ | |
546 | "hardware breakpoint function, optimized file" | |
547 | ||
548 | # | |
549 | # Run until the breakpoint at main is hit. For non-stubs-using targets. | |
550 | # | |
551 | gdb_run_cmd | |
552 | gdb_test_multiple "" "run until hardware function breakpoint, optimized file" { | |
553 | -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $" { | |
554 | pass "run until hardware function breakpoint, optimized file" | |
555 | } | |
556 | -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $" { | |
557 | pass "run until hardware function breakpoint, optimized file (code motion)" | |
558 | } | |
559 | } | |
560 | delete_breakpoints | |
561 | ||
562 | # | |
563 | # Test break at function. | |
564 | # | |
565 | gdb_test "hbreak marker4" \ | |
566 | "Hardware assisted breakpoint.*at.* file .*$srcfile1, line.*" \ | |
567 | "hardware breakpoint small function, optimized file" | |
568 | ||
569 | # | |
570 | # Run until the breakpoint at a small function. | |
571 | # | |
572 | ||
573 | # | |
574 | # Add a second pass pattern. The behavior differs here between stabs | |
575 | # and dwarf for one-line functions. Stabs preserves two line symbols | |
576 | # (one before the prologue and one after) with the same line number, | |
577 | # but dwarf regards these as duplicates and discards one of them. | |
578 | # Therefore the address after the prologue (where the breakpoint is) | |
579 | # has no exactly matching line symbol, and GDB reports the breakpoint | |
580 | # as if it were in the middle of a line rather than at the beginning. | |
581 | ||
582 | set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1] | |
583 | set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1] | |
584 | ||
585 | gdb_test_multiple "continue" \ | |
586 | "run until hardware breakpoint set at small function, optimized file" { | |
587 | -re "Breakpoint $decimal, marker4 \\(d=(d@entry=)?177601976\\) at .*$srcfile1:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" { | |
588 | pass "run until hardware breakpoint set at small function, optimized file" | |
589 | } | |
590 | -re "Breakpoint $decimal, $hex in marker4 \\(d=(d@entry=)?177601976\\) at .*$srcfile1:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" { | |
591 | pass "run until hardware breakpoint set at small function, optimized file" | |
592 | } | |
593 | -re "Breakpoint $decimal, marker4 \\(d=(d@entry=)?177601976\\) at .*$srcfile1:$bp_location14\[\r\n\]+$bp_location14\[\t \]+void marker4.*" { | |
594 | # marker4() is defined at line 46 when compiled with -DPROTOTYPES | |
595 | pass "run until hardware breakpoint set at small function, optimized file (line bp_location14)" | |
596 | } | |
597 | -re "Breakpoint $decimal, factorial \\(.*\\) .*\{\r\n$gdb_prompt" { | |
598 | # GCC 4.3 emits bad line number information - see gcc/36748. | |
599 | if { [test_compiler_info "gcc-4-3-*"] } { | |
600 | setup_xfail *-*-* | |
601 | } | |
602 | fail "run until hardware breakpoint set at small function, optimized file" | |
603 | } | |
604 | } |