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