d9538961cc
encapsulate all the steps/nexts done during self test, starting at main, and makes them less sensitive to optimization issues. Add "hppa*-*-hpux*" to setup_xfail for "backtrace through signal handler" test. * gdb.threads/pthreads.exp: Only run this for native configs. * gdb.base/signals.exp (test_handle_all_print): Remove code that increased timeouts, it now makes no difference. * gdb.base/structs.exp (do_function_calls): Add hppa*-*-hpux9*" setup_xfails for "p fun5()", "p fun6()", "p fun7()", and "p fun8" tests. gdb.c++/virtfunc.exp (do_tests): Add "mips-*-irix5*" setup_xfail for "runto test_calls(void)" test.
430 lines
12 KiB
Text
430 lines
12 KiB
Text
# Copyright (C) 1988, 1990, 1991, 1992, 1994 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 2 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, write to the Free Software
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|
|
|
# Please email any bugs, comments, and/or additions to this file to:
|
|
# bug-gdb@prep.ai.mit.edu
|
|
|
|
# This file was written by Rob Savoye. (rob@cygnus.com)
|
|
|
|
if $tracelevel then {
|
|
strace $tracelevel
|
|
}
|
|
|
|
set prms_id 0
|
|
set bug_id 0
|
|
|
|
# are we on a target board
|
|
if ![isnative] then {
|
|
return
|
|
}
|
|
if [istarget "m68k*-*-hpux*"] then {
|
|
# The top-level makefile passes CFLAGS= (no -g) for hp300. This probably
|
|
# should be fixed (it is only needed for gcc bootstrapping, not gdb),
|
|
# but until then.....
|
|
setup_xfail "*-*-*"
|
|
fail "cannot test self if compiled without debug info"
|
|
return -1
|
|
}
|
|
|
|
# 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 prompt
|
|
|
|
for {set count 0} {$count < 20} {incr count} {
|
|
send "list\n"
|
|
expect {
|
|
-re ".*symarg = NULL.*$prompt $" {
|
|
set description "step over symarg initialization"
|
|
set command "step"
|
|
}
|
|
-re ".*execarg = NULL.*$prompt $" {
|
|
set description "step over execarg initialization"
|
|
set command "step"
|
|
}
|
|
-re ".*corearg = NULL.*$prompt $" {
|
|
set description "step over corearg initialization"
|
|
set command "step"
|
|
}
|
|
-re ".*cdarg = NULL.*$prompt $" {
|
|
set description "step over cdarg initialization"
|
|
set command "step"
|
|
}
|
|
-re ".*ttyarg = NULL.*$prompt $" {
|
|
set description "step over ttyarg initialization"
|
|
set command "step"
|
|
}
|
|
-re ".*time_at_startup = get_run_time.*$prompt $" {
|
|
set description "next over get_run_time and everything it calls"
|
|
set command "next"
|
|
}
|
|
-re ".*START_PROGRESS.*$prompt $" {
|
|
set description "next over START_PROGRESS and everything it calls"
|
|
set command "next"
|
|
}
|
|
-re ".*mac_init.*$prompt $" {
|
|
set description "next over mac_init and everything it calls"
|
|
set command "next"
|
|
}
|
|
-re ".*init_malloc.*$prompt $" {
|
|
set description "next over init_malloc and everything it calls"
|
|
set command "next"
|
|
}
|
|
-re ".*SET_TOP_LEVEL.*$prompt $" {
|
|
set description "next over SET_TOP_LEVEL call"
|
|
set command "next"
|
|
}
|
|
-re ".*cmdsize = 1.*$prompt $" {
|
|
set description "step over cmdsize initialization"
|
|
set command "next"
|
|
}
|
|
-re ".*cmdarg = .* xmalloc.*$prompt $" {
|
|
set description "next over cmdarg initialization via xmalloc"
|
|
set command "next"
|
|
}
|
|
-re ".*ncmd = 0.*$prompt $" {
|
|
set description "next over ncmd initialization"
|
|
set command "next"
|
|
}
|
|
-re ".*dirsize = 1.*$prompt $" {
|
|
set description "next over dirsize initialization"
|
|
set command "next"
|
|
}
|
|
-re ".*dirarg = .* xmalloc.*$prompt $" {
|
|
return
|
|
}
|
|
-re "\[ \t\]+\{\r\n$prompt $" {
|
|
setup_xfail "mips-*-irix5*"
|
|
fail "$description ended up at odd location"
|
|
}
|
|
-re ".*main.c.*No such file or directory" {
|
|
setup_xfail "rs6000-*-aix3*"
|
|
fail "must be able to list source lines"
|
|
return
|
|
}
|
|
default {
|
|
fail "unknown source line near main"
|
|
return
|
|
}
|
|
}
|
|
send "$command\n"
|
|
expect {
|
|
-re ".*No such file or directory.\r\n$prompt $" {
|
|
fail "$description (no source available)"
|
|
}
|
|
-re ".*A file or directory .* does not exist..\r\n$prompt $" {
|
|
fail "$description (no source available)"
|
|
}
|
|
-re ".*$prompt $" {
|
|
pass "$description"
|
|
}
|
|
timeout {
|
|
fail "$description (timeout)"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
proc test_with_self {} {
|
|
global 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
|
|
if {[gdb_load "./x$tool"] <0} then {
|
|
set timeout $oldtimeout
|
|
verbose "Timeout is now $timeout seconds" 2
|
|
return -1
|
|
}
|
|
set timeout 30
|
|
verbose "Timeout is now $timeout seconds" 2
|
|
|
|
# disassemble yourself
|
|
send "x/10i main\n"
|
|
expect {
|
|
-re "x/10i.*main.*main.$decimal.*main.$decimal.*$prompt $"\
|
|
{ pass "Disassemble main" }
|
|
-re ".*$prompt $" { fail "Disassemble main" }
|
|
timeout { fail "(timeout) Disassemble main" }
|
|
}
|
|
|
|
set description "set breakpoint at main"
|
|
send "break main\n"
|
|
expect {
|
|
-re "Breakpoint.*at.* file.*, line.*$prompt $" {
|
|
pass "$description"
|
|
}
|
|
-re ".*$prompt $" {
|
|
fail "$description"
|
|
}
|
|
timeout {
|
|
fail "$description (timeout)"
|
|
}
|
|
}
|
|
|
|
# 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.
|
|
send "set listsize 1\n" ; expect -re "$prompt $"
|
|
|
|
# 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 main"
|
|
send "run -nw\n"
|
|
expect {
|
|
-re "Starting program.*Breakpoint \[0-9\]+,.*main .argc.*argv.* at .*main.c:.*$prompt $" {
|
|
pass "$description"
|
|
}
|
|
-re "Starting program.*Breakpoint \[0-9\]+,.*main .argc.*argv.*$prompt $" {
|
|
xfail "$description (line numbers scrambled?)"
|
|
}
|
|
-re "vfork: No more processes.*$prompt $" {
|
|
fail "$description (out of virtual memory)"
|
|
set timeout $oldtimeout
|
|
verbose "Timeout is now $timeout seconds" 2
|
|
return -1
|
|
}
|
|
-re ".*$prompt $" {
|
|
fail "$description"
|
|
set timeout $oldtimeout
|
|
verbose "Timeout is now $timeout seconds" 2
|
|
return -1
|
|
}
|
|
timeout {
|
|
fail "$description (timeout)"
|
|
}
|
|
}
|
|
|
|
set timeout 30
|
|
verbose "Timeout is now $timeout seconds" 2
|
|
|
|
# do we have a version number ?
|
|
send "print version\n"
|
|
expect {
|
|
-re ".\[0-9\]+ = +0x.*\[0-9.\]+.*$prompt $" {
|
|
pass "printed version"
|
|
}
|
|
-re ".\[0-9\]+ = +.+ +0x.*\[0-9.\]+.*$prompt $" {
|
|
pass "printed version with cast"
|
|
}
|
|
-re ".*$prompt $" { fail "printed version" }
|
|
timeout { fail "(timeout) printed version" }
|
|
}
|
|
|
|
do_steps_and_nexts
|
|
|
|
set description "print a string"
|
|
send "print \"foo\"\n"
|
|
expect {
|
|
-re ".\[0-9\]+ = \"foo\".*$prompt $" {
|
|
pass "$description"
|
|
}
|
|
-re ".*$prompt $" {
|
|
fail "$description"
|
|
}
|
|
timeout {
|
|
fail "$description (timeout)"
|
|
}
|
|
}
|
|
|
|
# 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.
|
|
setup_xfail "alpha-*-*" "hppa*-*-*" "mips-*-*"
|
|
set description "step into xmalloc call"
|
|
send "step\n"
|
|
expect {
|
|
-re "xmalloc.*size=.*at.*utils.c.*$prompt $" {
|
|
pass "$description"
|
|
}
|
|
-re ".*No such file or directory.\r\n$prompt $" {
|
|
pass "$description (no source available)"
|
|
}
|
|
-re "A file or directory .* does not exist..\r\n$prompt $" {
|
|
pass "$description (no source available)"
|
|
}
|
|
-re ".*$prompt $" {
|
|
fail "$description"
|
|
}
|
|
timeout {
|
|
fail "$description (timeout)"
|
|
}
|
|
}
|
|
|
|
# start the "xgdb" process
|
|
send "continue\n"
|
|
expect {
|
|
-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..*$prompt $"\
|
|
{ pass "xgdb is at prompt" }
|
|
-re ".*$prompt $" { fail "xgdb is at prompt" }
|
|
timeout { fail "(timeout) xgdb is at prompt" }
|
|
}
|
|
|
|
# set xgdb prompt so we can tell which is which
|
|
send "set prompt (xgdb) \n"
|
|
expect {
|
|
-re "\[(\]xgdb\[)\].*\[(\]xgdb\[)\] $" { pass "Set xgdb prompt" }
|
|
-re ".*$prompt $" { fail "Set xgdb prompt" }
|
|
default { fail "(timeout) Set xgdb prompt" }
|
|
}
|
|
|
|
# kill the xgdb process
|
|
set description "send ^C to child process"
|
|
send "\003"
|
|
expect {
|
|
-re "Program received signal SIGINT.*$prompt $" {
|
|
pass "$description"
|
|
}
|
|
-re ".*$prompt $" {
|
|
fail "$description"
|
|
}
|
|
timeout {
|
|
fail "$description (timeout)"
|
|
}
|
|
}
|
|
|
|
set description "send SIGINT signal to child process"
|
|
send "signal SIGINT\n"
|
|
expect {
|
|
-re "Continuing with signal SIGINT.*$prompt $" {
|
|
pass "$description"
|
|
}
|
|
-re ".*$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-*-linuxaout" "hppa*-*-hpux*"
|
|
set description "backtrace through signal handler"
|
|
send "backtrace\n"
|
|
expect {
|
|
-re "#0.*read.*in main \\(.*\\) at .*main\\.c.*$prompt $" {
|
|
pass "$description"
|
|
}
|
|
-re ".*$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)"
|
|
}
|
|
}
|
|
|
|
gdb_exit
|
|
|
|
# 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.
|
|
gdb_start
|
|
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 it's own
|
|
# text space.
|
|
|
|
set GDB_FULLPATH [find_gdb $GDB]
|
|
|
|
# Remove any old copy lying around.
|
|
catch "exec rm -f ./x$tool"
|
|
|
|
if ![file executable $GDB_FULLPATH] then {
|
|
fail "couldn't convert $GDB to absolute pathname to make local copy"
|
|
} else {
|
|
if [catch "exec cp $GDB_FULLPATH ./x$tool"] then {
|
|
fail "couldn't copy $GDB_FULLPATH to current directory"
|
|
} else {
|
|
verbose "\t\tCopied $GDB_FULLPATH to ./x$tool"
|
|
if {[test_with_self] <0} then {
|
|
warning "Couldn't test self"
|
|
catch "exec rm -f ./x$tool"
|
|
return -1
|
|
}
|
|
catch "exec rm -f ./x$tool"
|
|
}
|
|
}
|