📄 selftest.exp
字号:
# Copyright 1988, 1990, 1991, 1992, 1994, 1997, 1999, 2000, 2002, 2003, 2004,# 2005, 2006, 2007, 2008 Free Software Foundation, Inc.# This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 3 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program. If not, see <http://www.gnu.org/licenses/>.# This file was written by Rob Savoye. (rob@cygnus.com)if $tracelevel then { strace $tracelevel}set prms_id 0set bug_id 0# are we on a target boardif { [is_remote target] || ![isnative] } then { return}# Not all of the lines of code near the start of main are executed for# every machine. Also, optimization may reorder some of the lines.# So all we do is try to step or next over everything until we get# to a line that we know is always executed.proc do_steps_and_nexts {} { global gdb_prompt global srcdir gdb_reinitialize_dir $srcdir/.. set unlikely_line 0 for {set count 0} {$count < 32} {incr count} { send_gdb "list\n" # NOTE: carlton/2002-12-11: The "initial brace" and # "current_directory initialization" possibilities happen to # me with GCC 3.1 on i686-pc-linux-gnu when I compile with # optimization. gdb_expect { -re ".*context = data.*$gdb_prompt $" { set description "step over context initialization" set command "step" } -re ".*argc = context->argc.*$gdb_prompt $" { set description "step over argc initialization" set command "step" } -re ".*argv = context->argv.*$gdb_prompt $" { set description "step over argv initialization" set command "step" } -re ".*quiet = 0.*$gdb_prompt $" { set description "step over quiet initialization" set command "step" } -re ".*batch = 0.*$gdb_prompt $" { set description "step over batch initialization" set command "step" } -re ".*symarg = NULL.*$gdb_prompt $" { set description "step over symarg initialization" set command "step" } -re ".*execarg = NULL.*$gdb_prompt $" { set description "step over execarg initialization" set command "step" } -re ".*pidarg = NULL.*$gdb_prompt $" { set description "step over pidarg initialization" set command "step" } -re ".*corearg = NULL.*$gdb_prompt $" { set description "step over corearg initialization" set command "step" } -re ".*pid_or_core_arg = NULL.*$gdb_prompt $" { set description "step over pid_or_core_arg initialization" set command "step" } -re ".*cdarg = NULL.*$gdb_prompt $" { set description "step over cdarg initialization" set command "step" } -re ".*ttyarg = NULL.*$gdb_prompt $" { set description "step over ttyarg initialization" set command "step" } -re ".*time_at_startup = get_run_time.*$gdb_prompt $" { set description "next over get_run_time and everything it calls" set command "next" } -re ".*START_PROGRESS.*$gdb_prompt $" { # Note: ezannoni/2004/02/17: This check should be # removed, since as of today that source line is not # in gdb anymore. set description "next over START_PROGRESS and everything it calls" set command "next" } -re ".*mac_init.*$gdb_prompt $" { set description "next over mac_init and everything it calls" set command "next" } -re ".*init_malloc.*$gdb_prompt $" { # gdb 6.2.X is the last gdb which called init_malloc set description "next over init_malloc and everything it calls" set command "next" } -re ".*lim_at_start.*$gdb_prompt $" { set description "next over lim_at_start initialization" set command "next" } -re ".*count . 0x3.*$gdb_prompt $" { set description "next over conditional stack alignment code 1" set command "next" } -re ".*if .i != 0.*$gdb_prompt $" { set description "next over conditional stack alignment code 2" set command "next" } -re ".*alloca .i - 4.*$gdb_prompt $" { set description "next over conditional stack alignment alloca" set command "next" } -re ".*cmdsize = 1.*$gdb_prompt $" { set description "step over cmdsize initialization" set command "next" } -re ".*cmdarg = .* xmalloc.*$gdb_prompt $" { set description "next over cmdarg initialization via xmalloc" set command "next" } -re ".*ncmd = 0.*$gdb_prompt $" { set description "next over ncmd initialization" set command "next" } -re ".*dirsize = 1.*$gdb_prompt $" { set description "next over dirsize initialization" set command "next" } -re ".*dirarg = .* xmalloc.*$gdb_prompt $" { return } -re ".*setlocale .LC_MESSAGES,.*$gdb_prompt $" { set description "next over setlocale LC_MESSAGES" set command "next" } -re ".*setlocale .LC_CTYPE,.*$gdb_prompt $" { set description "next over setlocale LC_CTYPE" set command "next" } -re ".*bindtextdomain .PACKAGE, LOCALEDIR.;.*$gdb_prompt $" { set description "next over bindtextdomain" set command "next" } -re ".*textdomain .PACKAGE.;.*$gdb_prompt $" { set description "next over textdomain PACKAGE" set command "next" } -re "\[0-9\]+\[\t \]+\{\r\n$gdb_prompt $" { set description "step over initial brace" set command "step" } -re ".*current_directory = gdb_dirbuf.*$gdb_prompt $" { set description "step over current_directory initialization" set command "step" } -re ".*gdb_sysroot = .*$gdb_prompt $" { # NOTE: carlton/2003-01-15: More optimization reordering, # observed on GCC 3.1. set description "step over gdb_sysroot initialization" set command "step" } -re ".*ndir = 0.*$gdb_prompt $" { set description "step over ndir initialization" set command "step" } -re ".*instream = stdin.*$gdb_prompt $" { set description "step over instream initialization" set command "step" } -re ".*getcwd .gdb_dirbuf, sizeof .gdb_dirbuf..;.*$gdb_prompt $" { set description "next over getcwd" set command "next" } -re ".*quit_flag = 0.*$gdb_prompt $" { set description "step over quit_flag initialization" set command "step" } -re ".*gdb_stdout = stdio_fileopen .stdout.;.*$gdb_prompt $" { set description "step over gdb_stdout initialization" set command "step" } -re ".*gdb_stderr = stdio_fileopen .stderr.;.*$gdb_prompt $" { set description "step over gdb_stderr initialization" set command "step" } -re ".*main.c.*No such file or directory.*$gdb_prompt $" { setup_xfail "rs6000-*-aix3*" fail "must be able to list source lines" return } -re ".*interpreter_p = xstrdup.*$gdb_prompt $" { if { $unlikely_line == 0 } { # This is a GCC optimization bug; a constant has been # associated with the wrong line number. setup_xfail "*-*-*" gcc/26475 fail "$description (unlikely line from gcc)" set unlikely_line 1 } set description "next over xstrdup" set command "next" } -re ".*$gdb_prompt $" { fail "unknown source line after $description" return } default { fail "unknown source line near main" return } } send_gdb "$command\n" gdb_expect { -re ".*No such file or directory.\r\n$gdb_prompt $" { fail "$description (no source available)" } -re ".*A file or directory .* does not exist..\r\n$gdb_prompt $" { fail "$description (no source available)" } -re ".*$gdb_prompt $" { pass "$description" } timeout { fail "$description (timeout)" } } }}proc test_with_self { executable } { global gdb_prompt global tool global det_file global decimal global timeout # load yourself into the debugger # This can take a relatively long time, particularly for testing where # the executable is being accessed over a network, or where gdb does not # support partial symbols for a particular target and has to load the # entire symbol table. Set the timeout to 10 minutes, which should be # adequate for most environments (it *has* timed out with 5 min on a # SPARCstation SLC under moderate load, so this isn't unreasonable). # After gdb is started, set the timeout to 30 seconds for the duration # of this test, and then back to the original value. set oldtimeout $timeout set timeout 600 verbose "Timeout is now $timeout seconds" 2 global gdb_file_cmd_debug_info set gdb_file_cmd_debug_info "unset" set result [gdb_load $executable] set timeout $oldtimeout verbose "Timeout is now $timeout seconds" 2 if { $result != 0 } then { return -1 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -