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