diff options
Diffstat (limited to 'gdb/testsuite/gdb.base')
75 files changed, 4563 insertions, 752 deletions
diff --git a/gdb/testsuite/gdb.base/Makefile.in b/gdb/testsuite/gdb.base/Makefile.in index e59f57b6639..9f382db8b5a 100644 --- a/gdb/testsuite/gdb.base/Makefile.in +++ b/gdb/testsuite/gdb.base/Makefile.in @@ -3,7 +3,7 @@ srcdir = @srcdir@ EXECUTABLES = all-types annota1 bitfields break \ call-ar-st call-rt-st call-strs callfuncs callfwmall \ - commands compiler condbreak constvars coremaker \ + chng-syms commands compiler condbreak constvars coremaker \ dbx-test display ending-run execd-prog exprs \ foll-exec foll-fork foll-vfork funcargs int-type interrupt jump \ langs list long_long mips_pro miscexprs nodebug opaque overlays \ diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp index c3ceac34cd6..dc8ba29ca4d 100644 --- a/gdb/testsuite/gdb.base/annota1.exp +++ b/gdb/testsuite/gdb.base/annota1.exp @@ -296,7 +296,7 @@ match_max 3000 verbose "match_max now is: [match_max]" send_gdb "backtrace\n" gdb_expect { - -re "frame-begin 0 $hex\r\n#0.*frame-end.*frame-begin 1 $hex\r\n#1.*(\032\032signal-handler-caller\r\n.signal handler called.\r\n\r\n)*\032\032frame-end\r\n\r\n\032\032frame-begin 2 $hex\r\n#2.*(frame-begin 3 $hex\r\n#3.*)*frame-end.*$gdb_prompt$" { + -re "frame-begin 0 $hex\r\n#0.*frame-end.*frame-begin 1 $hex\r\n#1.*(\032\032signal-handler-caller\r\n.signal handler called.\r\n\r\n)+\032\032frame-end\r\n\r\n\032\032frame-begin 2 $hex\r\n#2.*(frame-begin 3 $hex\r\n#3.*)*frame-end.*$gdb_prompt$" { pass "backtrace @ signal handler" } -re ".*$gdb_prompt$" { fail "backtrace @ signal handler" } diff --git a/gdb/testsuite/gdb.base/auxv.c b/gdb/testsuite/gdb.base/auxv.c new file mode 100644 index 00000000000..94f9d000f48 --- /dev/null +++ b/gdb/testsuite/gdb.base/auxv.c @@ -0,0 +1,58 @@ +/* Simple little program that just generates a core dump from inside some + nested function calls. Keep this as self contained as possible, I.E. + use no environment resources other than possibly abort(). */ + +#ifndef __STDC__ +#define const /**/ +#endif + +#ifndef HAVE_ABORT +#define HAVE_ABORT 1 +#endif + +#if HAVE_ABORT +#define ABORT abort() +#else +#define ABORT {char *invalid = 0; *invalid = 0xFF;} +#endif + +/* Don't make these automatic vars or we will have to walk back up the + stack to access them. */ + +char *buf1; +char *buf2; + +int coremaker_data = 1; /* In Data section */ +int coremaker_bss; /* In BSS section */ + +const int coremaker_ro = 201; /* In Read-Only Data section */ + +void +func2 (int x) +{ + int coremaker_local[5]; + int i; + static int y; + + /* Make sure that coremaker_local doesn't get optimized away. */ + for (i = 0; i < 5; i++) + coremaker_local[i] = i; + coremaker_bss = 0; + for (i = 0; i < 5; i++) + coremaker_bss += coremaker_local[i]; + coremaker_data = coremaker_ro + 1; + y = 10 * x; + ABORT; +} + +void +func1 (int x) +{ + func2 (x * 2); +} + +int main () +{ + func1 (10); + return 0; +} diff --git a/gdb/testsuite/gdb.base/auxv.exp b/gdb/testsuite/gdb.base/auxv.exp new file mode 100644 index 00000000000..3a509b98242 --- /dev/null +++ b/gdb/testsuite/gdb.base/auxv.exp @@ -0,0 +1,187 @@ +# Test `info auxv' and related functionality. + +# Copyright 1992,1993,1994,1995,1996,1997,1998,1999,2000,2004 +# 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 is based on corefile.exp which was written by Fred +# Fish. (fnf@cygnus.com) + +if $tracelevel then { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +set testfile "auxv" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +set corefile ${objdir}/${subdir}/${testfile}.corefile +set gcorefile ${objdir}/${subdir}/${testfile}.gcore + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +# Use a fresh directory to confine the native core dumps. +# Make it the working directory for gdb and its child. +set coredir "${objdir}/${subdir}/coredir.[getpid]" +file mkdir $coredir +set core_works [isnative] + +# Run GDB on the test program up to where it will dump core. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} +gdb_test "set print sevenbit-strings" "" \ + "set print sevenbit-strings; ${testfile}" +gdb_test "set width 0" "" \ + "set width 0; ${testfile}" + +if {$core_works} { + if {[gdb_test "cd $coredir" ".*Working directory .*" \ + "cd to temporary directory for core dumps"]} { + set core_works 0 + } +} + +if { ![runto_main] } then { + gdb_suppress_tests; +} +set print_core_line [gdb_get_line_number "ABORT;"] +gdb_test "tbreak $print_core_line" +gdb_test continue ".*ABORT;.*" + +proc fetch_auxv {test} { + global gdb_prompt + + set auxv_lines {} + set bad -1 + if {[gdb_test_multiple "info auxv" $test { + -re "info auxv\[\r\n\]+" { + exp_continue + } + -ex "The program has no auxiliary information now" { + set bad 1 + } + -ex "Auxiliary vector is empty" { + set bad 1 + } + -ex "No auxiliary vector found" { + set bad 1 + } + -re "^\[0-9\]+\[ \t\]+(AT_\[^ \t\]+)\[^\r\n\]+\[\r\n\]+" { + lappend auxv_lines $expect_out(0,string) + exp_continue + } + -re "^\[0-9\]+\[ \t\]+\\?\\?\\?\[^\r\n\]+\[\r\n\]+" { + warning "Unrecognized tag value: $expect_out(0,string)" + set bad 1 + lappend auxv_lines $expect_out(0,string) + exp_continue + } + -re ".*$gdb_prompt $" { + incr bad + } + -re "^\[^\r\n\]+\[\r\n\]+" { + warning "Unrecognized output: $expect_out(0,string)" + set bad 1 + } + }] != 0} { + return {} + } + + if {$bad} { + fail $test + return {} + } + + pass $test + return $auxv_lines +} + +set live_data [fetch_auxv "info auxv on live process"] + +# Now try gcore. +set gcore_works 0 +set escapedfilename [string_to_regexp $gcorefile] +gdb_test_multiple "gcore $gcorefile" "gcore" { + -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" { + pass "gcore" + set gcore_works 1 + } + -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" { + unsupported "gcore" + } +} + +# Let the program continue and die. +gdb_test continue ".*Program received signal.*" +gdb_test continue ".*Program terminated with signal.*" + +# Now collect the core dump it left. +set test "generate native core dump" +if {$core_works} { + # Find the + set names [glob -nocomplain -directory $coredir *core*] + if {[llength $names] == 1} { + set file [file join $coredir [lindex $names 0]] + remote_exec build "mv $file $corefile" + pass $test + } else { + set core_works 0 + warning "can't generate a core file - core tests suppressed - check ulimit -c" + fail $test + } +} else { + unsupported $test +} +remote_exec build "rm -rf $coredir" + +# Now we can examine the core files and check that their data matches what +# we saw in the process. Note that the exact data can vary between runs, +# so it's important that the native core dump file and the gcore-created dump +# both be from the same run of the program as we examined live. + +proc do_core_test {works corefile test1 test2} { + if {! $works} { + unsupported $test1 + unsupported $test2 + } else { + gdb_test "core $corefile" "Core was generated by.*" \ + "load core file for $test1" \ + "A program is being debugged already.*" "y" + set core_data [fetch_auxv $test1] + global live_data + if {$core_data == $live_data} { + pass $test2 + } else { + fail $test2 + } + } +} + +do_core_test $core_works $corefile \ + "info auxv on native core dump" "matching auxv data from live and core" + +do_core_test $gcore_works $gcorefile \ + "info auxv on gcore-created dump" "matching auxv data from live and gcore" diff --git a/gdb/testsuite/gdb.base/bang.exp b/gdb/testsuite/gdb.base/bang.exp index f5840741f6b..1e18328613a 100644 --- a/gdb/testsuite/gdb.base/bang.exp +++ b/gdb/testsuite/gdb.base/bang.exp @@ -1,4 +1,4 @@ -# Copyright 2003 Free Software Foundation, Inc. +# Copyright 2003, 2004 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 @@ -35,7 +35,13 @@ gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} # Verify that we can run the program and that it terminates normally. -gdb_test "run" \ - ".*Program exited normally\." \ - "run program" +gdb_run_cmd +gdb_expect { + -re ".*Program exited normally\.\r\n$gdb_prompt $" { + pass "run program" + } + timeout { + fail "run program (timeout)" + } +} diff --git a/gdb/testsuite/gdb.base/bigcore.c b/gdb/testsuite/gdb.base/bigcore.c new file mode 100644 index 00000000000..8cd1b5f98d2 --- /dev/null +++ b/gdb/testsuite/gdb.base/bigcore.c @@ -0,0 +1,203 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2004 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 */ + +#include <unistd.h> +#include <stdlib.h> +#include <sys/resource.h> + +/* Print routines: + + The following are so that printf et.al. can be avoided. Those + might try to use malloc() and that, for this code, would be a + disaster. */ + +#define printf do not use + +const char digit[] = "0123456789abcdefghijklmnopqrstuvwxyz"; + +static void +print_char (char c) +{ + write (1, &c, sizeof (c)); +} + +static void +print_unsigned (unsigned long u) +{ + if (u >= 10) + print_unsigned (u / 10); + print_char (digit[u % 10]); +} + +static void +print_hex (unsigned long u) +{ + if (u >= 16) + print_hex (u / 16); + print_char (digit[u % 16]); +} + +static void +print_string (const char *s) +{ + for (; (*s) != '\0'; s++) + print_char ((*s)); +} + +static void +print_address (const void *a) +{ + print_string ("0x"); + print_hex ((unsigned long) a); +} + +/* Print the current values of RESOURCE. */ + +static void +print_rlimit (int resource) +{ + struct rlimit rl; + getrlimit (resource, &rl); + print_string ("cur=0x"); + print_hex (rl.rlim_cur); + print_string (" max=0x"); + print_hex (rl.rlim_max); +} + +static void +maximize_rlimit (int resource, const char *prefix) +{ + struct rlimit rl; + print_string (" "); + print_string (prefix); + print_string (": "); + print_rlimit (resource); + getrlimit (resource, &rl); + rl.rlim_cur = rl.rlim_max; + setrlimit (resource, &rl); + print_string (" -> "); + print_rlimit (resource); + print_string ("\n"); +} + +/* Maintain a doublely linked list. */ +struct list +{ + struct list *next; + struct list *prev; + size_t size; +}; + +/* Put the "heap" in the DATA section. That way it is more likely + that the variable will occur early in the core file (an address + before the heap) and hence more likely that GDB will at least get + its value right. + + To simplify the list append logic, start the heap out with one + entry (that lives in the BSS section). */ + +static struct list dummy; +static struct list heap = { &dummy, &dummy }; + +int +main () +{ + size_t max_chunk_size; + + /* Try to expand all the resource limits beyond the point of sanity + - we're after the biggest possible core file. */ + + print_string ("Maximize resource limits ...\n"); +#ifdef RLIMIT_CORE + maximize_rlimit (RLIMIT_CORE, "core"); +#endif +#ifdef RLIMIT_DATA + maximize_rlimit (RLIMIT_DATA, "data"); +#endif +#ifdef RLIMIT_STACK + maximize_rlimit (RLIMIT_STACK, "stack"); +#endif +#ifdef RLIMIT_AS + maximize_rlimit (RLIMIT_AS, "stack"); +#endif + + /* Compute an initial chunk size. The math is dodgy but it works + for the moment. Perhaphs there's a constant around somewhere. */ + { + size_t tmp; + for (tmp = 1; tmp > 0; tmp <<= 1) + max_chunk_size = tmp; + } + + /* Allocate as much memory as possible creating a linked list of + each section. The linking ensures that some, but not all, the + memory is allocated. NB: Some kernels handle this efficiently - + only allocating and writing out referenced pages leaving holes in + the file for unreferend pages - while others handle this poorly - + writing out all pages including those that wern't referenced. */ + + print_string ("Alocating the entire heap ...\n"); + { + size_t chunk_size; + long bytes_allocated = 0; + long chunks_allocated = 0; + /* Create a linked list of memory chunks. Start with + MAX_CHUNK_SIZE blocks of memory and then try allocating smaller + and smaller amounts until all (well at least most) memory has + been allocated. */ + for (chunk_size = max_chunk_size; + chunk_size >= sizeof (struct list); + chunk_size >>= 1) + { + unsigned long count = 0; + print_string (" "); + print_unsigned (chunk_size); + print_string (" bytes ... "); + while (1) + { + struct list *chunk = malloc (chunk_size); + if (chunk == NULL) + break; + chunk->size = chunk_size; + /* Link it in. */ + chunk->next = NULL; + chunk->prev = heap.prev; + heap.prev->next = chunk; + heap.prev = chunk; + count++; + } + print_unsigned (count); + print_string (" chunks\n"); + chunks_allocated += count; + bytes_allocated += chunk_size * count; + } + print_string ("Total of "); + print_unsigned (bytes_allocated); + print_string (" bytes "); + print_unsigned (chunks_allocated); + print_string (" chunks\n"); + } + + /* Push everything out to disk. */ + + print_string ("Dump core ....\n"); + *(char*)0 = 0; +} diff --git a/gdb/testsuite/gdb.base/bigcore.exp b/gdb/testsuite/gdb.base/bigcore.exp new file mode 100644 index 00000000000..58cbfa1cc66 --- /dev/null +++ b/gdb/testsuite/gdb.base/bigcore.exp @@ -0,0 +1,192 @@ +# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2004 +# 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 is based on corefile.exp which was written by Fred +# Fish. (fnf@cygnus.com) + +if $tracelevel then { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +# Are we on a target board? As of 2004-02-12, GDB didn't have a +# mechanism that would let it efficiently access a remote corefile. + +if ![isnative] then { + untested "Remote system" + return +} + +# Can the system run this test (in particular support sparse +# corefiles)? On systems that lack sparse corefile support this test +# consumes too many resources - gigabytes worth of disk space and and +# I/O bandwith. + +if { [istarget "*-*-*bsd*"] || [istarget "*-*-hpux*"] } { + untested "Kernel lacks sparse corefile support (PR gdb/1551)" + return +} + +set testfile "bigcore" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +set corefile ${objdir}/${subdir}/${testfile}.corefile + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +# Create a core file named "TESTFILE.corefile" rather than just +# "core", to avoid problems with sys admin types that like to +# regularly prune all files named "core" from the system. + +# Some systems append "core" to the name of the program; others append +# the name of the program to "core"; still others (like Linux, as of +# May 2003) create cores named "core.PID". In the latter case, we +# could have many core files lying around, and it may be difficult to +# tell which one is ours, so let's run the program in a subdirectory. + +set found 0 +set coredir "${objdir}/${subdir}/coredir.[getpid]" +file mkdir $coredir +catch "system \"(cd ${coredir}; ${binfile}; true) >/dev/null 2>&1\"" +set names [glob -nocomplain -directory $coredir *core*] +if {[llength $names] == 1} { + set file [file join $coredir [lindex $names 0]] + remote_exec build "mv $file $corefile" + set found 1 +} + +# Try to clean up after ourselves. +remote_file build delete [file join $coredir coremmap.data] +remote_exec build "rmdir $coredir" + +if { $found == 0 } { + warning "can't generate a core file - core tests suppressed - check ulimit -c" + return 0 +} + +# Run GDB on the bigcore program up-to where it will dump core. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} +gdb_test "set print sevenbit-strings" "" \ + "set print sevenbit-strings; ${testfile}" +gdb_test "set width 0" "" \ + "set width 0; ${testfile}" +if { ![runto_main] } then { + gdb_suppress_tests; +} +set print_core_line [gdb_get_line_number "Dump core"] +gdb_test "tbreak $print_core_line" +gdb_test continue ".*print_string.*" +gdb_test next ".*0 = 0.*" + +# Traverse part of bigcore's linked list of memory chunks (forward or +# backward), saving each chunk's address. I don't know why but +# expect_out didn't work with gdb_test_multiple. + +proc extract_heap { dir } { + global gdb_prompt + global expect_out + set heap "" + set test "extract ${dir} heap" + set lim 0 + send_gdb "print heap.${dir}\n" + gdb_expect { + -re " = \\(struct list \\*\\) 0x0.*$gdb_prompt $" { + pass "$test" + } + -re " = \\(struct list \\*\\) (0x\[0-9a-f\]*).*$gdb_prompt $" { + set heap [concat $heap $expect_out(1,string)] + if { $lim >= 50 } { + pass "$test (stop at $lim)" + } else { + incr lim + send_gdb "print \$.${dir}\n" + exp_continue + } + } + -re ".*$gdb_prompt $" { + fail "$test (entry $lim)" + } + timeout { + fail "$test (timeout)" + } + } + return $heap; +} +set next_heap [extract_heap next] +set prev_heap [extract_heap prev] + +# Now load up that core file + +set test "load corefile" +gdb_test_multiple "core $corefile" "$test" { + -re "A program is being debugged already. Kill it. .y or n. " { + send_gdb "y\n" + exp_continue + } + -re "Core was generated by.*$gdb_prompt $" { + pass "$test" + } +} + +# Finally, re-traverse bigcore's linked list, checking each chunk's +# address against the executable. Don't use gdb_test_multiple as want +# only one pass/fail. Don't use exp_continue as the regular +# expression involving $heap needs to be re-evaluated for each new +# response. + +proc check_heap { dir heap } { + global gdb_prompt + set test "check ${dir} heap" + set ok 1 + set lim 0 + send_gdb "print heap.${dir}\n" + while { $ok } { + gdb_expect { + -re " = \\(struct list \\*\\) [lindex $heap $lim].*$gdb_prompt $" { + if { $lim >= [llength $heap] } { + pass "$test" + set ok 0 + } else { + incr lim + send_gdb "print \$.${dir}\n" + } + } + -re ".*$gdb_prompt $" { + fail "$test (address [lindex $heap $lim])" + set ok 0 + } + timeout { + fail "$test (timeout)" + set ok 0 + } + } + } +} + +check_heap next $next_heap +check_heap prev $prev_heap diff --git a/gdb/testsuite/gdb.base/break.c b/gdb/testsuite/gdb.base/break.c index 9e458b316bb..bf398fcca91 100644 --- a/gdb/testsuite/gdb.base/break.c +++ b/gdb/testsuite/gdb.base/break.c @@ -1,3 +1,25 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003 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 */ + #ifdef vxworks # include <stdio.h> @@ -32,23 +54,16 @@ char *arg; # include <stdlib.h> #endif /* ! vxworks */ -/* - * The following functions do nothing useful. They are included simply - * as places to try setting breakpoints at. They are explicitly - * "one-line functions" to verify that this case works (some versions - * of gcc have or have had problems with this). - */ - #ifdef PROTOTYPES -int marker1 (void) { return (0); } -int marker2 (int a) { return (1); } -void marker3 (char *a, char *b) {} -void marker4 (long d) {} +extern int marker1 (void); +extern int marker2 (int a); +extern void marker3 (char *a, char *b); +extern void marker4 (long d); #else -int marker1 () { return (0); } -int marker2 (a) int a; { return (1); } -void marker3 (a, b) char *a, *b; {} -void marker4 (d) long d; {} +extern int marker1 (); +extern int marker2 (); +extern void marker3 (); +extern void marker4 (); #endif /* @@ -69,21 +84,21 @@ char *argv[], **envp; #endif { #ifdef usestubs - set_debug_traps(); + set_debug_traps(); /* set breakpoint 5 here */ breakpoint(); #endif - if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ + if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */ fprintf (stderr, "usage: factorial <number>\n"); return 1; } - printf ("%d\n", factorial (atoi ("6"))); - - marker1 (); - marker2 (43); - marker3 ("stack", "trace"); + printf ("%d\n", factorial (atoi ("6"))); /* set breakpoint 1 here */ + /* set breakpoint 12 here */ + marker1 (); /* set breakpoint 11 here */ + marker2 (43); /* set breakpoint 20 here */ + marker3 ("stack", "trace"); /* set breakpoint 21 here */ marker4 (177601976L); - argc = (argc == 12345); /* This is silly, but we can step off of it */ - return argc; + argc = (argc == 12345); /* This is silly, but we can step off of it */ /* set breakpoint 2 here */ + return argc; /* set breakpoint 10 here */ } #ifdef PROTOTYPES @@ -93,10 +108,10 @@ int factorial (value) int value; #endif { - if (value > 1) { + if (value > 1) { /* set breakpoint 7 here */ value *= factorial (value - 1); } - return (value); + return (value); /* set breakpoint 19 here */ } #ifdef PROTOTYPES @@ -106,7 +121,7 @@ int multi_line_if_conditional (a, b, c) int a, b, c; #endif { - if (a + if (a /* set breakpoint 3 here */ && b && c) return 0; @@ -121,7 +136,7 @@ int multi_line_while_conditional (a, b, c) int a, b, c; #endif { - while (a + while (a /* set breakpoint 4 here */ && b && c) { diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp index 38820ec9fc9..c425d1439cf 100644 --- a/gdb/testsuite/gdb.base/break.exp +++ b/gdb/testsuite/gdb.base/break.exp @@ -34,10 +34,19 @@ set bug_id 0 set testfile "break" set srcfile ${testfile}.c +set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { - gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } if [get_compiler_info ${binfile}] { @@ -87,7 +96,7 @@ gdb_test "break main" \ # test break at quoted function # gdb_test "break \"marker2\"" \ - "Breakpoint.*at.* file .*$srcfile, line.*" \ + "Breakpoint.*at.* file .*$srcfile1, line.*" \ "breakpoint quoted function" # @@ -97,6 +106,8 @@ gdb_test "break $srcfile:factorial" \ "Breakpoint.*at.* file .*$srcfile, line.*" \ "breakpoint function in file" +set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] + # # test break at line number # @@ -109,44 +120,51 @@ gdb_test "break $srcfile:factorial" \ gdb_test "list main" \ ".*main \\(argc, argv, envp\\).*" \ "use `list' to establish default source file" -gdb_test "break 79" \ - "Breakpoint.*at.* file .*$srcfile, line 79\\." \ +gdb_test "break $bp_location1" \ + "Breakpoint.*at.* file .*$srcfile, line $bp_location1\\." \ "breakpoint line number" # # test duplicate breakpoint # -gdb_test "break 79" \ - "Note: breakpoint \[0-9\]+ also set at pc.*Breakpoint \[0-9\]+ at.* file .*$srcfile, line 79\\." \ +gdb_test "break $bp_location1" \ + "Note: breakpoint \[0-9\]+ also set at pc.*Breakpoint \[0-9\]+ at.* file .*$srcfile, line $bp_location1\\." \ "breakpoint duplicate" +set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] + # # test break at line number in file # -gdb_test "break $srcfile:85" \ - "Breakpoint.*at.* file .*$srcfile, line 85\\." \ +gdb_test "break $srcfile:$bp_location2" \ + "Breakpoint.*at.* file .*$srcfile, line $bp_location2\\." \ "breakpoint line number in file" +set bp_location3 [gdb_get_line_number "set breakpoint 3 here"] +set bp_location4 [gdb_get_line_number "set breakpoint 4 here"] # # Test putting a break at the start of a multi-line if conditional. # Verify the breakpoint was put at the start of the conditional. # gdb_test "break multi_line_if_conditional" \ - "Breakpoint.*at.* file .*$srcfile, line 109\\." \ + "Breakpoint.*at.* file .*$srcfile, line $bp_location3\\." \ "breakpoint at start of multi line if conditional" gdb_test "break multi_line_while_conditional" \ - "Breakpoint.*at.* file .*$srcfile, line 124\\." \ + "Breakpoint.*at.* file .*$srcfile, line $bp_location4\\." \ "breakpoint at start of multi line while conditional" +set bp_location5 [gdb_get_line_number "set breakpoint 5 here"] +set bp_location6 [gdb_get_line_number "set breakpoint 6 here"] + # # check to see what breakpoints are set # if [target_info exists gdb_stub] { - set main_line 72 + set main_line $bp_location5 } else { - set main_line 75 + set main_line $bp_location6 } if {$hp_aCC_compiler} { @@ -155,16 +173,20 @@ if {$hp_aCC_compiler} { set proto "" } +set bp_location7 [gdb_get_line_number "set breakpoint 7 here"] +set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1] +set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1] + gdb_test "info break" \ "Num Type\[ \]+Disp Enb Address\[ \]+What.* \[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.* -\[0-9\]+\[\t \]+breakpoint keep y.* in marker2 at .*$srcfile:4\[49\].* -\[0-9\]+\[\t \]+breakpoint keep y.* in factorial$proto at .*$srcfile:96.* -\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:79.* -\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:79.* -\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:85.* -\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_if_conditional at .*$srcfile:109.* -\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_while_conditional at .*$srcfile:124" \ +\[0-9\]+\[\t \]+breakpoint keep y.* in marker2 at .*$srcfile1:($bp_location8|$bp_location9).* +\[0-9\]+\[\t \]+breakpoint keep y.* in factorial$proto at .*$srcfile:$bp_location7.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location2.* +\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_if_conditional at .*$srcfile:$bp_location3.* +\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_while_conditional at .*$srcfile:$bp_location4" \ "breakpoint info" # FIXME: The rest of this test doesn't work with anything that can't @@ -191,52 +213,53 @@ if ![target_info exists use_gdb_stub] { send_gdb "y\n" exp_continue } - -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:75.*75\[\t \]+if .argc.* \{.*$gdb_prompt $"\ + -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\ { pass "run until function breakpoint" } -re ".*$gdb_prompt $" { fail "run until function breakpoint" } timeout { fail "run until function breakpoint (timeout)" } } } else { if ![target_info exists gdb_stub] { - gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:75.*75\[\t \]+if .argc.*\{.*" "stub continue" + gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue" } } # # run until the breakpoint at a line number # -gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:79.*79\[\t \]+printf.*factorial.*" \ +gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location1.*$bp_location1\[\t \]+printf.*factorial.*" \ "run until breakpoint set at a line number" # # Run until the breakpoint set in a function in a file # for {set i 6} {$i >= 1} {incr i -1} { - gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, factorial \\(value=$i\\) at .*$srcfile:96.*96\[\t \]+.*if .value > 1. \{.*" \ + gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, factorial \\(value=$i\\) at .*$srcfile:$bp_location7.*$bp_location7\[\t \]+.*if .value > 1. \{.*" \ "run until file:function($i) breakpoint" } # # Run until the breakpoint set at a quoted function # -gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, (0x\[0-9a-f\]+ in )?marker2 \\(a=43\\) at .*$srcfile:4\[49\].*" \ +gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, (0x\[0-9a-f\]+ in )?marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*" \ "run until quoted breakpoint" # # run until the file:function breakpoint at a line number in a file # -gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:85.*85\[\t \]+argc = \\(argc == 12345\\);.*" \ +gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location2.*$bp_location2\[\t \]+argc = \\(argc == 12345\\);.*" \ "run until file:linenum breakpoint" # Test break at offset +1 +set bp_location10 [gdb_get_line_number "set breakpoint 10 here"] gdb_test "break +1" \ - "Breakpoint.*at.* file .*$srcfile, line 86\\." \ + "Breakpoint.*at.* file .*$srcfile, line $bp_location10\\." \ "breakpoint offset +1" # Check to see if breakpoint is hit when stepped onto gdb_test "step" \ - ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:86.*86\[\t \]+return argc;" \ + ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location10.*$bp_location10\[\t \]+return argc;.*breakpoint 10 here.*" \ "step onto breakpoint" # @@ -260,37 +283,38 @@ gdb_test "tbreak $srcfile:factorial" "Breakpoint.*at.* file .*$srcfile, line.*" # # test break at line number # -send_gdb "tbreak 79\n" +send_gdb "tbreak $bp_location1\n" gdb_expect { - -re "Breakpoint.*at.* file .*$srcfile, line 79.*$gdb_prompt $" { pass "Temporary breakpoint line number #1" } + -re "Breakpoint.*at.* file .*$srcfile, line $bp_location1.*$gdb_prompt $" { pass "Temporary breakpoint line number #1" } -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number #1" } timeout { fail "breakpoint line number #1 (timeout)" } } -gdb_test "tbreak 75" "Breakpoint.*at.* file .*$srcfile, line 75.*" "Temporary breakpoint line number #2" +gdb_test "tbreak $bp_location6" "Breakpoint.*at.* file .*$srcfile, line $bp_location6.*" "Temporary breakpoint line number #2" # # test break at line number in file # -send_gdb "tbreak $srcfile:85\n" +send_gdb "tbreak $srcfile:$bp_location2\n" gdb_expect { - -re "Breakpoint.*at.* file .*$srcfile, line 85.*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" } + -re "Breakpoint.*at.* file .*$srcfile, line $bp_location2.*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" } -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" } timeout { fail "Temporary breakpoint line number in file #1 (timeout)" } } -gdb_test "tbreak $srcfile:81" "Breakpoint.*at.* file .*$srcfile, line 81.*" "Temporary breakpoint line number in file #2" +set bp_location11 [gdb_get_line_number "set breakpoint 11 here"] +gdb_test "tbreak $srcfile:$bp_location11" "Breakpoint.*at.* file .*$srcfile, line $bp_location11.*" "Temporary breakpoint line number in file #2" # # check to see what breakpoints are set (temporary this time) # gdb_test "info break" "Num Type.*Disp Enb Address.*What.*\[\r\n\] \[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$main_line.*\[\r\n\] -\[0-9\]+\[\t \]+breakpoint del.*y.*in factorial$proto at .*$srcfile:96.*\[\r\n\] -\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:79.*\[\r\n\] -\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:75.*\[\r\n\] -\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:85.*\[\r\n\] -\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:81.*" \ +\[0-9\]+\[\t \]+breakpoint del.*y.*in factorial$proto at .*$srcfile:$bp_location7.*\[\r\n\] +\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location1.*\[\r\n\] +\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location6.*\[\r\n\] +\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location2.*\[\r\n\] +\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location11.*" \ "Temporary breakpoint info" @@ -378,7 +402,7 @@ gdb_expect { # Run to the desired default location. If not positioned here, the # tests below don't work. # -gdb_test "until 79" "main .* at .*:79.*" "until 79" +gdb_test "until $bp_location1" "main .* at .*:$bp_location1.*" "until bp_location1" # Verify that GDB allows one to just say "break", which is treated @@ -427,13 +451,13 @@ gdb_expect { # if ![runto_main] then { fail "break tests suppressed" } -send_gdb "break 79\n" +send_gdb "break $bp_location1\n" gdb_expect { - -re "Breakpoint (\[0-9\]*) at .*, line 79.*$gdb_prompt $"\ - {pass "set to-be-silent break 79"} + -re "Breakpoint (\[0-9\]*) at .*, line $bp_location1.*$gdb_prompt $"\ + {pass "set to-be-silent break bp_location1"} -re "$gdb_prompt $"\ - {fail "set to-be-silent break 79"} - timeout {fail "(timeout) set to-be-silent break 79"} + {fail "set to-be-silent break bp_location1"} + timeout {fail "(timeout) set to-be-silent break bp_location1"} } send_gdb "commands $expect_out(1,string)\n" @@ -441,33 +465,33 @@ send_gdb "silent\n" send_gdb "end\n" gdb_expect { -re ".*$gdb_prompt $"\ - {pass "set silent break 79"} - timeout {fail "(timeout) set silent break 79"} + {pass "set silent break bp_location1"} + timeout {fail "(timeout) set silent break bp_location1"} } send_gdb "info break $expect_out(1,string)\n" gdb_expect { - -re "\[0-9\]*\[ \t\]*breakpoint.*:79\r\n\[ \t\]*silent.*$gdb_prompt $"\ - {pass "info silent break 79"} + -re "\[0-9\]*\[ \t\]*breakpoint.*:$bp_location1\r\n\[ \t\]*silent.*$gdb_prompt $"\ + {pass "info silent break bp_location1"} -re "$gdb_prompt $"\ - {fail "info silent break 79"} - timeout {fail "(timeout) info silent break 79"} + {fail "info silent break bp_location1"} + timeout {fail "(timeout) info silent break bp_location1"} } send_gdb "continue\n" gdb_expect { -re "Continuing.\r\n$gdb_prompt $"\ - {pass "hit silent break 79"} + {pass "hit silent break bp_location1"} -re "$gdb_prompt $"\ - {fail "hit silent break 79"} - timeout {fail "(timeout) hit silent break 79"} + {fail "hit silent break bp_location1"} + timeout {fail "(timeout) hit silent break bp_location1"} } send_gdb "bt\n" gdb_expect { - -re "#0 main .* at .*:79.*$gdb_prompt $"\ - {pass "stopped for silent break 79"} + -re "#0 main .* at .*:$bp_location1.*$gdb_prompt $"\ + {pass "stopped for silent break bp_location1"} -re "$gdb_prompt $"\ - {fail "stopped for silent break 79"} - timeout {fail "(timeout) stopped for silent break 79"} + {fail "stopped for silent break bp_location1"} + timeout {fail "(timeout) stopped for silent break bp_location1"} } # Verify that GDB can at least parse a breakpoint with the @@ -475,7 +499,8 @@ gdb_expect { # thread-specific breakpoint really triggers appropriately. # The gdb.threads subdirectory contains tests for that.) # -send_gdb "break 80 thread 999\n" +set bp_location12 [gdb_get_line_number "set breakpoint 12 here"] +send_gdb "break $bp_location12 thread 999\n" gdb_expect { -re "Unknown thread 999.*$gdb_prompt $"\ {pass "thread-specific breakpoint on non-existent thread disallowed"} @@ -483,7 +508,7 @@ gdb_expect { {fail "thread-specific breakpoint on non-existent thread disallowed"} timeout {fail "(timeout) thread-specific breakpoint on non-existent thread disallowed"} } -send_gdb "break 80 thread foo\n" +send_gdb "break $bp_location12 thread foo\n" gdb_expect { -re "Junk after thread keyword..*$gdb_prompt $"\ {pass "thread-specific breakpoint on bogus thread ID disallowed"} @@ -495,7 +520,7 @@ gdb_expect { # Verify that GDB responds gracefully to a breakpoint command with # trailing garbage. # -send_gdb "break 80 foo\n" +send_gdb "break $bp_location12 foo\n" gdb_expect { -re "Junk at end of arguments..*$gdb_prompt $"\ {pass "breakpoint with trailing garbage disallowed"} @@ -542,15 +567,15 @@ gdb_test "clear marker3" {Deleted breakpoints [0-9]+ [0-9]+.*} # Verify that a breakpoint can be set via a convenience variable. # -send_gdb "set \$foo=81\n" +send_gdb "set \$foo=$bp_location11\n" gdb_expect { -re "$gdb_prompt $"\ - {pass "set convenience variable \$foo to 81"} - timeout {fail "(timeout) set convenience variable \$foo to 81"} + {pass "set convenience variable \$foo to bp_location11"} + timeout {fail "(timeout) set convenience variable \$foo to bp_location11"} } send_gdb "break \$foo\n" gdb_expect { - -re "Breakpoint (\[0-9\]*) at .*, line 81.*$gdb_prompt $"\ + -re "Breakpoint (\[0-9\]*) at .*, line $bp_location11.*$gdb_prompt $"\ {pass "set breakpoint via convenience variable"} -re "$gdb_prompt $"\ {fail "set breakpoint via convenience variable"} @@ -579,7 +604,7 @@ gdb_expect { # send_gdb "break marker2\n" gdb_expect { - -re "Breakpoint (\[0-9\]*) at .*, line 4\[49\].*$gdb_prompt $"\ + -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location8|$bp_location9).*$gdb_prompt $"\ {pass "set breakpoint on to-be-called function"} -re "$gdb_prompt $"\ {fail "set breakpoint on to-be-called function"} @@ -602,9 +627,9 @@ gdb_expect { # send_gdb "bt\n" gdb_expect { - -re "#0\[ \t\]*($hex in )?marker2.*:4\[49\]\r\n#1.*_sr4export.*$gdb_prompt $"\ + -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*_sr4export.*$gdb_prompt $"\ {pass "backtrace while in called function"} - -re "#0\[ \t\]*($hex in )?marker2.*:4\[49\]\r\n#1.*function called from gdb.*$gdb_prompt $"\ + -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*function called from gdb.*$gdb_prompt $"\ {pass "backtrace while in called function"} -re "$gdb_prompt $"\ {fail "backtrace while in called function"} @@ -617,11 +642,11 @@ gdb_expect { # send_gdb "finish\n" gdb_expect { - -re "Run till exit from .*marker2.* at .*4\[49\]\r\n.* in _sr4export.*$gdb_prompt $"\ + -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.* in _sr4export.*$gdb_prompt $"\ {pass "finish from called function"} - -re "Run till exit from .*marker2.* at .*4\[49\]\r\n.*function called from gdb.*$gdb_prompt $"\ + -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*function called from gdb.*$gdb_prompt $"\ {pass "finish from called function"} - -re "Run till exit from .*marker2.* at .*4\[49\]\r\n.*Value returned.*$gdb_prompt $"\ + -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*Value returned.*$gdb_prompt $"\ {pass "finish from called function"} -re "$gdb_prompt $"\ {fail "finish from called function"} @@ -833,8 +858,16 @@ test_next_with_recursion set binfileo2 ${objdir}/${subdir}/${testfile}o2 -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfileo2}" executable {debug additional_flags="-O2" }] != "" } { - gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}O0.o" object {debug "additional_flags=-w -O2"}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}O1.o" object {debug "additional_flags=-w -O2"}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${binfile}O0.o ${binfile}O1.o" "${binfileo2}" executable {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } if [get_compiler_info ${binfileo2}] { @@ -861,7 +894,7 @@ gdb_test "break main" \ # test break at function # gdb_test "break marker4" \ - "Breakpoint.*at.* file .*$srcfile, line.*" \ + "Breakpoint.*at.* file .*$srcfile1, line.*" \ "breakpoint small function, optimized file" # @@ -880,7 +913,7 @@ if ![target_info exists use_gdb_stub] { send_gdb "y\n" exp_continue } - -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:75.*75\[\t \]+if .argc.* \{.*$gdb_prompt $"\ + -re "Starting program.*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 "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $"\ { pass "run until function breakpoint, optimized file (code motion)" } @@ -889,7 +922,7 @@ if ![target_info exists use_gdb_stub] { } } else { if ![target_info exists gdb_stub] { - gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:75.*75\[\t \]+if .argc.*\{.*" "stub continue, optimized file" + gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue, optimized file" } } @@ -906,17 +939,19 @@ if ![target_info exists use_gdb_stub] { # 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" $srcfile1] +set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1] send_gdb "continue\n" gdb_expect { - -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile:51\[\r\n\]+51\[\t \]+void marker4.*" { + -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile1:$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:51\[\r\n\]+51\[\t \]+void marker4.*" { + -re "Breakpoint $decimal, $hex in marker4 \\(d=177601976\\) at .*$srcfile1:$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:46\[\r\n\]+46\[\t \]+void marker4.*" { + -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile1:$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 46)" + 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" diff --git a/gdb/testsuite/gdb.base/break1.c b/gdb/testsuite/gdb.base/break1.c new file mode 100644 index 00000000000..2ed8b2a4a02 --- /dev/null +++ b/gdb/testsuite/gdb.base/break1.c @@ -0,0 +1,44 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003 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 */ + +/* The code for this file was extracted from the gdb testsuite + testcase "break.c". */ + +/* The following functions do nothing useful. They are included + simply as places to try setting breakpoints at. They are + explicitly "one-line functions" to verify that this case works + (some versions of gcc have or have had problems with this). + + These functions are in a separate source file to prevent an + optimizing compiler from inlining them and optimizing them away. */ + +#ifdef PROTOTYPES +int marker1 (void) { return (0); } /* set breakpoint 15 here */ +int marker2 (int a) { return (1); } /* set breakpoint 8 here */ +void marker3 (char *a, char *b) {} /* set breakpoint 17 here */ +void marker4 (long d) {} /* set breakpoint 14 here */ +#else +int marker1 () { return (0); } /* set breakpoint 16 here */ +int marker2 (a) int a; { return (1); } /* set breakpoint 9 here */ +void marker3 (a, b) char *a, *b; {} /* set breakpoint 18 here */ +void marker4 (d) long d; {} /* set breakpoint 13 here */ +#endif diff --git a/gdb/testsuite/gdb.base/call-ar-st.exp b/gdb/testsuite/gdb.base/call-ar-st.exp index a7ea5cf56aa..9b0e5398a2f 100644 --- a/gdb/testsuite/gdb.base/call-ar-st.exp +++ b/gdb/testsuite/gdb.base/call-ar-st.exp @@ -1,4 +1,4 @@ -# Copyright 1998, 1999, 2000, 2001 +# Copyright 1998, 1999, 2000, 2001, 2004 # Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify @@ -89,8 +89,6 @@ proc set_lang_c {} { } } -source ${binfile}.ci - # Start with a fresh gdb. gdb_exit @@ -107,6 +105,8 @@ if ![runto_main] then { continue } +get_debug_format + #go -until 1209 gdb_test "tbreak 1209" \ "Breakpoint \[0-9\]+.*file.*$srcfile, line 1209.*" \ @@ -502,11 +502,14 @@ set ws "\[\n\r\t \]+" if {![gdb_skip_float_test "print_small_structs from print_long_arg_list"] && \ ![gdb_skip_stdio_test "print_small_structs from print_long_arg_list"] } { - # On Solaris, some of the args are passed by ref, others by value, - # and GDB gets confused and says "Invalid cast" because it thinks - # it has to cast the structure into a pointer to structure. A real - # GDB bug, probably for all Sparc configs, but obscure. -sts 1999-08-17. - setup_xfail "sparc*-*-solaris*" + + # On 32-bit SPARC, some of the args are passed by ref, others by + # value, and GDB gets confused and says "Invalid cast" because it + # thinks it has to cast the structure into a pointer to structure. + if { [test_debug_format "stabs"] } then { + setup_kfail "gdb/1539" "sparc-*-*" + } + send_gdb "print print_small_structs(struct1, struct2, struct3, struct4, flags, flags_combo, three_char, five_char, int_char_combo, d1, d2, d3, f1, f2, f3)\n" gdb_expect_list "print print_small_structs from print_long_arg_list" ".*$gdb_prompt $" { "\[\t\r\n \]+alpha" diff --git a/gdb/testsuite/gdb.base/call-rt-st.c b/gdb/testsuite/gdb.base/call-rt-st.c index 712f70ecbb5..09dd5bb52a9 100644 --- a/gdb/testsuite/gdb.base/call-rt-st.c +++ b/gdb/testsuite/gdb.base/call-rt-st.c @@ -31,6 +31,28 @@ struct small_rep_info_t { int head; }; +/* 6 bits : really fits in 8 bits and is promoted to 8 bits + */ +struct bit_flags_char_t { + unsigned char alpha :1; + unsigned char beta :1; + unsigned char gamma :1; + unsigned char delta :1; + unsigned char epsilon :1; + unsigned char omega :1; +}; + +/* 6 bits : really fits in 8 bits and is promoted to 16 bits + */ +struct bit_flags_short_t { + unsigned short alpha :1; + unsigned short beta :1; + unsigned short gamma :1; + unsigned short delta :1; + unsigned short epsilon :1; + unsigned short omega :1; +}; + /* 6 bits : really fits in 8 bits and is promoted to 32 bits */ struct bit_flags_t { @@ -107,6 +129,90 @@ void loop_count () { } /***************************************************************** + * INIT_BIT_FLAGS_CHAR : + * Initializes a bit_flags_char_t structure. Can call this function see + * the call command behavior when integer arguments do not fit into + * registers and must be placed on the stack. + * OUT struct bit_flags_char_t *bit_flags -- structure to be filled + * IN unsigned a -- 0 or 1 + * IN unsigned b -- 0 or 1 + * IN unsigned g -- 0 or 1 + * IN unsigned d -- 0 or 1 + * IN unsigned e -- 0 or 1 + * IN unsigned o -- 0 or 1 + *****************************************************************/ +#ifdef PROTOTYPES +void init_bit_flags_char ( +struct bit_flags_char_t *bit_flags, +unsigned a, +unsigned b, +unsigned g, +unsigned d, +unsigned e, +unsigned o) +#else +void init_bit_flags_char (bit_flags,a,b,g,d,e,o) +struct bit_flags_char_t *bit_flags; +unsigned a; +unsigned b; +unsigned g; +unsigned d; +unsigned e; +unsigned o; +#endif +{ + + bit_flags->alpha = a; + bit_flags->beta = b; + bit_flags->gamma = g; + bit_flags->delta = d; + bit_flags->epsilon = e; + bit_flags->omega = o; +} + +/***************************************************************** + * INIT_BIT_FLAGS_SHORT : + * Initializes a bit_flags_short_t structure. Can call this function see + * the call command behavior when integer arguments do not fit into + * registers and must be placed on the stack. + * OUT struct bit_flags_short_t *bit_flags -- structure to be filled + * IN unsigned a -- 0 or 1 + * IN unsigned b -- 0 or 1 + * IN unsigned g -- 0 or 1 + * IN unsigned d -- 0 or 1 + * IN unsigned e -- 0 or 1 + * IN unsigned o -- 0 or 1 + *****************************************************************/ +#ifdef PROTOTYPES +void init_bit_flags_short ( +struct bit_flags_short_t *bit_flags, +unsigned a, +unsigned b, +unsigned g, +unsigned d, +unsigned e, +unsigned o) +#else +void init_bit_flags_short (bit_flags,a,b,g,d,e,o) +struct bit_flags_short_t *bit_flags; +unsigned a; +unsigned b; +unsigned g; +unsigned d; +unsigned e; +unsigned o; +#endif +{ + + bit_flags->alpha = a; + bit_flags->beta = b; + bit_flags->gamma = g; + bit_flags->delta = d; + bit_flags->epsilon = e; + bit_flags->omega = o; +} + +/***************************************************************** * INIT_BIT_FLAGS : * Initializes a bit_flags_t structure. Can call this function see * the call command behavior when integer arguments do not fit into @@ -345,6 +451,50 @@ int seed; } /***************************************************************** + * PRINT_BIT_FLAGS_CHAR : + * IN struct bit_flags_char_t bit_flags + ****************************************************************/ +#ifdef PROTOTYPES +struct bit_flags_char_t print_bit_flags_char (struct bit_flags_char_t bit_flags) +#else +struct bit_flags_char_t print_bit_flags_char ( bit_flags) +struct bit_flags_char_t bit_flags; +#endif +{ + + if (bit_flags.alpha) printf("alpha\n"); + if (bit_flags.beta) printf("beta\n"); + if (bit_flags.gamma) printf("gamma\n"); + if (bit_flags.delta) printf("delta\n"); + if (bit_flags.epsilon) printf("epsilon\n"); + if (bit_flags.omega) printf("omega\n"); + return bit_flags; + +} + +/***************************************************************** + * PRINT_BIT_FLAGS_SHORT : + * IN struct bit_flags_short_t bit_flags + ****************************************************************/ +#ifdef PROTOTYPES +struct bit_flags_short_t print_bit_flags_short (struct bit_flags_short_t bit_flags) +#else +struct bit_flags_short_t print_bit_flags_short ( bit_flags) +struct bit_flags_short_t bit_flags; +#endif +{ + + if (bit_flags.alpha) printf("alpha\n"); + if (bit_flags.beta) printf("beta\n"); + if (bit_flags.gamma) printf("gamma\n"); + if (bit_flags.delta) printf("delta\n"); + if (bit_flags.epsilon) printf("epsilon\n"); + if (bit_flags.omega) printf("omega\n"); + return bit_flags; + +} + +/***************************************************************** * PRINT_BIT_FLAGS : * IN struct bit_flags_t bit_flags ****************************************************************/ @@ -553,6 +703,8 @@ int main () { /* variables for testing a small structures and a very long argument list */ struct small_rep_info_t *struct1; + struct bit_flags_char_t *cflags; + struct bit_flags_short_t *sflags; struct bit_flags_t *flags; struct bit_flags_combo_t *flags_combo; struct three_char_t *three_char; @@ -577,6 +729,8 @@ int main () { /* Allocate space for small structures */ struct1 = (struct small_rep_info_t *)malloc(sizeof(struct small_rep_info_t)); + cflags = (struct bit_flags_char_t *)malloc(sizeof(struct bit_flags_char_t)); + sflags = (struct bit_flags_short_t *)malloc(sizeof(struct bit_flags_short_t)); flags = (struct bit_flags_t *)malloc(sizeof(struct bit_flags_t)); flags_combo = (struct bit_flags_combo_t *)malloc(sizeof(struct bit_flags_combo_t)); three_char = (struct three_char_t *)malloc(sizeof(struct three_char_t)); @@ -590,6 +744,10 @@ int main () { */ init_one_double ( d1, 1.11111); init_two_floats ( f3, -2.345, 1.0); + init_bit_flags_char(cflags, (unsigned)1, (unsigned)0, (unsigned)1, + (unsigned)0, (unsigned)1, (unsigned)0 ); + init_bit_flags_short(sflags, (unsigned)1, (unsigned)0, (unsigned)1, + (unsigned)0, (unsigned)1, (unsigned)0 ); init_bit_flags(flags, (unsigned)1, (unsigned)0, (unsigned)1, (unsigned)0, (unsigned)1, (unsigned)0 ); init_bit_flags_combo(flags_combo, (unsigned)1, (unsigned)0, 'y', @@ -605,6 +763,8 @@ int main () { */ print_one_double(*d1); print_two_floats(*f3); + print_bit_flags_char(*cflags); + print_bit_flags_short(*sflags); print_bit_flags(*flags); print_bit_flags_combo(*flags_combo); print_three_chars(*three_char); diff --git a/gdb/testsuite/gdb.base/call-rt-st.exp b/gdb/testsuite/gdb.base/call-rt-st.exp index 0acd1393a7a..4a912fcdc29 100644 --- a/gdb/testsuite/gdb.base/call-rt-st.exp +++ b/gdb/testsuite/gdb.base/call-rt-st.exp @@ -1,4 +1,5 @@ -# Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +# Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 +# 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 @@ -91,11 +92,6 @@ proc set_lang_c {} { } } - - -source ${binfile}.ci - - # Start with a fresh gdb. gdb_exit @@ -114,13 +110,13 @@ if ![runto_main] then { gdb_test "break loop_count" \ - "Breakpoint.* file .*call-rt-st.c, line 106\\." \ + "Breakpoint.* file .*call-rt-st.c, line 128\\." \ "breakpoint loop_count" send_gdb "continue\n" gdb_expect { - -re "Continuing\\..*Breakpoint.*loop_count \\(\\) at.*call-rt-st.c:106\[ \t\r\n\]+106\[\t \]+for \\(index=0; index.4; index..\\);\[\r\n \]+$gdb_prompt $" { + -re "Continuing\\..*Breakpoint.*loop_count \\(\\) at.*call-rt-st.c:128\[ \t\r\n\]+128\[\t \]+for \\(index=0; index.4; index..\\);\[\r\n \]+$gdb_prompt $" { pass "continue to loop_count"} -re ".*$gdb_prompt $" { fail "continue to loop_count"} timeout { fail "(timeout) continue to loop_count"} @@ -128,11 +124,11 @@ gdb_expect { send_gdb "finish\n" gdb_expect { - -re "Run till exit from .0 loop_count \\(\\) at.*call-rt-st.c:106\[ \t\r\n\]+main \\(\\) at.*call-rt-st.c:617\[ \t\r\n\]+617\[\t \]+return 0;.*$gdb_prompt $" { - pass "finish out from loop_count (line 617)" + -re "Run till exit from .0 loop_count \\(\\) at.*call-rt-st.c:128\[ \t\r\n\]+main \\(\\) at.*call-rt-st.c:777\[ \t\r\n\]+777\[\t \]+return 0;.*$gdb_prompt $" { + pass "finish out from loop_count (line 777)" } - -re "Run till exit from .0 loop_count \\(\\) at.*call-rt-st.c:106\[ \t\r\n\]+main \\(\\) at.*call-rt-st.c:615\[ \t\r\n\]+615\[\t \]+loop_count.*$gdb_prompt $" { - pass "finish out from loop_count (line 615)" + -re "Run till exit from .0 loop_count \\(\\) at.*call-rt-st.c:128\[ \t\r\n\]+main \\(\\) at.*call-rt-st.c:775\[ \t\r\n\]+775\[\t \]+loop_count.*$gdb_prompt $" { + pass "finish out from loop_count (line 775)" } -re ".*$gdb_prompt $" { fail "finish out from loop_count" @@ -191,6 +187,16 @@ if {![gdb_skip_float_test "print print_two_floats(*f3)"] && \ ".*Contents of two_floats_t:\[ \r\n\]+-2\\.345000\[ \t]+1\\.000000\[ \r\n\]+.\[0-9\]+ = \\{float1 = -2\\.34500003, float2 = 1\\}" } +if ![gdb_skip_stdio_test "print print_bit_flags_char(*flags)"] { + print_struct_call "print_bit_flags_char(*flags)" \ + ".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+.\[0-9\]+ = \\{alpha = 1 '\\\\001', beta = 0 '\\\\0', gamma = 1 '\\\\001', delta = 0 '\\\\0', epsilon = 1 '\\\\001', omega = 0 '\\\\0'\\}" +} + +if ![gdb_skip_stdio_test "print print_bit_flags_short(*flags)"] { + print_struct_call "print_bit_flags_short(*flags)" \ + ".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+.\[0-9\]+ = \\{alpha = 1, beta = 0, gamma = 1, delta = 0, epsilon = 1, omega = 0\\}" +} + if ![gdb_skip_stdio_test "print print_bit_flags(*flags)"] { print_struct_call "print_bit_flags(*flags)" \ ".*alpha\[ \r\n\]+gamma\[ \r\n\]+epsilon\[ \r\n\]+.\[0-9\]+ = \\{alpha = 1, beta = 0, gamma = 1, delta = 0, epsilon = 1, omega = 0\\}" diff --git a/gdb/testsuite/gdb.base/callfuncs.c b/gdb/testsuite/gdb.base/callfuncs.c index 9917e788d0a..a52b2b138f9 100644 --- a/gdb/testsuite/gdb.base/callfuncs.c +++ b/gdb/testsuite/gdb.base/callfuncs.c @@ -1,3 +1,25 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 1993, 1994, 1995, 1998, 1999, 2000, 2001, 2004 + 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 */ + /* Support program for testing gdb's ability to call functions in the inferior, pass appropriate arguments to those functions, and get the returned result. */ @@ -357,7 +379,7 @@ int a, b; /* Gotta have a main to be able to generate a linked, runnable executable, and also provide a useful place to set a breakpoint. */ -extern void * malloc() ; + int main () { #ifdef usestubs diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp index 7a5f14302d7..feccd6f7ea5 100644 --- a/gdb/testsuite/gdb.base/callfuncs.exp +++ b/gdb/testsuite/gdb.base/callfuncs.exp @@ -1,5 +1,5 @@ -# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 -# Free Software Foundation, Inc. +# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 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 @@ -95,7 +95,6 @@ proc set_lang_c {} { proc do_function_calls {} { global prototypes - global gcc_compiled global gdb_prompt # We need to up this because this can be really slow on some boards. @@ -149,7 +148,7 @@ proc do_function_calls {} { # to be a generic problem on quite a few platforms. if $prototypes then { setup_xfail "sparc-*-*" "mips*-*-*" 5318 - if {!$gcc_compiled} then { + if { ! [test_compiler_info gcc-*-*] } then { setup_xfail "alpha-dec-osf2*" "i*86-*-sysv4*" 5318 } } @@ -182,30 +181,27 @@ proc do_function_calls {} { gdb_test "p t_func_values(func_val2,func_val1)" " = 0" gdb_test "p t_func_values(func_val1,func_val2)" " = 1" - # On the rs6000, we need to pass the address of the trampoline routine, - # not the address of add itself. I don't know how to go from add to - # the address of the trampoline. Similar problems exist on the HPPA, - # and in fact can present an unsolvable problem as the stubs may not - # even exist in the user's program. We've slightly recoded t_func_values - # to avoid such problems in the common case. This may or may not help - # the RS6000. - setup_xfail "rs6000*-*-*" - setup_xfail "powerpc*-*-*" - if {![istarget hppa*-*-hpux*]} then { - gdb_test "p t_func_values(add,func_val2)" " = 1" - } - - setup_xfail "rs6000*-*-*" - setup_xfail "powerpc*-*-*" - if {![istarget hppa*-*-hpux*]} then { - gdb_test "p t_func_values(func_val1,doubleit)" " = 1" - } - - setup_xfail "rs6000*-*-*" - setup_xfail "powerpc*-*-*" - if {![istarget hppa*-*-hpux*]} then { - gdb_test "p t_call_add(add,3,4)" " = 7" - } + # GDB currently screws up the passing of function parameters for + # ABIs that use function descriptors. Instead of passing the + # address of te function descriptor, GDB passes the address of the + # function body. This results in the called function treating the + # first few instructions of the function proper as a descriptor + # and attempting a jump through that (a totally random address). + setup_kfail "rs6000*-*-aix*" gdb/1457 + setup_kfail "powerpc*-*-aix*" gdb/1457 + setup_kfail "powerpc64*-*-*" gdb/1457 + setup_kfail hppa*-*-hpux* gdb/1457 + gdb_test "p t_func_values(add,func_val2)" " = 1" + setup_kfail "rs6000*-*-aix*" gdb/1457 + setup_kfail "powerpc*-*-aix*" gdb/1457 + setup_kfail "powerpc64*-*-*" gdb/1457 + setup_kfail hppa*-*-hpux* gdb/1457 + gdb_test "p t_func_values(func_val1,doubleit)" " = 1" + setup_kfail "rs6000*-*-aix*" gdb/1457 + setup_kfail "powerpc*-*-aix*" gdb/1457 + setup_kfail "powerpc64*-*-*" gdb/1457 + setup_kfail hppa*-*-hpux* gdb/1457 + gdb_test "p t_call_add(add,3,4)" " = 7" gdb_test "p t_call_add(func_val1,3,4)" " = 7" gdb_test "p t_enum_value1(enumval1)" " = 1" @@ -228,7 +224,7 @@ proc do_function_calls {} { gdb_test "p t_structs_c(struct_val1)" "= 120 'x'" \ "call inferior func with struct - returns char" gdb_test "p t_structs_s(struct_val1)" "= 87" \ - "call inferior func with struct - returns short" + "call inferior func with struct - returns short" gdb_test "p t_structs_i(struct_val1)" "= 76" \ "call inferior func with struct - returns int" gdb_test "p t_structs_l(struct_val1)" "= 51" \ diff --git a/gdb/testsuite/gdb.base/charset.c b/gdb/testsuite/gdb.base/charset.c index ece684a1ef9..4361ffc7bc2 100644 --- a/gdb/testsuite/gdb.base/charset.c +++ b/gdb/testsuite/gdb.base/charset.c @@ -1,7 +1,28 @@ -/* Test GDB's character set support - Jim Blandy <jimb@cygnus.com> --- December 2001 */ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2001, 2004 Free Software Foundation, Inc. + + Contributed by Red Hat, originally written by Jim Blandy. + + 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@gnu.org */ #include <stdio.h> +#include <string.h> /* X_string is a null-terminated string in the X charset whose @@ -13,21 +34,20 @@ [0] --- the `alert' character, '\a' [1] --- the `backspace' character, '\b' - [2] --- the `escape' character, '\e' - [3] --- the `form feed' character, '\f' - [4] --- the `line feed' character, '\n' - [5] --- the `carriage return' character, '\r' - [6] --- the `horizontal tab' character, '\t' - [7] --- the `vertical tab' character, '\v' - [8 .. 33] --- the uppercase letters A-Z - [34 .. 59] --- the lowercase letters a-z - [60 .. 69] --- the digits 0-9 - [70] --- the `cent' character - [71] --- a control character with no defined backslash escape + [2] --- the `form feed' character, '\f' + [3] --- the `line feed' character, '\n' + [4] --- the `carriage return' character, '\r' + [5] --- the `horizontal tab' character, '\t' + [6] --- the `vertical tab' character, '\v' + [7 .. 32] --- the uppercase letters A-Z + [33 .. 58] --- the lowercase letters a-z + [59 .. 68] --- the digits 0-9 + [69] --- the `cent' character + [70] --- a control character with no defined backslash escape Feel free to extend these as you like. */ -#define NUM_CHARS (72) +#define NUM_CHARS (71) char ascii_string[NUM_CHARS]; char iso_8859_1_string[NUM_CHARS]; @@ -38,21 +58,20 @@ char ibm1047_string[NUM_CHARS]; void init_string (char string[], char x, - char alert, char backspace, char escape, char form_feed, + char alert, char backspace, char form_feed, char line_feed, char carriage_return, char horizontal_tab, char vertical_tab, char cent, char misc_ctrl) { memset (string, x, NUM_CHARS); string[0] = alert; string[1] = backspace; - string[2] = escape; - string[3] = form_feed; - string[4] = line_feed; - string[5] = carriage_return; - string[6] = horizontal_tab; - string[7] = vertical_tab; - string[70] = cent; - string[71] = misc_ctrl; + string[2] = form_feed; + string[3] = line_feed; + string[4] = carriage_return; + string[5] = horizontal_tab; + string[6] = vertical_tab; + string[69] = cent; + string[70] = misc_ctrl; } @@ -76,56 +95,56 @@ int main () /* Initialize ascii_string. */ init_string (ascii_string, 120, - 7, 8, 27, 12, + 7, 8, 12, 10, 13, 9, 11, 120, 17); - fill_run (ascii_string, 8, 26, 65); - fill_run (ascii_string, 34, 26, 97); - fill_run (ascii_string, 60, 10, 48); + fill_run (ascii_string, 7, 26, 65); + fill_run (ascii_string, 33, 26, 97); + fill_run (ascii_string, 59, 10, 48); /* Initialize iso_8859_1_string. */ init_string (iso_8859_1_string, 120, - 7, 8, 27, 12, + 7, 8, 12, 10, 13, 9, 11, 162, 17); - fill_run (iso_8859_1_string, 8, 26, 65); - fill_run (iso_8859_1_string, 34, 26, 97); - fill_run (iso_8859_1_string, 60, 10, 48); + fill_run (iso_8859_1_string, 7, 26, 65); + fill_run (iso_8859_1_string, 33, 26, 97); + fill_run (iso_8859_1_string, 59, 10, 48); /* Initialize ebcdic_us_string. */ init_string (ebcdic_us_string, 167, - 47, 22, 39, 12, + 47, 22, 12, 37, 13, 5, 11, 74, 17); /* In EBCDIC, the upper-case letters are broken into three separate runs. */ - fill_run (ebcdic_us_string, 8, 9, 193); - fill_run (ebcdic_us_string, 17, 9, 209); - fill_run (ebcdic_us_string, 26, 8, 226); + fill_run (ebcdic_us_string, 7, 9, 193); + fill_run (ebcdic_us_string, 16, 9, 209); + fill_run (ebcdic_us_string, 25, 8, 226); /* The lower-case letters are, too. */ - fill_run (ebcdic_us_string, 34, 9, 129); - fill_run (ebcdic_us_string, 43, 9, 145); - fill_run (ebcdic_us_string, 52, 8, 162); + fill_run (ebcdic_us_string, 33, 9, 129); + fill_run (ebcdic_us_string, 42, 9, 145); + fill_run (ebcdic_us_string, 51, 8, 162); /* The digits, at least, are contiguous. */ - fill_run (ebcdic_us_string, 60, 10, 240); + fill_run (ebcdic_us_string, 59, 10, 240); /* Initialize ibm1047_string. */ init_string (ibm1047_string, 167, - 47, 22, 39, 12, + 47, 22, 12, 37, 13, 5, 11, 74, 17); /* In EBCDIC, the upper-case letters are broken into three separate runs. */ - fill_run (ibm1047_string, 8, 9, 193); - fill_run (ibm1047_string, 17, 9, 209); - fill_run (ibm1047_string, 26, 8, 226); + fill_run (ibm1047_string, 7, 9, 193); + fill_run (ibm1047_string, 16, 9, 209); + fill_run (ibm1047_string, 25, 8, 226); /* The lower-case letters are, too. */ - fill_run (ibm1047_string, 34, 9, 129); - fill_run (ibm1047_string, 43, 9, 145); - fill_run (ibm1047_string, 52, 8, 162); + fill_run (ibm1047_string, 33, 9, 129); + fill_run (ibm1047_string, 42, 9, 145); + fill_run (ibm1047_string, 51, 8, 162); /* The digits, at least, are contiguous. */ - fill_run (ibm1047_string, 60, 10, 240); + fill_run (ibm1047_string, 59, 10, 240); puts ("All set!"); /* all strings initialized */ } diff --git a/gdb/testsuite/gdb.base/charset.exp b/gdb/testsuite/gdb.base/charset.exp index e17bb14bbce..780e909dbca 100644 --- a/gdb/testsuite/gdb.base/charset.exp +++ b/gdb/testsuite/gdb.base/charset.exp @@ -1,4 +1,6 @@ -# Copyright 2001 Free Software Foundation, Inc. +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2001, 2004 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 @@ -15,7 +17,7 @@ # 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 +# bug-gdb@gnu.org # Test GDB's character set support. @@ -439,7 +441,7 @@ foreach target_charset [all_charset_names] { # Compute a regexp matching the results we expect. This is static, # but it's easier than writing it out. - regsub -all "." "abefnrtv" "(\\\\&|x)" escapes + regsub -all "." "abfnrtv" "(\\\\&|x)" escapes set uppercase "ABCDEFGHIJKLMNOPQRSTUVWXYZ" set lowercase "abcdefghijklmnopqrstuvwxyz" set digits "0123456789" @@ -448,7 +450,7 @@ foreach target_charset [all_charset_names] { send_gdb "print $var_name\n" # ${escapes}${uppercase}${lowercase}${digits}${octal}${octal} gdb_expect { - -re ".* = \"(\\\\a|x)(\\\\b|x)(\\\\e|x)(\\\\f|x)(\\\\n|x)(\\\\r|x)(\\\\t|x)(\\\\v|x)${uppercase}${lowercase}${digits}(\\\\\[0-9\]\[0-9\]\[0-9\]|x)(\\\\\[0-9\]\[0-9\]\[0-9\]|x).*\"\[\r\n\]+$gdb_prompt $" { + -re ".* = \"(\\\\a|x)(\\\\b|x)(\\\\f|x)(\\\\n|x)(\\\\r|x)(\\\\t|x)(\\\\v|x)${uppercase}${lowercase}${digits}(\\\\\[0-9\]\[0-9\]\[0-9\]|x)(\\\\\[0-9\]\[0-9\]\[0-9\]|x).*\"\[\r\n\]+$gdb_prompt $" { pass "print string in $target_charset" } -re "$gdb_prompt $" { @@ -465,7 +467,7 @@ foreach target_charset [all_charset_names] { "parse character literal in ${target_charset}" # Check that the character literal was encoded correctly. - gdb_test "print 'A' == $var_name\[8\]" \ + gdb_test "print 'A' == $var_name\[7\]" \ " = 1" \ "check value of parsed character literal in ${target_charset}" @@ -475,14 +477,14 @@ foreach target_charset [all_charset_names] { "parse string literal in ${target_charset}" # Check that the string literal was encoded correctly. - gdb_test "print \"q\"\[0\] == $var_name\[50\]" \ + gdb_test "print \"q\"\[0\] == $var_name\[49\]" \ " = 1" \ "check value of parsed string literal in ${target_charset}" # Test handling of characters in the target charset which # can't be translated into the host charset. if {! [string compare $target_charset iso-8859-1]} { - gdb_test "print iso_8859_1_string\[70\]" \ + gdb_test "print iso_8859_1_string\[69\]" \ " = \[0-9-\]+ '\\\\242'" \ "print character with no equivalent in host character set" gdb_test "print iso_8859_1_string + 70" \ @@ -493,7 +495,7 @@ foreach target_charset [all_charset_names] { # Make sure that we don't apply the ISO-8859-1 `print_literally' # function to ASCII. if {! [string compare $target_charset ascii]} { - gdb_test "print iso_8859_1_string\[70\]" \ + gdb_test "print iso_8859_1_string\[69\]" \ " = \[0-9-\]+ '\\\\242'" \ "print ASCII unprintable character" gdb_test "print iso_8859_1_string + 70" \ @@ -502,7 +504,7 @@ foreach target_charset [all_charset_names] { } # Try printing characters with backslash escape equivalents. - set escapees {a b e f n r t v} + set escapees {a b f n r t v} for {set i 0} {$i < [llength $escapees]} {incr i} { set escape [lindex $escapees $i] send_gdb "print $var_name\[$i\]\n" @@ -541,7 +543,7 @@ foreach target_charset [all_charset_names] { # get the unescaped character, in the target character set. gdb_test "print '\\q'" " = \[0-9-\]+ 'q'" \ "print escape that doesn't exist in $target_charset" - gdb_test "print '\\q' == $var_name\[50\]" " = 1" \ + gdb_test "print '\\q' == $var_name\[49\]" " = 1" \ "check value of escape that doesn't exist in $target_charset" } diff --git a/gdb/testsuite/gdb.base/chng-syms.c b/gdb/testsuite/gdb.base/chng-syms.c new file mode 100644 index 00000000000..3394f5c3897 --- /dev/null +++ b/gdb/testsuite/gdb.base/chng-syms.c @@ -0,0 +1,22 @@ +/* + * Test that GDB cleans up properly after errors that result when a + * breakpoint is reset. + */ + +/* VARIABLE is a macro defined on the compiler command line. */ + +#include <stdlib.h> + +int VARIABLE = 42; + +void stop_here () +{ + VARIABLE *= 2; +} + +int main () +{ + stop_here (); + exit (0); +} + diff --git a/gdb/testsuite/gdb.base/chng-syms.exp b/gdb/testsuite/gdb.base/chng-syms.exp new file mode 100644 index 00000000000..b967d21614b --- /dev/null +++ b/gdb/testsuite/gdb.base/chng-syms.exp @@ -0,0 +1,126 @@ +# Copyright 2004 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 + +# Author: Paul N. Hilfinger (Hilfinger@gnat.com) + +# Test that GDB cleans up properly after errors that result when a +# breakpoint is reset. + +if $tracelevel then { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +# IDT/SIM apparently doesn't have enough file descriptors to allow the +# problem checked by this test to occur. +if [istarget "mips-idt-*"] { + return 0; +} + +set testfile "chng-syms" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var1}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +set oldtimeout $timeout +set timeout 10 +verbose "Timeout is now 10 seconds" 2 + +proc expect_to_stop_here { ident } { + global gdb_prompt + global decimal + + # the "at foo.c:36" output we get with -g. + # the "in func" output we get without -g. + gdb_expect { + -re "Breakpoint \[0-9\]*, stop_here .*$gdb_prompt $" { + return 1 + } + -re "$gdb_prompt $" { + fail "running to stop_here $ident" + return 0 + } + timeout { + fail "running to stop_here $ident (timeout)" + return 0 + } + } + return 1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +gdb_test "break stop_here if (var1 == 42)" \ + "Breakpoint.*at.* file .*$srcfile, line.*" \ + "setting conditional breakpoint on function" +gdb_run_cmd + +expect_to_stop_here "first time" + +gdb_continue_to_end "breakpoint first time through" + +# Now we recompile the executable, but without a variable named "var1", first +# waiting to insure that even on fast machines, the file modification times +# are distinct. This will force GDB to reload the file on the +# next "run" command, causing an error when GDB tries to tries to reset +# the breakpoint. + +sleep 2 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DVARIABLE=var2}] != "" } { + +# Complication: Since GDB generally holds an open file descriptor on the +# executable at this point, there are some systems in which the +# re-compilation will fail. In such cases, we'll consider the test +# (vacuously) passed providing that re-running it succeeds as before. + + gdb_run_cmd + expect_to_stop_here "after re-compile fails" + gdb_continue_to_end "after re-compile fails" + +} else { + + gdb_run_cmd + gdb_expect { + -re "Error in re-setting .*No symbol .var1..*Program exited normally.*$gdb_prompt $" { + pass "running with invalidated bpt condition after executable changes" + } + -re "Error in re-setting .*No symbol .var1..*Breakpoint .*,( 0x.* in)? exit .*$gdb_prompt $" { + pass "running with invalidated bpt condition after executable changes" + } + -re "$gdb_prompt $" { + fail "running with invalidated bpt condition after executable changes" + } + timeout { + fail "(timeout) running with invalidated bpt condition after executable changes" + } + } + +} + +set timeout $oldtimeout +verbose "Timeout is now $timeout seconds" 2 +return 0 diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp index d35353d6469..93ddd7ed9cb 100644 --- a/gdb/testsuite/gdb.base/commands.exp +++ b/gdb/testsuite/gdb.base/commands.exp @@ -1,5 +1,5 @@ # Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1997, 1998, 1999, 2000, -# 2001 Free Software Foundation, Inc. +# 2001, 2002, 2003 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 @@ -443,6 +443,11 @@ proc deprecated_command_test {} { proc bp_deleted_in_command_test {} { global gdb_prompt + if [target_info exists noargs] { + verbose "Skipping bp_deleted_in_command_test because of noargs." + return + } + gdb_test "set args 1" "" "set args in bp_deleted_in_command_test" delete_breakpoints @@ -504,6 +509,11 @@ proc bp_deleted_in_command_test {} { proc temporary_breakpoint_commands {} { global gdb_prompt + if [target_info exists noargs] { + verbose "Skipping temporary_breakpoint_commands because of noargs." + return + } + gdb_test "set args 1" "" "set args in temporary_breakpoint_commands" delete_breakpoints diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp index a1ff58a2554..1698a3056d3 100644 --- a/gdb/testsuite/gdb.base/completion.exp +++ b/gdb/testsuite/gdb.base/completion.exp @@ -1,4 +1,4 @@ -# Copyright 1998, 1999, 2002, 2003 Free Software Foundation, Inc. +# Copyright 1998, 1999, 2002, 2003, 2004 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 @@ -38,8 +38,8 @@ # "info ajksdlfk " no completions # "info" " " # "info " ambiguous (all info commands) -# "p \"break" unambiguous (completes to filename "break.c") -# "p \"break." unambiguous (should complete to "break.c" but does not, +# "p \"break1" unambiguous (completes to filename "break1.c") +# "p \"break1." unambiguous (should complete to "break1.c" but does not, # due to readline limitations) # "p 'a" ambiguous (all symbols starting with a) # "p b-a" ambiguous (all symbols starting with a) @@ -64,9 +64,19 @@ set bug_id 0 set testfile "break" set srcfile ${testfile}.c +set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { - gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } if [get_compiler_info ${binfile}] { @@ -351,61 +361,61 @@ gdb_expect { } -send_gdb "p \"break\t" +send_gdb "p \"break1\t" sleep 1 gdb_expect { - -re "^p \"break\\\x07$"\ + -re "^p \"break1\\\x07$"\ { send_gdb "\n" gdb_expect { - -re ".*$gdb_prompt $" { fail "complete 'p \"break'"} - timeout {fail "(timeout) complete 'p \"break'"} + -re ".*$gdb_prompt $" { fail "complete 'p \"break1'"} + timeout {fail "(timeout) complete 'p \"break1'"} } } - -re "^p \"break\\.c\"$"\ + -re "^p \"break1\\.c\"$"\ { send_gdb "\n" gdb_expect { - -re ".*$gdb_prompt $" { pass "complete 'p \"break'"} - timeout {fail "(timeout) complete 'p \"break'"} + -re ".*$gdb_prompt $" { pass "complete 'p \"break1'"} + timeout {fail "(timeout) complete 'p \"break1'"} } } - -re "^p \"break.*$" + -re "^p \"break1.*$" { send_gdb "\n" gdb_expect { - -re ".*$gdb_prompt $" { fail "complete 'p \"break'"} - timeout {fail "(timeout) complete 'p \"break'"} + -re ".*$gdb_prompt $" { fail "complete 'p \"break1'"} + timeout {fail "(timeout) complete 'p \"break1'"} } } - -re ".*$gdb_prompt $" { fail "complete 'p \"break'" } - timeout { fail "(timeout) complete 'p \"break'" } + -re ".*$gdb_prompt $" { fail "complete 'p \"break1'" } + timeout { fail "(timeout) complete 'p \"break1'" } } setup_xfail "*-*-*" -send_gdb "p \"break.\t" +send_gdb "p \"break1.\t" sleep 1 gdb_expect { - -re "^p \"break\\.\\\x07$"\ + -re "^p \"break1\\.\\\x07$"\ { send_gdb "\n" gdb_expect { - -re ".*$gdb_prompt $" { fail "complete 'p \"break.'"} - timeout {fail "(timeout) complete 'p \"break.'"} + -re ".*$gdb_prompt $" { fail "complete 'p \"break1.'"} + timeout {fail "(timeout) complete 'p \"break1.'"} } } - -re "^p \"break\\.c\"$"\ + -re "^p \"break1\\.c\"$"\ { send_gdb "\n" gdb_expect { - -re ".*$gdb_prompt $" { pass "complete 'p \"break.'"} - timeout {fail "(timeout) complete 'p \"break.'"} + -re ".*$gdb_prompt $" { pass "complete 'p \"break1.'"} + timeout {fail "(timeout) complete 'p \"break1.'"} } } - -re "^p \"break\\..*$" + -re "^p \"break1\\..*$" { send_gdb "\n" gdb_expect { - -re ".*$gdb_prompt $" { fail "complete 'p \"break.'"} - timeout {fail "(timeout) complete 'p \"break.'"} + -re ".*$gdb_prompt $" { fail "complete 'p \"break1.'"} + timeout {fail "(timeout) complete 'p \"break1.'"} } } - -re ".*$gdb_prompt $" { fail "complete 'p \"break.'" } - timeout { fail "(timeout) complete 'p \"break.'" } + -re ".*$gdb_prompt $" { fail "complete 'p \"break1.'" } + timeout { fail "(timeout) complete 'p \"break1.'" } } send_gdb "p 'a\t" @@ -647,6 +657,15 @@ gdb_test "cd ${fullsrcdir}" \ "Working directory [string_to_regexp ${fullsrcdir}].*" \ "cd to \${srcdir}" +send_gdb "complete file ./gdb.base/compl\n" +sleep 1 +gdb_expect { + -re "file ./gdb.base/completion\\.exp.*$gdb_prompt $" + { pass "complete-command 'file ./gdb.base/compl'"} + -re ".*$gdb_prompt $" { fail "complete-command 'file ./gdb.base/compl'" } + timeout { fail "(timeout) complete-command 'file ./gdb.base/compl'" } +} + send_gdb "file ./gdb.base/complet\t" sleep 1 gdb_expect { @@ -654,7 +673,6 @@ gdb_expect { { send_gdb "\n" gdb_expect { -re "\r\nA program is being debugged already\\. Kill it\\? \\(y or n\\) $" -\ { send_gdb "n\n" gdb_expect { -re "\r\nProgram not killed\\.\r\n$gdb_prompt $"\ @@ -682,7 +700,7 @@ gdb_expect { -re "marker1.*$gdb_prompt info func marker$"\ { send_gdb "\n" gdb_expect { - -re "All functions matching regular expression \"marker\":.*File.*break.c:\r\nint marker1\\((void|)\\);\r\nint marker2\\(int\\).*marker3\\(char.*char.*\\).*marker4\\(long int\\);.*$gdb_prompt $"\ + -re "All functions matching regular expression \"marker\":.*File.*break1.c:\r\nint marker1\\((void|)\\);\r\nint marker2\\(int\\).*marker3\\(char.*char.*\\).*marker4\\(long int\\);.*$gdb_prompt $"\ { pass "complete 'info func marke'"} -re ".*$gdb_prompt $" { fail "complete 'info func marke'"} timeout {fail "(timeout) complete 'info func marke'"} @@ -700,10 +718,10 @@ gdb_expect { send_gdb "set follow-fork-mode \t\t" sleep 1 gdb_expect { - -re "ask.*child.*parent.*$gdb_prompt set follow-fork-mode $"\ + -re "child.*parent.*$gdb_prompt set follow-fork-mode $"\ { send_gdb "\n" gdb_expect { - -re "Requires an argument.*ask.*child.*parent.*$gdb_prompt $"\ + -re "Requires an argument.*child.*parent.*$gdb_prompt $"\ { pass "complete 'set follow-fork-mode'"} -re "Ambiguous item \"\"\\..*$gdb_prompt $"\ { pass "complete 'set follow-fork-mode'"} diff --git a/gdb/testsuite/gdb.base/complex.exp b/gdb/testsuite/gdb.base/complex.exp index f3f25e561b7..fac7f4f45c8 100644 --- a/gdb/testsuite/gdb.base/complex.exp +++ b/gdb/testsuite/gdb.base/complex.exp @@ -48,7 +48,7 @@ gdb_load $binfile if [runto f2] then { get_debug_format - if {$gcc_compiled == 2 && [test_debug_format "DWARF 2"]} then { + if { [test_compiler_info gcc-2-*] && [test_debug_format "DWARF 2"] } then { setup_xfail "*-*-*" } gdb_test "p *y" "\\\$\[0-9\]* = \{c = 42 '\\*', f = 1 \\+ 0 \\* I\}" \ diff --git a/gdb/testsuite/gdb.base/condbreak.exp b/gdb/testsuite/gdb.base/condbreak.exp index c234431f15f..dc4df21fc0c 100644 --- a/gdb/testsuite/gdb.base/condbreak.exp +++ b/gdb/testsuite/gdb.base/condbreak.exp @@ -1,4 +1,4 @@ -# Copyright 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. +# Copyright 1997, 1998, 1999, 2000, 2001, 2003 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 @@ -12,7 +12,7 @@ # # 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. */ +# 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 @@ -35,10 +35,19 @@ set bug_id 0 set testfile "break" set srcfile ${testfile}.c +set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { - gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } if [get_compiler_info ${binfile}] { @@ -55,6 +64,13 @@ if [target_info exists gdb_stub] { gdb_step_for_stub; } +set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] +set bp_location6 [gdb_get_line_number "set breakpoint 6 here"] +set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1] +set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1] +set bp_location15 [gdb_get_line_number "set breakpoint 15 here" $srcfile1] +set bp_location16 [gdb_get_line_number "set breakpoint 16 here" $srcfile1] + # # test break at function # @@ -66,15 +82,15 @@ gdb_test "break main" \ # test conditional break at function # gdb_test "break marker1 if 1==1" \ - "Breakpoint.*at.* file .*$srcfile, line.*" + "Breakpoint.*at.* file .*$srcfile1, line.*" gdb_test "delete 2" "" # # test conditional break at line number # -gdb_test "break 79 if 1==1" \ - "Breakpoint.*at.* file .*$srcfile, line 79\\." +gdb_test "break $srcfile:$bp_location1 if 1==1" \ + "Breakpoint.*at.* file .*$srcfile, line $bp_location1\\." gdb_test "delete 3" "" @@ -82,16 +98,16 @@ gdb_test "delete 3" "" # test conditional break at function # gdb_test "break marker1 if (1==1)" \ - "Breakpoint.*at.* file .*$srcfile, line.*" + "Breakpoint.*at.* file .*$srcfile1, line.*" # # test conditional break at line number # -gdb_test "break 79 if (1==1)" \ - "Breakpoint.*at.* file .*$srcfile, line 79\\." +gdb_test "break $srcfile:$bp_location1 if (1==1)" \ + "Breakpoint.*at.* file .*$srcfile, line $bp_location1\\." gdb_test "break marker2 if (a==43)" \ - "Breakpoint.*at.* file .*$srcfile, line.*" + "Breakpoint.*at.* file .*$srcfile1, line.*" # # check to see what breakpoints are set @@ -105,15 +121,14 @@ if {$hp_aCC_compiler} { set marker2_proto "" } -set main_line 75 gdb_test "info break" \ "Num Type\[ \]+Disp Enb Address\[ \]+What.* -\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.* -\[0-9\]+\[\t \]+breakpoint keep y.* in marker1$marker1_proto at .*$srcfile:4\[38\].* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location6.* +\[0-9\]+\[\t \]+breakpoint keep y.* in marker1$marker1_proto at .*$srcfile1:($bp_location15|$bp_location16).* \[\t \]+stop only if 1 == 1.* -\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:79.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.* \[\t \]+stop only if 1 == 1.* -\[0-9\]+\[\t \]+breakpoint keep y.* in marker2$marker2_proto at .*$srcfile:4\[49\].* +\[0-9\]+\[\t \]+breakpoint keep y.* in marker2$marker2_proto at .*$srcfile1:($bp_location8|$bp_location9).* \[\t \]+stop only if a == 43.*" \ "breakpoint info" @@ -128,7 +143,7 @@ rerun_to_main # # run until the breakpoint at a line number # -gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:79.*79\[\t \]+printf.*factorial.*" \ +gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location1.*$bp_location1\[\t \]+printf.*factorial.*" \ "run until breakpoint set at a line number" # @@ -173,10 +188,10 @@ gdb_test "continue" "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=. # Until the Dwarf2 writer gets fixed, I'm going to XFAIL its behavior. send_gdb "continue\n" gdb_expect { - -re "Continuing\\..*Breakpoint \[0-9\]+, marker1 \\(\\) at .*$srcfile:4\[38\].*4\[38\]\[\t \]+.*$gdb_prompt $" { + -re "Continuing\\..*Breakpoint \[0-9\]+, marker1 \\(\\) at .*$srcfile1:($bp_location15|$bp_location16).*($bp_location15|$bp_location16)\[\t \]+.*$gdb_prompt $" { pass "run until breakpoint at marker1" } - -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker1 \\(\\) at .*$srcfile:4\[38\].*4\[38\]\[\t \]+.*$gdb_prompt $" { + -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker1 \\(\\) at .*$srcfile1:($bp_location15|$bp_location16).*($bp_location15|$bp_location16)\[\t \]+.*$gdb_prompt $" { xfail "run until breakpoint at marker1" } -re "$gdb_prompt $" { @@ -192,10 +207,10 @@ gdb_expect { setup_xfail hppa2.0w-*-* 11512CLLbs send_gdb "continue\n" gdb_expect { - -re "Continuing\\..*Breakpoint \[0-9\]+, marker2 \\(a=43\\) at .*$srcfile:4\[49\].*4\[49\]\[\t \]+.*" { + -re "Continuing\\..*Breakpoint \[0-9\]+, marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*($bp_location8|$bp_location9)\[\t \]+.*" { pass "run until breakpoint at marker2" } - -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker2 \\(a=43\\) at .*$srcfile:4\[49\].*4\[49\]\[\t \]+.*" { + -re "Continuing\\..*Breakpoint \[0-9\]+, $hex in marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*($bp_location8|$bp_location9)\[\t \]+.*" { xfail "run until breakpoint at marker2" } -re "$gdb_prompt $" { diff --git a/gdb/testsuite/gdb.base/constvars.exp b/gdb/testsuite/gdb.base/constvars.exp index 8a6b60b3ed5..68732867d50 100644 --- a/gdb/testsuite/gdb.base/constvars.exp +++ b/gdb/testsuite/gdb.base/constvars.exp @@ -1,4 +1,4 @@ -# Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003 +# Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 # Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify @@ -48,23 +48,10 @@ if [get_compiler_info ${binfile}] { return -1; } -if {$hp_aCC_compiler || $hp_cc_compiler} { - set lang "c++" -} else { - set lang "" -} - -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [concat debug $lang]] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug ] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -# Create and source the file that provides information about the compiler -# used to compile the test case. - -if [get_compiler_info ${binfile}] { - return -1; -} - gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir @@ -82,14 +69,17 @@ if ![runto_main] then { get_debug_format proc local_compiler_xfail_check { } { - global gcc_compiled; - - if {$gcc_compiled == 2} then { + if { [test_compiler_info gcc-2-*] } then { if { ![test_debug_format "HP"] \ && ![test_debug_format "DWARF 2"] } then { setup_xfail "*-*-*" } } + + global hp_cc_compiler + if { $hp_cc_compiler } { + setup_xfail "hppa*-*-hpux*" + } } send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $" @@ -128,7 +118,7 @@ send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $" # test function parameters local_compiler_xfail_check -if {$gcc_compiled == 3 && [test_debug_format "stabs"]} then { +if { [test_compiler_info gcc-3-*] && [test_debug_format "stabs"] } then { # With stabs, even GCC 3 does not get the const char arguments correct. setup_xfail "*-*-*" } @@ -144,8 +134,6 @@ gdb_expect { # test vars and pointers proc do_constvar_tests {} { - global gcc_compiled - gdb_test "print lave" " = 66 'B'" gdb_test "ptype lave" "type = char" gdb_test "print lavish" " = 10 '\\\\n'" @@ -285,7 +273,7 @@ proc do_constvar_tests {} { gdb_test "ptype locust" "type = double \\* const" local_compiler_xfail_check - if {$gcc_compiled == 3 && [test_debug_format "stabs"]} then { + if { [test_compiler_info gcc-3-*] && [test_debug_format "stabs"] } then { # With stabs, even GCC 3 does not get the constant structure member # correct. setup_xfail "*-*-*" diff --git a/gdb/testsuite/gdb.base/corefile.exp b/gdb/testsuite/gdb.base/corefile.exp index d059ef56b25..eb58ed259d3 100644 --- a/gdb/testsuite/gdb.base/corefile.exp +++ b/gdb/testsuite/gdb.base/corefile.exp @@ -222,29 +222,22 @@ gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp" gdb_test "x/8bd buf1" ".*:.*0.*1.*2.*3.*4.*5.*6.*7" "accessing original mmap data in core file" setup_xfail "*-*-sunos*" "*-*-ultrix*" "*-*-aix*" -send_gdb "x/8bd buf2\n" -gdb_expect { +set test "accessing mmapped data in core file" +gdb_test_multiple "x/8bd buf2" "$test" { -re ".*:.*0.*1.*2.*3.*4.*5.*6.*7.*$gdb_prompt $" { - pass "accessing mmapped data in core file" + pass "$test" } -re "0x\[f\]*:.*Cannot access memory at address 0x\[f\]*.*$gdb_prompt $" { - fail "accessing mmapped data (mapping failed at runtime)" + fail "$test (mapping failed at runtime)" } -re "0x.*:.*Cannot access memory at address 0x.*$gdb_prompt $" { - fail "accessing mmapped data (mapping address not found in core file)" - } - -re ".*$gdb_prompt $" { - fail "accessing mmapped data (incorrect data found in core file)" - } - timeout { - fail "accessing mmapped data (timeout)" + fail "$test (mapping address not found in core file)" } } # test reinit_frame_cache gdb_load ${binfile} -setup_xfail "*-*-*" CLLbs17002 gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(\\).*" "up in corefile.exp (reinit)" gdb_test "core" "No core file now." diff --git a/gdb/testsuite/gdb.base/cvexpr.c b/gdb/testsuite/gdb.base/cvexpr.c index 587120928e4..afbcd3172c3 100644 --- a/gdb/testsuite/gdb.base/cvexpr.c +++ b/gdb/testsuite/gdb.base/cvexpr.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2004 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 @@ -409,26 +409,26 @@ int main () use (&v_boolean2); use (&v_misordered); - use (v_char_func); - use (v_signed_char_func); - use (v_unsigned_char_func); + use (&v_char_func); + use (&v_signed_char_func); + use (&v_unsigned_char_func); - use (v_short_func); - use (v_signed_short_func); - use (v_unsigned_short_func); + use (&v_short_func); + use (&v_signed_short_func); + use (&v_unsigned_short_func); - use (v_int_func); - use (v_signed_int_func); - use (v_unsigned_int_func); + use (&v_int_func); + use (&v_signed_int_func); + use (&v_unsigned_int_func); - use (v_long_func); - use (v_signed_long_func); - use (v_unsigned_long_func); + use (&v_long_func); + use (&v_signed_long_func); + use (&v_unsigned_long_func); - use (v_long_long_func); - use (v_signed_long_long_func); - use (v_unsigned_long_long_func); + use (&v_long_long_func); + use (&v_signed_long_long_func); + use (&v_unsigned_long_long_func); - use (v_float_func); - use (v_double_func); + use (&v_float_func); + use (&v_double_func); } diff --git a/gdb/testsuite/gdb.base/define.exp b/gdb/testsuite/gdb.base/define.exp index 06ea1c0f4f8..7e948f18e01 100644 --- a/gdb/testsuite/gdb.base/define.exp +++ b/gdb/testsuite/gdb.base/define.exp @@ -1,4 +1,4 @@ -# Copyright 1998, 1999, 2001 Free Software Foundation, Inc. +# Copyright 1998, 1999, 2001, 2003 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 @@ -12,7 +12,7 @@ # # 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. */ +# 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 @@ -34,10 +34,19 @@ set bug_id 0 set testfile "break" set srcfile ${testfile}.c +set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { - gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } gdb_exit @@ -45,6 +54,9 @@ gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} +set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] +set bp_location11 [gdb_get_line_number "set breakpoint 11 here"] + if ![runto_main] then { fail "define tests suppressed" } # Verify that GDB allows a user to define their very own commands. @@ -68,7 +80,7 @@ gdb_expect { # send_gdb "nextwhere\n" gdb_expect { - -re ".*79\[ \t\]*printf.*#0\[ \t\]*main.*:79.*$gdb_prompt $"\ + -re ".*$bp_location1\[ \t\]*printf.*#0\[ \t\]*main.*:$bp_location1.*$gdb_prompt $"\ {pass "use user command: nextwhere"} -re "$gdb_prompt $"\ {fail "use user command: nextwhere"} @@ -224,7 +236,7 @@ gdb_expect { send_gdb "next\n" gdb_expect { - -re "#0\[ \t\]*main.*:81.*$gdb_prompt $"\ + -re "#0\[ \t\]*main.*:$bp_location11.*$gdb_prompt $"\ {pass "use hook-stop command"} -re "$gdb_prompt $"\ {fail "use hook-stop command"} diff --git a/gdb/testsuite/gdb.base/dump.c b/gdb/testsuite/gdb.base/dump.c index 784edf6ac8b..bc68778ee7a 100644 --- a/gdb/testsuite/gdb.base/dump.c +++ b/gdb/testsuite/gdb.base/dump.c @@ -1,3 +1,5 @@ +#include <string.h> + #define ARRSIZE 32 int intarray[ARRSIZE], intarray2[ARRSIZE]; diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp index 0bc4472b366..5e88693889b 100644 --- a/gdb/testsuite/gdb.base/dump.exp +++ b/gdb/testsuite/gdb.base/dump.exp @@ -1,4 +1,4 @@ -# Copyright 2002 Free Software Foundation, Inc. +# Copyright 2002, 2004 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 @@ -264,7 +264,7 @@ gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} # Run to main. -if { ! [ runto main ] } then { +if { ! [ runto_main ] } then { gdb_suppress_entire_file "Program failed to run, so remaining tests in this file will automatically fail." } @@ -353,9 +353,9 @@ test_restore_saved_value "intstr2.bin binary $struct_start" \ set array2_start [capture_value "/x &intarray2\[0\]"] set struct2_start [capture_value "/x &intstruct2"] set array2_offset \ - [capture_value "/x (char *) &intarray2 - (char *) &intarray"] + [capture_value "(char *) &intarray2 - (char *) &intarray"] set struct2_offset \ - [capture_value "/x (char *) &intstruct2 - (char *) &intstruct"] + [capture_value "(char *) &intstruct2 - (char *) &intstruct"] gdb_test "print zero_all ()" "" diff --git a/gdb/testsuite/gdb.base/ena-dis-br.exp b/gdb/testsuite/gdb.base/ena-dis-br.exp index 93f6707097c..b0e3c1de623 100644 --- a/gdb/testsuite/gdb.base/ena-dis-br.exp +++ b/gdb/testsuite/gdb.base/ena-dis-br.exp @@ -1,5 +1,4 @@ -# Copyright 1997, 1998, 1999 Free Software Foundation, Inc. - +# Copyright 1997, 1998, 1999, 2003 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 @@ -13,7 +12,7 @@ # # 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. */ +# 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 @@ -32,9 +31,18 @@ set bug_id 0 set testfile "break" set srcfile ${testfile}.c +set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } @@ -43,6 +51,17 @@ gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} +set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] +set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1] +set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1] +set bp_location11 [gdb_get_line_number "set breakpoint 11 here"] +set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1] +set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1] +set bp_location15 [gdb_get_line_number "set breakpoint 15 here" $srcfile1] +set bp_location16 [gdb_get_line_number "set breakpoint 16 here" $srcfile1] +set bp_location17 [gdb_get_line_number "set breakpoint 17 here" $srcfile1] +set bp_location18 [gdb_get_line_number "set breakpoint 18 here" $srcfile1] + if ![runto_main] then { fail "enable/disable break tests suppressed" } # Verify that we can set a breakpoint (the location is irrelevant), @@ -50,7 +69,7 @@ if ![runto_main] then { fail "enable/disable break tests suppressed" } # send_gdb "break marker1\n" gdb_expect { - -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\ + -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location15|$bp_location16).*$gdb_prompt $"\ {pass "break marker1"} -re "$gdb_prompt $"\ {fail "break marker1"} @@ -98,7 +117,7 @@ gdb_expect { # send_gdb "break marker2\n" gdb_expect { - -re "Breakpoint (\[0-9\]*) at .*, line 4\[49\].*$gdb_prompt $"\ + -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location8|$bp_location9).*$gdb_prompt $"\ {pass "break marker2"} -re "$gdb_prompt $"\ {fail "break marker2"} @@ -156,7 +175,7 @@ if ![runto_main] then { fail "enable/disable break tests suppressed" } send_gdb "break marker3\n" gdb_expect { - -re "Breakpoint (\[0-9\]*) at .*, line (45|50).*$gdb_prompt $"\ + -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location17|$bp_location18).*$gdb_prompt $"\ {pass "break marker3"} -re "$gdb_prompt $"\ {fail "break marker3"} @@ -181,7 +200,7 @@ gdb_expect { send_gdb "continue\n" gdb_expect { - -re ".*marker3 .*:(45|50).*$gdb_prompt $"\ + -re ".*marker3 .*:($bp_location17|$bp_location18).*$gdb_prompt $"\ {pass "continue to auto-deleted break marker3"} -re "Breakpoint \[0-9\]*, marker3.*$gdb_prompt $"\ {fail "continue to auto-deleted break marker3"} @@ -206,7 +225,7 @@ gdb_expect { # send_gdb "break marker4\n" gdb_expect { - -re "Breakpoint (\[0-9\]*) at .*, line (46|51).*$gdb_prompt $"\ + -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location14|$bp_location13).*$gdb_prompt $"\ {pass "break marker4"} -re "$gdb_prompt $"\ {fail "break marker4"} @@ -237,7 +256,7 @@ if ![runto_main] then { fail "enable/disable break tests suppressed" } send_gdb "break marker1\n" gdb_expect { - -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\ + -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location15|$bp_location16).*$gdb_prompt $"\ {pass "break marker1"} -re "$gdb_prompt $"\ {fail "break marker1"} @@ -328,7 +347,7 @@ if ![runto_main] then { fail "enable/disable break tests suppressed" } send_gdb "break marker1\n" gdb_expect { - -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\ + -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location15|$bp_location16).*$gdb_prompt $"\ {pass "break marker1"} -re "$gdb_prompt $"\ {fail "break marker1"} @@ -365,7 +384,7 @@ rerun_to_main send_gdb "continue\n" gdb_expect { - -re ".*marker1 .*:4\[38\].*$gdb_prompt $"\ + -re ".*marker1 .*:($bp_location15|$bp_location16).*$gdb_prompt $"\ {pass "continue to ignored & auto-deleted break marker1"} -re "Breakpoint \[0-9\]*, marker1.*$gdb_prompt $"\ {fail "continue to ignored & auto-deleted break marker1"} @@ -381,7 +400,7 @@ if ![runto_main] then { fail "enable/disable break tests suppressed" } send_gdb "break marker1\n" gdb_expect { - -re "Breakpoint (\[0-9\]*) at .*, line 4\[38\].*$gdb_prompt $"\ + -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location15|$bp_location16).*$gdb_prompt $"\ {pass "break marker1"} -re "$gdb_prompt $"\ {fail "break marker1"} @@ -423,9 +442,9 @@ gdb_expect { # if ![runto_main] then { fail "enable/disable break tests suppressed" } -send_gdb "break 79\n" +send_gdb "break $bp_location1\n" gdb_expect { - -re "Breakpoint \[0-9\]*.*, line 79.*$gdb_prompt $"\ + -re "Breakpoint \[0-9\]*.*, line $bp_location1.*$gdb_prompt $"\ {pass "prepare to continue with ignore count"} -re "$gdb_prompt $"\ {fail "prepare to continue with ignore count"} @@ -442,7 +461,7 @@ gdb_expect { send_gdb "next\n" gdb_expect { - -re ".*81\[ \t\]*marker1.*$gdb_prompt $"\ + -re ".*$bp_location11\[ \t\]*marker1.*$gdb_prompt $"\ {pass "step after continue with ignore count"} -re "$gdb_prompt $"\ {fail "step after continue with ignore count"} diff --git a/gdb/testsuite/gdb.base/ending-run.exp b/gdb/testsuite/gdb.base/ending-run.exp index 3960f0621d7..af32acd0673 100644 --- a/gdb/testsuite/gdb.base/ending-run.exp +++ b/gdb/testsuite/gdb.base/ending-run.exp @@ -202,6 +202,11 @@ gdb_expect { -re ".*in __wrap__?main ().*$gdb_prompt $" { pass "step out of main (status wrapper)" } + -re "__setup_argv_for_main (.*).*$gdb_prompt $" { + # On sh, another wrapper function (start_l) exists, so + # another `next' is necessary. + gdb_test "next" ".*in start_l ().*" "step out of main (on sh)" + } -re ".*$gdb_prompt $" { fail "step out of main (at end 2)" } timeout { fail "step out of main (hang or timeout on step at end 2)" diff --git a/gdb/testsuite/gdb.base/environ.exp b/gdb/testsuite/gdb.base/environ.exp index 55ff0a0b779..b00052ba00d 100644 --- a/gdb/testsuite/gdb.base/environ.exp +++ b/gdb/testsuite/gdb.base/environ.exp @@ -1,5 +1,4 @@ -# Copyright 1997, 1998, 1999 Free Software Foundation, Inc. - +# Copyright 1997, 1998, 1999, 2003 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 @@ -39,11 +38,19 @@ if ![istarget "hppa*-*-hpux*"] then { set testfile "break" set srcfile ${testfile}.c +set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } gdb_exit diff --git a/gdb/testsuite/gdb.base/fileio.c b/gdb/testsuite/gdb.base/fileio.c index 591b3b67588..c9ef71506a9 100644 --- a/gdb/testsuite/gdb.base/fileio.c +++ b/gdb/testsuite/gdb.base/fileio.c @@ -75,7 +75,7 @@ test_open () /* Test opening */ errno = 0; - ret = open (FILENAME, O_CREAT | O_TRUNC | O_RDONLY, S_IWUSR | S_IRUSR); + ret = open (FILENAME, O_CREAT | O_TRUNC | O_RDWR, S_IWUSR | S_IRUSR); printf ("open 1: ret = %d, errno = %d %s\n", ret, errno, ret >= 0 ? "OK" : ""); if (ret >= 0) @@ -103,7 +103,7 @@ test_open () close (ret); /* Open for write but no write permission */ errno = 0; - ret = open (NOWRITE, O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR); + ret = open (NOWRITE, O_CREAT | O_RDONLY, S_IRUSR); if (ret >= 0) { close (ret); @@ -479,6 +479,9 @@ strerrno (int err) #ifdef ENOTEMPTY case ENOTEMPTY: return "ENOTEMPTY"; #endif +#ifdef EBUSY + case EBUSY: return "EBUSY"; +#endif default: return "E??"; } } diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp index 98c64db8bca..2a717bff182 100644 --- a/gdb/testsuite/gdb.base/fileio.exp +++ b/gdb/testsuite/gdb.base/fileio.exp @@ -1,4 +1,4 @@ -# Copyright 2002 +# Copyright 2002, 2003, 2004 # Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify @@ -20,16 +20,11 @@ # This file was written by Corinna Vinschen <vinschen@redhat.com> -if [target_info exists gdb,nointerrupts] { - verbose "Skipping interrupt.exp because of nointerrupts." +if [target_info exists gdb,nofileio] { + verbose "Skipping fileio.exp because of no fileio capabilities." continue } -if [target_info exists gdb,noinferiorio] { - verbose "Skipping interrupt.exp because of noinferiorio." - return -} - if $tracelevel then { strace $tracelevel } @@ -221,9 +216,19 @@ gdb_test continue \ "Renaming a file to existing directory returns EISDIR" send_gdb "tbreak 388\n" ; gdb_expect -re "$gdb_prompt $" -gdb_test continue \ - "Continuing\\..*rename 3:.*(ENOTEMPTY|EEXIST).*test_rename \\(\\) at.*$srcfile:388.*" \ -"Renaming a directory to a non-empty directory returns ENOTEMPTY or EEXIST" +set test "Renaming a directory to a non-empty directory returns ENOTEMPTY or EEXIST" +gdb_test_multiple continue "${test}" { + -re "Continuing\\..*rename 3:.*(ENOTEMPTY|EEXIST).*test_rename \\(\\) at.*$srcfile:388.*$gdb_prompt $" { + pass "${test}" + } + -re "Continuing\\..*rename 3:.*EBUSY.*test_rename \\(\\) at.*$srcfile:388.*$gdb_prompt $" { + # At least version <= 2.6/2004-01-08 of the Linux Kernel gets + # this wrong (reporting EBUSY) when the file system is NFS + # mounted. + setup_xfail *-*-*linux* gdb/1502 + fail "${test}" + } +} send_gdb "tbreak 393\n" ; gdb_expect -re "$gdb_prompt $" gdb_test continue \ diff --git a/gdb/testsuite/gdb.base/finish.exp b/gdb/testsuite/gdb.base/finish.exp index 064f26e39dc..88182333395 100644 --- a/gdb/testsuite/gdb.base/finish.exp +++ b/gdb/testsuite/gdb.base/finish.exp @@ -1,4 +1,4 @@ -# Copyright 2000 Free Software Foundation, Inc. +# Copyright 2000, 2004 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 @@ -100,7 +100,7 @@ proc finish_void { } { proc finish_tests { } { global gdb_prompt - if { ! [ runto main ] } then { + if { ! [ runto_main ] } then { gdb_suppress_entire_file "Run to main failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/float.exp b/gdb/testsuite/gdb.base/float.exp index 6c80fbb07c3..01b0a998132 100644 --- a/gdb/testsuite/gdb.base/float.exp +++ b/gdb/testsuite/gdb.base/float.exp @@ -63,6 +63,8 @@ if { [istarget "alpha*-*-*"] } then { gdb_test "info float" "f0.*f1.*f127.*" "info float" } elseif [istarget "m68k-*-*"] then { gdb_test "info float" "fp0.*fp1.*fp7.*" "info float" +} elseif [istarget "s390*-*-*"] then { + gdb_test "info float" "fpc.*f0.*f1.*f15.*" "info float" } elseif [istarget "sh*-*"] then { # SH may or may not have an FPU gdb_test_multiple "info float" "info float" { diff --git a/gdb/testsuite/gdb.base/freebpcmd.c b/gdb/testsuite/gdb.base/freebpcmd.c new file mode 100644 index 00000000000..765e12d2ca8 --- /dev/null +++ b/gdb/testsuite/gdb.base/freebpcmd.c @@ -0,0 +1,35 @@ +/* Test program for GDB crashes while doing bp commands that continue inferior. + Copyright 2003 Free Software Foundation, Inc. + + This file is part of the gdb testsuite. + + 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. */ + +int +main (int argc, char **argv) +{ + int i; + +#ifdef usestubs + set_debug_traps(); + breakpoint(); +#endif + + for (i = 0; i < 100; i++) + printf (">>> %d\n", i); /* euphonium */ + + return 0; +} diff --git a/gdb/testsuite/gdb.base/freebpcmd.exp b/gdb/testsuite/gdb.base/freebpcmd.exp new file mode 100644 index 00000000000..fed067f1d8d --- /dev/null +++ b/gdb/testsuite/gdb.base/freebpcmd.exp @@ -0,0 +1,121 @@ +# Copyright 2003 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. + + +# This is a regression test for the following bug, as of 2003-12-12: +# +# Set a breakpoint which will be hit many times. Attach a complex set +# of commands to it, including a "continue" command. Run the program, +# so that the breakpoint is hit, its commands get executed, and the +# program continues and hits the breakpoint again. You will see +# messages like "warning: Invalid control type in command structure.", +# or maybe GDB will crash. +# +# When the breakpoint is hit, bpstat_stop_status copies the +# breakpoint's command tree to the bpstat. bpstat_do_actions then +# calls execute_control_command to run the commands. The 'continue' +# command invokes the following chain of calls: +# +# continue_command +# -> clear_proceed_status +# -> bpstat_clear +# -> free_command_lines +# -> frees the commands we are currently running. +# +# When control does eventually return to execute_control_command, GDB +# continues to walk the tree of freed command nodes, resulting in the +# error messages and / or crashes. +# +# Since this bug depends on storage being reused between the time that +# we continue and the time that we fall back to bpstat_do_actions, the +# reproduction recipe is more delicate than I would like. I welcome +# suggestions for improving this. + +set prms_id 0 +set bug_id 0 + +set testfile "freebpcmd" +set srcfile ${testfile}.c +set srcfile1 ${testfile}1.c +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +gdb_test "break [gdb_get_line_number "euphonium"]" "" "set breakpoint" + +# The goal of all this is to make sure that there's plenty of memory +# churn, and different amounts of it each time the inferior stops; +# this seems to make GDB crash more reliably. +set lines {{if (i%2) == 0} + {echo "even "} + {print i} + {else} + {echo "odd "} + {print i} + {end} + {set variable $foo = 0} + {set variable $j = 0} + {while $j < i} + {set variable $foo += $j} + {set variable $j++} + {end} + {print $foo} + {if i != 40} + {c} + {end} + {end}} + +send_gdb "commands\n" +for {set i 0} {$i < [llength $lines]} {incr i} { + gdb_expect { + -re ".*>" { + send_gdb "[lindex $lines $i]\n" + } + -re "$gdb_prompt $" { + set reason "got top-level prompt early" + break + } + timeout { + set reason "timeout" + break + } + } +} +if {$i >= [llength $lines]} { + pass "send breakpoint commands" +} else { + fail "send breakpoint commands ($reason)" +} + +gdb_run_cmd +gdb_test_multiple "" "run program with breakpoint commands" { + -re "warning: Invalid control type in command structure" { + kfail "gdb/1489" "run program with breakpoint commands" + } + -re "$gdb_prompt $" { + pass "run program with breakpoint commands" + } + eof { + kfail "gdb/1489" "run program with breakpoint commands (GDB died)" + } +} diff --git a/gdb/testsuite/gdb.base/funcargs.exp b/gdb/testsuite/gdb.base/funcargs.exp index 38949f1599c..f3284c01b95 100644 --- a/gdb/testsuite/gdb.base/funcargs.exp +++ b/gdb/testsuite/gdb.base/funcargs.exp @@ -1,5 +1,5 @@ -# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003 -# Free Software Foundation, Inc. +# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, +# 2004 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 @@ -162,7 +162,6 @@ proc float_and_integral_args {} { global gdb_prompt global det_file global gcc_compiled - global hp_cc_compiler delete_breakpoints @@ -178,8 +177,6 @@ proc float_and_integral_args {} { # Run; should stop at call2a and print actual arguments. if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "mips-sgi-irix5*" } - # The debug info. for "f" is not correct. It's a known bug. - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} gdb_run_cmd gdb_expect { -re ".* call2a \\(c=97 'a', f1=4, s=1, d1=5, i=2, f2=4, l=3, d2=5\\) .*$gdb_prompt $" { pass "run to call2a" } @@ -190,55 +187,46 @@ proc float_and_integral_args {} { # Print each arg as a double check to see if we can print gdb_test "print c" ".* = 97 'a'" "print c after run to call2a" - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} gdb_test "print f1" ".* = 4" "print f1 after run to call2a" gdb_test "print s" ".* = 1" "print s after run to call2a" gdb_test "print d1" ".* = 5" "print d1 after run to call2a" gdb_test "print i" ".* = 2" "print i after run to call2a" - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} gdb_test "print f2" ".* = 4" "print f2 after run to call2a" gdb_test "print l" ".* = 3" "print l after run to call2a" gdb_test "print d2" ".* = 5" "print d2 after run to call2a" setup_xfail "rs6000-*-*" - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix*" } # Continue; should stop at call2b and print actual arguments. if [gdb_test "cont" ".* call2b \\(f1=4, s=1, d1=5, i=2, f2=4, l=3, d2=5, c=97 'a'\\) .*" "continue to call2b"] { gdb_suppress_tests; } - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} # Continue; should stop at call2c and print actual arguments. if [gdb_test "cont" ".* call2c \\(s=1, d1=5, i=2, f2=4, l=3, d2=5, c=97 'a', f1=4\\) .*" "continue to call2c"] { gdb_suppress_tests; } - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} # Continue; should stop at call2d and print actual arguments. if [gdb_test "cont" ".* call2d \\(d1=5, i=2, f2=4, l=3, d2=5, c=97 'a', f1=4, s=1\\) .*" "continue to call2d"] { gdb_suppress_tests; } - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} # Continue; should stop at call2e and print actual arguments. if [gdb_test "cont" ".* call2e \\(i=2, f2=4, l=3, d2=5, c=97 'a', f1=4, s=1, d1=5\\) .*" "continue to call2e"] { gdb_suppress_tests; } - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} # Continue; should stop at call2f and print actual arguments. if [gdb_test "cont" ".* call2f \\(f2=4, l=3, d2=5, c=97 'a', f1=4, s=1, d1=5, i=2\\) .*" "continue to call2f"] { gdb_suppress_tests; } - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} # Continue; should stop at call2g and print actual arguments. if [gdb_test "cont" ".* call2g \\(l=3, d2=5, c=97 'a', f1=4, s=1, d1=5, i=2, f2=4\\) .*" "continue to call2g"] { gdb_suppress_tests; } - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} # Continue; should stop at call2h and print actual arguments. if [gdb_test "cont" ".* call2h \\(d2=5, c=97 'a', f1=4, s=1, d1=5, i=2, f2=4, l=3\\) .*" "continue to call2h"] { gdb_suppress_tests; @@ -249,7 +237,6 @@ proc float_and_integral_args {} { delete_breakpoints gdb_breakpoint call2i - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} # Continue; should stop at call2i and print actual arguments. if [gdb_test "cont" ".* call2i \\(c1=97 'a', f1=4, c2=97 'a', c3=97 'a', d1=5, c4=97 'a', c5=97 'a', c6=97 'a', f2=4, s=1, c7=97 'a', d2=5\\) .*" "continue to call2i"] { gdb_suppress_tests; @@ -445,7 +432,6 @@ proc discard_and_shuffle {} { global decimal global det_file global gcc_compiled - global hp_cc_compiler delete_breakpoints @@ -474,8 +460,6 @@ proc discard_and_shuffle {} { setup_xfail "mips-sgi-irix5*" } - # The debug info. for "f" is not correct. It's a known bug. - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" gdb_expect { -re "backtrace 100\[\r\n\]+ @@ -505,7 +489,6 @@ $gdb_prompt $" { gdb_continue call6b - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" if [gdb_expect_list "backtrace from call6b" ".*$gdb_prompt $" { ".*\[\r\n\]#0 .* call6b \\(s=1, i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " @@ -520,7 +503,6 @@ $gdb_prompt $" { gdb_continue call6c - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" if [gdb_expect_list "backtrace from call6c" ".*$gdb_prompt $" { ".*\[\r\n\]#0 .* call6c \\(i=2, l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " @@ -535,7 +517,6 @@ $gdb_prompt $" { gdb_continue call6d - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" if [gdb_expect_list "backtrace from call6d" ".*$gdb_prompt $" { ".*\[\r\n\]#0 .* call6d \\(l=3, f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " @@ -552,7 +533,6 @@ $gdb_prompt $" { gdb_continue call6e - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" if [gdb_expect_list "backtrace from call6e" ".*$gdb_prompt $" { ".*\[\r\n\]#0 .* call6e \\(f=4, d=5, uc=98 'b', us=6, ui=7, ul=8\\) " @@ -570,7 +550,6 @@ $gdb_prompt $" { gdb_continue call6f - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" if [gdb_expect_list "backtrace from call6f" ".*$gdb_prompt $" { ".*\[\r\n\]#0 .* call6f \\(d=5, uc=98 'b', us=6, ui=7, ul=8\\) " @@ -589,7 +568,6 @@ $gdb_prompt $" { gdb_continue call6g - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" if [gdb_expect_list "backtrace from call6g" ".*$gdb_prompt $" { ".*\[\r\n\]#0 .* call6g \\(uc=98 'b', us=6, ui=7, ul=8\\) " @@ -609,7 +587,6 @@ $gdb_prompt $" { gdb_continue call6h - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" if [gdb_expect_list "backtrace from call6h" ".*$gdb_prompt $" { ".*\[\r\n\]#0 .* call6h \\(us=6, ui=7, ul=8\\) " @@ -637,7 +614,6 @@ $gdb_prompt $" { gdb_continue call6i - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" if [gdb_expect_list "backtrace from call6i" ".*$gdb_prompt $" { ".*\[\r\n\]#0 .* call6i \\(ui=7, ul=8\\) " @@ -659,7 +635,6 @@ $gdb_prompt $" { gdb_continue call6j - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" if [gdb_expect_list "backtrace from call6j" ".*$gdb_prompt $" { ".*\[\r\n\]#0 .* call6j \\(ul=8\\) " @@ -681,7 +656,6 @@ $gdb_prompt $" { # Print backtrace. gdb_continue call6k - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" if [gdb_expect_list "backtrace from call6k" ".*$gdb_prompt $" { ".*\[\r\n\]#0 .* call6k \\(\\) " @@ -713,7 +687,6 @@ proc shuffle_round_robin {} { global decimal global det_file global gcc_compiled - global hp_cc_compiler delete_breakpoints @@ -739,8 +712,6 @@ proc shuffle_round_robin {} { } if {!$gcc_compiled} then { setup_xfail "rs6000-*-*" "mips-sgi-irix5*" } - # The debug info. for "f" is not correct. It's a known bug. - if {$hp_cc_compiler} {setup_xfail hppa2.0w-*-*} send_gdb "backtrace 100\n" gdb_expect { -re "backtrace 100\[\r\n\]+ @@ -1183,8 +1154,6 @@ gdb_load ${binfile} if [istarget "mips*tx39-*"] { set timeout 300 -} elseif [istarget "hppa*-hp-hpux*"] then { - set timeout 240 } else { set timeout 60 } diff --git a/gdb/testsuite/gdb.base/gcore.exp b/gdb/testsuite/gdb.base/gcore.exp index 8c0ae8eb5c4..33fcba4810e 100644 --- a/gdb/testsuite/gdb.base/gcore.exp +++ b/gdb/testsuite/gdb.base/gcore.exp @@ -1,4 +1,4 @@ -# Copyright 2002 Free Software Foundation, Inc. +# Copyright 2002, 2003, 2004 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 @@ -61,7 +61,7 @@ gdb_expect { } } -if { ! [ runto main ] } then { +if { ! [ runto_main ] } then { gdb_suppress_entire_file "Run to main failed, so all tests in this file will automatically fail." } @@ -106,9 +106,25 @@ set pre_corefile_extern_array \ set escapedfilename [string_to_regexp ${objdir}/${subdir}/gcore.test] -gdb_test "gcore ${objdir}/${subdir}/gcore.test" \ - "Saved corefile ${escapedfilename}" \ - "save a corefile" +gdb_test_multiple "gcore ${objdir}/${subdir}/gcore.test" \ + "save a corefile" \ +{ + -re "Saved corefile ${escapedfilename}\[\r\n\]+$gdb_prompt $" { + pass "save a corefile" + global core_supported + set core_supported 1 + } + -re "Can't create a corefile\[\r\n\]+$gdb_prompt $" { + unsupported "save a corefile" + global core_supported + set core_supported 0 + } +} + +global core_supported +if {!$core_supported} { + return -1 +} # Now restart gdb and load the corefile. gdb_exit diff --git a/gdb/testsuite/gdb.base/gdb1056.exp b/gdb/testsuite/gdb.base/gdb1056.exp new file mode 100644 index 00000000000..623f8370838 --- /dev/null +++ b/gdb/testsuite/gdb.base/gdb1056.exp @@ -0,0 +1,48 @@ +# Copyright 2003 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. + +# Test for PR gdb/1056. +# 2003-10-18 Michael Chastain <mec@shout.net> + +if $tracelevel then { + strace $tracelevel +} + +# test SIGFPE (such as division by 0) inside gdb itself + +set prms_id 0 +set bug_id 0 + +gdb_start + +# When SIGFPE happens, the operating system may restart the +# offending instruction after the signal handler returns, +# rather than proceeding to the next instruction. This happens +# on i686-pc-linux-gnu with a linux kernel. If gdb has a naive +# signal handler that just returns, then it will restart the +# broken instruction and gdb gets an endless stream of SIGFPE's +# and makes no progress. +# +# On a broken gdb this test will just time out. + +gdb_test_multiple "print 1/0" "" { + -re ".*$gdb_prompt $" { + pass "print 1/0" + } + timeout { + kfail "gdb/1056" "print 1/0" + } +} diff --git a/gdb/testsuite/gdb.base/gdb1476.c b/gdb/testsuite/gdb.base/gdb1476.c new file mode 100644 index 00000000000..c3f43760bf3 --- /dev/null +++ b/gdb/testsuite/gdb.base/gdb1476.c @@ -0,0 +1,12 @@ +void x() +{ + void (*fp)() = 0; + fp(); +} + +int +main() +{ + x(); + return 0; +} diff --git a/gdb/testsuite/gdb.base/gdb1476.exp b/gdb/testsuite/gdb.base/gdb1476.exp new file mode 100644 index 00000000000..b88b2de0652 --- /dev/null +++ b/gdb/testsuite/gdb.base/gdb1476.exp @@ -0,0 +1,72 @@ +# Copyright 2004 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@gnu.org + +# This file is part of the gdb testsuite. + +if $tracelevel { + strace $tracelevel +} + +# Testcase for backtrace/gdb1476. + +set prms_id 0 +set bug_id 0 + +set testfile "gdb1476" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +# +# Run to `main' where we begin our tests. +# + +if ![runto_main] then { + gdb_suppress_tests +} + +# If we can examine what's at memory address 0, it is possible that we +# could also execute it. This could probably make us run away, +# executing random code, which could have all sorts of ill effects, +# especially on targets without an MMU. Don't run the tests in that +# case. + +send_gdb "x 0\n" +gdb_expect { + -re "0x0:.*Cannot access memory at address 0x0.*$gdb_prompt $" { } + -re "0x0:.*Error accessing memory address 0x0.*$gdb_prompt $" { } + -re ".*$gdb_prompt $" { + untested "Memory at address 0 is possibly executable" + return + } +} + +gdb_test "continue" "Program received signal SIGSEGV.*" \ + "continue to null pointer call" + +gdb_test "backtrace 10" \ + "#0\[ \t\]*0x0* in .*\r\n#1\[ \t\]*$hex in x.*\r\n#2\[ \t\]*$hex in main.*" \ + "backtrace from null pointer call" diff --git a/gdb/testsuite/gdb.base/gdb1555-main.c b/gdb/testsuite/gdb.base/gdb1555-main.c new file mode 100644 index 00000000000..de054f7c935 --- /dev/null +++ b/gdb/testsuite/gdb.base/gdb1555-main.c @@ -0,0 +1,29 @@ +/* Test step/next in a shared library + + Copyright 2004, Free Software Foundation, Inc. + + This file is part of GDB. + + 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. */ + +extern int hithere2 (); + +int +main() +{ + hithere2(); + return 0; +} diff --git a/gdb/testsuite/gdb.base/gdb1555.c b/gdb/testsuite/gdb.base/gdb1555.c new file mode 100644 index 00000000000..62082615ceb --- /dev/null +++ b/gdb/testsuite/gdb.base/gdb1555.c @@ -0,0 +1,28 @@ +/* Test step/next in a shared library + + Copyright 2004, Free Software Foundation, Inc. + + This file is part of GDB. + + 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. */ + +int hithere2() +{ + int a; + a = 21; + return a; +} + diff --git a/gdb/testsuite/gdb.base/gdb1555.exp b/gdb/testsuite/gdb.base/gdb1555.exp new file mode 100644 index 00000000000..8bea6329160 --- /dev/null +++ b/gdb/testsuite/gdb.base/gdb1555.exp @@ -0,0 +1,119 @@ +# Copyright 2004 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 + +# Test stepping into and continuing on from a function in +# a shared library (PR gdb/1555, was PR shlib/1280, shlib/1237). +# Tested on ppc-yellowdog-linux (Yellow Dog Linux 3.0 3.2.2-2a) + +if $tracelevel then { + strace $tracelevel +} + +set testfile gdb1555-main +set libfile gdb1555 +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +remote_exec build "rm -f ${binfile}" + +# get the value of gcc_compiled +if [get_compiler_info ${binfile}] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}.o" object {debug}] != "" } { + return -1 +} + +# Build the shared libraries this test case needs. +# + +if {$gcc_compiled == 0} { + if [istarget "hppa*-hp-hpux*"] then { + set additional_flags "additional_flags=+z" + } elseif { [istarget "mips-sgi-irix*"] } { + # Disable SGI compiler's implicit -Dsgi + set additional_flags "additional_flags=-Usgi" + } else { + # don't know what the compiler is... + set additional_flags "" + } +} else { + if { ([istarget "powerpc*-*-aix*"] + || [istarget "rs6000*-*-aix*"]) } { + set additional_flags "" + } else { + set additional_flags "additional_flags=-fpic" + } +} + +set additional_flags "$additional_flags -shared" +if {[gdb_compile "${srcdir}/${subdir}/${libfile}.c" "${objdir}/${subdir}/${libfile}.so" executable [list debug $additional_flags "incdir=${objdir}"]] != ""} { + return -1 +} + +if { ($gcc_compiled +&& ([istarget "powerpc*-*-aix*"] +|| [istarget "rs6000*-*-aix*"] )) } { + set additional_flags "additional_flags=-L${objdir}/${subdir}" +} elseif { [istarget "mips-sgi-irix*"] } { + set additional_flags "additional_flags=-rpath ${objdir}/${subdir}" +} else { + set additional_flags "" +} + +if {[gdb_compile "${objdir}/${subdir}/${testfile}.o ${objdir}/${subdir}/${libfile}.so" "${binfile}" executable [list debug $additional_flags]] != ""} { + return -1 +} + + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + fail "Can't run to main" + return 0 +} + +# PR/1555 (was shlib 1280) +set name "Step into shared lib function" +gdb_test_multiple "s" $name \ +{ + -re "hithere2 \\(\\) at.*${libfile}.c:25\r\n25.*a = 21;.*$gdb_prompt $" { + pass $name + } + -re "0x\[0-9a-f\]+ in .* \\(\\) from /lib/ld.so.1.*$gdb_prompt $" { + kfail "gdb/1555" $name + } +} + +# PR/1555 (was shlib 1237) +set name "Next while in a shared lib function" +gdb_test_multiple "n" $name \ +{ + -re "26.*return a;.*$gdb_prompt $" { + pass $name + } + -re "Single stepping until exit from function .*, \r\nwhich has no line number information.\r\n\r\nProgram exited normally.*$gdb_prompt $" { + kfail "gdb/1555" $name + } +} + diff --git a/gdb/testsuite/gdb.base/huge.c b/gdb/testsuite/gdb.base/huge.c index 419b92cc5b7..446bb180371 100644 --- a/gdb/testsuite/gdb.base/huge.c +++ b/gdb/testsuite/gdb.base/huge.c @@ -2,6 +2,8 @@ * Test GDB's ability to read a very large data object from target memory. */ +#include <string.h> + /* A value that will produce a target data object large enough to crash GDB. 0x200000 is big enough on GNU/Linux, other systems may need a larger number. */ diff --git a/gdb/testsuite/gdb.base/huge.exp b/gdb/testsuite/gdb.base/huge.exp index fa50d0115ac..733ddeee7a3 100644 --- a/gdb/testsuite/gdb.base/huge.exp +++ b/gdb/testsuite/gdb.base/huge.exp @@ -1,4 +1,4 @@ -# Copyright 2001 Free Software Foundation, Inc. +# Copyright 2001, 2004 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 @@ -49,7 +49,7 @@ gdb_load ${binfile} set timeout 30 -if { ! [ runto main ] } then { +if { ! [ runto_main ] } then { gdb_suppress_entire_file "Run to main failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/info-proc.exp b/gdb/testsuite/gdb.base/info-proc.exp index 2a9a4b09a3d..fc68601621c 100644 --- a/gdb/testsuite/gdb.base/info-proc.exp +++ b/gdb/testsuite/gdb.base/info-proc.exp @@ -1,4 +1,4 @@ -# Copyright 2002 Free Software Foundation, Inc. +# Copyright 2002, 2003, 2004 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 @@ -27,12 +27,22 @@ if $tracelevel then { set prms_id 0 set bug_id 0 -set testfile "break" -set srcfile ${testfile}.c -set binfile ${objdir}/${subdir}/${testfile} set ws "\[ \t\]+" -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { +set testfile "break" +set srcfile ${testfile}.c +set srcfile1 ${testfile}1.c +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } @@ -64,7 +74,7 @@ gdb_expect { gdb_test "info proc" "No current process.*" "info proc without a process" -if { ! [ runto main ] } then { +if { ! [ runto_main ] } then { gdb_suppress_entire_file "Run to main failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/langs.exp b/gdb/testsuite/gdb.base/langs.exp index 8006bbfd788..49b9c5d5adf 100644 --- a/gdb/testsuite/gdb.base/langs.exp +++ b/gdb/testsuite/gdb.base/langs.exp @@ -65,8 +65,15 @@ gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load $binfile -gdb_test "b langs0" "Function \"langs0\" not defined\.|Breakpoint .* (deferred).*" \ - "break on nonexistent function in langs.exp" +gdb_test_multiple "b langs0" "break on nonexistent function in langs.exp" { + -re "Function \"langs0\" not defined\..*Make breakpoint pending on future shared library load.*y or .n.. $" { + + gdb_test "n" "" "break on nonexistent function in langs.exp" + } + -re "Breakpoint .* (deferred).*$gdb_prompt $" { + pass "break on nonexistent function in langs.exp" + } +} if {$hp_aCC_compiler} { set isfixed 1 diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp index 84a15cfacbe..b38995c94a0 100644 --- a/gdb/testsuite/gdb.base/list.exp +++ b/gdb/testsuite/gdb.base/list.exp @@ -222,7 +222,6 @@ proc test_list_filename_and_number {} { proc test_list_function {} { global gdb_prompt - global gcc_compiled # gcc appears to generate incorrect debugging information for code # in include files, which breaks this test. diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp index f82bf0202b0..53d58251883 100644 --- a/gdb/testsuite/gdb.base/maint.exp +++ b/gdb/testsuite/gdb.base/maint.exp @@ -1,4 +1,4 @@ -# Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +# Copyright 1998, 1999, 2000, 2001, 2002, 2003 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 @@ -65,10 +65,19 @@ set bug_id 0 set testfile "break" set srcfile ${testfile}.c +set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" - } { - gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } @@ -182,6 +191,11 @@ gdb_expect { send_gdb "maint print statistics\n" gdb_expect { -re "Statistics for.*break.*Number of \"minimal\" symbols read.*Number of \"partial\" symbols read.*Number of \"types\" defined.*Number of psym tables \\(not yet expanded\\).*Number of symbol tables.*Number of symbol tables with line tables.*Number of symbol tables with blockvectors.*Total memory used for psymbol obstack.*Total memory used for psymbol cache.*Total memory used for symbol obstack.*Total memory used for type obstack.*$gdb_prompt $"\ + { + # Old output for gdb 6.0 and earlier + pass "maint print statistics" + } + -re "Statistics for.*break.*Number of \"minimal\" symbols read.*Number of \"partial\" symbols read.*Number of \"types\" defined.*Number of psym tables \\(not yet expanded\\).*Number of symbol tables.*Number of symbol tables with line tables.*Number of symbol tables with blockvectors.*Total memory used for objfile obstack.*Total memory used for psymbol cache.*Total memory used for macro cache.*$gdb_prompt $"\ { pass "maint print statistics" } -re ".*$gdb_prompt $" { fail "maint print statistics" } timeout { fail "(timeout) maint print statistics" } @@ -391,6 +405,7 @@ gdb_expect { -re ".*bss.*$gdb_prompt $" { fail "maint info sections .text" } -re ".*data.*$gdb_prompt $" { fail "maint info sections .text" } -re ".* .text .*$gdb_prompt $" { pass "maint info sections .text" } + -re ".*$gdb_prompt $" { fail "maint info sections .text" } timeout { fail "(timeout) maint info sections .text" } } @@ -400,6 +415,7 @@ send_gdb "maint info sections CODE\n" gdb_expect { -re ".* .data .*$gdb_prompt $" { fail "maint info sections CODE" } -re ".* .text .*$gdb_prompt $" { pass "maint info sections CODE" } + -re ".*$gdb_prompt $" { fail "maint info sections CODE" } timeout { fail "(timeout) maint info sections CODE" } } @@ -409,14 +425,17 @@ send_gdb "maint info sections DATA\n" gdb_expect { -re ".* .text .*$gdb_prompt $" { fail "maint info sections DATA" } -re ".* .data .*$gdb_prompt $" { pass "maint info sections DATA" } + -re ".*$gdb_prompt $" { fail "maint info sections DATA" } timeout { fail "(timeout) maint info sections DATA" } } +set bp_location6 [gdb_get_line_number "set breakpoint 6 here"] + send_gdb "maint info breakpoints\n" gdb_expect { - -re "Num\[ \t\]+Type\[ \t\]+Disp\[ \t\]+Enb\[ \t\]+Address\[ \t\]+What\r\n1\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+$hex\[ \t\]+in main at.*break.c:75\r\n\[ \t\]+breakpoint already hit 1 time\r\n.*$gdb_prompt $"\ + -re "Num\[ \t\]+Type\[ \t\]+Disp\[ \t\]+Enb\[ \t\]+Address\[ \t\]+What\r\n1\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+$hex\[ \t\]+in main at.*break.c:$bp_location6\r\n\[ \t\]+breakpoint already hit 1 time\r\n.*$gdb_prompt $"\ { pass "maint info breakpoints" } - -re "Num\[ \t\]+Type\[ \t\]+Disp\[ \t\]+Enb\[ \t\]+Address\[ \t\]+What\r\n1\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+$hex in main at.*break.c:75\r\n\[ \t\]+breakpoint already hit 1 time\r\n-1\[ \t\]+shlib events\[ \t\]+keep\[ \t\]+y\[ \t\]+$hex.*breakpoint already hit.*$gdb_prompt $"\ + -re "Num\[ \t\]+Type\[ \t\]+Disp\[ \t\]+Enb\[ \t\]+Address\[ \t\]+What\r\n1\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+$hex in main at.*break.c:$bp_location6\r\n\[ \t\]+breakpoint already hit 1 time\r\n-1\[ \t\]+shlib events\[ \t\]+keep\[ \t\]+y\[ \t\]+$hex.*breakpoint already hit.*$gdb_prompt $"\ { pass "maint info breakpoints (with shlib events)" } -re ".*$gdb_prompt $" { fail "maint info breakpoints" } timeout { fail "(timeout) maint info breakpoints" } @@ -650,34 +669,22 @@ gdb_expect { } send_gdb "maint internal-error\n" -gdb_expect { - -re "Quit this debugging session.*\\(y or n\\) $" { - send_gdb "n\n" - gdb_expect { - -re "Create a core file.*\\(y or n\\) $" { - send_gdb "n\n" - gdb_expect { - -re ".*$gdb_prompt $" { - pass "maint internal-error" - } - timeout { - fail "(timeout) maint internal-error" - } - } - } - -re ".*$gdb_prompt $" { - fail "maint internal-error" - } - timeout { - fail "(timeout) maint internal-error" - } +gdb_expect { + -re "A problem internal to GDB has been detected" { + pass "maint internal-error" + if [gdb_internal_error_resync] { + pass "internal-error resync" + } else { + fail "internal-error resync" } } -re ".*$gdb_prompt $" { fail "maint internal-error" + untested "internal-error resync" } timeout { - fail "(timeout) maint internal-error" + fail "maint internal-error (timeout)" + untested "internal-error resync" } } diff --git a/gdb/testsuite/gdb.base/mips_pro.exp b/gdb/testsuite/gdb.base/mips_pro.exp index a860e6335d0..53ea9fdee21 100644 --- a/gdb/testsuite/gdb.base/mips_pro.exp +++ b/gdb/testsuite/gdb.base/mips_pro.exp @@ -37,7 +37,7 @@ if [get_compiler_info ${binfile}] { # This test must be compiled with -O2 if using gcc. -if {$gcc_compiled} then { +if { [test_compiler_info gcc-*-*] } then { if { [gdb_compile "${srcdir}/$subdir/${srcfile}" "${binfile}" executable {debug additional_flags=-O2}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } @@ -56,7 +56,7 @@ if [runto middle] then { # PR 3016 # warning: Hit heuristic-fence-post without finding # warning: enclosing function for pc 0x1006ead0 - if {$gcc_compiled} then { + if { [test_compiler_info gcc-*-*] } then { setup_xfail "mips*-sgi-irix4*" "mips64*-*-elf" } # The call chain is main -> top -> middle. But gcc can optimize a tail diff --git a/gdb/testsuite/gdb.base/nodebug.exp b/gdb/testsuite/gdb.base/nodebug.exp index 836ff8637e1..ba1fbe86ccf 100644 --- a/gdb/testsuite/gdb.base/nodebug.exp +++ b/gdb/testsuite/gdb.base/nodebug.exp @@ -1,4 +1,4 @@ -# Copyright 1997, 1999 Free Software Foundation, Inc. +# Copyright 1997, 1999, 2004 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 @@ -39,8 +39,6 @@ if [get_compiler_info ${binfile}] { return -1; } -source ${binfile}.ci - gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir @@ -67,7 +65,7 @@ if [runto inner] then { # even without -g, which should be accepted. # Irix5, even though it is ELF, counts as "ecoff" because it # encapsulates ecoff debugging info in a .mdebug section. - # Irix6 gcc omits no debug info at all for static functions and + # Irix6 gcc emits no debug info at all for static functions and # variables, so all tests involving statics fail. if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix5*" "mips-sgi-irix6*" } diff --git a/gdb/testsuite/gdb.base/pc-fp.exp b/gdb/testsuite/gdb.base/pc-fp.exp index f94e3314388..c7daf6f08a4 100644 --- a/gdb/testsuite/gdb.base/pc-fp.exp +++ b/gdb/testsuite/gdb.base/pc-fp.exp @@ -1,4 +1,4 @@ -# Copyright 2002 Free Software Foundation, Inc. +# Copyright 2002, 2004 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 @@ -65,7 +65,7 @@ proc get_valueofx { fmt exp default } { pass "get value of ${exp} ($val)" } timeout { - set size ${default} + set val ${default} fail "get value of ${exp} (timeout)" } } diff --git a/gdb/testsuite/gdb.base/pending.c b/gdb/testsuite/gdb.base/pending.c new file mode 100644 index 00000000000..a83a451b94e --- /dev/null +++ b/gdb/testsuite/gdb.base/pending.c @@ -0,0 +1,35 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2004 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 */ + +#include <stdio.h> + +int k = 0; + +extern void pendfunc (int x); + +int main() +{ + pendfunc (3); /* break main here */ + pendfunc (4); + k = 1; + pendfunc (3); + return 0; +} diff --git a/gdb/testsuite/gdb.base/pending.exp b/gdb/testsuite/gdb.base/pending.exp new file mode 100644 index 00000000000..315e544ee74 --- /dev/null +++ b/gdb/testsuite/gdb.base/pending.exp @@ -0,0 +1,266 @@ +# Copyright 2003, 2004 +# 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 created by Jeff Johnston. (jjohnstn@redhat.com) +# The shared library compilation portion was copied from shlib-call.exp which was +# written by Elena Zannoni (ezannoni@redhat.com). + +if $tracelevel then { + strace $tracelevel +} + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +# are we on a target board? +if ![isnative] then { + return 0 +} + +set testfile "pending" +set libfile "pendshr" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile}] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}.o" object {debug}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +# Build the shared libraries this test case needs. +# + +if {$gcc_compiled == 0} { + if [istarget "hppa*-hp-hpux*"] then { + set additional_flags "additional_flags=+z" + } elseif { [istarget "mips-sgi-irix*"] } { + # Disable SGI compiler's implicit -Dsgi + set additional_flags "additional_flags=-Usgi" + } else { + # don't know what the compiler is... + set additional_flags "" + } +} else { + if { ([istarget "powerpc*-*-aix*"] + || [istarget "rs6000*-*-aix*"]) } { + set additional_flags "" + } else { + set additional_flags "additional_flags=-fpic" + } +} + +if {[gdb_compile "${srcdir}/${subdir}/${libfile}.c" "${objdir}/${subdir}/${libfile}.o" object [list debug $additional_flags]] != ""} { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if [istarget "hppa*-*-hpux*"] { + remote_exec build "ld -b ${objdir}/${subdir}/${libfile}.o -o ${objdir}/${subdir}/${libfile}.sl" +} else { + set additional_flags "additional_flags=-shared" + if {[gdb_compile "${objdir}/${subdir}/${libfile}.o" "${objdir}/${subdir}/${libfile}.sl" executable [list debug $additional_flags]] != ""} { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." + } +} + +if { ($gcc_compiled + && ([istarget "powerpc*-*-aix*"] + || [istarget "rs6000*-*-aix*"] )) } { + set additional_flags "additional_flags=-L${objdir}/${subdir}" +} elseif { [istarget "mips-sgi-irix*"] } { + set additional_flags "additional_flags=-rpath ${objdir}/${subdir}" +} else { + set additional_flags "" +} +if {[gdb_compile "${objdir}/${subdir}/${testfile}.o ${objdir}/${subdir}/${libfile}.sl" "${binfile}" executable [list debug $additional_flags]] != ""} { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if [target_info exists gdb_stub] { + gdb_step_for_stub; +} +# +# Test setting, querying, and modifying pending breakpoints +# + +gdb_test_multiple "break pendfunc1" "set pending breakpoint" { + -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" { + gdb_test "y" "Breakpoint.*pendfunc1.*pending." "set pending breakpoint" + } +} + +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* +\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.*" \ +"single pending breakpoint info" + +# +# Test breaking at existing function +# + +set mainline [gdb_get_line_number "break main here"] + +gdb_test "break main" \ + "Breakpoint.*at.* file .*$srcfile, line $mainline.*" \ + "breakpoint function" + +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* +\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \ +"pending plus real breakpoint info" + + +# +# Test not setting a pending breakpoint +# +gdb_test_multiple "break pendfunc2" "Don't set pending breakpoint" { + -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" { + gdb_test "n" "" "Don't set pending breakpoint" + } +} + +# +# Add condition to pending breakpoint +# + +gdb_test "condition 1 k == 1" "" + +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* +\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendfunc1.* +\[\t \]+stop only if k == 1.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \ +"pending plus condition" + +# +# Disable pending breakpoint +# + +gdb_test "disable 1" "" + +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* +\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.* +\[\t \]+stop only if k == 1.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \ +"pending disabled" + +# +# Add commands to pending breakpoint +# +gdb_test "commands 1\nprint k\nend" "" \ + "Set commands for pending breakpoint" + +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* +\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.* +\[\t \]+stop only if k == 1.* +\[\t \]+print k.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline" \ +"pending disabled plus commands" + +# +# Try a pending break for a line in a source file with a condition +# + +gdb_test_multiple "break pendshr.c:26 if x > 3" "Set pending breakpoint 2" { + -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" { + gdb_test "y" "Breakpoint.*pendshr.c:26.*pending." \ + "Set pending breakpoint 2" + } +} + +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* +\[0-9\]+\[\t \]+breakpoint keep n.*PENDING.*pendfunc1.* +\[\t \]+stop only if k == 1.* +\[\t \]+print k.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.* +\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*pendshr.c:26 if x > 3.*" \ +"multiple pending breakpoints" + +# +# Run to main which should resolve a pending breakpoint +# + +gdb_test "run" \ +"Breakpoint.*at.* +Pending breakpoint \"pendshr.c:26 if x > 3\" resolved.* +Breakpoint.*, main.*$mainline.*" \ +"running to main" + +# +# Re-enable the first pending breakpoint which should resolve +# + +gdb_test "enable 1" \ +"Breakpoint.*at.* +Pending breakpoint \"pendfunc1.* resolved.*" \ +"re-enabling pending breakpoint that can resolve instantly" + +# +# Continue to verify conditionals and commands for breakpoints are honored +# + +gdb_test "continue" \ +".*Breakpoint.*pendfunc1.*at.*pendshr.c:26.*4;" \ +"continue to resolved breakpoint 2" + +gdb_test "continue" \ +".*Breakpoint.*pendfunc1.*at.*pendshr.c:26.* +\[$\]1 = 1." \ +"continue to resolved breakpoint 1" + +delete_breakpoints + +gdb_breakpoint "main" + +# +# Set non-existent pending breakpoint +# +gdb_test_multiple "break imaginary" "set imaginary pending breakpoint" { + -re ".*Make breakpoint pending.*y or \\\[n\\\]. $" { + gdb_test "y" "Breakpoint.*imaginary.*pending." \ + "set imaginary pending breakpoint" + } +} + +# +# rerun program and make sure that any pending breakpoint remains and no +# error messages are issued for the missing function +# + +rerun_to_main +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$mainline.* +\[0-9\]+\[\t \]+breakpoint keep y.*PENDING.*imaginary.*" \ +"verify pending breakpoint after restart" diff --git a/gdb/testsuite/gdb.base/pendshr.c b/gdb/testsuite/gdb.base/pendshr.c new file mode 100644 index 00000000000..672fe8ab7ee --- /dev/null +++ b/gdb/testsuite/gdb.base/pendshr.c @@ -0,0 +1,33 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2004 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 */ + +#include <stdio.h> + +void pendfunc1 (int x) +{ + int y = x + 4; + printf ("in pendfunc1, x is %d\n", x); +} + +void pendfunc (int x) +{ + pendfunc1 (x); +} diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp index 8f3ba89eb99..e532d71de09 100644 --- a/gdb/testsuite/gdb.base/printcmds.exp +++ b/gdb/testsuite/gdb.base/printcmds.exp @@ -1,5 +1,7 @@ -# Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2003 Free -# Software Foundation, Inc. +# This testcase is part of GDB, the GNU debugger. + +# Copyright 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2003, 2004 +# 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 @@ -16,7 +18,7 @@ # 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 +# bug-gdb@gnu.org # This file was written by Fred Fish. (fnf@cygnus.com) @@ -161,7 +163,7 @@ proc test_print_all_chars {} { gdb_test "p ctable1\[24\]" " = 24 '\\\\030'" gdb_test "p ctable1\[25\]" " = 25 '\\\\031'" gdb_test "p ctable1\[26\]" " = 26 '\\\\032'" - gdb_test "p ctable1\[27\]" " = 27 '\\\\e'" + gdb_test "p ctable1\[27\]" " = 27 '\\\\033'" gdb_test "p ctable1\[28\]" " = 28 '\\\\034'" gdb_test "p ctable1\[29\]" " = 29 '\\\\035'" gdb_test "p ctable1\[30\]" " = 30 '\\\\036'" @@ -479,7 +481,7 @@ proc test_print_strings {} { gdb_test "p &ctable1\[2*8\]" \ " = \\(unsigned char \\*\\) \"\\\\020\\\\021\\\\022\\\\023\\\\024\\\\025\\\\026\\\\027\"..." gdb_test "p &ctable1\[3*8\]" \ - " = \\(unsigned char \\*\\) \"\\\\030\\\\031\\\\032\\\\e\\\\034\\\\035\\\\036\\\\037\"..." + " = \\(unsigned char \\*\\) \"\\\\030\\\\031\\\\032\\\\033\\\\034\\\\035\\\\036\\\\037\"..." gdb_test "p &ctable1\[4*8\]" \ " = \\(unsigned char \\*\\) \" !\\\\\"#\\\$%&'\"..." gdb_test "p &ctable1\[5*8\]" \ diff --git a/gdb/testsuite/gdb.base/relocate.c b/gdb/testsuite/gdb.base/relocate.c index df8545dc62e..90e70ffe8b6 100644 --- a/gdb/testsuite/gdb.base/relocate.c +++ b/gdb/testsuite/gdb.base/relocate.c @@ -3,7 +3,7 @@ static int static_bar = 2; /* This padding is just for the benefit of the test harness. It causes the globals to have different addresses than the functions. */ -int dummy[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +int dummy[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; int global_foo = 3; int global_bar = 4; diff --git a/gdb/testsuite/gdb.base/return2.exp b/gdb/testsuite/gdb.base/return2.exp index c87d9e46935..050ccf9fa77 100644 --- a/gdb/testsuite/gdb.base/return2.exp +++ b/gdb/testsuite/gdb.base/return2.exp @@ -1,4 +1,4 @@ -# Copyright 2000, 2001 Free Software Foundation, Inc. +# Copyright 2000, 2001, 2004 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 @@ -100,7 +100,7 @@ proc return_void { } { proc return2_tests { } { global gdb_prompt - if { ! [ runto main ] } then { + if { ! [ runto_main ] } then { gdb_suppress_entire_file "Run to main failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/scope.exp b/gdb/testsuite/gdb.base/scope.exp index db2c7ea9f91..3749d2348b8 100644 --- a/gdb/testsuite/gdb.base/scope.exp +++ b/gdb/testsuite/gdb.base/scope.exp @@ -1,5 +1,5 @@ -# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002 Free -# Software Foundation, Inc. +# Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, +# 2004 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 @@ -59,7 +59,6 @@ proc test_at_main {} { global det_file global srcdir global subdir - global gcc_compiled global hp_cc_compiler # skip past init. There may be a call to __main at the start of @@ -97,13 +96,13 @@ proc test_at_main {} { # No clue why the powerpc fails this test. setup_xfail "powerpc-*-*" - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } if [gdb_test "print filelocal_ro" "\\\$$decimal = 201" "print filelocal_ro in test_at_main" ] { gdb_suppress_tests ; } - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } setup_xfail "powerpc-*-*" if [gdb_test "print 'scope0.c'::filelocal_ro" "\\\$$decimal = 201" "print 'scope0.c'::filelocal_ro" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_ro"] { gdb_suppress_tests ; @@ -112,8 +111,7 @@ proc test_at_main {} { # Print scope1.c::filelocal, which is 2 - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - if {$hp_cc_compiler} then { setup_xfail "hppa2.0w-*-*" 11747CLLbs} + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } if [gdb_test "print 'scope1.c'::filelocal" "\\\$$decimal = 2" "print 'scope1.c'::filelocal" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal"] { gdb_suppress_tests ; } @@ -121,8 +119,7 @@ proc test_at_main {} { # Print scope1.c::filelocal_bss, which is 102 - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } - if {$hp_cc_compiler} then { setup_xfail "hppa2.0w-*-*" 11747CLLbs} + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } if [gdb_test "print 'scope1.c'::filelocal_bss" "\\\$$decimal = 102" "print 'scope1.c'::filelocal_bss" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_bss"] { gdb_suppress_tests ; } @@ -130,7 +127,7 @@ proc test_at_main {} { # Print scope1.c::filelocal_ro, which is 202 - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } if {$hp_cc_compiler} then { setup_xfail "hppa2.0w-*-*" 11747CLLbs} if [gdb_test "print 'scope1.c'::filelocal_ro" "\\\$$decimal = 202" "print 'scope1.c'::filelocal_ro" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_ro"] { gdb_suppress_tests ; @@ -144,7 +141,7 @@ proc test_at_main {} { } - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } if [gdb_test "print 'scope1.c'::foo::funclocal" "\\\$$decimal = 3" "print 'scope1.c'::foo::funclocal" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal"] { gdb_suppress_tests ; } @@ -157,7 +154,7 @@ proc test_at_main {} { } - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } if [gdb_test "print 'scope1.c'::foo::funclocal_ro" "\\\$$decimal = 203" "print 'scope1.c'::foo::funclocal_ro" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro"] { gdb_suppress_tests ; } @@ -170,7 +167,7 @@ proc test_at_main {} { } - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } if [gdb_test "print 'scope1.c'::bar::funclocal" "\\\$$decimal = 4" "print 'scope1.c'::bar::funclocal" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::bar::funclocal"] { gdb_suppress_tests ; } @@ -184,7 +181,6 @@ proc test_at_foo {} { global det_file global srcdir global subdir - global gcc_compiled if [gdb_test "next" ".*bar \\(\\);" "" ] { gdb_suppress_tests ; @@ -207,7 +203,7 @@ proc test_at_foo {} { # Print scope0.c::filelocal_ro, which is 201 - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } setup_xfail "powerpc-*-*" if [gdb_test "print 'scope0.c'::filelocal_ro" "\\\$$decimal = 201" "print 'scope0.c'::filelocal_ro" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_ro"] { gdb_suppress_tests ; @@ -218,7 +214,7 @@ proc test_at_foo {} { # Print scope1.c::filelocal, which is 2 - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } if [gdb_test "print 'scope1.c'::filelocal" "\\\$$decimal = 2" "print 'scope1.c'::filelocal at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal"] { gdb_suppress_tests ; } @@ -227,14 +223,14 @@ proc test_at_foo {} { gdb_test "print filelocal_bss" "\\\$$decimal = 102" \ "print filelocal_bss at foo" - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } gdb_test "print 'scope1.c'::filelocal_bss" "\\\$$decimal = 102" "print 'scope1.c'::filelocal_bss at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_bss" gdb_test "print filelocal_ro" "\\\$$decimal = 202" \ "print filelocal_ro at foo" - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } gdb_test "print 'scope1.c'::filelocal_ro" "\\\$$decimal = 202" "print 'scope1.c'::filelocal_ro at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_ro" @@ -245,7 +241,7 @@ proc test_at_foo {} { gdb_test "print foo::funclocal" "\\\$$decimal = 3" \ "print foo::funclocal at foo" - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } gdb_test "print 'scope1.c'::foo::funclocal" "\\\$$decimal = 3" "print 'scope1.c'::foo::funclocal at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal" @@ -257,7 +253,7 @@ proc test_at_foo {} { gdb_test "print foo::funclocal_bss" "\\\$$decimal = 103" \ "print foo::funclocal_bss at foo" - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } gdb_test "print 'scope1.c'::foo::funclocal_bss" "\\\$$decimal = 103" "print 'scope1.c'::foo::funclocal_bss at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss" @@ -269,7 +265,7 @@ proc test_at_foo {} { gdb_test "print foo::funclocal_ro" "\\\$$decimal = 203" \ "print foo::funclocal_ro at foo" - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } gdb_test "print 'scope1.c'::foo::funclocal_ro" "\\\$$decimal = 203" "print 'scope1.c'::foo::funclocal_ro at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro" @@ -278,7 +274,7 @@ proc test_at_foo {} { gdb_test "print bar::funclocal" "\\\$$decimal = 4" \ "print bar::funclocal at foo" - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } gdb_test "print 'scope1.c'::bar::funclocal" "\\\$$decimal = 4" "print 'scope1.c'::bar::funclocal at foo" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::bar::funclocal" gdb_stop_suppressing_tests; @@ -290,7 +286,6 @@ proc test_at_bar {} { global det_file global srcdir global subdir - global gcc_compiled if [gdb_test "next" ".*" "" ] { gdb_suppress_tests ; @@ -313,7 +308,7 @@ proc test_at_bar {} { # Print scope0.c::filelocal_ro, which is 201 - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } setup_xfail "powerpc-*-*" if [gdb_test "print 'scope0.c'::filelocal_ro" "\\\$$decimal = 201" "print 'scope0.c'::filelocal_ro at bar" "No symbol \"scope0.c\" in current context.*" "print '$srcdir/$subdir/scope0.c'::filelocal_ro"] { gdb_suppress_tests ; @@ -327,7 +322,7 @@ proc test_at_bar {} { } - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } if [gdb_test "print 'scope1.c'::filelocal" "\\\$$decimal = 2" "print 'scope1.c'::filelocal at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal"] { gdb_suppress_tests ; } @@ -340,7 +335,7 @@ proc test_at_bar {} { } - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } if [gdb_test "print 'scope1.c'::filelocal_bss" "\\\$$decimal = 102" "print 'scope1.c'::filelocal_bss at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_bss"] { gdb_suppress_tests ; } @@ -353,7 +348,7 @@ proc test_at_bar {} { } - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } if [gdb_test "print 'scope1.c'::filelocal_ro" "\\\$$decimal = 202" "print 'scope1.c'::filelocal_ro at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::filelocal_ro"] { gdb_suppress_tests ; } @@ -366,7 +361,7 @@ proc test_at_bar {} { } - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } if [gdb_test "print 'scope1.c'::foo::funclocal" "\\\$$decimal = 3" "print 'scope1.c'::foo::funclocal at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal"] { gdb_suppress_tests ; } @@ -379,7 +374,7 @@ proc test_at_bar {} { } - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } if [gdb_test "print 'scope1.c'::foo::funclocal_bss" "\\\$$decimal = 103" "print 'scope1.c'::foo::funclocal_bss at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_bss"] { gdb_suppress_tests ; } @@ -392,7 +387,7 @@ proc test_at_bar {} { } - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } if [gdb_test "print 'scope1.c'::foo::funclocal_ro" "\\\$$decimal = 203" "print 'scope1.c'::foo::funclocal_ro at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::foo::funclocal_ro"] { gdb_suppress_tests ; } @@ -410,7 +405,7 @@ proc test_at_bar {} { } - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } if [gdb_test "print 'scope1.c'::bar::funclocal" "\\\$$decimal = 4" "print 'scope1.c'::bar::funclocal at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::bar::funclocal"] { gdb_suppress_tests ; } @@ -428,7 +423,7 @@ proc test_at_bar {} { } - if {$gcc_compiled} then { setup_xfail "rs6000-*-*" } + if { [test_compiler_info gcc-*-*] } then { setup_xfail "rs6000-*-*" } if [gdb_test "print 'scope1.c'::bar::funclocal_bss" "\\\$$decimal = 104" "print 'scope1.c'::bar::funclocal_bss at bar" "No symbol \"scope1.c\" in current context.*" "print '$srcdir/$subdir/scope1.c'::bar::funclocal_bss"] { gdb_suppress_tests ; } diff --git a/gdb/testsuite/gdb.base/sect-cmd.exp b/gdb/testsuite/gdb.base/sect-cmd.exp index 10c0e74959a..0b86b79a90d 100644 --- a/gdb/testsuite/gdb.base/sect-cmd.exp +++ b/gdb/testsuite/gdb.base/sect-cmd.exp @@ -1,4 +1,4 @@ -# Copyright 1997, 1998, 1999 Free Software Foundation, Inc. +# Copyright 1997, 1998, 1999, 2003 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 @@ -40,9 +40,19 @@ if ![istarget "hppa*-*-hpux*"] then { set testfile "break" set srcfile ${testfile}.c +set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } gdb_exit diff --git a/gdb/testsuite/gdb.base/selftest.exp b/gdb/testsuite/gdb.base/selftest.exp index 9e1d4ddfb60..4196b74e786 100644 --- a/gdb/testsuite/gdb.base/selftest.exp +++ b/gdb/testsuite/gdb.base/selftest.exp @@ -95,6 +95,9 @@ proc do_steps_and_nexts {} { 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" } @@ -342,6 +345,11 @@ proc test_with_self { executable } { 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" diff --git a/gdb/testsuite/gdb.base/sepdebug.c b/gdb/testsuite/gdb.base/sepdebug.c new file mode 100644 index 00000000000..adb69210a88 --- /dev/null +++ b/gdb/testsuite/gdb.base/sepdebug.c @@ -0,0 +1,150 @@ +/* Copyright 1994, 1995, 1999, 2002, 2003, 2004 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 */ + +#ifdef vxworks + +# include <stdio.h> + +/* VxWorks does not supply atoi. */ +static int +atoi (z) + char *z; +{ + int i = 0; + + while (*z >= '0' && *z <= '9') + i = i * 10 + (*z++ - '0'); + return i; +} + +/* I don't know of any way to pass an array to VxWorks. This function + can be called directly from gdb. */ + +vxmain (arg) +char *arg; +{ + char *argv[2]; + + argv[0] = ""; + argv[1] = arg; + main (2, argv, (char **) 0); +} + +#else /* ! vxworks */ +# include <stdio.h> +# include <stdlib.h> +#endif /* ! vxworks */ + +/* + * The following functions do nothing useful. They are included simply + * as places to try setting breakpoints at. They are explicitly + * "one-line functions" to verify that this case works (some versions + * of gcc have or have had problems with this). + */ + +#ifdef PROTOTYPES +int marker1 (void) { return (0); } +int marker2 (int a) { return (1); } /* set breakpoint 8 here */ +void marker3 (char *a, char *b) {} +void marker4 (long d) {} /* set breakpoint 14 here */ +#else +int marker1 () { return (0); } +int marker2 (a) int a; { return (1); } /* set breakpoint 9 here */ +void marker3 (a, b) char *a, *b; {} +void marker4 (d) long d; {} /* set breakpoint 13 here */ +#endif + +/* + * This simple classical example of recursion is useful for + * testing stack backtraces and such. + */ + +#ifdef PROTOTYPES +int factorial(int); + +int +main (int argc, char **argv, char **envp) +#else +int +main (argc, argv, envp) +int argc; +char *argv[], **envp; +#endif +{ +#ifdef usestubs + set_debug_traps(); /* set breakpoint 5 here */ + breakpoint(); +#endif + if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */ + fprintf (stderr, "usage: factorial <number>\n"); + return 1; + } + printf ("%d\n", factorial (atoi ("6"))); /* set breakpoint 1 here */ + /* set breakpoint 12 here */ + marker1 (); /* set breakpoint 11 here */ + marker2 (43); + marker3 ("stack", "trace"); + marker4 (177601976L); + argc = (argc == 12345); /* This is silly, but we can step off of it */ /* set breakpoint 2 here */ + return argc; /* set breakpoint 10 here */ +} + +#ifdef PROTOTYPES +int factorial (int value) +#else +int factorial (value) +int value; +#endif +{ + if (value > 1) { /* set breakpoint 7 here */ + value *= factorial (value - 1); + } + return (value); +} + +#ifdef PROTOTYPES +int multi_line_if_conditional (int a, int b, int c) +#else +int multi_line_if_conditional (a, b, c) + int a, b, c; +#endif +{ + if (a /* set breakpoint 3 here */ + && b + && c) + return 0; + else + return 1; +} + +#ifdef PROTOTYPES +int multi_line_while_conditional (int a, int b, int c) +#else +int multi_line_while_conditional (a, b, c) + int a, b, c; +#endif +{ + while (a /* set breakpoint 4 here */ + && b + && c) + { + a--, b--, c--; + } + return 0; +} diff --git a/gdb/testsuite/gdb.base/sepdebug.exp b/gdb/testsuite/gdb.base/sepdebug.exp new file mode 100644 index 00000000000..1028dab575b --- /dev/null +++ b/gdb/testsuite/gdb.base/sepdebug.exp @@ -0,0 +1,987 @@ +# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2002, 2003, 2004 +# 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 + +# Based on break.exp, written by Rob Savoye. (rob@cygnus.com) +# Modified to test gdb's handling of separate debug info files. + +# This file has two parts. The first is testing that gdb behaves +# normally after reading in an executable and its corresponding +# separate debug file. The second moves the .debug file to a different +# location and tests the "set debug-file-directory" command. + + +if $tracelevel then { + strace $tracelevel +} + +# +# test running programs +# +set prms_id 0 +set bug_id 0 + +set testfile "sepdebug" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +# FIXME: this is nasty. We need to check for the stabs debug format. +# To do this we must run gdb on the unstripped executable, list 'main' +# (as to have a default source file), use get_debug_format (which does +# 'info source') and then see if the debug info is stabs. If so, we +# bail out. We cannot do this any other way because get_debug_format +# finds out the debug format using gdb itself, and in case of stabs we +# get an error loading the program if it is already stripped. An +# alternative would be to find out the debug info from the flags +# passed to dejagnu when the test is run. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} +gdb_test "list main" "" "" +get_debug_format +if { [test_debug_format "stabs"] } then { + # the separate debug info feature doesn't work well in binutils with stabs. + # It produces a corrupted debug info only file, and gdb chokes on it. + # It is almost impossible to capture the failing message out of gdb, + # because it happens inside gdb_load. At that point any error message + # is intercepted by dejagnu itself, and, because of the error threshold, + # any faulty test result is changed into an UNRESOLVED. + # (see dejagnu/lib/framework.exp) + unsupported "no separate debug info handling with stabs" + return -1 +} elseif { [test_debug_format "unknown"] } then { + # gdb doesn't know what the debug format is. We are out of luck here. + unsupported "unknown debugging format" + return -1 +} +gdb_exit + +# Note: the procedure gdb_gnu_strip_debug will produce an executable called +# ${binfile}, which is just like the executable ($binfile) but without +# the debuginfo. Instead $binfile has a .gnudebuglink section which contains +# the name of a debuginfo only file. This file will be stored in the +# gdb.base/.debug subdirectory. + +if [gdb_gnu_strip_debug $binfile] { + # check that you have a recent version of strip and objcopy installed + unsupported "cannot produce separate debug info files" + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if [target_info exists gdb_stub] { + gdb_step_for_stub; +} +# +# test simple breakpoint setting commands +# + +# Test deleting all breakpoints when there are none installed, +# GDB should not prompt for confirmation. +# Note that gdb-init.exp provides a "delete_breakpoints" proc +# for general use elsewhere. + +send_gdb "delete breakpoints\n" +gdb_expect { + -re "Delete all breakpoints.*$" { + send_gdb "y\n" + gdb_expect { + -re "$gdb_prompt $" { + fail "Delete all breakpoints when none (unexpected prompt)" + } + timeout { fail "Delete all breakpoints when none (timeout after unexpected prompt)" } + } + } + -re ".*$gdb_prompt $" { pass "Delete all breakpoints when none" } + timeout { fail "Delete all breakpoints when none (timeout)" } +} + +# +# test break at function +# +gdb_test "break main" \ + "Breakpoint.*at.* file .*$srcfile, line.*" \ + "breakpoint function" + +# +# test break at quoted function +# +gdb_test "break \"marker2\"" \ + "Breakpoint.*at.* file .*$srcfile, line.*" \ + "breakpoint quoted function" + +# +# test break at function in file +# +gdb_test "break $srcfile:factorial" \ + "Breakpoint.*at.* file .*$srcfile, line.*" \ + "breakpoint function in file" + +set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] + +# +# test break at line number +# +# Note that the default source file is the last one whose source text +# was printed. For native debugging, before we've executed the +# program, this is the file containing main, but for remote debugging, +# it's wherever the processor was stopped when we connected to the +# board. So, to be sure, we do a list command. +# +gdb_test "list main" \ + ".*main \\(argc, argv, envp\\).*" \ + "use `list' to establish default source file" +gdb_test "break $bp_location1" \ + "Breakpoint.*at.* file .*$srcfile, line $bp_location1\\." \ + "breakpoint line number" + +# +# test duplicate breakpoint +# +gdb_test "break $bp_location1" \ + "Note: breakpoint \[0-9\]+ also set at pc.*Breakpoint \[0-9\]+ at.* file .*$srcfile, line $bp_location1\\." \ + "breakpoint duplicate" + +set bp_location2 [gdb_get_line_number "set breakpoint 2 here"] + +# +# test break at line number in file +# +gdb_test "break $srcfile:$bp_location2" \ + "Breakpoint.*at.* file .*$srcfile, line $bp_location2\\." \ + "breakpoint line number in file" + +set bp_location3 [gdb_get_line_number "set breakpoint 3 here"] +set bp_location4 [gdb_get_line_number "set breakpoint 4 here"] + +# +# Test putting a break at the start of a multi-line if conditional. +# Verify the breakpoint was put at the start of the conditional. +# +gdb_test "break multi_line_if_conditional" \ + "Breakpoint.*at.* file .*$srcfile, line $bp_location3\\." \ + "breakpoint at start of multi line if conditional" + +gdb_test "break multi_line_while_conditional" \ + "Breakpoint.*at.* file .*$srcfile, line $bp_location4\\." \ + "breakpoint at start of multi line while conditional" + +set bp_location5 [gdb_get_line_number "set breakpoint 5 here"] +set bp_location6 [gdb_get_line_number "set breakpoint 6 here"] + +# +# check to see what breakpoints are set +# +if [target_info exists gdb_stub] { + set main_line $bp_location5 +} else { + set main_line $bp_location6 +} + +set bp_location7 [gdb_get_line_number "set breakpoint 7 here"] +set bp_location8 [gdb_get_line_number "set breakpoint 8 here"] +set bp_location9 [gdb_get_line_number "set breakpoint 9 here"] + +gdb_test "info break" \ + "Num Type\[ \]+Disp Enb Address\[ \]+What.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.* +\[0-9\]+\[\t \]+breakpoint keep y.* in marker2 at .*$srcfile:($bp_location8|$bp_location9).* +\[0-9\]+\[\t \]+breakpoint keep y.* in factorial at .*$srcfile:$bp_location7.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.* +\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location2.* +\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_if_conditional at .*$srcfile:$bp_location3.* +\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_while_conditional at .*$srcfile:$bp_location4" \ + "breakpoint info" + +# FIXME: The rest of this test doesn't work with anything that can't +# handle arguments. +# Huh? There doesn't *appear* to be anything that passes arguments +# below. +if [istarget "mips-idt-*"] then { + return +} + +# +# run until the breakpoint at main is hit. For non-stubs-using targets. +# +if ![target_info exists use_gdb_stub] { + if [istarget "*-*-vxworks*"] then { + send_gdb "run vxmain \"2\"\n" + set timeout 120 + verbose "Timeout is now $timeout seconds" 2 + } else { + send_gdb "run\n" + } + gdb_expect { + -re "The program .* has been started already.*y or n. $" { + send_gdb "y\n" + exp_continue + } + -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\ + { pass "run until function breakpoint" } + -re ".*$gdb_prompt $" { fail "run until function breakpoint" } + timeout { fail "run until function breakpoint (timeout)" } + } +} else { + if ![target_info exists gdb_stub] { + gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue" + } +} + +# +# run until the breakpoint at a line number +# +gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location1.*$bp_location1\[\t \]+printf.*factorial.*" \ + "run until breakpoint set at a line number" + +# +# Run until the breakpoint set in a function in a file +# +for {set i 6} {$i >= 1} {incr i -1} { + gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, factorial \\(value=$i\\) at .*$srcfile:$bp_location7.*$bp_location7\[\t \]+.*if .value > 1. \{.*" \ + "run until file:function($i) breakpoint" +} + +# +# Run until the breakpoint set at a quoted function +# +gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, (0x\[0-9a-f\]+ in )?marker2 \\(a=43\\) at .*$srcfile:($bp_location8|$bp_location9).*" \ + "run until quoted breakpoint" +# +# run until the file:function breakpoint at a line number in a file +# +gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location2.*$bp_location2\[\t \]+argc = \\(argc == 12345\\);.*" \ + "run until file:linenum breakpoint" + +# Test break at offset +1 +set bp_location10 [gdb_get_line_number "set breakpoint 10 here"] + +gdb_test "break +1" \ + "Breakpoint.*at.* file .*$srcfile, line $bp_location10\\." \ + "breakpoint offset +1" + +# Check to see if breakpoint is hit when stepped onto + +gdb_test "step" \ + ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location10.*$bp_location10\[\t \]+return argc;.*breakpoint 10 here.*" \ + "step onto breakpoint" + +# +# delete all breakpoints so we can start over, course this can be a test too +# +delete_breakpoints + +# +# test temporary breakpoint at function +# + +gdb_test "tbreak main" "Breakpoint.*at.* file .*$srcfile, line.*" "Temporary breakpoint function" + +# +# test break at function in file +# + +gdb_test "tbreak $srcfile:factorial" "Breakpoint.*at.* file .*$srcfile, line.*" \ + "Temporary breakpoint function in file" + +# +# test break at line number +# +send_gdb "tbreak $bp_location1\n" +gdb_expect { + -re "Breakpoint.*at.* file .*$srcfile, line $bp_location1.*$gdb_prompt $" { pass "Temporary breakpoint line number #1" } + -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number #1" } + timeout { fail "breakpoint line number #1 (timeout)" } +} + +gdb_test "tbreak $bp_location6" "Breakpoint.*at.* file .*$srcfile, line $bp_location6.*" "Temporary breakpoint line number #2" + +# +# test break at line number in file +# +send_gdb "tbreak $srcfile:$bp_location2\n" +gdb_expect { + -re "Breakpoint.*at.* file .*$srcfile, line $bp_location2.*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" } + -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" } + timeout { fail "Temporary breakpoint line number in file #1 (timeout)" } +} + +set bp_location11 [gdb_get_line_number "set breakpoint 11 here"] +gdb_test "tbreak $srcfile:$bp_location11" "Breakpoint.*at.* file .*$srcfile, line $bp_location11.*" "Temporary breakpoint line number in file #2" + +# +# check to see what breakpoints are set (temporary this time) +# +gdb_test "info break" "Num Type.*Disp Enb Address.*What.*\[\r\n\] +\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$main_line.*\[\r\n\] +\[0-9\]+\[\t \]+breakpoint del.*y.*in factorial at .*$srcfile:$bp_location7.*\[\r\n\] +\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location1.*\[\r\n\] +\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location6.*\[\r\n\] +\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location2.*\[\r\n\] +\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location11.*" \ + "Temporary breakpoint info" + + +#*********** + +# Verify that catchpoints for fork, vfork and exec don't trigger +# inappropriately. (There are no calls to those system functions +# in this test program.) +# +if ![runto_main] then { fail "break tests suppressed" } + +send_gdb "catch\n" +gdb_expect { + -re "Catch requires an event name.*$gdb_prompt $"\ + {pass "catch requires an event name"} + -re "$gdb_prompt $"\ + {fail "catch requires an event name"} + timeout {fail "(timeout) catch requires an event name"} +} + + +set name "set catch fork, never expected to trigger" +send_gdb "catch fork\n" +gdb_expect { + -re "Catchpoint \[0-9\]* .fork..*$gdb_prompt $" + {pass $name} + -re "Catch of fork not yet implemented.*$gdb_prompt $" + {pass $name} + -re "$gdb_prompt $" + {fail $name} + timeout {fail "(timeout) $name"} +} + + +set name "set catch vfork, never expected to trigger" +send_gdb "catch vfork\n" + +# If we are on HP-UX 10.20, we expect an error message to be +# printed if we type "catch vfork" at the gdb gdb_prompt. This is +# because on HP-UX 10.20, we cannot catch vfork events. + +if [istarget "hppa*-hp-hpux10.20"] then { + gdb_expect { + -re "Catch of vfork events not supported on HP-UX 10.20..*$gdb_prompt $" + {pass $name} + -re "$gdb_prompt $" + {fail $name} + timeout {fail "(timeout) $name"} + } +} else { + gdb_expect { + -re "Catchpoint \[0-9\]* .vfork..*$gdb_prompt $" + {pass $name} + -re "Catch of vfork not yet implemented.*$gdb_prompt $" + {pass $name} + -re "$gdb_prompt $" + {fail $name} + timeout {fail "(timeout) $name"} + } +} + +set name "set catch exec, never expected to trigger" +send_gdb "catch exec\n" +gdb_expect { + -re "Catchpoint \[0-9\]* .exec..*$gdb_prompt $" + {pass $name} + -re "Catch of exec not yet implemented.*$gdb_prompt $" + {pass $name} + -re "$gdb_prompt $" {fail $name} + timeout {fail "(timeout) $name"} +} + +# Verify that GDB responds gracefully when asked to set a breakpoint +# on a nonexistent source line. +# +send_gdb "break 999\n" +gdb_expect { + -re "No line 999 in file .*$gdb_prompt $"\ + {pass "break on non-existent source line"} + -re "$gdb_prompt $"\ + {fail "break on non-existent source line"} + timeout {fail "(timeout) break on non-existent source line"} +} + +# Run to the desired default location. If not positioned here, the +# tests below don't work. +# +gdb_test "until $bp_location1" "main .* at .*:$bp_location1.*" "until bp_location1" + + +# Verify that GDB allows one to just say "break", which is treated +# as the "default" breakpoint. Note that GDB gets cute when printing +# the informational message about other breakpoints at the same +# location. We'll hit that bird with this stone too. +# +send_gdb "break\n" +gdb_expect { + -re "Breakpoint \[0-9\]*.*$gdb_prompt $"\ + {pass "break on default location, 1st time"} + -re "$gdb_prompt $"\ + {fail "break on default location, 1st time"} + timeout {fail "(timeout) break on default location, 1st time"} +} + +send_gdb "break\n" +gdb_expect { + -re "Note: breakpoint \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\ + {pass "break on default location, 2nd time"} + -re "$gdb_prompt $"\ + {fail "break on default location, 2nd time"} + timeout {fail "(timeout) break on default location, 2nd time"} +} + +send_gdb "break\n" +gdb_expect { + -re "Note: breakpoints \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\ + {pass "break on default location, 3rd time"} + -re "$gdb_prompt $"\ + {fail "break on default location, 3rd time"} + timeout {fail "(timeout) break on default location, 3rd time"} +} + +send_gdb "break\n" +gdb_expect { + -re "Note: breakpoints \[0-9\]*, \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\ + {pass "break on default location, 4th time"} + -re "$gdb_prompt $"\ + {fail "break on default location, 4th time"} + timeout {fail "(timeout) break on default location, 4th time"} +} + +# Verify that a "silent" breakpoint can be set, and that GDB is indeed +# "silent" about its triggering. +# +if ![runto_main] then { fail "break tests suppressed" } + +send_gdb "break $bp_location1\n" +gdb_expect { + -re "Breakpoint (\[0-9\]*) at .*, line $bp_location1.*$gdb_prompt $"\ + {pass "set to-be-silent break bp_location1"} + -re "$gdb_prompt $"\ + {fail "set to-be-silent break bp_location1"} + timeout {fail "(timeout) set to-be-silent break bp_location1"} +} + +send_gdb "commands $expect_out(1,string)\n" +send_gdb "silent\n" +send_gdb "end\n" +gdb_expect { + -re ".*$gdb_prompt $"\ + {pass "set silent break bp_location1"} + timeout {fail "(timeout) set silent break bp_location1"} +} + +send_gdb "info break $expect_out(1,string)\n" +gdb_expect { + -re "\[0-9\]*\[ \t\]*breakpoint.*:$bp_location1\r\n\[ \t\]*silent.*$gdb_prompt $"\ + {pass "info silent break bp_location1"} + -re "$gdb_prompt $"\ + {fail "info silent break bp_location1"} + timeout {fail "(timeout) info silent break bp_location1"} +} +send_gdb "continue\n" +gdb_expect { + -re "Continuing.\r\n$gdb_prompt $"\ + {pass "hit silent break bp_location1"} + -re "$gdb_prompt $"\ + {fail "hit silent break bp_location1"} + timeout {fail "(timeout) hit silent break bp_location1"} +} +send_gdb "bt\n" +gdb_expect { + -re "#0 main .* at .*:$bp_location1.*$gdb_prompt $"\ + {pass "stopped for silent break bp_location1"} + -re "$gdb_prompt $"\ + {fail "stopped for silent break bp_location1"} + timeout {fail "(timeout) stopped for silent break bp_location1"} +} + +# Verify that GDB can at least parse a breakpoint with the +# "thread" keyword. (We won't attempt to test here that a +# thread-specific breakpoint really triggers appropriately. +# The gdb.threads subdirectory contains tests for that.) +# +set bp_location12 [gdb_get_line_number "set breakpoint 12 here"] +send_gdb "break $bp_location12 thread 999\n" +gdb_expect { + -re "Unknown thread 999.*$gdb_prompt $"\ + {pass "thread-specific breakpoint on non-existent thread disallowed"} + -re "$gdb_prompt $"\ + {fail "thread-specific breakpoint on non-existent thread disallowed"} + timeout {fail "(timeout) thread-specific breakpoint on non-existent thread disallowed"} +} +send_gdb "break $bp_location12 thread foo\n" +gdb_expect { + -re "Junk after thread keyword..*$gdb_prompt $"\ + {pass "thread-specific breakpoint on bogus thread ID disallowed"} + -re "$gdb_prompt $"\ + {fail "thread-specific breakpoint on bogus thread ID disallowed"} + timeout {fail "(timeout) thread-specific breakpoint on bogus thread ID disallowed"} +} + +# Verify that GDB responds gracefully to a breakpoint command with +# trailing garbage. +# +send_gdb "break $bp_location12 foo\n" +gdb_expect { + -re "Junk at end of arguments..*$gdb_prompt $"\ + {pass "breakpoint with trailing garbage disallowed"} + -re "$gdb_prompt $"\ + {fail "breakpoint with trailing garbage disallowed"} + timeout {fail "(timeout) breakpoint with trailing garbage disallowed"} +} + +# Verify that GDB responds gracefully to a "clear" command that has +# no matching breakpoint. (First, get us off the current source line, +# which we know has a breakpoint.) +# +send_gdb "next\n" +gdb_expect { + -re ".*$gdb_prompt $"\ + {pass "step over breakpoint"} + timeout {fail "(timeout) step over breakpoint"} +} +send_gdb "clear 81\n" +gdb_expect { + -re "No breakpoint at 81..*$gdb_prompt $"\ + {pass "clear line has no breakpoint disallowed"} + -re "$gdb_prompt $"\ + {fail "clear line has no breakpoint disallowed"} + timeout {fail "(timeout) clear line has no breakpoint disallowed"} +} +send_gdb "clear\n" +gdb_expect { + -re "No breakpoint at this line..*$gdb_prompt $"\ + {pass "clear current line has no breakpoint disallowed"} + -re "$gdb_prompt $"\ + {fail "clear current line has no breakpoint disallowed"} + timeout {fail "(timeout) clear current line has no breakpoint disallowed"} +} + +# Verify that we can set and clear multiple breakpoints. +# +# We don't test that it deletes the correct breakpoints. We do at +# least test that it deletes more than one breakpoint. +# +gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #1" +gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #2" +gdb_test "clear marker3" {Deleted breakpoints [0-9]+ [0-9]+.*} + +# Verify that a breakpoint can be set via a convenience variable. +# +send_gdb "set \$foo=$bp_location11\n" +gdb_expect { + -re "$gdb_prompt $"\ + {pass "set convenience variable \$foo to bp_location11"} + timeout {fail "(timeout) set convenience variable \$foo to bp_location11"} +} +send_gdb "break \$foo\n" +gdb_expect { + -re "Breakpoint (\[0-9\]*) at .*, line $bp_location11.*$gdb_prompt $"\ + {pass "set breakpoint via convenience variable"} + -re "$gdb_prompt $"\ + {fail "set breakpoint via convenience variable"} + timeout {fail "(timeout) set breakpoint via convenience variable"} +} + +# Verify that GDB responds gracefully to an attempt to set a +# breakpoint via a convenience variable whose type is not integer. +# +send_gdb "set \$foo=81.5\n" +gdb_expect { + -re "$gdb_prompt $"\ + {pass "set convenience variable \$foo to 81.5"} + timeout {fail "(timeout) set convenience variable \$foo to 81.5"} +} +send_gdb "break \$foo\n" +gdb_expect { + -re "Convenience variables used in line specs must have integer values..*$gdb_prompt $"\ + {pass "set breakpoint via non-integer convenience variable disallowed"} + -re "$gdb_prompt $"\ + {fail "set breakpoint via non-integer convenience variable disallowed"} + timeout {fail "(timeout) set breakpoint via non-integer convenience variable disallowed"} +} + +# Verify that we can set and trigger a breakpoint in a user-called function. +# +send_gdb "break marker2\n" +gdb_expect { + -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location8|$bp_location9).*$gdb_prompt $"\ + {pass "set breakpoint on to-be-called function"} + -re "$gdb_prompt $"\ + {fail "set breakpoint on to-be-called function"} + timeout {fail "(timeout) set breakpoint on to-be-called function"} +} +send_gdb "print marker2(99)\n" +gdb_expect { + -re "The program being debugged stopped while in a function called from GDB.\r\nWhen the function .marker2. is done executing, GDB will silently\r\nstop .instead of continuing to evaluate the expression containing\r\nthe function call...*$gdb_prompt $"\ + {pass "hit breakpoint on called function"} + -re "$gdb_prompt $"\ + {fail "hit breakpoint on called function"} + timeout {fail "(timeout) hit breakpoint on called function"} +} + +# As long as we're stopped (breakpointed) in a called function, +# verify that we can successfully backtrace & such from here. +# +# In this and the following test, the _sr4export check apparently is needed +# for hppa*-*-hpux. +# +send_gdb "bt\n" +gdb_expect { + -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*_sr4export.*$gdb_prompt $"\ + {pass "backtrace while in called function"} + -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*function called from gdb.*$gdb_prompt $"\ + {pass "backtrace while in called function"} + -re "$gdb_prompt $"\ + {fail "backtrace while in called function"} + timeout {fail "(timeout) backtrace while in called function"} +} + +# Return from the called function. For remote targets, it's important to do +# this before runto_main, which otherwise may silently stop on the dummy +# breakpoint inserted by GDB at the program's entry point. +# +send_gdb "finish\n" +gdb_expect { + -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.* in _sr4export.*$gdb_prompt $"\ + {pass "finish from called function"} + -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*function called from gdb.*$gdb_prompt $"\ + {pass "finish from called function"} + -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*Value returned.*$gdb_prompt $"\ + {pass "finish from called function"} + -re "$gdb_prompt $"\ + {fail "finish from called function"} + timeout {fail "(timeout) finish from called function"} +} + +# Verify that GDB responds gracefully to a "finish" command with +# arguments. +# +if ![runto_main] then { fail "break tests suppressed" } + +send_gdb "finish 123\n" +gdb_expect { + -re "The \"finish\" command does not take any arguments.\r\n$gdb_prompt $"\ + {pass "finish with arguments disallowed"} + -re "$gdb_prompt $"\ + {fail "finish with arguments disallowed"} + 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 + + if [target_info exists use_gdb_stub] { + # Reload the program. + delete_breakpoints + gdb_load ${binfile}; + } else { + # FIXME: should be using runto + 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 + + if [istarget "*-*-vxworks*"] then { + send_gdb "run vxmain \"6\"\n" + } else { + 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 + + +#******** + +# 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}" +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_test "set debug-file-directory ${objdir}/${subdir}" ".*" "set separate debug location" +gdb_load ${binfile} + +if [target_info exists gdb_stub] { + gdb_step_for_stub; +} + +# +# test break at function +# +gdb_test "break main" \ + "Breakpoint.*at.* file .*$srcfile, line.*" \ + "breakpoint function, optimized file" + +# +# test break at function +# +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. +# +if ![target_info exists use_gdb_stub] { + if [istarget "*-*-vxworks*"] then { + send_gdb "run vxmain \"2\"\n" + set timeout 120 + verbose "Timeout is now $timeout seconds" 2 + } else { + send_gdb "run\n" + } + gdb_expect { + -re "The program .* has been started already.*y or n. $" { + send_gdb "y\n" + exp_continue + } + -re "Starting program.*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 "Starting program.*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)" } + } +} else { + if ![target_info exists gdb_stub] { + gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue, optimized file" + } +} + +# +# 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" +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 $" {} +} diff --git a/gdb/testsuite/gdb.base/setvar.exp b/gdb/testsuite/gdb.base/setvar.exp index e14ed5d948e..c101f9c4ce2 100644 --- a/gdb/testsuite/gdb.base/setvar.exp +++ b/gdb/testsuite/gdb.base/setvar.exp @@ -1,24 +1,7 @@ -# Copyright 1997, 1999, 2000 Free Software Foundation, Inc. +# This testcase is part of GDB, the GNU debugger. -# 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 - -# Copyright (C) 1988, 1990, 1991, 1992, 1994, 1995 -# Free Software Foundation, Inc. +# Copyright 1988, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, +# 1999, 2000, 2001, 2004 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 @@ -35,7 +18,7 @@ # 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 +# bug-gdb@gnu.org # This file was written by Rob Savoye. (rob@cygnus.com) @@ -139,7 +122,7 @@ proc test_set { args } { test_set "set variable v_char=0" "print v_char" ".\[0-9\]* = 0 \'.0\'" "set variable char=0" test_set "set variable v_char=1" "print v_char" ".\[0-9\]* = 1 \'.001\'" "set variable char=1" -test_set "set variable v_char=27" "print v_char" ".\[0-9\]* = 27 \'.e\'" "set variable char=27 (Esc)" +test_set "set variable v_char=7" "print v_char" ".\[0-9\]* = 7 \'.a\'" "set variable char=7 (Bel)" test_set "set variable v_char=32" "print v_char" ".\[0-9\]* = 32 \' \'" "set variable char=32 (SPC)" test_set "set variable v_char=65" "print v_char" ".\[0-9\]* = 65 \'A\'" "set variable char=65 ('A')" test_set "set variable v_char=97" "print v_char" ".\[0-9\]* = 97 \'a\'" "set variable char=97 ('a')" @@ -150,7 +133,7 @@ test_set "set variable v_char=127" "print v_char" ".\[0-9\]* = 127 \'.177\'" # test_set "set variable v_char=0" "print v_signed_char" ".\[0-9\]* = 0 \'.0\'" "set variable signed char=0" test_set "set variable v_signed_char=1" "print v_signed_char" ".\[0-9\]* = 1 \'.001\'" "set variable signed char=1" -test_set "set variable v_signed_char=27" "print v_signed_char" ".\[0-9\]* = 27 \'.e\'" "set variable signed char=27 (Esc)" +test_set "set variable v_signed_char=7" "print v_signed_char" ".\[0-9\]* = 7 \'.a\'" "set variable signed char=7 (Bel)" test_set "set variable v_signed_char=32" "print v_signed_char" ".\[0-9\]* = 32 \' \'" "set variable signed char=32 (SPC)" test_set "set variable v_signed_char=65" "print v_signed_char" ".\[0-9\]* = 65 \'A\'" "set variable signed char=65 ('A')" test_set "set variable v_signed_char=97" "print v_signed_char" ".\[0-9\]* = 97 \'a\'" "set variable signed char=97 ('a')" @@ -169,7 +152,7 @@ gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \ # test_set "set variable v_unsigned_char=0" "print v_unsigned_char" ".\[0-9\]* = 0 \'.0\'" "set variable unsigned char=0" test_set "set variable v_unsigned_char=1" "print v_unsigned_char" ".\[0-9\]* = 1 \'.001\'" "set variable unsigned char=1" -test_set "set variable v_unsigned_char=27" "print v_unsigned_char" ".\[0-9\]* = 27 \'.e\'" "set variable unsigned char=27 (Esc)" +test_set "set variable v_unsigned_char=7" "print v_unsigned_char" ".\[0-9\]* = 7 \'.a\'" "set variable unsigned char=7 (Bel)" test_set "set variable v_unsigned_char=32" "print v_unsigned_char" ".\[0-9\]* = 32 \' \'" "set variable unsigned char=32 (SPC)" test_set "set variable v_unsigned_char=65" "print v_unsigned_char" ".\[0-9\]* = 65 \'A\'" "set variable unsigned char=65 ('A')" test_set "set variable v_unsigned_char=97" "print v_unsigned_char" ".\[0-9\]* = 97 \'a\'" "set variable unsigned char=97 ('a')" @@ -329,12 +312,8 @@ gdb_test "print *(v_signed_short_pointer+1)" ".\[0-9\]*.*=.*-456" gdb_test "set v_unsigned_short_pointer=v_unsigned_short_array" "" gdb_test "set variable *(v_unsigned_short_pointer)=123" "" gdb_test "set variable *(v_unsigned_short_pointer+1)=-456" "" -# DTS 10060CLLbs - bad type info from cc -if {$hp_cc_compiler} {setup_xfail hppa*-*-*11* 10060CLLbs} gdb_test "print v_unsigned_short_array" ".\[0-9\]* =.*\\{123,.*65080\\}" \ "set variable unsigned short pointer" -# DTS 10060CLLbs - bad type info from cc -if {$hp_cc_compiler} {setup_xfail hppa*-*-*11* 10060CLLbs} gdb_test "print *(v_unsigned_short_pointer+1)" ".\[0-9\]* = 65080" # # test "set variable" for type "int *" diff --git a/gdb/testsuite/gdb.base/shlib-call.exp b/gdb/testsuite/gdb.base/shlib-call.exp index 8fe8b22da39..4205253e2f5 100644 --- a/gdb/testsuite/gdb.base/shlib-call.exp +++ b/gdb/testsuite/gdb.base/shlib-call.exp @@ -1,4 +1,4 @@ -# Copyright 1997, 1998, 1999, 2000 Free Software Foundation, Inc. +# Copyright 1997, 1998, 1999, 2000, 2004 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 @@ -291,7 +291,7 @@ send_gdb "set width 0\n" ; gdb_expect -re "$gdb_prompt $" # PR's 16495, 18213 # test that we can re-set breakpoints in shared libraries -gdb_test "break shr1" "Breakpoint 1.*" "set bp in shared library" +gdb_breakpoint "shr1" # FIXME: should not send "run" explicitly. Non-portable. diff --git a/gdb/testsuite/gdb.base/shreloc.exp b/gdb/testsuite/gdb.base/shreloc.exp index ac48774676f..55ec1e776bb 100644 --- a/gdb/testsuite/gdb.base/shreloc.exp +++ b/gdb/testsuite/gdb.base/shreloc.exp @@ -23,6 +23,11 @@ # them gets relocated at load-time. Check that gdb gets the right # values for the debugging and minimal symbols. +if {[istarget *-elf*] || [istarget *-coff] || [istarget *-aout]} then { + verbose "test skipped - shared object files not supported by this target." + return 0 +} + if $tracelevel then { strace $tracelevel } diff --git a/gdb/testsuite/gdb.base/so-impl-ld.exp b/gdb/testsuite/gdb.base/so-impl-ld.exp index 68a1bf41c00..bcc7120c66c 100644 --- a/gdb/testsuite/gdb.base/so-impl-ld.exp +++ b/gdb/testsuite/gdb.base/so-impl-ld.exp @@ -1,4 +1,4 @@ -# Copyright 1997, 1998, 1999, 2000 Free Software Foundation, Inc. +# Copyright 1997, 1998, 1999, 2000, 2001, 2003 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 @@ -55,15 +55,15 @@ if [get_compiler_info ${binfile}] { #remote_exec build "$CC -g +z -c ${libfile}1.c -o ${libfile}1.o" -if {$gcc_compiled == 0} { +if { [test_compiler_info gcc-*-*] } then { + set additional_flags "additional_flags=-fpic" +} else { if [istarget "hppa*-hp-hpux*"] then { set additional_flags "additional_flags=+z" } else { # don't know that the compiler is, hope for the best... set additional_flags "" } -} else { - set additional_flags "additional_flags=-fpic" } if {[gdb_compile "${srcdir}/${subdir}/${libfile}1.c" "${libfile}1.o" object [list debug $additional_flags]] != ""} { diff --git a/gdb/testsuite/gdb.base/structs.c b/gdb/testsuite/gdb.base/structs.c index 356f0729f1e..f7124dace9f 100644 --- a/gdb/testsuite/gdb.base/structs.c +++ b/gdb/testsuite/gdb.base/structs.c @@ -1,4 +1,6 @@ -/* Copyright 1996, 1999 Free Software Foundation, Inc. +/* This testcase is part of GDB, the GNU debugger. + + Copyright 1996, 1999, 2003 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 @@ -17,37 +19,110 @@ Please email any bugs, comments, and/or additions to this file to: bug-gdb@prep.ai.mit.edu */ -struct struct1 { char a;}; -struct struct2 { char a, b;}; -struct struct3 { char a, b, c; }; -struct struct4 { char a, b, c, d; }; -struct struct5 { char a, b, c, d, e; }; -struct struct6 { char a, b, c, d, e, f; }; -struct struct7 { char a, b, c, d, e, f, g; }; -struct struct8 { char a, b, c, d, e, f, g, h; }; -struct struct9 { char a, b, c, d, e, f, g, h, i; }; -struct struct10 { char a, b, c, d, e, f, g, h, i, j; }; -struct struct11 { char a, b, c, d, e, f, g, h, i, j, k; }; -struct struct12 { char a, b, c, d, e, f, g, h, i, j, k, l; }; -struct struct16 { char a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p; }; - -struct struct1 foo1 = {'1'}, L1; -struct struct2 foo2 = { 'a', 'b'}, L2; -struct struct3 foo3 = { 'A', 'B', 'C'}, L3; -struct struct4 foo4 = {'1', '2', '3', '4'}, L4; -struct struct5 foo5 = {'a', 'b', 'c', 'd', 'e'}, L5; -struct struct6 foo6 = {'A', 'B', 'C', 'D', 'E', 'F'}, L6; -struct struct7 foo7 = {'1', '2', '3', '4', '5', '6', '7'}, L7; -struct struct8 foo8 = {'1', '2', '3', '4', '5', '6', '7', '8'}, L8; -struct struct9 foo9 = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'}, L9; -struct struct10 foo10 = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'}, L10; -struct struct11 foo11 = { - '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B'}, L11; -struct struct12 foo12 = { - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L'}, L12; -struct struct16 foo16 = { - 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p'}, L16; +/* Useful abreviations. */ +typedef void t; +typedef char tc; +typedef short ts; +typedef int ti; +typedef long tl; +typedef long long tll; +typedef float tf; +typedef double td; +typedef long double tld; + +/* Force the type of each field. */ +#ifndef tA +typedef t tA; +#endif +#ifndef tB +typedef tA tB; +#endif +#ifndef tC +typedef tB tC; +#endif +#ifndef tD +typedef tC tD; +#endif +#ifndef tE +typedef tD tE; +#endif +#ifndef tF +typedef tE tF; +#endif +#ifndef tG +typedef tF tG; +#endif +#ifndef tH +typedef tG tH; +#endif +#ifndef tI +typedef tH tI; +#endif +#ifndef tJ +typedef tI tJ; +#endif +#ifndef tK +typedef tJ tK; +#endif +#ifndef tL +typedef tK tL; +#endif +#ifndef tM +typedef tL tM; +#endif +#ifndef tN +typedef tM tN; +#endif +#ifndef tO +typedef tN tO; +#endif +#ifndef tP +typedef tO tP; +#endif +#ifndef tQ +typedef tP tQ; +#endif +#ifndef tR +typedef tQ tR; +#endif + +struct struct1 {tA a;}; +struct struct2 {tA a; tB b;}; +struct struct3 {tA a; tB b; tC c; }; +struct struct4 {tA a; tB b; tC c; tD d; }; +struct struct5 {tA a; tB b; tC c; tD d; tE e; }; +struct struct6 {tA a; tB b; tC c; tD d; tE e; tF f; }; +struct struct7 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; }; +struct struct8 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; }; +struct struct9 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; }; +struct struct10 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; }; +struct struct11 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; }; +struct struct12 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; }; +struct struct13 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; }; +struct struct14 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; }; +struct struct15 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; }; +struct struct16 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; tP p; }; +struct struct17 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; tP p; tQ q; }; +struct struct18 {tA a; tB b; tC c; tD d; tE e; tF f; tG g; tH h; tI i; tJ j; tK k; tL l; tM m; tN n; tO o; tP p; tQ q; tR r; }; + +struct struct1 foo1 = {'1'}, L1; +struct struct2 foo2 = {'a','2'}, L2; +struct struct3 foo3 = {'1','b','3'}, L3; +struct struct4 foo4 = {'a','2','c','4'}, L4; +struct struct5 foo5 = {'1','b','3','d','5'}, L5; +struct struct6 foo6 = {'a','2','c','4','e','6'}, L6; +struct struct7 foo7 = {'1','b','3','d','5','f','7'}, L7; +struct struct8 foo8 = {'a','2','c','4','e','6','g','8'}, L8; +struct struct9 foo9 = {'1','b','3','d','5','f','7','h','9'}, L9; +struct struct10 foo10 = {'a','2','c','4','e','6','g','8','i','A'}, L10; +struct struct11 foo11 = {'1','b','3','d','5','f','7','h','9','j','B'}, L11; +struct struct12 foo12 = {'a','2','c','4','e','6','g','8','i','A','k','C'}, L12; +struct struct13 foo13 = {'1','b','3','d','5','f','7','h','9','j','B','l','D'}, L13; +struct struct14 foo14 = {'a','2','c','4','e','6','g','8','i','A','k','C','m','E'}, L14; +struct struct15 foo15 = {'1','b','3','d','5','f','7','h','9','j','B','l','D','n','F'}, L15; +struct struct16 foo16 = {'a','2','c','4','e','6','g','8','i','A','k','C','m','E','o','G'}, L16; +struct struct17 foo17 = {'1','b','3','d','5','f','7','h','9','j','B','l','D','n','F','p','H'}, L17; +struct struct18 foo18 = {'a','2','c','4','e','6','g','8','i','A','k','C','m','E','o','G','q','I'}, L18; struct struct1 fun1() { @@ -97,10 +172,30 @@ struct struct12 fun12() { return foo12; } +struct struct13 fun13() +{ + return foo13; +} +struct struct14 fun14() +{ + return foo14; +} +struct struct15 fun15() +{ + return foo15; +} struct struct16 fun16() { return foo16; } +struct struct17 fun17() +{ + return foo17; +} +struct struct18 fun18() +{ + return foo18; +} #ifdef PROTOTYPES void Fun1(struct struct1 foo1) @@ -211,6 +306,33 @@ void Fun12(foo12) L12 = foo12; } #ifdef PROTOTYPES +void Fun13(struct struct13 foo13) +#else +void Fun13(foo13) + struct struct13 foo13; +#endif +{ + L13 = foo13; +} +#ifdef PROTOTYPES +void Fun14(struct struct14 foo14) +#else +void Fun14(foo14) + struct struct14 foo14; +#endif +{ + L14 = foo14; +} +#ifdef PROTOTYPES +void Fun15(struct struct15 foo15) +#else +void Fun15(foo15) + struct struct15 foo15; +#endif +{ + L15 = foo15; +} +#ifdef PROTOTYPES void Fun16(struct struct16 foo16) #else void Fun16(foo16) @@ -219,6 +341,64 @@ void Fun16(foo16) { L16 = foo16; } +#ifdef PROTOTYPES +void Fun17(struct struct17 foo17) +#else +void Fun17(foo17) + struct struct17 foo17; +#endif +{ + L17 = foo17; +} +#ifdef PROTOTYPES +void Fun18(struct struct18 foo18) +#else +void Fun18(foo18) + struct struct18 foo18; +#endif +{ + L18 = foo18; +} + +zed () +{ + + L1.a = L2.a = L3.a = L4.a = L5.a = L6.a = L7.a = L8.a = L9.a = L10.a = L11.a = L12.a = L13.a = L14.a = L15.a = L16.a = L17.a = L18.a = 'Z'; + + L2.b = L3.b = L4.b = L5.b = L6.b = L7.b = L8.b = L9.b = L10.b = L11.b = L12.b = L13.b = L14.b = L15.b = L16.b = L17.b = L18.b = 'Z'; + + L3.c = L4.c = L5.c = L6.c = L7.c = L8.c = L9.c = L10.c = L11.c = L12.c = L13.c = L14.c = L15.c = L16.c = L17.c = L18.c = 'Z'; + + L4.d = L5.d = L6.d = L7.d = L8.d = L9.d = L10.d = L11.d = L12.d = L13.d = L14.d = L15.d = L16.d = L17.d = L18.d = 'Z'; + + L5.e = L6.e = L7.e = L8.e = L9.e = L10.e = L11.e = L12.e = L13.e = L14.e = L15.e = L16.e = L17.e = L18.e = 'Z'; + + L6.f = L7.f = L8.f = L9.f = L10.f = L11.f = L12.f = L13.f = L14.f = L15.f = L16.f = L17.f = L18.f = 'Z'; + + L7.g = L8.g = L9.g = L10.g = L11.g = L12.g = L13.g = L14.g = L15.g = L16.g = L17.g = L18.g = 'Z'; + + L8.h = L9.h = L10.h = L11.h = L12.h = L13.h = L14.h = L15.h = L16.h = L17.h = L18.h = 'Z'; + + L9.i = L10.i = L11.i = L12.i = L13.i = L14.i = L15.i = L16.i = L17.i = L18.i = 'Z'; + + L10.j = L11.j = L12.j = L13.j = L14.j = L15.j = L16.j = L17.j = L18.j = 'Z'; + + L11.k = L12.k = L13.k = L14.k = L15.k = L16.k = L17.k = L18.k = 'Z'; + + L12.l = L13.l = L14.l = L15.l = L16.l = L17.l = L18.l = 'Z'; + + L13.m = L14.m = L15.m = L16.m = L17.m = L18.m = 'Z'; + + L14.n = L15.n = L16.n = L17.n = L18.n = 'Z'; + + L15.o = L16.o = L17.o = L18.o = 'Z'; + + L16.p = L17.p = L18.p = 'Z'; + + L17.q = L18.q = 'Z'; + + L18.r = 'Z'; +} int main() { @@ -226,24 +406,7 @@ int main() set_debug_traps(); breakpoint(); #endif - - /* TEST C FUNCTIONS */ - L1 = fun1(); - L2 = fun2(); - L3 = fun3(); - L4 = fun4(); - L5 = fun5(); - L6 = fun6(); - L7 = fun7(); - L8 = fun8(); - L9 = fun9(); - L10 = fun10(); - L11 = fun11(); - L12 = fun12(); - L16 = fun16(); - - foo1.a = foo2.a = foo3.a = foo4.a = foo5.a = foo6.a = foo7.a = foo8.a = - foo9.a = foo10.a = foo11.a = foo12.a = foo16.a = '$'; + int i; Fun1(foo1); Fun2(foo2); @@ -257,7 +420,40 @@ int main() Fun10(foo10); Fun11(foo11); Fun12(foo12); + Fun13(foo13); + Fun14(foo14); + Fun15(foo15); Fun16(foo16); + Fun17(foo17); + Fun18(foo18); + + /* An infinite loop that first clears all the variables and then + calls each function. This "hack" is to make testing random + functions easier - "advance funN" is guaranteed to have always + been preceeded by a global variable clearing zed call. */ + + while (1) + { + zed (); + L1 = fun1(); + L2 = fun2(); + L3 = fun3(); + L4 = fun4(); + L5 = fun5(); + L6 = fun6(); + L7 = fun7(); + L8 = fun8(); + L9 = fun9(); + L10 = fun10(); + L11 = fun11(); + L12 = fun12(); + L13 = fun13(); + L14 = fun14(); + L15 = fun15(); + L16 = fun16(); + L17 = fun17(); + L18 = fun18(); + } return 0; } diff --git a/gdb/testsuite/gdb.base/structs.exp b/gdb/testsuite/gdb.base/structs.exp index ed91c86e482..4d282d2e58d 100644 --- a/gdb/testsuite/gdb.base/structs.exp +++ b/gdb/testsuite/gdb.base/structs.exp @@ -1,4 +1,6 @@ -# Copyright 1996, 1997, 1999 Free Software Foundation, Inc. +# This testcase is part of GDB, the GNU debugger. + +# Copyright 1996, 1997, 1999, 2003, 2004 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 @@ -17,8 +19,6 @@ # Please email any bugs, comments, and/or additions to this file to: # bug-gdb@prep.ai.mit.edu -# This file was written by Jeff Law. (law@cygnus.com) - if $tracelevel then { strace $tracelevel } @@ -26,142 +26,661 @@ if $tracelevel then { set prms_id 0 set bug_id 0 -set prototypes 1 +# Some targets can't call functions, so don't even bother with this +# test. + +if [target_info exists gdb,cannot_call_functions] { + setup_xfail "*-*-*" + fail "This target can not call functions" + continue +} + set testfile "structs" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -# build the first test case -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - # built the second test case since we can't use prototypes - warning "Prototypes not supported, rebuilding with -DNO_PROTOTYPES" -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DNO_PROTOTYPES}] != "" } { - gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." - } - set prototypes 0 -} +# Create and source the file that provides information about the +# compiler used to compile the test case. -# Create and source the file that provides information about the compiler -# used to compile the test case. if [get_compiler_info ${binfile}] { return -1; } +# Compile a variant of structs.c using TYPES to specify the type of +# the first N struct elements (the remaining elements take the type of +# the last TYPES field). Run the compmiled program up to "main". +# Also updates the global "testfile" to reflect the most recent build. -# Some targets can't call functions, so don't even bother with this -# test. -if [target_info exists gdb,cannot_call_functions] { - setup_xfail "*-*-*" 2416 - fail "This target can not call functions" - continue +proc start_structs_test { types } { + global testfile + global srcfile + global binfile + global objdir + global subdir + global srcdir + global gdb_prompt + + # Create the additional flags + set flags "debug" + set testfile "structs" + set n 0 + for {set n 0} {$n<[llength ${types}]} {incr n} { + set m [I2A ${n}] + set t [lindex ${types} $n] + lappend flags "additional_flags=-Dt${m}=${t}" + append testfile "-" "$t" + } + + set binfile ${objdir}/${subdir}/${testfile} + if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags}"] != "" } { + # built the second test case since we can't use prototypes + warning "Prototypes not supported, rebuilding with -DNO_PROTOTYPES" + if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags} additional_flags=-DNO_PROTOTYPES"] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." + } + } + + # Start with a fresh gdb. + gdb_exit + gdb_start + gdb_reinitialize_dir $srcdir/$subdir + gdb_load ${binfile} + + # Make certain that the output is consistent + gdb_test "set print sevenbit-strings" "" \ + "set print sevenbit-strings; ${testfile}" + gdb_test "set print address off" "" \ + "set print address off; ${testfile}" + gdb_test "set width 0" "" \ + "set width 0; ${testfile}" + + # Advance to main + if { ![runto_main] } then { + gdb_suppress_tests; + } + + # Get the debug format + get_debug_format + + # check that at the struct containing all the relevant types is correct + set foo_t "type = struct struct[llength ${types}] \{" + for {set n 0} {$n<[llength ${types}]} {incr n} { + append foo_t "\[\r\n \]+[lindex ${types} $n] [i2a $n];" + } + append foo_t "\[\r\n \]+\}" + gdb_test "ptype foo[llength ${types}]" "${foo_t}" \ + "ptype foo[llength ${types}]; ${testfile}" } +# The expected value for fun${n}, L${n} and foo${n}. First element is +# empty to make indexing easier. "foo" returns the modified value, +# "zed" returns the invalid value. -# Call FUNC with no arguments, and expect to see the regexp RESULT in -# the output. If we get back the error message "Function return value -# unknown", call that an unsupported test; on some architectures, it's -# impossible to find structs returned by value reliably. -proc call_struct_func { func result } { - global gdb_prompt - - set command "p ${func}()" - send_gdb "${command}\n" - gdb_expect { - -re "$result\[\r\n\]+$gdb_prompt $" { - pass "$command" - } - -re "Function return value unknown.\[\r\n\]+$gdb_prompt $" { - unsupported "$command" - } - -re "$gdb_prompt $" { - fail "$command" - } - timeout { - fail "$command (timeout)" - } +proc foo { n } { + return [lindex { + "{}" + "{a = 49 '1'}" + "{a = 97 'a', b = 50 '2'}" + "{a = 49 '1', b = 98 'b', c = 51 '3'}" + "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4'}" + "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5'}" + "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6'}" + "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7'}" + "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8'}" + "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9'}" + "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A'}" + "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B'}" + "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A', k = 107 'k', l = 67 'C'}" + "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B', l = 108 'l', m = 68 'D'}" + "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A', k = 107 'k', l = 67 'C', m = 109 'm', n = 69 'E'}" + "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B', l = 108 'l', m = 68 'D', n = 110 'n', o = 70 'F'}" + "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A', k = 107 'k', l = 67 'C', m = 109 'm', n = 69 'E', o = 111 'o', p = 71 'G'}" + "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B', l = 108 'l', m = 68 'D', n = 110 'n', o = 70 'F', p = 112 'p', q = 72 'H'}" + } $n] +} + +proc zed { n } { + return [lindex { + "{}" + "{a = 90 'Z'}" + "{a = 90 'Z', b = 90 'Z'}" + "{a = 90 'Z', b = 90 'Z', c = 90 'Z'}" + "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z'}" + "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z'}" + "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z'}" + "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z'}" + "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z'}" + "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z'}" + "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z'}" + "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z'}" + "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 90 'Z'}" + "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 90 'Z', m = 90 'Z'}" + "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 90 'Z', m = 90 'Z', n = 90 'Z'}" + "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 90 'Z', m = 90 'Z', n = 90 'Z', o = 90 'Z'}" + "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 90 'Z', m = 90 'Z', n = 90 'Z', o = 90 'Z', p = 90 'Z'}" + "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 90 'Z', m = 90 'Z', n = 90 'Z', o = 90 'Z', p = 90 'Z', q = 90 'Z'}" + } $n] +} + +# Given N (0..25), return the corresponding alphabetic letter in lower +# or upper case. This is ment to be i18n proof. + +proc i2a { n } { + return [string range "abcdefghijklmnopqrstuvwxyz" $n $n] +} + +proc I2A { n } { + return [string toupper [i2a $n]] +} + + +# Use the file name, compiler and tuples to set up any needed KFAILs. + +proc setup_kfails { file tuples bug } { + global testfile + if [string match $file $testfile] { + foreach f $tuples { setup_kfail $f $bug } + } +} + +proc setup_compiler_kfails { file compiler format tuples bug } { + global testfile + if {[string match $file $testfile] && [test_compiler_info $compiler] && [test_debug_format $format]} { + foreach f $tuples { setup_kfail $f $bug } } } -# FIXME: Before calling this proc, we should probably verify that -# we can call inferior functions and get a valid integral value -# returned. -# Note that it is OK to check for 0 or 1 as the returned values, because C -# specifies that the numeric value of a relational or logical expression -# (computed in the inferior) is 1 for true and 0 for false. +# Test GDB's ability to make inferior function calls to functions +# returning (or passing in a single structs. -proc do_function_calls {} { - global prototypes - global gcc_compiled +# N identifies the number of elements in the struct that will be used +# for the test case. FAILS is a list of target tuples that will fail +# this test. + +# start_structs_test() will have previously built a program with a +# specified combination of types for those elements. To ensure +# robustness of the output, "p/c" is used. + +# This tests the code paths "which return-value convention?" and +# "extract return-value from registers" called by "infcall.c". + +proc test_struct_calls { n } { + global testfile global gdb_prompt - # First, call the "fun" functions and examine the value they return. - call_struct_func "fun1" " = {a = 49 '1'}" - call_struct_func "fun2" " = {a = 97 'a', b = 98 'b'}" - call_struct_func "fun3" " = {a = 65 'A', b = 66 'B', c = 67 'C'}" - call_struct_func "fun4" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4'}" - call_struct_func "fun5" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e'}" - call_struct_func "fun6" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F'}" - call_struct_func "fun7" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7'}" - call_struct_func "fun8" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7', h = 56 '8'}" - call_struct_func "fun9" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e', f = 102 'f', g = 103 'g', h = 104 'h', i = 105 'i'}" - call_struct_func "fun10" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F', g = 71 'G', h = 72 'H', i = 73 'I', j = 74 'J'}" - call_struct_func "fun11" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7', h = 56 '8', i = 57 '9', j = 65 'A', k = 66 'B'}" - call_struct_func "fun12" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F', g = 71 'G', h = 72 'H', i = 73 'I', j = 74 'J', k = 75 'K', l = 76 'L'}" - call_struct_func "fun16" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e', f = 102 'f', g = 103 'g', h = 104 'h', i = 105 'i', j = 106 'j', k = 107 'k', l = 108 'l', m = 109 'm', n = 110 'n', o = 111 'o', p = 112 'p'}" - - # Now call the Fun functions to set the L* variables. This - # tests that gdb properly passes structures to functions. - gdb_test "p Fun1(foo1)" " = (void|0)" - gdb_test "p Fun2(foo2)" " = (void|0)" - gdb_test "p Fun3(foo3)" " = (void|0)" - gdb_test "p Fun4(foo4)" " = (void|0)" - gdb_test "p Fun5(foo5)" " = (void|0)" - gdb_test "p Fun6(foo6)" " = (void|0)" - gdb_test "p Fun7(foo7)" " = (void|0)" - gdb_test "p Fun8(foo8)" " = (void|0)" - gdb_test "p Fun9(foo9)" " = (void|0)" - gdb_test "p Fun10(foo10)" " = (void|0)" - gdb_test "p Fun11(foo11)" " = (void|0)" - gdb_test "p Fun12(foo12)" " = (void|0)" - gdb_test "p Fun16(foo16)" " = (void|0)" - - # Now print the L* variables and examine their values. - gdb_test "p L1" " = {a = 49 '1'}" - gdb_test "p L2" " = {a = 97 'a', b = 98 'b'}" - gdb_test "p L3" " = {a = 65 'A', b = 66 'B', c = 67 'C'}" - gdb_test "p L4" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4'}" - gdb_test "p L5" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e'}" - gdb_test "p L6" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F'}" - gdb_test "p L7" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7'}" - gdb_test "p L8" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7', h = 56 '8'}" - gdb_test "p L9" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e', f = 102 'f', g = 103 'g', h = 104 'h', i = 105 'i'}" - gdb_test "p L10" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F', g = 71 'G', h = 72 'H', i = 73 'I', j = 74 'J'}" - gdb_test "p L11" " = {a = 49 '1', b = 50 '2', c = 51 '3', d = 52 '4', e = 53 '5', f = 54 '6', g = 55 '7', h = 56 '8', i = 57 '9', j = 65 'A', k = 66 'B'}" - gdb_test "p L12" " = {a = 65 'A', b = 66 'B', c = 67 'C', d = 68 'D', e = 69 'E', f = 70 'F', g = 71 'G', h = 72 'H', i = 73 'I', j = 74 'J', k = 75 'K', l = 76 'L'}" - gdb_test "p L16" " = {a = 97 'a', b = 98 'b', c = 99 'c', d = 100 'd', e = 101 'e', f = 102 'f', g = 103 'g', h = 104 'h', i = 105 'i', j = 106 'j', k = 107 'k', l = 108 'l', m = 109 'm', n = 110 'n', o = 111 'o', p = 112 'p'}" -} -# Start with a fresh gdb. + # Check that GDB can always extract a struct-return value from an + # inferior function call. Since GDB always knows the location of an + # inferior function call's return value these should never fail + + # Implemented by calling the parameterless function "fun$N" and then + # examining the return value printed by GDB. -gdb_start -gdb_reinitialize_dir $srcdir/$subdir -gdb_load ${binfile} + set tests "call $n ${testfile}" -gdb_test "set print sevenbit-strings" "" -gdb_test "set print address off" "" -gdb_test "set width 0" "" + # Call fun${n}, checking the printed return-value. + setup_kfails structs-*tld* i*86-*-* gdb/1447 + setup_kfails structs-*tld* sparc64-*-* gdb/1447 + setup_kfails structs-*tld* sparc*-*-solaris2* gdb/1447 + setup_kfails structs-*tld* x86_64-*-* gdb/1447 + setup_compiler_kfails structs-tc-* gcc-3-3 "DWARF 2" i*86-*-* gdb/1455 + gdb_test "p/c fun${n}()" "[foo ${n}]" "p/c fun<n>(); ${tests}" -if [target_info exists gdb,cannot_call_functions] { - setup_xfail "*-*-*" 2416 - fail "This target can not call functions" - return 0 + # Check that GDB can always pass a structure to an inferior function. + # This test can never fail. + + # Implemented by calling the one parameter function "Fun$N" which + # stores its parameter in the global variable "L$N". GDB then + # examining that global to confirm that the value is as expected. + + gdb_test "call Fun${n}(foo${n})" "" "call Fun<n>(foo<n>); ${tests}" + setup_kfails structs-*tld* i*86-*-* gdb/1447 + setup_kfails structs-*tld* sparc64-*-* gdb/1447 + setup_kfails structs-*tld* sparc*-*-solaris2* gdb/1447 + setup_kfails structs-*tld* x86_64-*-* gdb/1447 + setup_compiler_kfails structs-tc-* gcc-3-3 "DWARF 2" i*86-*-* gdb/1455 + gdb_test "p/c L${n}" [foo ${n}] "p/c L<n>; ${tests}" } -if { ![runto_main] } then { - gdb_suppress_tests; +# Test GDB's ability to both return a function (with "return" or +# "finish") and correctly extract/store any corresponding +# return-value. + +# Check that GDB can consistently extract/store structure return +# values. There are two cases - returned in registers and returned in +# memory. For the latter case, the return value can't be found and a +# failure is "expected". However GDB must still both return the +# function and display the final source and line information. + +# N identifies the number of elements in the struct that will be used +# for the test case. FAILS is a list of target tuples that will fail +# this test. + +# This tests the code paths "which return-value convention?", "extract +# return-value from registers", and "store return-value in registers". +# Unlike "test struct calls", this test is expected to "fail" when the +# return-value is in memory (GDB can't find the location). The test +# is in three parts: test "return"; test "finish"; check that the two +# are consistent. GDB can sometimes work for one command and not the +# other. + +proc test_struct_returns { n } { + global gdb_prompt + global testfile + + set tests "return $n ${testfile}" + + + # Check that "return" works. + + # GDB must always force the return of a function that has + # a struct result. Dependant on the ABI, it may, or may not be + # possible to store the return value in a register. + + # The relevant code looks like "L{n} = fun{n}()". The test forces + # "fun{n}" to "return" with an explicit value. Since that code + # snippet will store the the returned value in "L{n}" the return + # is tested by examining "L{n}". This assumes that the + # compiler implemented this as fun{n}(&L{n}) and hence that when + # the value isn't stored "L{n}" remains unchanged. Also check for + # consistency between this and the "finish" case. + + # Get into a call of fun${n} + gdb_test "advance fun${n}" \ + "fun${n} .*\[\r\n\]+\[0-9\].*return foo${n}.*" \ + "advance to fun<n> for return; ${tests}" + + # Check that the program invalidated the relevant global. + setup_kfails structs-tld i*86-*-* gdb/1447 + setup_kfails structs-tld sparc64-*-* gdb/1447 + setup_kfails structs-tld sparc*-*-solaris2* gdb/1447 + setup_kfails structs-tld x86_64-*-* gdb/1447 + gdb_test "p/c L${n}" " = [zed $n]" "zed L<n> for return; ${tests}" + + # Force the "return". This checks that the return is always + # performed, and that GDB correctly reported this to the user. + # GDB 6.0 and earlier, when the return-value's location wasn't + # known, both failed to print a final "source and line" and misplaced + # the frame ("No frame"). + + # The test is writen so that it only reports one FAIL/PASS for the + # entire operation. The value returned is checked further down. + # "return_value_unknown", if non-empty, records why GDB realised + # that it didn't know where the return value was. + + set test "return foo<n>; ${tests}" + set return_value_unknown 0 + set return_value_unimplemented 0 + gdb_test_multiple "return foo${n}" "${test}" { + -re "The location" { + # Ulgh, a struct return, remember this (still need prompt). + set return_value_unknown 1 + exp_continue + } + -re "A structure or union" { + # Ulgh, a struct return, remember this (still need prompt). + set return_value_unknown 1 + # Double ulgh. Architecture doesn't use return_value and + # hence hasn't implemented small structure return. + set return_value_unimplemented 1 + exp_continue + } + -re "Make fun${n} return now.*y or n. $" { + gdb_test_multiple "y" "${test}" { + -re "L${n} *= fun${n}.*${gdb_prompt} $" { + # Need to step off the function call + gdb_test "next" "L.* *= fun.*" "${test}" + } + -re "L[expr ${n} + 1] *= fun[expr ${n} + 1].*${gdb_prompt} $" { + pass "${test}" + } + } + } + } + + # Check that the return-value is as expected. At this stage we're + # just checking that GDB has returned a value consistent with + # "return_value_unknown" set above. + + set test "value foo<n> returned; ${tests}" + setup_kfails structs-*tld* i*86-*-* gdb/1447 + setup_kfails structs-*tld* sparc64-*-* gdb/1447 + setup_kfails structs-*tld* sparc*-*-solaris2* gdb/1447 + setup_kfails structs-*tld* x86_64-*-* gdb/1447 + gdb_test_multiple "p/c L${n}" "${test}" { + -re " = [foo ${n}].*${gdb_prompt} $" { + if $return_value_unknown { + # This contradicts the above claim that GDB didn't + # know the location of the return-value. + fail "${test}" + } else { + pass "${test}" + } + } + -re " = [zed ${n}].*${gdb_prompt} $" { + if $return_value_unknown { + # The struct return case. Since any modification + # would be by reference, and that can't happen, the + # value should be unmodified and hence Z is expected. + # Is this a reasonable assumption? + pass "${test}" + } else { + # This contradicts the above claim that GDB knew + # the location of the return-value. + fail "${test}" + } + } + -re ".*${gdb_prompt} $" { + if $return_value_unimplemented { + # What a suprize. The architecture hasn't implemented + # return_value, and hence has to fail. + kfail "$test" gdb/1444 + } else { + fail "$test" + } + } + } + + # Check that a "finish" works. + + # This is almost but not quite the same as "call struct funcs". + # Architectures can have subtle differences in the two code paths. + + # The relevant code snippet is "L{n} = fun{n}()". The program is + # advanced into a call to "fun{n}" and then that function is + # finished. The returned value that GDB prints, reformatted using + # "p/c", is checked. + + # Get into "fun${n}()". + gdb_test "advance fun${n}" \ + "fun${n} .*\[\r\n\]+\[0-9\].*return foo${n}.*" \ + "advance to fun<n> for finish; ${tests}" + + # Check that the program invalidated the relevant global. + setup_kfails structs-tld i*86-*-* gdb/1447 + setup_kfails structs-tld sparc64-*-* gdb/1447 + setup_kfails structs-tld sparc*-*-solaris2* gdb/1447 + setup_kfails structs-tld x86_64-*-* gdb/1447 + gdb_test "p/c L${n}" " = [zed $n]" "zed L<n> for finish; ${tests}" + + # Finish the function, set 'finish_value_unknown" to non-empty if the + # return-value was not found. + set test "finish foo<n>; ${tests}" + set finish_value_unknown 0 + gdb_test_multiple "finish" "${test}" { + -re "Value returned is .*${gdb_prompt} $" { + pass "${test}" + } + -re "Cannot determine contents.*${gdb_prompt} $" { + # Expected bad value. For the moment this is ok. + set finish_value_unknown 1 + pass "${test}" + } + } + + # Re-print the last (return-value) using the more robust + # "p/c". If no return value was found, the 'Z' from the previous + # check that the variable was cleared, is printed. + set test "value foo<n> finished; ${tests}" + setup_kfails structs-*tld* i*86-*-* gdb/1447 + setup_kfails structs-*tld* sparc64-*-* gdb/1447 + setup_kfails structs-*tld* sparc*-*-solaris2* gdb/1447 + setup_kfails structs-*tld* x86_64-*-* gdb/1447 + gdb_test_multiple "p/c" "${test}" { + -re "[foo ${n}]\[\r\n\]+${gdb_prompt} $" { + if $finish_value_unknown { + # This contradicts the above claim that GDB didn't + # know the location of the return-value. + fail "${test}" + } else { + pass "${test}" + } + } + -re "[zed ${n}]\[\r\n\]+${gdb_prompt} $" { + # The value didn't get found. This is "expected". + if $finish_value_unknown { + pass "${test}" + } else { + # This contradicts the above claim that GDB did + # know the location of the return-value. + fail "${test}" + } + } + } + + # Finally, check that "return" and finish" have consistent + # behavior. + + # Since both "return" and "finish" use equivalent "which + # return-value convention" logic, both commands should have + # identical can/can-not find return-value messages. + + # Note that since "call" and "finish" use common code paths, a + # failure here is a strong indicator of problems with "store + # return-value" code paths. Suggest looking at "return_value" + # when investigating a fix. + + set test "return and finish use same convention; ${tests}" + if {$finish_value_unknown == $return_value_unknown} { + pass "${test}" + } else { + kfail gdb/1444 "${test}" + } } -do_function_calls; +# ABIs pass anything >8 or >16 bytes in memory but below that things +# randomly use register and/and structure conventions. Check all +# possible sized char structs in that range. But only a restricted +# range of the other types. + +# NetBSD/PPC returns "unnatural" (3, 5, 6, 7) sized structs in memory. + +# d10v is weird. 5/6 byte structs go in memory. 2 or more char +# structs go in memory. Everything else is in a register! + +# Test every single char struct from 1..17 in size. This is what the +# original "structs" test was doing. + +start_structs_test { tc } +test_struct_calls 1 +test_struct_calls 2 +test_struct_calls 3 +test_struct_calls 4 +test_struct_calls 5 +test_struct_calls 6 +test_struct_calls 7 +test_struct_calls 8 +test_struct_calls 9 +test_struct_calls 10 +test_struct_calls 11 +test_struct_calls 12 +test_struct_calls 13 +test_struct_calls 14 +test_struct_calls 15 +test_struct_calls 16 +test_struct_calls 17 +test_struct_returns 1 +test_struct_returns 2 +test_struct_returns 3 +test_struct_returns 4 +test_struct_returns 5 +test_struct_returns 6 +test_struct_returns 7 +test_struct_returns 8 + + +# Let the fun begin. + +# Assuming that any integer struct larger than 8 bytes goes in memory, +# come up with many and varied combinations of a return struct. For +# "struct calls" test just beyond that 8 byte boundary, for "struct +# returns" test up to that boundary. + +# For floats, assumed that up to two struct elements can be stored in +# floating point registers, regardless of their size. + +# The approx size of each structure it is computed assumed that tc=1, +# ts=2, ti=4, tl=4, tll=8, tf=4, td=8, tld=16, and that all fields are +# naturally aligned. Padding being added where needed. Note that +# these numbers are just approx, the d10v has ti=2, a 64-bit has has +# tl=8. + +# Approx size: 2, 4, ... +start_structs_test { ts } +test_struct_calls 1 +test_struct_calls 2 +test_struct_calls 3 +test_struct_calls 4 +test_struct_calls 5 +test_struct_returns 1 +test_struct_returns 2 +test_struct_returns 3 +test_struct_returns 4 + +# Approx size: 4, 8, ... +start_structs_test { ti } +test_struct_calls 1 +test_struct_calls 2 +test_struct_calls 3 +test_struct_returns 1 +test_struct_returns 2 + +# Approx size: 4, 8, ... +start_structs_test { tl } +test_struct_calls 1 +test_struct_calls 2 +test_struct_calls 3 +test_struct_returns 1 +test_struct_returns 2 + +# Approx size: 8, 16, ... +start_structs_test { tll } +test_struct_calls 1 +test_struct_calls 2 +test_struct_returns 1 + +# Approx size: 4, 8, ... +start_structs_test { tf } +test_struct_calls 1 +test_struct_calls 2 +test_struct_calls 3 +test_struct_returns 1 +test_struct_returns 2 + +# Approx size: 8, 16, ... +start_structs_test { td } +test_struct_calls 1 +test_struct_calls 2 +test_struct_returns 1 + +# Approx size: 16, 32, ... +start_structs_test { tld } +test_struct_calls 1 +test_struct_calls 2 +test_struct_returns 1 + +# Approx size: 2+1=3, 4, ... +start_structs_test { ts tc } +test_struct_calls 2 +test_struct_calls 3 +test_struct_calls 4 +test_struct_calls 5 +test_struct_calls 6 +test_struct_calls 7 +test_struct_calls 8 +test_struct_returns 2 + +# Approx size: 4+1=5, 6, ... +start_structs_test { ti tc } +test_struct_calls 2 +test_struct_calls 3 +test_struct_calls 4 +test_struct_calls 5 +test_struct_calls 6 +test_struct_returns 2 + +# Approx size: 4+1=5, 6, ... +start_structs_test { tl tc } +test_struct_calls 2 +test_struct_calls 3 +test_struct_calls 4 +test_struct_calls 5 +test_struct_calls 6 +test_struct_returns 2 + +# Approx size: 8+1=9, 10, ... +start_structs_test { tll tc } +test_struct_calls 2 + +# Approx size: 4+1=5, 6, ... +start_structs_test { tf tc } +test_struct_calls 2 +test_struct_calls 3 +test_struct_calls 4 +test_struct_calls 5 +test_struct_calls 6 +test_struct_returns 2 + +# Approx size: 8+1=9, 10, ... +start_structs_test { td tc } +test_struct_calls 2 + +# Approx size: 16+1=17, 18, ... +start_structs_test { tld tc } +test_struct_calls 2 + +# Approx size: (1+1)+2=4, 6, ... +start_structs_test { tc ts } +test_struct_calls 2 +test_struct_calls 3 +test_struct_calls 4 +test_struct_calls 5 +test_struct_calls 6 +test_struct_returns 2 + +# Approx size: (1+3)+4=8, 12, ... +start_structs_test { tc ti } +test_struct_calls 2 +test_struct_calls 3 +test_struct_calls 4 +test_struct_returns 2 + +# Approx size: (1+3)+4=8, 12, ... +start_structs_test { tc tl } +test_struct_calls 2 +test_struct_calls 3 +test_struct_calls 4 +test_struct_returns 2 + +# Approx size: (1+7)+8=16, 24, ... +start_structs_test { tc tll } +test_struct_calls 2 + +# Approx size: (1+3)+4=8, 12, ... +start_structs_test { tc tf } +test_struct_calls 2 +test_struct_calls 3 +test_struct_calls 4 + +# Approx size: (1+7)+8=16, 24, ... +start_structs_test { tc td } +test_struct_calls 2 + +# Approx size: (1+15)+16=32, 48, ... +start_structs_test { tc tld } +test_struct_calls 2 + +# Some float combinations + +# Approx size: 8+4=12, 16, ... +# d10v: 4+4=8, 12, ... +start_structs_test { td tf } +test_struct_calls 2 +test_struct_returns 2 -gdb_stop_suppressing_tests; +# Approx size: (4+4)+8=16, 32, ... +# d10v: 4+4=8, 12, ... +start_structs_test { tf td } +test_struct_calls 2 +test_struct_returns 2 return 0 diff --git a/gdb/testsuite/gdb.base/until.exp b/gdb/testsuite/gdb.base/until.exp index f646c6d36ae..033005db0fd 100644 --- a/gdb/testsuite/gdb.base/until.exp +++ b/gdb/testsuite/gdb.base/until.exp @@ -23,13 +23,21 @@ if $tracelevel then { strace $tracelevel } -set testfile break +set testfile "break" set srcfile ${testfile}.c +set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} -remote_exec build "rm -f ${binfile}" -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { - gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." +} + +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { + gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } gdb_exit @@ -37,6 +45,11 @@ gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} +set bp_location1 [gdb_get_line_number "set breakpoint 1 here"] +set bp_location19 [gdb_get_line_number "set breakpoint 19 here"] +set bp_location20 [gdb_get_line_number "set breakpoint 20 here"] +set bp_location21 [gdb_get_line_number "set breakpoint 21 here"] + if ![runto_main] then { fail "Can't run to main" return 0 @@ -45,8 +58,8 @@ if ![runto_main] then { # Verify that "until <location>" works. (This is really just syntactic # sugar for "tbreak <location>; continue".) # -gdb_test "until 79" \ - "main .* at .*:79.*" \ +gdb_test "until $bp_location1" \ + "main .* at .*:$bp_location1.*" \ "until line number" # Verify that a malformed "advance" is gracefully caught. @@ -62,8 +75,8 @@ delete_breakpoints # inner invocations of factorial() are completed and we are back at this # frame. # -gdb_test "until 99" \ - "factorial.*value=720.*at.*${srcfile}:99.*return \\(value\\)." \ +gdb_test "until $bp_location19" \ + "factorial.*value=720.*at.*${srcfile}:$bp_location19.*return \\(value\\).*" \ "until factorial, recursive function" # Run to a function called by main @@ -76,6 +89,6 @@ delete_breakpoints # stop at main, the caller, where we put the 'guard' breakpoint. # gdb_test "until marker3" \ - "($hex in |)main.*argc.*argv.*envp.*at.*${srcfile}:(82.*marker2 \\(43\\)|83.*marker3 \\(.stack., .trace.\\))." \ + "($hex in |)main.*argc.*argv.*envp.*at.*${srcfile}:($bp_location20.*marker2 \\(43\\)|$bp_location21.*marker3 \\(.stack., .trace.\\)).*" \ "until func, not called by current frame" diff --git a/gdb/testsuite/gdb.base/volatile.exp b/gdb/testsuite/gdb.base/volatile.exp index 704369605eb..c12e3d88eae 100644 --- a/gdb/testsuite/gdb.base/volatile.exp +++ b/gdb/testsuite/gdb.base/volatile.exp @@ -1,4 +1,4 @@ -# Copyright 1997, 1998, 1999, 2003 Free Software Foundation, Inc. +# Copyright 1997, 1998, 1999, 2003, 2004 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 @@ -55,28 +55,15 @@ if [get_compiler_info ${binfile}] { return -1; } -if {$hp_aCC_compiler || $hp_cc_compiler} { - set lang "c++" -} else { - set lang "" -} - -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [concat debug $lang]] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug ] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -remote_exec build "rm -f ${binfile}.ci" -if [get_compiler_info ${binfile}] { - return -1 -} - gdb_exit gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} -source ${binfile}.ci - # # set it up at a breakpoint so we can play with the variable values # @@ -88,14 +75,17 @@ if ![runto_main] then { get_debug_format proc local_compiler_xfail_check { } { - global gcc_compiled; - - if {$gcc_compiled == 2} then { + if { [test_compiler_info gcc-2-*] } then { if { ![test_debug_format "HP"] \ && ![test_debug_format "DWARF 2"] } then { setup_xfail "*-*-*" } } + + global hp_cc_compiler + if { $hp_cc_compiler } { + setup_xfail "hppa*-*-hpux*" + } } send_gdb "break marker1\n" ; gdb_expect -re ".*$gdb_prompt $" @@ -258,7 +248,7 @@ gdb_test "ptype vendor" "type = const volatile unsigned char \\* const volatile. # test function parameters local_compiler_xfail_check -if {$gcc_compiled == 3 && [test_debug_format "stabs"]} then { +if { [test_compiler_info gcc-3-*] && [test_debug_format "stabs"] } then { # For reasons unknown, GCC 3 with stabs mangles several cv-qualified # arguments to this function. setup_xfail "*-*-*" diff --git a/gdb/testsuite/gdb.base/watchpoint.exp b/gdb/testsuite/gdb.base/watchpoint.exp index fd5d8f286b2..a69271b0aff 100644 --- a/gdb/testsuite/gdb.base/watchpoint.exp +++ b/gdb/testsuite/gdb.base/watchpoint.exp @@ -374,32 +374,8 @@ proc test_stepping {} { gdb_test "break func2 if 0" "Breakpoint.*at.*" gdb_test "p \$func2_breakpoint_number = \$bpnum" " = .*" - # The problem is that GDB confuses stepping through the call - # dummy with hitting the breakpoint at the end of the call dummy. - # Will be fixed once all architectures define - # DEPRECATED_CALL_DUMMY_BREAKPOINT_OFFSET. - setup_xfail "*-*-*" - # This doesn't occur if the call dummy starts with a call, - # because we are out of the dummy by the first time the inferior - # stops. - clear_xfail "arm*-*-*" - clear_xfail "xscale*-*-*" - clear_xfail "d10v*-*-*" - clear_xfail "m68*-*-*" - clear_xfail "i*86*-*-*" - clear_xfail "vax-*-*" - # The following architectures define DEPRECATED_CALL_DUMMY_BREAKPOINT_OFFSET. - clear_xfail "alpha-*-*" - clear_xfail "mips*-*-*" - clear_xfail "sparc-*-*" - clear_xfail "hppa*-*-*bsd*" - # It works with the generic inferior function calling code too. - # OBSOLETE clear_xfail "mn10200*-*-*" - clear_xfail "mn10300*-*-*" - # The following architectures define CALL_DUMMY_HAS_COMPLETED. - clear_xfail "hppa*-*-*hpux*" gdb_test "p func1 ()" "= 73" \ - "calling function with watchpoint enabled" + "calling function with watchpoint enabled" # # "finish" brings us back to main. |