📄 selftest.exp
字号:
if { $gdb_file_cmd_debug_info != "debug" } then { untested "No debug information, skipping testcase." return -1 } # disassemble yourself gdb_test "x/10i main" \ "x/10i.*main.*main.$decimal.*main.$decimal.*" \ "Disassemble main" # Set a breakpoint at main gdb_test "break captured_main" \ "Breakpoint.*at.* file.*, line.*" \ "breakpoint in captured_main" # We'll need this when we send a ^C to GDB. Need to do it before we # run the program and gdb starts saving and restoring tty states. # On Ultrix, we don't need it and it is really slow (because shell_escape # doesn't use vfork). if ![istarget "*-*-ultrix*"] then { gdb_test "shell stty intr '^C'" "" \ "set interrupt character in test_with_self" } # FIXME: If we put this after the run to main, the first list # command doesn't print the same line as the current line where # gdb is stopped. gdb_test "set listsize 1" "" "set listsize to 1" # run yourself # It may take a very long time for the inferior gdb to start (lynx), # so we bump it back up for the duration of this command. set timeout 600 set description "run until breakpoint at captured_main" send_gdb "run -nw\n" gdb_expect { -re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.* at .*main.c:.*$gdb_prompt $" { pass "$description" } -re "Starting program.*Breakpoint \[0-9\]+,.*captured_main .data.*$gdb_prompt $" { xfail "$description (line numbers scrambled?)" } -re "vfork: No more processes.*$gdb_prompt $" { fail "$description (out of virtual memory)" set timeout $oldtimeout verbose "Timeout is now $timeout seconds" 2 return -1 } -re ".*$gdb_prompt $" { fail "$description" set timeout $oldtimeout verbose "Timeout is now $timeout seconds" 2 return -1 } timeout { fail "$description (timeout)" } } set timeout $oldtimeout verbose "Timeout is now $timeout seconds" 2 # do we have a version number ? send_gdb "print version\n" gdb_expect { -re ".\[0-9\]+ = .\[0-9.\]+.*$gdb_prompt $" { pass "printed version as string" } -re ".\[0-9\]+ = +0x.*\[0-9.\]+.*$gdb_prompt $" { pass "printed version as pointer" } -re ".\[0-9\]+ = +.+ +0x.*\[0-9.\]+.*$gdb_prompt $" { pass "printed version with cast" } -re ".*$gdb_prompt $" { fail "printed version" } timeout { fail "(timeout) printed version" } } do_steps_and_nexts gdb_test "print \"foo\"" ".\[0-9\]+ = \"foo\"" "print a string" # do_steps_and_nexts left us ready to execute an xmalloc call, # so give that a try. # If we don't actually enter the xmalloc call when we give a # step command that seems like a genuine bug. It seems to happen # on most RISC processors. # NOTE drow/2003-06-22: However, if we step back to the preceding two # lines, just keep stepping until we enter. set stepped_back 0 setup_xfail "alpha-*-*" "mips-*-*" set description "step into xmalloc call" send_gdb "step\n" gdb_expect { -re "ncmd = 0;.*$gdb_prompt $" { set stepped_back 1 send_gdb "step\n" exp_continue } -re ".*cmdarg = .* xmalloc.*$gdb_prompt $" { set stepped_back 1 send_gdb "step\n" exp_continue } -re "dirsize = 1;.*$gdb_prompt $" { set stepped_back 1 send_gdb "step\n" exp_continue } -re ".*dirarg = .* xmalloc.*$gdb_prompt $" { if { $stepped_back == 1 } { send_gdb "step\n" exp_continue } else { fail "$description" } } -re "xmalloc.*size=.*at.*utils.c.*$gdb_prompt $" { pass "$description" } -re ".*No such file or directory.\r\n$gdb_prompt $" { pass "$description (no source available)" } -re "A file or directory .* does not exist..\r\n$gdb_prompt $" { pass "$description (no source available)" } -re ".*$gdb_prompt $" { fail "$description" } timeout { fail "$description (timeout)" } } # start the "xgdb" process send_gdb "continue\n" gdb_expect { -re "GNU gdb \[0-9\.\]*.*Copyright \\(C\\) \[0-9\]* Free Software Foundation, Inc.*License GPLv3\\+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.*This is free software: you are free to change and redistribute it.*There is NO WARRANTY, to the extent permitted by law. Type \"show copying\".*and \"show warranty\" for details.*This GDB was configured as .*$gdb_prompt $"\ { pass "xgdb is at prompt" } -re "GNU gdb \[0-9\.\]*.*Copyright \\(C\\) \[0-9\]* Free Software Foundation, Inc.*GDB is free software, covered by the GNU General Public License, and you are.*welcome to change it and/or distribute copies of it under certain conditions.*Type \"show copying\" to see the conditions.*There is absolutely no warranty for GDB. Type \"show warranty\" for details.*This GDB was configured as .*$gdb_prompt $"\ { pass "xgdb is at prompt (obsolescent gdb 2)" } -re "GDB is free software and you are welcome to distribute copies of it.* under certain conditions; type \"show copying\" to see the conditions..*There is absolutely no warranty for GDB; type \"show warranty\" for details..*GDB.*Copyright \[0-9\]+ Free Software Foundation, Inc..*$gdb_prompt $"\ { pass "xgdb is at prompt (obsolescent gdb 1)" } -re ".*$gdb_prompt $" { fail "xgdb is at prompt" } timeout { fail "(timeout) xgdb is at prompt" } } # set xgdb prompt so we can tell which is which send_gdb "set prompt (xgdb) \n" gdb_expect { -re "\[(\]xgdb\[)\].*\[(\]xgdb\[)\] $" { pass "Set xgdb prompt" } -re ".*$gdb_prompt $" { fail "Set xgdb prompt" } default { fail "(timeout) Set xgdb prompt" } } # kill the xgdb process set description "send ^C to child process" send_gdb "\003" gdb_expect { -re "Program received signal SIGINT.*$gdb_prompt $" { pass "$description" } -re ".*$gdb_prompt $" { fail "$description" } timeout { fail "$description (timeout)" } } set description "send SIGINT signal to child process" send_gdb "signal SIGINT\n" gdb_expect { -re "Continuing with signal SIGINT.*$gdb_prompt $" { pass "$description" } -re ".*$gdb_prompt $" { fail "$description" } timeout { fail "$description (timeout)" } } # get a stack trace # # This fails on some linux systems for unknown reasons. On the # systems where it fails, sometimes it works fine when run manually. # The testsuite failures may not be limited to just aout systems. setup_xfail "i*86-pc-linuxaout-gnu" set description "backtrace through signal handler" send_gdb "backtrace\n" gdb_expect { -re "#0.*(read|poll).*in main \\(.*\\) at .*gdb\\.c.*$gdb_prompt $" { pass "$description" } -re ".*$gdb_prompt $" { # On the alpha, we hit the infamous problem about gdb # being unable to get the frame pointer (mentioned in # gdb/README). As it is intermittent, there is no way to # XFAIL it which will give us an XPASS if the problem goes # away. setup_xfail "alpha*-*-osf*" fail "$description" } timeout { fail "$description (timeout)" } } # Set the timeout back to the value it had when we were called. set timeout $oldtimeout verbose "Timeout is now $timeout seconds" 2 # Restart gdb in case next test expects it to be started already. return 0}# Find a pathname to a file that we would execute if the shell was asked# to run $arg using the current PATH.proc find_gdb { arg } { # If the arg directly specifies an existing executable file, then # simply use it. if [file executable $arg] then { return $arg } set result [which $arg] if [string match "/" [ string range $result 0 0 ]] then { return $result } # If everything fails, just return the unqualified pathname as default # and hope for best. return $arg}# Run the test with self.# Copy the file executable file in case this OS doesn't like to edit its own# text space.set GDB_FULLPATH [find_gdb $GDB]# Remove any old copy lying around.remote_file host delete x$toolgdb_startset file [remote_download host $GDB_FULLPATH x$tool]set result [test_with_self $file];gdb_exit;catch "remote_file host delete $file";if {$result <0} then { warning "Couldn't test self" return -1}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -