diff options
author | Jason Molenda <jmolenda@apple.com> | 1999-07-19 23:30:11 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 1999-07-19 23:30:11 +0000 |
commit | adf40b2e16832f7382ee79e498d43a70ad22e305 (patch) | |
tree | 933de2a465a4003b9016471a466079459693ae3e /gdb/testsuite/gdb.base | |
parent | dc9e099fc0eced486ae2b49455c9da113c11f4ff (diff) | |
download | gdb-adf40b2e16832f7382ee79e498d43a70ad22e305.zip gdb-adf40b2e16832f7382ee79e498d43a70ad22e305.tar.gz gdb-adf40b2e16832f7382ee79e498d43a70ad22e305.tar.bz2 |
import gdb-1999-07-19 snapshot
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r-- | gdb/testsuite/gdb.base/configure | 21 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/configure.in | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/maint.exp | 64 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/pointers.c | 50 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/pointers.exp | 232 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/selftest.exp | 430 |
6 files changed, 765 insertions, 34 deletions
diff --git a/gdb/testsuite/gdb.base/configure b/gdb/testsuite/gdb.base/configure index 29e69bf..77d2d14 100644 --- a/gdb/testsuite/gdb.base/configure +++ b/gdb/testsuite/gdb.base/configure @@ -1,7 +1,7 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.12.1 +# Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation @@ -333,7 +333,7 @@ EOF verbose=yes ;; -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.12.1" + echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) @@ -451,7 +451,7 @@ echo > confdefs.h # A filename unique to this package, relative to the directory that # configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=a1-selftest.exp +ac_unique_file=gdbvars.exp # Find the source files, if location was not specified. if test -z "$srcdir"; then @@ -503,9 +503,11 @@ ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross +ac_exeext= +ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then @@ -569,7 +571,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:573: checking host system type" >&5 +echo "configure:575: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -590,7 +592,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:594: checking target system type" >&5 +echo "configure:596: checking target system type" >&5 target_alias=$target case "$target_alias" in @@ -608,7 +610,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$target" 1>&6 echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:612: checking build system type" >&5 +echo "configure:614: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -654,7 +656,7 @@ EOF # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | - case `(ac_space=' '; set) 2>&1 | grep ac_space` in + case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). @@ -733,7 +735,7 @@ do echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.12.1" + echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; @@ -756,6 +758,7 @@ s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g diff --git a/gdb/testsuite/gdb.base/configure.in b/gdb/testsuite/gdb.base/configure.in index e5bcb19..7c4e397 100644 --- a/gdb/testsuite/gdb.base/configure.in +++ b/gdb/testsuite/gdb.base/configure.in @@ -5,7 +5,7 @@ dnl script appropriate for this directory. For more information, check dnl any existing configure script. AC_PREREQ(2.5) -AC_INIT(a1-selftest.exp) +AC_INIT(gdbvars.exp) CC=${CC-cc} AC_SUBST(CC) diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp index ba59ed1..29e3134 100644 --- a/gdb/testsuite/gdb.base/maint.exp +++ b/gdb/testsuite/gdb.base/maint.exp @@ -176,29 +176,41 @@ gdb_expect { } send_gdb "maint print objfiles\n" + # To avoid timeouts, we avoid expects with many .* patterns that match -# many lines. -gdb_expect { - -re ".*Object file.*break: Objfile at $hex, bfd at $hex, \[0-9\]* minsyms\[\r\t \]+\n" - { pass "maint print objfiles: header" } - -re ".*$gdb_prompt $" { fail "maint print objfiles: header" } - timeout { fail "(timeout) maint print objfiles: header" } -} -gdb_expect { - -re ".*Psymtabs:\[\r\t \]+\n" { pass "maint print objfiles: psymtabs" } - -re ".*$gdb_prompt $" { fail "maint print objfiles: psymtabs" } - timeout { fail "(timeout) maint print objfiles: psymtabs" } -} -gdb_expect { - -re ".*Symtabs:\[\r\t \]+\n" { pass "maint print objfiles: symtabs" } - -re ".*$gdb_prompt $" { fail "maint print objfiles: symtabs" } - timeout { fail "(timeout) maint print objfiles: symtabs" } +# many lines. Instead, we keep track of which milestones we've seen +# in the output, and stop when we've seen all of them. + +set header 0 +set psymtabs 0 +set symtabs 0 +set keep_looking 1 + +while {$keep_looking} { + gdb_expect { + + -re ".*Object file.*break: Objfile at $hex, bfd at $hex, \[0-9\]* minsyms\[\r\t \]+\n" { set header 1 } + -re ".*Psymtabs:\[\r\t \]+\n" { set psymtabs 1 } + -re ".*Symtabs:\[\r\t \]+\n" { set symtabs 1 } + + -re ".*$gdb_prompt $" { + set keep_looking 0 + } + timeout { + fail "(timeout) maint print objfiles" + set keep_looking 0 + } + } } -gdb_expect { - -re ".*$gdb_prompt $" { pass "maint print objfiles: prompt" } - timeout { fail "(timeout) maint print objfiles: prompt" } + +proc maint_pass_if {val name} { + if $val { pass $name } else { fail $name } } +maint_pass_if $header "maint print objfiles: header" +maint_pass_if $psymtabs "maint print objfiles: psymtabs" +maint_pass_if $symtabs "maint print objfiles: symtabs" + send_gdb "maint print psymbols\n" gdb_expect { -re "print-psymbols takes an output file name and optional symbol file name.*$gdb_prompt $"\ @@ -282,6 +294,13 @@ gdb_expect { timeout { fail "(timeout) maint print symbols w/o args" } } +# This command can legitimately take many minutes to execute. If the +# executable is dynamically linked, then you get all the debugging +# info for the entire library --- 89Mb on my system. -jimb + +set old_timeout $timeout +set timeout 600 + send_gdb "maint print symbols symbols_output\n" gdb_expect { -re "^maint print symbols symbols_output\r\n$gdb_prompt $"\ @@ -291,7 +310,7 @@ gdb_expect { -re "symbols_output\r\n$gdb_prompt $"\ { # See comments for `maint print psymbols'. - send_gdb "shell grep 'main.*block' symbols_output\n" + send_gdb "shell grep 'main(.*block' symbols_output\n" gdb_expect { -re "int main\\(int, char \\*\\*, char \\*\\*\\); block.*$gdb_prompt $"\ { pass "maint print symbols" } @@ -309,6 +328,7 @@ gdb_expect { timeout { fail "(timeout) maint print symbols" } } +set timeout $old_timeout send_gdb "maint print type argc\n" gdb_expect { @@ -356,7 +376,9 @@ gdb_expect { } # Try it again, and check for shlib event info. Not supported everywhere. -if {! [istarget "hppa*-*-hpux*"]} then { +if {! ([istarget "hppa*-*-hpux*"] + || [istarget "*-*-linux*"] + || [istarget "*-*-solaris*"])} then { setup_xfail "*-*-*" } send_gdb "maint info breakpoints\n" diff --git a/gdb/testsuite/gdb.base/pointers.c b/gdb/testsuite/gdb.base/pointers.c index 8cac2c2..60e6444 100644 --- a/gdb/testsuite/gdb.base/pointers.c +++ b/gdb/testsuite/gdb.base/pointers.c @@ -97,7 +97,9 @@ int main () v_unsigned_int_pointer = v_double_pointer; v_unsigned_int_pointer = v_unsigned_int;*/ - + + more_code (); + return 0; } @@ -172,5 +174,49 @@ void dummy() } +void marker1 () +{ +} - +int more_code() +{ + char C, *pC, **ppC, ***pppC, ****ppppC, *****pppppC, ******ppppppC; + unsigned char UC, *pUC; + short S, *pS; + unsigned short US, *pUS; + int I, *pI; + unsigned int UI, *pUI; + long L, *pL; + unsigned long UL, *pUL; + float F, *pF; + double D, *pD; + + C = 'A'; + UC = 21; + S = -14; + US = 7; + I = 102; + UI = 1002; + L = -234; + UL = 234; + F = 1.25E10; + D = -1.375E-123; + pC = &C; + ppC = &pC; + pppC = &ppC; + ppppC = &pppC; + pppppC = &ppppC; + ppppppC = &pppppC; + pUC = &UC; + pS = &S; + pUS = &US; + pI = &I; + pUI = &UI; + pL = &L; + pUL = &UL; + pF = &F; + pD = &D; + + marker1(); + return 0; +} diff --git a/gdb/testsuite/gdb.base/pointers.exp b/gdb/testsuite/gdb.base/pointers.exp index 6b9f135..bccda66 100644 --- a/gdb/testsuite/gdb.base/pointers.exp +++ b/gdb/testsuite/gdb.base/pointers.exp @@ -62,7 +62,7 @@ if ![runto_main] then { continue } -gdb_test "next" "return 0;" "continuing after dummy()" +gdb_test "next" "" "continuing after dummy()" # @@ -359,3 +359,233 @@ gdb_expect { -re ".*$gdb_prompt $" { fail "print through ptr to ptr" } timeout { fail "(timeout) print through ptr to ptr" } } + +# tests for pointers +# with elementary type variables and pointers. +# + +send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $" + + send_gdb "cont\n" + gdb_expect { + -re "Break.* marker1 \\(\\) at .*:$decimal.*$gdb_prompt $" { + send_gdb "up\n" + gdb_expect { + -re ".*$gdb_prompt $" {} + timeout { fail "up from marker1" } + } + } + -re "$gdb_prompt $" { fail "continue to marker1" } + timeout { fail "(timeout) continue to marker1" } + } + + +send_gdb "print *pUC\n" +gdb_expect { + -re ".\[0-9\]* = 21 \'.025\'.*$gdb_prompt $" { + pass "print value of *pUC" + } + -re ".*$gdb_prompt $" { fail "print value of *pUC" } + timeout { fail "(timeout) print value of *pUC" } + } + + +send_gdb "ptype pUC\n" +gdb_expect { + -re "type = unsigned char \\*.*$gdb_prompt $" { pass "ptype pUC" } + -re ".*$gdb_prompt $" { fail "ptype pUC" } + timeout { fail "(timeout) ptype pUC" } +} + +send_gdb "print *pS\n" +gdb_expect { + -re ".\[0-9\]* = -14.*$gdb_prompt $" { + pass "print value of *pS" + } + -re ".*$gdb_prompt $" { fail "print value of *pS" } + timeout { fail "(timeout) print value of *pS" } + } + + +send_gdb "ptype pS\n" +gdb_expect { + -re "type = short \\*.*$gdb_prompt $" { pass "ptype pS" } + -re "type = short int \\*.*$gdb_prompt $" { pass "ptype pS" } + -re ".*$gdb_prompt $" { fail "ptype pS" } + timeout { fail "(timeout) ptype pS" } +} + +send_gdb "print *pUS\n" +gdb_expect { + -re ".\[0-9\]* = 7.*$gdb_prompt $" { + pass "print value of *pUS" + } + -re ".*$gdb_prompt $" { fail "print value of *pUS" } + timeout { fail "(timeout) print value of *pUS" } + } + + +send_gdb "ptype pUS\n" +gdb_expect { + -re "type = unsigned short \\*.*$gdb_prompt $" { pass "ptype pUS" } + -re "type = short unsigned int \\*.*$gdb_prompt $" { pass "ptype pUS" } + -re ".*$gdb_prompt $" { fail "ptype pUS" } + timeout { fail "(timeout) ptype pUS" } +} + +send_gdb "print *pI\n" +gdb_expect { + -re ".\[0-9\]* = 102.*$gdb_prompt $" { + pass "print value of *pI" + } + -re ".*$gdb_prompt $" { fail "print value of *pI" } + timeout { fail "(timeout) print value of *pI" } + } + + +send_gdb "ptype pI\n" +gdb_expect { + -re "type = int \\*.*$gdb_prompt $" { pass "ptype pI" } + -re ".*$gdb_prompt $" { fail "ptype pI" } + timeout { fail "(timeout) ptype pI" } +} + +send_gdb "print *pUI\n" +gdb_expect { + -re ".\[0-9\]* = 1002.*$gdb_prompt $" { + pass "print value of *pUI" + } + -re ".*$gdb_prompt $" { fail "print value of *pUI" } + timeout { fail "(timeout) print value of *pUI" } + } + + +send_gdb "ptype pUI\n" +gdb_expect { + -re "type = unsigned int \\*.*$gdb_prompt $" { pass "ptype pUI" } + -re ".*$gdb_prompt $" { fail "ptype pUI" } + timeout { fail "(timeout) ptype pUI" } +} + +send_gdb "print *pL\n" +gdb_expect { + -re ".\[0-9\]* = -234.*$gdb_prompt $" { + pass "print value of *pL" + } + -re ".*$gdb_prompt $" { fail "print value of *pL" } + timeout { fail "(timeout) print value of *pL" } + } + + +send_gdb "ptype pL\n" +gdb_expect { + -re "type = long \\*.*$gdb_prompt $" { pass "ptype pL" } + -re "type = long int \\*.*$gdb_prompt $" { pass "ptype pL" } + -re ".*$gdb_prompt $" { fail "ptype pL" } + timeout { fail "(timeout) ptype pL" } +} + +send_gdb "print *pUL\n" +gdb_expect { + -re ".\[0-9\]* = 234.*$gdb_prompt $" { + pass "print value of *pUL" + } + -re ".*$gdb_prompt $" { fail "print value of *pUL" } + timeout { fail "(timeout) print value of *pUL" } + } + + +send_gdb "ptype pUL\n" +gdb_expect { + -re "type = unsigned long \\*.*$gdb_prompt $" { pass "ptype pUL" } + -re "type = long unsigned int \\*.*$gdb_prompt $" { pass "ptype pUL" } + -re ".*$gdb_prompt $" { fail "ptype pUL" } + timeout { fail "(timeout) ptype pUL" } +} + +send_gdb "print *pF\n" +gdb_expect { + -re ".\[0-9\]* = 1.2\[0-9\]*e\\+10.*$gdb_prompt $" { + pass "print value of *pF" + } + -re ".*$gdb_prompt $" { fail "print value of *pF" } + timeout { fail "(timeout) print value of *pF" } + } + + +send_gdb "ptype pF\n" +gdb_expect { + -re "type = float \\*.*$gdb_prompt $" { pass "ptype pF" } + -re ".*$gdb_prompt $" { fail "ptype pF" } + timeout { fail "(timeout) ptype pF" } +} + +send_gdb "print *pD\n" +gdb_expect { + -re ".\[0-9\]* = -1.375e-123.*$gdb_prompt $" { + pass "print value of *pD" + } + -re ".*$gdb_prompt $" { fail "print value of *pD" } + timeout { fail "(timeout) print value of *pD" } + } + + +send_gdb "ptype pD\n" +gdb_expect { + -re "type = double \\*.*$gdb_prompt $" { pass "ptype pD" } + -re ".*$gdb_prompt $" { fail "ptype pD" } + timeout { fail "(timeout) ptype pD" } +} + +send_gdb "print ******ppppppC\n" +gdb_expect { + -re ".\[0-9\]* = 65 \'A\'.*$gdb_prompt $" { + pass "print value of ******ppppppC" + } + -re ".*$gdb_prompt $" { fail "print value of ******ppppppC" } + timeout { fail "(timeout) print value of ******ppppppC" } + } + + +send_gdb "ptype pC\n" +gdb_expect { + -re "type = char \\*.*$gdb_prompt $" { pass "ptype pC" } + -re ".*$gdb_prompt $" { fail "ptype pC" } + timeout { fail "(timeout) ptype pC" } +} + +send_gdb "ptype ppC\n" +gdb_expect { + -re "type = char \\*\\*.*$gdb_prompt $" { pass "ptype ppC" } + -re ".*$gdb_prompt $" { fail "ptype ppC" } + timeout { fail "(timeout) ptype ppC" } +} + +send_gdb "ptype pppC\n" +gdb_expect { + -re "type = char \\*\\*\\*.*$gdb_prompt $" { pass "ptype pppC" } + -re ".*$gdb_prompt $" { fail "ptype pppC" } + timeout { fail "(timeout) ptype pppC" } +} + +send_gdb "ptype ppppC\n" +gdb_expect { + -re "type = char \\*\\*\\*\\*.*$gdb_prompt $" { pass "ptype ppppC" } + -re ".*$gdb_prompt $" { fail "ptype ppppC" } + timeout { fail "(timeout) ptype ppppC" } +} + +send_gdb "ptype pppppC\n" +gdb_expect { + -re "type = char \\*\\*\\*\\*\\*.*$gdb_prompt $" { pass "ptype pppppC" } + -re ".*$gdb_prompt $" { fail "ptype pppppC" } + timeout { fail "(timeout) ptype pppppC" } +} + +send_gdb "ptype ppppppC\n" +gdb_expect { + -re "type = char \\*\\*\\*\\*\\*\\*.*$gdb_prompt $" { pass "ptype ppppppC" } + -re ".*$gdb_prompt $" { fail "ptype ppppppC" } + timeout { fail "(timeout) ptype ppppppC" } +} + diff --git a/gdb/testsuite/gdb.base/selftest.exp b/gdb/testsuite/gdb.base/selftest.exp new file mode 100644 index 0000000..c0d17c8 --- /dev/null +++ b/gdb/testsuite/gdb.base/selftest.exp @@ -0,0 +1,430 @@ +# Copyright (C) 1988, 1990, 1991, 1992, 1994, 1997 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 [is_remote target] { + 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 gdb_prompt + global srcdir + + gdb_reinitialize_dir $srcdir/.. + + for {set count 0} {$count < 20} {incr count} { + send_gdb "list\n" + gdb_expect { + -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 ".*corearg = NULL.*$gdb_prompt $" { + set description "step over corearg 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 ".*interparg = NULL.*$gdb_prompt $" { + set description "step over interparg 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 $" { + 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 $" { + set description "next over init_malloc and everything it calls" + 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 ".*SET_TOP_LEVEL.*$gdb_prompt $" { + set description "next over SET_TOP_LEVEL call" + 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 "\[ \t\]+\{\r\n$gdb_prompt $" { + setup_xfail "mips-*-irix5*" + fail "$description ended up at odd location" + } + -re ".*main.c.*No such file or directory.*$gdb_prompt $" { + setup_xfail "rs6000-*-aix3*" + fail "must be able to list source lines" + return + } + -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 + if {[gdb_load $executable] <0} then { + set timeout $oldtimeout + verbose "Timeout is now $timeout seconds" 2 + return -1 + } + set timeout $oldtimeout + verbose "Timeout is now $timeout seconds" 2 + + # disassemble yourself + gdb_test "x/10i main" \ + "x/10i.*main.*main.$decimal.*main.$decimal.*" \ + "Disassemble main" + + # Set a breakpoint at main + gdb_test "break main" \ + "Breakpoint.*at.* file.*, line.*" \ + "breakpoint in 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 main" + send_gdb "run -nw\n" + gdb_expect { + -re "Starting program.*Breakpoint \[0-9\]+,.*main .argc.*argv.* at .*main.c:.*$gdb_prompt $" { + pass "$description" + } + -re "Starting program.*Breakpoint \[0-9\]+,.*main .argc.*argv.*$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\]+ = +0x.*\[0-9.\]+.*$gdb_prompt $" { + pass "printed version" + } + -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. + setup_xfail "alpha-*-*" "mips-*-*" + set description "step into xmalloc call" + send_gdb "step\n" + gdb_expect { + -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 \[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" } + -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)" } + -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" "hppa*-*-hpux*" + set description "backtrace through signal handler" + send_gdb "backtrace\n" + gdb_expect { + -re "#0.*read.*in main \\(.*\\) at .*main\\.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$tool + +gdb_start +set 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 +} |