📄 sepdebug.exp
字号:
gdb_expect { -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*_sr4export.*$gdb_prompt $"\ {pass "backtrace while in called function"} -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*function called from gdb.*$gdb_prompt $"\ {pass "backtrace while in called function"} -re "$gdb_prompt $"\ {fail "backtrace while in called function"} timeout {fail "(timeout) backtrace while in called function"}}# Return from the called function. For remote targets, it's important to do# this before runto_main, which otherwise may silently stop on the dummy# breakpoint inserted by GDB at the program's entry point.#send_gdb "finish\n"gdb_expect { -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.* in _sr4export.*$gdb_prompt $"\ {pass "finish from called function"} -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*function called from gdb.*$gdb_prompt $"\ {pass "finish from called function"} -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*Value returned.*$gdb_prompt $"\ {pass "finish from called function"} -re "$gdb_prompt $"\ {fail "finish from called function"} timeout {fail "(timeout) finish from called function"}}# Verify that GDB responds gracefully to a "finish" command with# arguments.#if ![runto_main] then { fail "break tests suppressed" }send_gdb "finish 123\n"gdb_expect { -re "The \"finish\" command does not take any arguments.\r\n$gdb_prompt $"\ {pass "finish with arguments disallowed"} -re "$gdb_prompt $"\ {fail "finish with arguments disallowed"} timeout {fail "(timeout) finish with arguments disallowed"}}# Verify that GDB responds gracefully to a request to "finish" from# the outermost frame. On a stub that never exits, this will just# run to the stubs routine, so we don't get this error... Thus the # second condition.#send_gdb "finish\n"gdb_expect { -re "\"finish\" not meaningful in the outermost frame.\r\n$gdb_prompt $"\ {pass "finish from outermost frame disallowed"} -re "Run till exit from.*\r\n$gdb_prompt $" { pass "finish from outermost frame disallowed" } -re "$gdb_prompt $"\ {fail "finish from outermost frame disallowed"} timeout {fail "(timeout) finish from outermost frame disallowed"}}# Verify that we can explicitly ask GDB to stop on all shared library# events, and that it does so.#if [istarget "hppa*-*-hpux*"] then { if ![runto_main] then { fail "break tests suppressed" } send_gdb "set stop-on-solib-events 1\n" gdb_expect { -re "$gdb_prompt $"\ {pass "set stop-on-solib-events"} timeout {fail "(timeout) set stop-on-solib-events"} } send_gdb "run\n" gdb_expect { -re ".*Start it from the beginning.*y or n. $"\ {send_gdb "y\n" gdb_expect { -re ".*Stopped due to shared library event.*$gdb_prompt $"\ {pass "triggered stop-on-solib-events"} -re "$gdb_prompt $"\ {fail "triggered stop-on-solib-events"} timeout {fail "(timeout) triggered stop-on-solib-events"} } } -re "$gdb_prompt $"\ {fail "rerun for stop-on-solib-events"} timeout {fail "(timeout) rerun for stop-on-solib-events"} } send_gdb "set stop-on-solib-events 0\n" gdb_expect { -re "$gdb_prompt $"\ {pass "reset stop-on-solib-events"} timeout {fail "(timeout) reset stop-on-solib-events"} }}# Hardware breakpoints are unsupported on HP-UX. Verify that GDB# gracefully responds to requests to create them.#if [istarget "hppa*-*-hpux*"] then { if ![runto_main] then { fail "break tests suppressed" } send_gdb "hbreak\n" gdb_expect { -re "No hardware breakpoint support in the target.*$gdb_prompt $"\ {pass "hw breaks disallowed"} -re "$gdb_prompt $"\ {fail "hw breaks disallowed"} timeout {fail "(timeout) hw breaks disallowed"} } send_gdb "thbreak\n" gdb_expect { -re "No hardware breakpoint support in the target.*$gdb_prompt $"\ {pass "temporary hw breaks disallowed"} -re "$gdb_prompt $"\ {fail "temporary hw breaks disallowed"} timeout {fail "(timeout) temporary hw breaks disallowed"} }}#********## Test "next" over recursive function call.#proc test_next_with_recursion {} { global gdb_prompt global decimal global binfile if [target_info exists use_gdb_stub] { # Reload the program. delete_breakpoints gdb_load ${binfile}; } else { # FIXME: should be using runto gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y" delete_breakpoints } gdb_test "break factorial" "Breakpoint $decimal at .*" "break at factorial" # Run until we call factorial with 6 if [istarget "*-*-vxworks*"] then { send_gdb "run vxmain \"6\"\n" } else { gdb_run_cmd } gdb_expect { -re "Break.* factorial .value=6. .*$gdb_prompt $" {} -re ".*$gdb_prompt $" { fail "run to factorial(6)"; gdb_suppress_tests; } timeout { fail "run to factorial(6) (timeout)" ; gdb_suppress_tests } } # Continue until we call factorial recursively with 5. if [gdb_test "continue" \ "Continuing.*Break.* factorial .value=5. .*" \ "continue to factorial(5)"] then { gdb_suppress_tests } # Do a backtrace just to confirm how many levels deep we are. if [gdb_test "backtrace" \ "#0\[ \t\]+ factorial .value=5..*" \ "backtrace from factorial(5)"] then { gdb_suppress_tests } # Now a "next" should position us at the recursive call, which # we will be performing with 4. if [gdb_test "next" \ ".* factorial .value - 1.;.*" \ "next to recursive call"] then { gdb_suppress_tests } # Disable the breakpoint at the entry to factorial by deleting them all. # The "next" should run until we return to the next line from this # recursive call to factorial with 4. # Buggy versions of gdb will stop instead at the innermost frame on # the line where we are trying to "next" to. delete_breakpoints if [istarget "mips*tx39-*"] { set timeout 60 } # We used to set timeout here for all other targets as well. This # is almost certainly wrong. The proper timeout depends on the # target system in use, and how we communicate with it, so there # is no single value appropriate for all targets. The timeout # should be established by the Dejagnu config file(s) for the # board, and respected by the test suite. # # For example, if I'm running GDB over an SSH tunnel talking to a # portmaster in California talking to an ancient 68k board running # a crummy ROM monitor (a situation I can only wish were # hypothetical), then I need a large timeout. But that's not the # kind of knowledge that belongs in this file. gdb_test next "\[0-9\]*\[\t \]+return \\(value\\);.*" \ "next over recursive call" # OK, we should be back in the same stack frame we started from. # Do a backtrace just to confirm. set result [gdb_test "backtrace" \ "#0\[ \t\]+ factorial .value=120.*\r\n#1\[ \t\]+ \[0-9a-fx\]+ in factorial .value=6..*" \ "backtrace from factorial(5.1)"] if { $result != 0 } { gdb_suppress_tests } if [target_info exists gdb,noresults] { gdb_suppress_tests } gdb_continue_to_end "recursive next test" gdb_stop_suppressing_tests;}test_next_with_recursion#********# now move the .debug file to a different location so that we can test# the "set debug-file-directory" command. remote_exec build "mv ${objdir}/${subdir}/.debug/${testfile}.debug ${objdir}/${subdir}"gdb_exitgdb_startgdb_reinitialize_dir $srcdir/$subdirgdb_test "set debug-file-directory ${objdir}/${subdir}" ".*" "set separate debug location"gdb_load ${binfile}if [target_info exists gdb_stub] { gdb_step_for_stub;}## test break at function#gdb_test "break main" \ "Breakpoint.*at.* file .*$srcfile, line.*" \ "breakpoint function, optimized file"## test break at function#gdb_test "break marker4" \ "Breakpoint.*at.* file .*$srcfile, line.*" \ "breakpoint small function, optimized file"## run until the breakpoint at main is hit. For non-stubs-using targets.#if ![target_info exists use_gdb_stub] { if [istarget "*-*-vxworks*"] then { send_gdb "run vxmain \"2\"\n" set timeout 120 verbose "Timeout is now $timeout seconds" 2 } else { send_gdb "run\n" } gdb_expect { -re "The program .* has been started already.*y or n. $" { send_gdb "y\n" exp_continue } -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\ { pass "run until function breakpoint, optimized file" } -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $"\ { pass "run until function breakpoint, optimized file (code motion)" } -re ".*$gdb_prompt $" { fail "run until function breakpoint, optimized file" } timeout { fail "run until function breakpoint, optimized file (timeout)" } }} else { if ![target_info exists gdb_stub] { gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue, optimized file" }}## run until the breakpoint at a small function### Add a second pass pattern. The behavior differs here between stabs# and dwarf for one-line functions. Stabs preserves two line symbols# (one before the prologue and one after) with the same line number, # but dwarf regards these as duplicates and discards one of them.# Therefore the address after the prologue (where the breakpoint is)# has no exactly matching line symbol, and GDB reports the breakpoint# as if it were in the middle of a line rather than at the beginning.set bp_location13 [gdb_get_line_number "set breakpoint 13 here"]set bp_location14 [gdb_get_line_number "set breakpoint 14 here"]send_gdb "continue\n"gdb_expect { -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" { pass "run until breakpoint set at small function, optimized file" } -re "Breakpoint $decimal, $hex in marker4 \\(d=177601976\\) at .*$srcfile:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" { pass "run until breakpoint set at small function, optimized file" } -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile:$bp_location14\[\r\n\]+$bp_location14\[\t \]+void marker4.*" { # marker4() is defined at line 46 when compiled with -DPROTOTYPES pass "run until breakpoint set at small function, optimized file (line bp_location14)" } -re ".*$gdb_prompt " { fail "run until breakpoint set at small function, optimized file" } timeout { fail "run until breakpoint set at small function, optimized file (timeout)" }}# Reset the default arguments for VxWorksif [istarget "*-*-vxworks*"] { set timeout 10 verbose "Timeout is now $timeout seconds" 2 send_gdb "set args main\n" gdb_expect -re ".*$gdb_prompt $" {}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -