📄 sepdebug.exp
字号:
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 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 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#********proc test_different_dir {type test_different_dir xfail} { global srcdir subdir objdir binfile srcfile timeout gdb_prompt global pf_prefix global bp_location6 decimal hex set old_pf_prefix $pf_prefix append pf_prefix " $type:" gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_test "set debug-file-directory ${test_different_dir}" ".*" "set separate debug location" gdb_load ${binfile} if [target_info exists gdb_stub] { gdb_step_for_stub; } # # test break at function # if {$xfail} { setup_xfail "*-*-*" } gdb_test "break main" \ "Breakpoint.*at.* file .*$srcfile, line.*" \ "breakpoint function, optimized file" # # test break at function # if {$xfail} { setup_xfail "*-*-*" } 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. # gdb_run_cmd if {$xfail} { setup_xfail "*-*-*" } gdb_expect { -re "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 "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)" } } # # 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" if {$xfail} { setup_xfail "*-*-*" } 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 VxWorks if [istarget "*-*-vxworks*"] { set timeout 10 verbose "Timeout is now $timeout seconds" 2 send_gdb "set args main\n" gdb_expect -re ".*$gdb_prompt $" {} } set pf_prefix $old_pf_prefix# proc test_different_dir}# 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}"set debugfile "${objdir}/${subdir}/${testfile}.debug"test_different_dir debuglink "${objdir}/${subdir}" 0# NT_GNU_BUILD_ID / .note.gnu.build-id test:set build_id_debug_filename [build_id_debug_filename_get $binfile]if ![string compare $build_id_debug_filename ""] then { unsupported "build-id is not supported by the compiler" # Spare debug files may confuse testsuite runs in the future. remote_exec build "rm -f $debugfile"} else { set build_id_debugself_filename [build_id_debug_filename_get $debugfile] set test "build-id support by binutils" set xfail 0 if ![string compare $build_id_debugself_filename ""] then { unsupported $test set xfail 1 } elseif {[string compare $build_id_debugself_filename $build_id_debug_filename] != 0} then { fail $test } else { pass $test } file mkdir [file dirname ${objdir}/${subdir}/${build_id_debug_filename}] remote_exec build "mv $debugfile ${objdir}/${subdir}/${build_id_debug_filename}" test_different_dir build-id "${objdir}/${subdir}" $xfail # Spare debug files may confuse testsuite runs in the future. remote_exec build "rm -f ${objdir}/${subdir}/${build_id_debug_filename}"}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -