|
|
861f93 |
Index: gdb-7.5.91.20130323/gdb/testsuite/configure.ac
|
|
|
861f93 |
===================================================================
|
|
|
861f93 |
--- gdb-7.5.91.20130323.orig/gdb/testsuite/configure.ac 2013-03-11 09:59:00.000000000 +0100
|
|
|
861f93 |
+++ gdb-7.5.91.20130323/gdb/testsuite/configure.ac 2013-03-23 19:47:24.189683555 +0100
|
|
|
861f93 |
@@ -96,6 +96,6 @@ AC_OUTPUT([Makefile \
|
|
|
861f93 |
gdb.hp/gdb.aCC/Makefile gdb.hp/gdb.compat/Makefile \
|
|
|
861f93 |
gdb.hp/gdb.defects/Makefile gdb.linespec/Makefile \
|
|
|
861f93 |
gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile \
|
|
|
861f93 |
- gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile \
|
|
|
861f93 |
+ gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.pie/Makefile \
|
|
|
861f93 |
gdb.python/Makefile gdb.reverse/Makefile gdb.stabs/Makefile \
|
|
|
861f93 |
gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile])
|
|
|
861f93 |
Index: gdb-7.5.91.20130323/gdb/testsuite/configure
|
|
|
861f93 |
===================================================================
|
|
|
861f93 |
--- gdb-7.5.91.20130323.orig/gdb/testsuite/configure 2013-03-11 09:59:00.000000000 +0100
|
|
|
861f93 |
+++ gdb-7.5.91.20130323/gdb/testsuite/configure 2013-03-23 19:47:47.256822312 +0100
|
|
|
861f93 |
@@ -3448,7 +3448,7 @@ done
|
|
|
861f93 |
|
|
|
861f93 |
|
|
|
861f93 |
|
|
|
861f93 |
-ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.btrace/Makefile gdb.cell/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.go/Makefile gdb.server/Makefile gdb.java/Makefile gdb.hp/Makefile gdb.hp/gdb.objdbg/Makefile gdb.hp/gdb.base-hp/Makefile gdb.hp/gdb.aCC/Makefile gdb.hp/gdb.compat/Makefile gdb.hp/gdb.defects/Makefile gdb.linespec/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.stabs/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile"
|
|
|
861f93 |
+ac_config_files="$ac_config_files Makefile gdb.ada/Makefile gdb.arch/Makefile gdb.asm/Makefile gdb.base/Makefile gdb.btrace/Makefile gdb.cell/Makefile gdb.cp/Makefile gdb.disasm/Makefile gdb.dwarf2/Makefile gdb.fortran/Makefile gdb.go/Makefile gdb.server/Makefile gdb.java/Makefile gdb.hp/Makefile gdb.hp/gdb.objdbg/Makefile gdb.hp/gdb.base-hp/Makefile gdb.hp/gdb.aCC/Makefile gdb.hp/gdb.compat/Makefile gdb.hp/gdb.defects/Makefile gdb.linespec/Makefile gdb.mi/Makefile gdb.modula2/Makefile gdb.multi/Makefile gdb.objc/Makefile gdb.opencl/Makefile gdb.opt/Makefile gdb.pascal/Makefile gdb.pie/Makefile gdb.python/Makefile gdb.reverse/Makefile gdb.stabs/Makefile gdb.threads/Makefile gdb.trace/Makefile gdb.xml/Makefile"
|
|
|
861f93 |
|
|
|
861f93 |
cat >confcache <<\_ACEOF
|
|
|
861f93 |
# This file is a shell script that caches the results of configure
|
|
|
861f93 |
@@ -4176,6 +4176,7 @@ do
|
|
|
861f93 |
"gdb.opencl/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.opencl/Makefile" ;;
|
|
|
861f93 |
"gdb.opt/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.opt/Makefile" ;;
|
|
|
861f93 |
"gdb.pascal/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.pascal/Makefile" ;;
|
|
|
861f93 |
+ "gdb.pie/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.pie/Makefile" ;;
|
|
|
861f93 |
"gdb.python/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.python/Makefile" ;;
|
|
|
861f93 |
"gdb.reverse/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.reverse/Makefile" ;;
|
|
|
861f93 |
"gdb.stabs/Makefile") CONFIG_FILES="$CONFIG_FILES gdb.stabs/Makefile" ;;
|
|
|
861f93 |
Index: gdb-7.5.91.20130323/gdb/testsuite/gdb.pie/attach.c
|
|
|
861f93 |
===================================================================
|
|
|
861f93 |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
861f93 |
+++ gdb-7.5.91.20130323/gdb/testsuite/gdb.pie/attach.c 2013-03-23 19:47:24.191683466 +0100
|
|
|
861f93 |
@@ -0,0 +1,20 @@
|
|
|
861f93 |
+/* This program is intended to be started outside of gdb, and then
|
|
|
861f93 |
+ attached to by gdb. Thus, it simply spins in a loop. The loop
|
|
|
861f93 |
+ is exited when & if the variable 'should_exit' is non-zero. (It
|
|
|
861f93 |
+ is initialized to zero in this program, so the loop will never
|
|
|
861f93 |
+ exit unless/until gdb sets the variable to non-zero.)
|
|
|
861f93 |
+ */
|
|
|
861f93 |
+#include <stdio.h>
|
|
|
861f93 |
+
|
|
|
861f93 |
+int should_exit = 0;
|
|
|
861f93 |
+
|
|
|
861f93 |
+int main ()
|
|
|
861f93 |
+{
|
|
|
861f93 |
+ int local_i = 0;
|
|
|
861f93 |
+
|
|
|
861f93 |
+ while (! should_exit)
|
|
|
861f93 |
+ {
|
|
|
861f93 |
+ local_i++;
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ return 0;
|
|
|
861f93 |
+}
|
|
|
861f93 |
Index: gdb-7.5.91.20130323/gdb/testsuite/gdb.pie/attach2.c
|
|
|
861f93 |
===================================================================
|
|
|
861f93 |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
861f93 |
+++ gdb-7.5.91.20130323/gdb/testsuite/gdb.pie/attach2.c 2013-03-23 19:47:24.192683421 +0100
|
|
|
861f93 |
@@ -0,0 +1,24 @@
|
|
|
861f93 |
+/* This program is intended to be started outside of gdb, and then
|
|
|
861f93 |
+ attached to by gdb. Thus, it simply spins in a loop. The loop
|
|
|
861f93 |
+ is exited when & if the variable 'should_exit' is non-zero. (It
|
|
|
861f93 |
+ is initialized to zero in this program, so the loop will never
|
|
|
861f93 |
+ exit unless/until gdb sets the variable to non-zero.)
|
|
|
861f93 |
+ */
|
|
|
861f93 |
+#include <stdio.h>
|
|
|
861f93 |
+#include <stdlib.h>
|
|
|
861f93 |
+#include <unistd.h>
|
|
|
861f93 |
+
|
|
|
861f93 |
+int should_exit = 0;
|
|
|
861f93 |
+
|
|
|
861f93 |
+int main ()
|
|
|
861f93 |
+{
|
|
|
861f93 |
+ int local_i = 0;
|
|
|
861f93 |
+
|
|
|
861f93 |
+ sleep( 10 ); /* System call causes register fetch to fail */
|
|
|
861f93 |
+ /* This is a known HPUX "feature" */
|
|
|
861f93 |
+ while (! should_exit)
|
|
|
861f93 |
+ {
|
|
|
861f93 |
+ local_i++;
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ return (0);
|
|
|
861f93 |
+}
|
|
|
861f93 |
Index: gdb-7.5.91.20130323/gdb/testsuite/gdb.pie/break.c
|
|
|
861f93 |
===================================================================
|
|
|
861f93 |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
861f93 |
+++ gdb-7.5.91.20130323/gdb/testsuite/gdb.pie/break.c 2013-03-23 19:47:24.192683421 +0100
|
|
|
861f93 |
@@ -0,0 +1,146 @@
|
|
|
861f93 |
+/* This testcase is part of GDB, the GNU debugger.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003 Free Software
|
|
|
861f93 |
+ Foundation, Inc.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ This program is free software; you can redistribute it and/or modify
|
|
|
861f93 |
+ it under the terms of the GNU General Public License as published by
|
|
|
861f93 |
+ the Free Software Foundation; either version 2 of the License, or
|
|
|
861f93 |
+ (at your option) any later version.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ This program is distributed in the hope that it will be useful,
|
|
|
861f93 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
861f93 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
861f93 |
+ GNU General Public License for more details.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ You should have received a copy of the GNU General Public License
|
|
|
861f93 |
+ along with this program; if not, write to the Free Software
|
|
|
861f93 |
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ Please email any bugs, comments, and/or additions to this file to:
|
|
|
861f93 |
+ bug-gdb@prep.ai.mit.edu */
|
|
|
861f93 |
+
|
|
|
861f93 |
+#ifdef vxworks
|
|
|
861f93 |
+
|
|
|
861f93 |
+# include <stdio.h>
|
|
|
861f93 |
+
|
|
|
861f93 |
+/* VxWorks does not supply atoi. */
|
|
|
861f93 |
+static int
|
|
|
861f93 |
+atoi (z)
|
|
|
861f93 |
+ char *z;
|
|
|
861f93 |
+{
|
|
|
861f93 |
+ int i = 0;
|
|
|
861f93 |
+
|
|
|
861f93 |
+ while (*z >= '0' && *z <= '9')
|
|
|
861f93 |
+ i = i * 10 + (*z++ - '0');
|
|
|
861f93 |
+ return i;
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+/* I don't know of any way to pass an array to VxWorks. This function
|
|
|
861f93 |
+ can be called directly from gdb. */
|
|
|
861f93 |
+
|
|
|
861f93 |
+vxmain (arg)
|
|
|
861f93 |
+char *arg;
|
|
|
861f93 |
+{
|
|
|
861f93 |
+ char *argv[2];
|
|
|
861f93 |
+
|
|
|
861f93 |
+ argv[0] = "";
|
|
|
861f93 |
+ argv[1] = arg;
|
|
|
861f93 |
+ main (2, argv, (char **) 0);
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+#else /* ! vxworks */
|
|
|
861f93 |
+# include <stdio.h>
|
|
|
861f93 |
+# include <stdlib.h>
|
|
|
861f93 |
+#endif /* ! vxworks */
|
|
|
861f93 |
+
|
|
|
861f93 |
+#ifdef PROTOTYPES
|
|
|
861f93 |
+extern int marker1 (void);
|
|
|
861f93 |
+extern int marker2 (int a);
|
|
|
861f93 |
+extern void marker3 (char *a, char *b);
|
|
|
861f93 |
+extern void marker4 (long d);
|
|
|
861f93 |
+#else
|
|
|
861f93 |
+extern int marker1 ();
|
|
|
861f93 |
+extern int marker2 ();
|
|
|
861f93 |
+extern void marker3 ();
|
|
|
861f93 |
+extern void marker4 ();
|
|
|
861f93 |
+#endif
|
|
|
861f93 |
+
|
|
|
861f93 |
+/*
|
|
|
861f93 |
+ * This simple classical example of recursion is useful for
|
|
|
861f93 |
+ * testing stack backtraces and such.
|
|
|
861f93 |
+ */
|
|
|
861f93 |
+
|
|
|
861f93 |
+#ifdef PROTOTYPES
|
|
|
861f93 |
+int factorial(int);
|
|
|
861f93 |
+
|
|
|
861f93 |
+int
|
|
|
861f93 |
+main (int argc, char **argv, char **envp)
|
|
|
861f93 |
+#else
|
|
|
861f93 |
+int
|
|
|
861f93 |
+main (argc, argv, envp)
|
|
|
861f93 |
+int argc;
|
|
|
861f93 |
+char *argv[], **envp;
|
|
|
861f93 |
+#endif
|
|
|
861f93 |
+{
|
|
|
861f93 |
+#ifdef usestubs
|
|
|
861f93 |
+ set_debug_traps(); /* set breakpoint 5 here */
|
|
|
861f93 |
+ breakpoint();
|
|
|
861f93 |
+#endif
|
|
|
861f93 |
+ if (argc == 12345) { /* an unlikely value < 2^16, in case uninited */ /* set breakpoint 6 here */
|
|
|
861f93 |
+ fprintf (stderr, "usage: factorial <number>\n");
|
|
|
861f93 |
+ return 1;
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ printf ("%d\n", factorial (atoi ("6"))); /* set breakpoint 1 here */
|
|
|
861f93 |
+ /* set breakpoint 12 here */
|
|
|
861f93 |
+ marker1 (); /* set breakpoint 11 here */
|
|
|
861f93 |
+ marker2 (43); /* set breakpoint 20 here */
|
|
|
861f93 |
+ marker3 ("stack", "trace"); /* set breakpoint 21 here */
|
|
|
861f93 |
+ marker4 (177601976L);
|
|
|
861f93 |
+ argc = (argc == 12345); /* This is silly, but we can step off of it */ /* set breakpoint 2 here */
|
|
|
861f93 |
+ return argc; /* set breakpoint 10 here */
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+#ifdef PROTOTYPES
|
|
|
861f93 |
+int factorial (int value)
|
|
|
861f93 |
+#else
|
|
|
861f93 |
+int factorial (value)
|
|
|
861f93 |
+int value;
|
|
|
861f93 |
+#endif
|
|
|
861f93 |
+{
|
|
|
861f93 |
+ if (value > 1) { /* set breakpoint 7 here */
|
|
|
861f93 |
+ value *= factorial (value - 1);
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ return (value); /* set breakpoint 19 here */
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+#ifdef PROTOTYPES
|
|
|
861f93 |
+int multi_line_if_conditional (int a, int b, int c)
|
|
|
861f93 |
+#else
|
|
|
861f93 |
+int multi_line_if_conditional (a, b, c)
|
|
|
861f93 |
+ int a, b, c;
|
|
|
861f93 |
+#endif
|
|
|
861f93 |
+{
|
|
|
861f93 |
+ if (a /* set breakpoint 3 here */
|
|
|
861f93 |
+ && b
|
|
|
861f93 |
+ && c)
|
|
|
861f93 |
+ return 0;
|
|
|
861f93 |
+ else
|
|
|
861f93 |
+ return 1;
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+#ifdef PROTOTYPES
|
|
|
861f93 |
+int multi_line_while_conditional (int a, int b, int c)
|
|
|
861f93 |
+#else
|
|
|
861f93 |
+int multi_line_while_conditional (a, b, c)
|
|
|
861f93 |
+ int a, b, c;
|
|
|
861f93 |
+#endif
|
|
|
861f93 |
+{
|
|
|
861f93 |
+ while (a /* set breakpoint 4 here */
|
|
|
861f93 |
+ && b
|
|
|
861f93 |
+ && c)
|
|
|
861f93 |
+ {
|
|
|
861f93 |
+ a--, b--, c--;
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ return 0;
|
|
|
861f93 |
+}
|
|
|
861f93 |
Index: gdb-7.5.91.20130323/gdb/testsuite/gdb.pie/break1.c
|
|
|
861f93 |
===================================================================
|
|
|
861f93 |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
861f93 |
+++ gdb-7.5.91.20130323/gdb/testsuite/gdb.pie/break1.c 2013-03-23 19:47:24.192683421 +0100
|
|
|
861f93 |
@@ -0,0 +1,44 @@
|
|
|
861f93 |
+/* This testcase is part of GDB, the GNU debugger.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ Copyright 1992, 1993, 1994, 1995, 1999, 2002, 2003 Free Software
|
|
|
861f93 |
+ Foundation, Inc.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ This program is free software; you can redistribute it and/or modify
|
|
|
861f93 |
+ it under the terms of the GNU General Public License as published by
|
|
|
861f93 |
+ the Free Software Foundation; either version 2 of the License, or
|
|
|
861f93 |
+ (at your option) any later version.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ This program is distributed in the hope that it will be useful,
|
|
|
861f93 |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
861f93 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
861f93 |
+ GNU General Public License for more details.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ You should have received a copy of the GNU General Public License
|
|
|
861f93 |
+ along with this program; if not, write to the Free Software
|
|
|
861f93 |
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ Please email any bugs, comments, and/or additions to this file to:
|
|
|
861f93 |
+ bug-gdb@prep.ai.mit.edu */
|
|
|
861f93 |
+
|
|
|
861f93 |
+/* The code for this file was extracted from the gdb testsuite
|
|
|
861f93 |
+ testcase "break.c". */
|
|
|
861f93 |
+
|
|
|
861f93 |
+/* The following functions do nothing useful. They are included
|
|
|
861f93 |
+ simply as places to try setting breakpoints at. They are
|
|
|
861f93 |
+ explicitly "one-line functions" to verify that this case works
|
|
|
861f93 |
+ (some versions of gcc have or have had problems with this).
|
|
|
861f93 |
+
|
|
|
861f93 |
+ These functions are in a separate source file to prevent an
|
|
|
861f93 |
+ optimizing compiler from inlining them and optimizing them away. */
|
|
|
861f93 |
+
|
|
|
861f93 |
+#ifdef PROTOTYPES
|
|
|
861f93 |
+int marker1 (void) { return (0); } /* set breakpoint 15 here */
|
|
|
861f93 |
+int marker2 (int a) { return (1); } /* set breakpoint 8 here */
|
|
|
861f93 |
+void marker3 (char *a, char *b) {} /* set breakpoint 17 here */
|
|
|
861f93 |
+void marker4 (long d) {} /* set breakpoint 14 here */
|
|
|
861f93 |
+#else
|
|
|
861f93 |
+int marker1 () { return (0); } /* set breakpoint 16 here */
|
|
|
861f93 |
+int marker2 (a) int a; { return (1); } /* set breakpoint 9 here */
|
|
|
861f93 |
+void marker3 (a, b) char *a, *b; {} /* set breakpoint 18 here */
|
|
|
861f93 |
+void marker4 (d) long d; {} /* set breakpoint 13 here */
|
|
|
861f93 |
+#endif
|
|
|
861f93 |
Index: gdb-7.5.91.20130323/gdb/testsuite/gdb.pie/coremaker.c
|
|
|
861f93 |
===================================================================
|
|
|
861f93 |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
861f93 |
+++ gdb-7.5.91.20130323/gdb/testsuite/gdb.pie/coremaker.c 2013-03-23 19:47:24.192683421 +0100
|
|
|
861f93 |
@@ -0,0 +1,142 @@
|
|
|
861f93 |
+/* Copyright 1992, 1993, 1994, 1995, 1996, 1999
|
|
|
861f93 |
+ Free Software Foundation, Inc.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ This file is part of GDB.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ This program is free software; you can redistribute it and/or modify
|
|
|
861f93 |
+ it under the terms of the GNU General Public License as published by
|
|
|
861f93 |
+ the Free Software Foundation; either version 2 of the License, or (at
|
|
|
861f93 |
+ your option) any later version.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ This program is distributed in the hope that it will be useful, but
|
|
|
861f93 |
+ WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
861f93 |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
861f93 |
+ General Public License for more details.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ You should have received a copy of the GNU General Public License
|
|
|
861f93 |
+ along with this program; if not, write to the Free Software
|
|
|
861f93 |
+ Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
861f93 |
+ Boston, MA 02111-1307, USA. */
|
|
|
861f93 |
+
|
|
|
861f93 |
+/* Simple little program that just generates a core dump from inside some
|
|
|
861f93 |
+ nested function calls. */
|
|
|
861f93 |
+
|
|
|
861f93 |
+#include <stdio.h>
|
|
|
861f93 |
+#include <sys/types.h>
|
|
|
861f93 |
+#include <fcntl.h>
|
|
|
861f93 |
+#include <sys/mman.h>
|
|
|
861f93 |
+#include <signal.h>
|
|
|
861f93 |
+#include <stdlib.h>
|
|
|
861f93 |
+#include <unistd.h>
|
|
|
861f93 |
+
|
|
|
861f93 |
+#ifndef __STDC__
|
|
|
861f93 |
+#define const /**/
|
|
|
861f93 |
+#endif
|
|
|
861f93 |
+
|
|
|
861f93 |
+#define MAPSIZE (8 * 1024)
|
|
|
861f93 |
+
|
|
|
861f93 |
+/* Don't make these automatic vars or we will have to walk back up the
|
|
|
861f93 |
+ stack to access them. */
|
|
|
861f93 |
+
|
|
|
861f93 |
+char *buf1;
|
|
|
861f93 |
+char *buf2;
|
|
|
861f93 |
+
|
|
|
861f93 |
+int coremaker_data = 1; /* In Data section */
|
|
|
861f93 |
+int coremaker_bss; /* In BSS section */
|
|
|
861f93 |
+
|
|
|
861f93 |
+const int coremaker_ro = 201; /* In Read-Only Data section */
|
|
|
861f93 |
+
|
|
|
861f93 |
+/* Note that if the mapping fails for any reason, we set buf2
|
|
|
861f93 |
+ to -1 and the testsuite notices this and reports it as
|
|
|
861f93 |
+ a failure due to a mapping error. This way we don't have
|
|
|
861f93 |
+ to test for specific errors when running the core maker. */
|
|
|
861f93 |
+
|
|
|
861f93 |
+void
|
|
|
861f93 |
+mmapdata ()
|
|
|
861f93 |
+{
|
|
|
861f93 |
+ int j, fd;
|
|
|
861f93 |
+
|
|
|
861f93 |
+ /* Allocate and initialize a buffer that will be used to write
|
|
|
861f93 |
+ the file that is later mapped in. */
|
|
|
861f93 |
+
|
|
|
861f93 |
+ buf1 = (char *) malloc (MAPSIZE);
|
|
|
861f93 |
+ for (j = 0; j < MAPSIZE; ++j)
|
|
|
861f93 |
+ {
|
|
|
861f93 |
+ buf1[j] = j;
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ /* Write the file to map in */
|
|
|
861f93 |
+
|
|
|
861f93 |
+ fd = open ("coremmap.data", O_CREAT | O_RDWR, 0666);
|
|
|
861f93 |
+ if (fd == -1)
|
|
|
861f93 |
+ {
|
|
|
861f93 |
+ perror ("coremmap.data open failed");
|
|
|
861f93 |
+ buf2 = (char *) -1;
|
|
|
861f93 |
+ return;
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ write (fd, buf1, MAPSIZE);
|
|
|
861f93 |
+
|
|
|
861f93 |
+ /* Now map the file into our address space as buf2 */
|
|
|
861f93 |
+
|
|
|
861f93 |
+ buf2 = (char *) mmap (0, MAPSIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
|
|
|
861f93 |
+ if (buf2 == (char *) -1)
|
|
|
861f93 |
+ {
|
|
|
861f93 |
+ perror ("mmap failed");
|
|
|
861f93 |
+ return;
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ /* Verify that the original data and the mapped data are identical.
|
|
|
861f93 |
+ If not, we'd rather fail now than when trying to access the mapped
|
|
|
861f93 |
+ data from the core file. */
|
|
|
861f93 |
+
|
|
|
861f93 |
+ for (j = 0; j < MAPSIZE; ++j)
|
|
|
861f93 |
+ {
|
|
|
861f93 |
+ if (buf1[j] != buf2[j])
|
|
|
861f93 |
+ {
|
|
|
861f93 |
+ fprintf (stderr, "mapped data is incorrect");
|
|
|
861f93 |
+ buf2 = (char *) -1;
|
|
|
861f93 |
+ return;
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+void
|
|
|
861f93 |
+func2 ()
|
|
|
861f93 |
+{
|
|
|
861f93 |
+ int coremaker_local[5];
|
|
|
861f93 |
+ int i;
|
|
|
861f93 |
+
|
|
|
861f93 |
+#ifdef SA_FULLDUMP
|
|
|
861f93 |
+ /* Force a corefile that includes the data section for AIX. */
|
|
|
861f93 |
+ {
|
|
|
861f93 |
+ struct sigaction sa;
|
|
|
861f93 |
+
|
|
|
861f93 |
+ sigaction (SIGABRT, (struct sigaction *)0, &sa);
|
|
|
861f93 |
+ sa.sa_flags |= SA_FULLDUMP;
|
|
|
861f93 |
+ sigaction (SIGABRT, &sa, (struct sigaction *)0);
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+#endif
|
|
|
861f93 |
+
|
|
|
861f93 |
+ /* Make sure that coremaker_local doesn't get optimized away. */
|
|
|
861f93 |
+ for (i = 0; i < 5; i++)
|
|
|
861f93 |
+ coremaker_local[i] = i;
|
|
|
861f93 |
+ coremaker_bss = 0;
|
|
|
861f93 |
+ for (i = 0; i < 5; i++)
|
|
|
861f93 |
+ coremaker_bss += coremaker_local[i];
|
|
|
861f93 |
+ coremaker_data = coremaker_ro + 1;
|
|
|
861f93 |
+ abort ();
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+void
|
|
|
861f93 |
+func1 ()
|
|
|
861f93 |
+{
|
|
|
861f93 |
+ func2 ();
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+int main ()
|
|
|
861f93 |
+{
|
|
|
861f93 |
+ mmapdata ();
|
|
|
861f93 |
+ func1 ();
|
|
|
861f93 |
+ return 0;
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
Index: gdb-7.5.91.20130323/gdb/testsuite/gdb.pie/attach.exp
|
|
|
861f93 |
===================================================================
|
|
|
861f93 |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
861f93 |
+++ gdb-7.5.91.20130323/gdb/testsuite/gdb.pie/attach.exp 2013-03-23 19:47:24.193683377 +0100
|
|
|
861f93 |
@@ -0,0 +1,417 @@
|
|
|
861f93 |
+# Copyright 1997, 1999, 2002 Free Software Foundation, Inc.
|
|
|
861f93 |
+
|
|
|
861f93 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
861f93 |
+# it under the terms of the GNU General Public License as published by
|
|
|
861f93 |
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
861f93 |
+# (at your option) any later version.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# This program is distributed in the hope that it will be useful,
|
|
|
861f93 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
861f93 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
861f93 |
+# GNU General Public License for more details.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# You should have received a copy of the GNU General Public License
|
|
|
861f93 |
+# along with this program; if not, write to the Free Software
|
|
|
861f93 |
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|
|
861f93 |
+
|
|
|
861f93 |
+# On HP-UX 11.0, this test is causing a process running the program
|
|
|
861f93 |
+# "attach" to be left around spinning. Until we figure out why, I am
|
|
|
861f93 |
+# commenting out the test to avoid polluting tiamat (our 11.0 nightly
|
|
|
861f93 |
+# test machine) with these processes. RT
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# Setting the magic bit in the target app should work. I added a
|
|
|
861f93 |
+# "kill", and also a test for the R3 register warning. JB
|
|
|
861f93 |
+if { [istarget "hppa*-*-hpux*"] } {
|
|
|
861f93 |
+ return 0
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# are we on a target board
|
|
|
861f93 |
+if [is_remote target] then {
|
|
|
861f93 |
+ return 0
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+set testfile "attach"
|
|
|
861f93 |
+set srcfile ${testfile}.c
|
|
|
861f93 |
+set srcfile2 ${testfile}2.c
|
|
|
861f93 |
+set binfile ${objdir}/${subdir}/${testfile}
|
|
|
861f93 |
+set binfile2 ${objdir}/${subdir}/${testfile}2
|
|
|
861f93 |
+set escapedbinfile [string_to_regexp ${objdir}/${subdir}/${testfile}]
|
|
|
861f93 |
+set cleanupfile ${objdir}/${subdir}/${testfile}.awk
|
|
|
861f93 |
+
|
|
|
861f93 |
+#execute_anywhere "rm -f ${binfile} ${binfile2}"
|
|
|
861f93 |
+remote_exec build "rm -f ${binfile} ${binfile2}"
|
|
|
861f93 |
+# For debugging this test
|
|
|
861f93 |
+#
|
|
|
861f93 |
+#log_user 1
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Clean out any old files from past runs.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+remote_exec build "${cleanupfile}"
|
|
|
861f93 |
+
|
|
|
861f93 |
+# build the first test case
|
|
|
861f93 |
+#
|
|
|
861f93 |
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags= -fpie -pie"}] != "" } {
|
|
|
861f93 |
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Build the in-system-call test
|
|
|
861f93 |
+
|
|
|
861f93 |
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug "additional_flags= -fpie -pie"}] != "" } {
|
|
|
861f93 |
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+if [get_compiler_info ${binfile}] {
|
|
|
861f93 |
+ return -1
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+proc do_attach_tests {} {
|
|
|
861f93 |
+ global gdb_prompt
|
|
|
861f93 |
+ global binfile
|
|
|
861f93 |
+ global escapedbinfile
|
|
|
861f93 |
+ global srcfile
|
|
|
861f93 |
+ global testfile
|
|
|
861f93 |
+ global objdir
|
|
|
861f93 |
+ global subdir
|
|
|
861f93 |
+ global timeout
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Start the program running and then wait for a bit, to be sure
|
|
|
861f93 |
+ # that it can be attached to.
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ set testpid [eval exec $binfile &]
|
|
|
861f93 |
+ exec sleep 2
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Verify that we cannot attach to nonsense.
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ send_gdb "attach abc\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re ".*Illegal process-id: abc.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "attach to nonsense is prohibited"}
|
|
|
861f93 |
+ -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $"\
|
|
|
861f93 |
+ {
|
|
|
861f93 |
+ # Response expected from /proc-based systems.
|
|
|
861f93 |
+ pass "attach to nonsense is prohibited"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "Attaching to.*$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "attach to nonsense is prohibited (bogus pid allowed)"}
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "attach to nonsense is prohibited"}
|
|
|
861f93 |
+ timeout {fail "(timeout) attach to nonsense is prohibited"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Verify that we cannot attach to what appears to be a valid
|
|
|
861f93 |
+ # process ID, but is a process that doesn't exist. Traditionally,
|
|
|
861f93 |
+ # most systems didn't have a process with ID 0, so we take that as
|
|
|
861f93 |
+ # the default. However, there are a few exceptions.
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ set boguspid 0
|
|
|
861f93 |
+ if { [istarget "*-*-*bsd*"] } {
|
|
|
861f93 |
+ # In FreeBSD 5.0, PID 0 is used for "swapper". Use -1 instead
|
|
|
861f93 |
+ # (which should have the desired effect on any version of
|
|
|
861f93 |
+ # FreeBSD, and probably other *BSD's too).
|
|
|
861f93 |
+ set boguspid -1
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ send_gdb "attach $boguspid\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "Attaching to.*, process $boguspid.*No such process.*$gdb_prompt $"\
|
|
|
861f93 |
+ {
|
|
|
861f93 |
+ # Response expected on ptrace-based systems (i.e. HP-UX 10.20).
|
|
|
861f93 |
+ pass "attach to nonexistent process is prohibited"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "Attaching to.*, process $boguspid failed.*Hint.*$gdb_prompt $"\
|
|
|
861f93 |
+ {
|
|
|
861f93 |
+ # Response expected on ttrace-based systems (i.e. HP-UX 11.0).
|
|
|
861f93 |
+ pass "attach to nonexistent process is prohibited"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "Attaching to.*, process $boguspid.*denied.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "attach to nonexistent process is prohibited"}
|
|
|
861f93 |
+ -re "Attaching to.*, process $boguspid.*not permitted.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "attach to nonexistent process is prohibited"}
|
|
|
861f93 |
+ -re "Attaching to.*, process .*couldn't open /proc file.*$gdb_prompt $"\
|
|
|
861f93 |
+ {
|
|
|
861f93 |
+ # Response expected from /proc-based systems.
|
|
|
861f93 |
+ pass "attach to nonexistent process is prohibited"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "attach to nonexistent process is prohibited"}
|
|
|
861f93 |
+ timeout {
|
|
|
861f93 |
+ fail "(timeout) attach to nonexistent process is prohibited"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Verify that we can attach to the process by first giving its
|
|
|
861f93 |
+ # executable name via the file command, and using attach with
|
|
|
861f93 |
+ # the process ID.
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ # (Actually, the test system appears to do this automatically
|
|
|
861f93 |
+ # for us. So, we must also be prepared to be asked if we want
|
|
|
861f93 |
+ # to discard an existing set of symbols.)
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ send_gdb "file $binfile\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "Load new symbol table from.*y or n.*$" {
|
|
|
861f93 |
+ send_gdb "y\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "(re)set file, before attach1"}
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "(re)set file, before attach1"}
|
|
|
861f93 |
+ timeout {fail "(timeout) (re)set file, before attach1"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "Reading symbols from $escapedbinfile\.\.\.*done.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "set file, before attach1"}
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "set file, before attach1"}
|
|
|
861f93 |
+ timeout {fail "(timeout) set file, before attach1"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ send_gdb "attach $testpid\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*main.*at .*$srcfile:.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "attach1, after setting file"}
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "attach1, after setting file"}
|
|
|
861f93 |
+ timeout {fail "(timeout) attach1, after setting file"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Verify that we can "see" the variable "should_exit" in the
|
|
|
861f93 |
+ # program, and that it is zero.
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ send_gdb "print should_exit\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re ".* = 0.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "after attach1, print should_exit"}
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "after attach1, print should_exit"}
|
|
|
861f93 |
+ timeout {fail "(timeout) after attach1, print should_exit"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Detach the process.
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ send_gdb "detach\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "Detaching from program: .*$escapedbinfile.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "attach1 detach"}
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "attach1 detach"}
|
|
|
861f93 |
+ timeout {fail "(timeout) attach1 detach"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Wait a bit for gdb to finish detaching
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ exec sleep 5
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Purge the symbols from gdb's brain. (We want to be certain
|
|
|
861f93 |
+ # the next attach, which won't be preceded by a "file" command,
|
|
|
861f93 |
+ # is really getting the executable file without our help.)
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ set old_timeout $timeout
|
|
|
861f93 |
+ set timeout 15
|
|
|
861f93 |
+ send_gdb "file\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re ".*gdb internal error.*$" {
|
|
|
861f93 |
+ fail "Internal error, prob. Memory corruption"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "No executable file now.*Discard symbol table.*y or n.*$" {
|
|
|
861f93 |
+ send_gdb "y\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "No symbol file now.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "attach1, purging symbols after detach"}
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "attach1, purging symbols after detach"}
|
|
|
861f93 |
+ timeout {fail "(timeout) attach1, purging symbols after detach"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "attach1, purging file after detach"}
|
|
|
861f93 |
+ timeout {
|
|
|
861f93 |
+ fail "(timeout) attach1, purging file after detach"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ set timeout $old_timeout
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Verify that we can attach to the process just by giving the
|
|
|
861f93 |
+ # process ID.
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ send_gdb "attach $testpid\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "attach2"}
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "attach2"}
|
|
|
861f93 |
+ timeout {fail "(timeout) attach2"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Verify that we can modify the variable "should_exit" in the
|
|
|
861f93 |
+ # program.
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ send_gdb "set should_exit=1\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "$gdb_prompt $" {pass "after attach2, set should_exit"}
|
|
|
861f93 |
+ timeout {fail "(timeout) after attach2, set should_exit"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Verify that the modification really happened.
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ send_gdb "tbreak 19\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "reakpoint .*at.*$srcfile, line 19.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "after attach2, set tbreak postloop"}
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "after attach2, set tbreak postloop"}
|
|
|
861f93 |
+ timeout {fail "(timeout) after attach2, set tbreak postloop"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ send_gdb "continue\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "main.*at.*$srcfile:19.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "after attach2, reach tbreak postloop"}
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "after attach2, reach tbreak postloop"}
|
|
|
861f93 |
+ timeout {fail "(timeout) after attach2, reach tbreak postloop"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Allow the test process to exit, to cleanup after ourselves.
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ gdb_test "continue" {\[Inferior .* exited normally\]} "after attach2, exit"
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Make sure we don't leave a process around to confuse
|
|
|
861f93 |
+ # the next test run (and prevent the compile by keeping
|
|
|
861f93 |
+ # the text file busy), in case the "set should_exit" didn't
|
|
|
861f93 |
+ # work.
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ remote_exec build "kill -9 ${testpid}"
|
|
|
861f93 |
+ # Start the program running and then wait for a bit, to be sure
|
|
|
861f93 |
+ # that it can be attached to.
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ set testpid [eval exec $binfile &]
|
|
|
861f93 |
+ exec sleep 2
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Verify that we can attach to the process, and find its a.out
|
|
|
861f93 |
+ # when we're cd'd to some directory that doesn't contain the
|
|
|
861f93 |
+ # a.out. (We use the source path set by the "dir" command.)
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ send_gdb "dir ${objdir}/${subdir}\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re ".*Source directories searched: .*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "set source path"}
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "set source path"}
|
|
|
861f93 |
+ timeout {fail "(timeout) set source path"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ send_gdb "cd /tmp\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re ".*Working directory /tmp.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "cd away from process' a.out"}
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "cd away from process' a.out"}
|
|
|
861f93 |
+ timeout {fail "(timeout) cd away from process' a.out"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Explicitly flush out any knowledge of the previous attachment.
|
|
|
861f93 |
+ send_gdb "symbol\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re ".*Discard symbol table from.*y or n. $"\
|
|
|
861f93 |
+ {send_gdb "y\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re ".*No symbol file now.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "before attach3, flush symbols"}
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "before attach3, flush symbols"}
|
|
|
861f93 |
+ timeout {fail "(timeout) before attach3, flush symbols"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re ".*No symbol file now.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "before attach3, flush symbols"}
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "before attach3, flush symbols"}
|
|
|
861f93 |
+ timeout {fail "(timeout) before attach3, flush symbols"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ send_gdb "exec\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re ".*No executable file now.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "before attach3, flush exec"}
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "before attach3, flush exec"}
|
|
|
861f93 |
+ timeout {fail "(timeout) before attach3, flush exec"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ send_gdb "attach $testpid\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "Attaching to process $testpid.*Reading symbols from $escapedbinfile.*main.*at .*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "attach when process' a.out not in cwd"}
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "attach when process' a.out not in cwd"}
|
|
|
861f93 |
+ timeout {fail "(timeout) attach when process' a.out not in cwd"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ send_gdb "kill\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re ".*Kill the program being debugged.*y or n. $"\
|
|
|
861f93 |
+ {send_gdb "y\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "$gdb_prompt $" {pass "after attach3, exit"}
|
|
|
861f93 |
+ timeout {fail "(timeout) after attach3, exit"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "after attach3, exit"}
|
|
|
861f93 |
+ timeout {fail "(timeout) after attach3, exit"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Another "don't leave a process around"
|
|
|
861f93 |
+ remote_exec build "kill -9 ${testpid}"
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+proc do_call_attach_tests {} {
|
|
|
861f93 |
+ global gdb_prompt
|
|
|
861f93 |
+ global binfile2
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Start the program running and then wait for a bit, to be sure
|
|
|
861f93 |
+ # that it can be attached to.
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ set testpid [eval exec $binfile2 &]
|
|
|
861f93 |
+ exec sleep 2
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Attach
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ gdb_test "file $binfile2" ".*" "force switch to gdb64, if necessary"
|
|
|
861f93 |
+ send_gdb "attach $testpid\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re ".*warning: reading register.*I.*O error.*$gdb_prompt $" {
|
|
|
861f93 |
+ fail "attach call, read register 3 error"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "Attaching to.*process $testpid.*$gdb_prompt $" {
|
|
|
861f93 |
+ # libc is relocated, not relocated, therefore not printed.
|
|
|
861f93 |
+ pass "attach call"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail "attach call"}
|
|
|
861f93 |
+ timeout {fail "(timeout) attach call"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # See if other registers are problems
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ send_gdb "i r r3\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re ".*warning: reading register.*$gdb_prompt $" {
|
|
|
861f93 |
+ pass "CHFts23490: known bug"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re ".*r3.*$gdb_prompt $" {
|
|
|
861f93 |
+ pass "Bug fixed, Yayyy!"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ timeout { fail "timeout on info reg" }
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Get rid of the process
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ gdb_test "p should_exit = 1" ".*"
|
|
|
861f93 |
+ gdb_test "c" {\[Inferior .* exited normally\]}
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Be paranoid
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ remote_exec build "kill -9 ${testpid}"
|
|
|
861f93 |
+
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Start with a fresh gdb
|
|
|
861f93 |
+#
|
|
|
861f93 |
+gdb_exit
|
|
|
861f93 |
+gdb_start
|
|
|
861f93 |
+gdb_reinitialize_dir $srcdir/$subdir
|
|
|
861f93 |
+gdb_load ${binfile}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# This is a test of gdb's ability to attach to a running process.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+do_attach_tests
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Test attaching when the target is inside a system call
|
|
|
861f93 |
+#
|
|
|
861f93 |
+gdb_exit
|
|
|
861f93 |
+gdb_start
|
|
|
861f93 |
+
|
|
|
861f93 |
+gdb_reinitialize_dir $srcdir/$subdir
|
|
|
861f93 |
+do_call_attach_tests
|
|
|
861f93 |
+
|
|
|
861f93 |
+return 0
|
|
|
861f93 |
Index: gdb-7.5.91.20130323/gdb/testsuite/gdb.pie/break.exp
|
|
|
861f93 |
===================================================================
|
|
|
861f93 |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
861f93 |
+++ gdb-7.5.91.20130323/gdb/testsuite/gdb.pie/break.exp 2013-03-23 19:47:24.194683332 +0100
|
|
|
861f93 |
@@ -0,0 +1,962 @@
|
|
|
861f93 |
+# Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999,
|
|
|
861f93 |
+# 2000, 2002, 2003, 2004
|
|
|
861f93 |
+# Free Software Foundation, Inc.
|
|
|
861f93 |
+
|
|
|
861f93 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
861f93 |
+# it under the terms of the GNU General Public License as published by
|
|
|
861f93 |
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
861f93 |
+# (at your option) any later version.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# This program is distributed in the hope that it will be useful,
|
|
|
861f93 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
861f93 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
861f93 |
+# GNU General Public License for more details.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# You should have received a copy of the GNU General Public License
|
|
|
861f93 |
+# along with this program; if not, write to the Free Software
|
|
|
861f93 |
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Please email any bugs, comments, and/or additions to this file to:
|
|
|
861f93 |
+# bug-gdb@prep.ai.mit.edu
|
|
|
861f93 |
+
|
|
|
861f93 |
+# This file was written by Rob Savoye. (rob@cygnus.com)
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Test the same stuff but with PIE executables
|
|
|
861f93 |
+
|
|
|
861f93 |
+set testfile "break"
|
|
|
861f93 |
+set srcfile ${testfile}.c
|
|
|
861f93 |
+set srcfile1 ${testfile}1.c
|
|
|
861f93 |
+set binfile ${objdir}/${subdir}/${testfile}
|
|
|
861f93 |
+
|
|
|
861f93 |
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug "additional_flags=-w -fpie -pie"}] != "" } {
|
|
|
861f93 |
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug "additional_flags=-w -fpie -pie"}] != "" } {
|
|
|
861f93 |
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug "additional_flags=-w -fpie -pie"}] != "" } {
|
|
|
861f93 |
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+if [get_compiler_info ${binfile}] {
|
|
|
861f93 |
+ return -1
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+gdb_exit
|
|
|
861f93 |
+gdb_start
|
|
|
861f93 |
+gdb_reinitialize_dir $srcdir/$subdir
|
|
|
861f93 |
+gdb_load ${binfile}
|
|
|
861f93 |
+
|
|
|
861f93 |
+if [target_info exists gdb_stub] {
|
|
|
861f93 |
+ gdb_step_for_stub;
|
|
|
861f93 |
+}
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# test simple breakpoint setting commands
|
|
|
861f93 |
+#
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Test deleting all breakpoints when there are none installed,
|
|
|
861f93 |
+# GDB should not prompt for confirmation.
|
|
|
861f93 |
+# Note that gdb-init.exp provides a "delete_breakpoints" proc
|
|
|
861f93 |
+# for general use elsewhere.
|
|
|
861f93 |
+
|
|
|
861f93 |
+send_gdb "delete breakpoints\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "Delete all breakpoints.*$" {
|
|
|
861f93 |
+ send_gdb "y\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "$gdb_prompt $" {
|
|
|
861f93 |
+ fail "Delete all breakpoints when none (unexpected prompt)"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ timeout { fail "Delete all breakpoints when none (timeout after unexpected prompt)" }
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re ".*$gdb_prompt $" { pass "Delete all breakpoints when none" }
|
|
|
861f93 |
+ timeout { fail "Delete all breakpoints when none (timeout)" }
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# test break at function
|
|
|
861f93 |
+#
|
|
|
861f93 |
+gdb_test "break main" \
|
|
|
861f93 |
+ "Breakpoint.*at.* file .*$srcfile, line.*" \
|
|
|
861f93 |
+ "breakpoint function"
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# test break at quoted function
|
|
|
861f93 |
+#
|
|
|
861f93 |
+gdb_test "break \"marker2\"" \
|
|
|
861f93 |
+ "Breakpoint.*at.* file .*$srcfile1, line.*" \
|
|
|
861f93 |
+ "breakpoint quoted function"
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# test break at function in file
|
|
|
861f93 |
+#
|
|
|
861f93 |
+gdb_test "break $srcfile:factorial" \
|
|
|
861f93 |
+ "Breakpoint.*at.* file .*$srcfile, line.*" \
|
|
|
861f93 |
+ "breakpoint function in file"
|
|
|
861f93 |
+
|
|
|
861f93 |
+set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# test break at line number
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# Note that the default source file is the last one whose source text
|
|
|
861f93 |
+# was printed. For native debugging, before we've executed the
|
|
|
861f93 |
+# program, this is the file containing main, but for remote debugging,
|
|
|
861f93 |
+# it's wherever the processor was stopped when we connected to the
|
|
|
861f93 |
+# board. So, to be sure, we do a list command.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+gdb_test "list main" \
|
|
|
861f93 |
+ ".*main \\(argc, argv, envp\\).*" \
|
|
|
861f93 |
+ "use `list' to establish default source file"
|
|
|
861f93 |
+gdb_test "break $bp_location1" \
|
|
|
861f93 |
+ "Breakpoint.*at.* file .*$srcfile, line $bp_location1\\." \
|
|
|
861f93 |
+ "breakpoint line number"
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# test duplicate breakpoint
|
|
|
861f93 |
+#
|
|
|
861f93 |
+gdb_test "break $bp_location1" \
|
|
|
861f93 |
+ "Note: breakpoint \[0-9\]+ also set at pc.*Breakpoint \[0-9\]+ at.* file .*$srcfile, line $bp_location1\\." \
|
|
|
861f93 |
+ "breakpoint duplicate"
|
|
|
861f93 |
+
|
|
|
861f93 |
+set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# test break at line number in file
|
|
|
861f93 |
+#
|
|
|
861f93 |
+gdb_test "break $srcfile:$bp_location2" \
|
|
|
861f93 |
+ "Breakpoint.*at.* file .*$srcfile, line $bp_location2\\." \
|
|
|
861f93 |
+ "breakpoint line number in file"
|
|
|
861f93 |
+
|
|
|
861f93 |
+set bp_location3 [gdb_get_line_number "set breakpoint 3 here"]
|
|
|
861f93 |
+set bp_location4 [gdb_get_line_number "set breakpoint 4 here"]
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# Test putting a break at the start of a multi-line if conditional.
|
|
|
861f93 |
+# Verify the breakpoint was put at the start of the conditional.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+gdb_test "break multi_line_if_conditional" \
|
|
|
861f93 |
+ "Breakpoint.*at.* file .*$srcfile, line $bp_location3\\." \
|
|
|
861f93 |
+ "breakpoint at start of multi line if conditional"
|
|
|
861f93 |
+
|
|
|
861f93 |
+gdb_test "break multi_line_while_conditional" \
|
|
|
861f93 |
+ "Breakpoint.*at.* file .*$srcfile, line $bp_location4\\." \
|
|
|
861f93 |
+ "breakpoint at start of multi line while conditional"
|
|
|
861f93 |
+
|
|
|
861f93 |
+set bp_location5 [gdb_get_line_number "set breakpoint 5 here"]
|
|
|
861f93 |
+set bp_location6 [gdb_get_line_number "set breakpoint 6 here"]
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# check to see what breakpoints are set
|
|
|
861f93 |
+#
|
|
|
861f93 |
+if [target_info exists gdb_stub] {
|
|
|
861f93 |
+ set main_line $bp_location5
|
|
|
861f93 |
+} else {
|
|
|
861f93 |
+ set main_line $bp_location6
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+if {$hp_aCC_compiler} {
|
|
|
861f93 |
+ set proto "\\(int\\)"
|
|
|
861f93 |
+} else {
|
|
|
861f93 |
+ set proto ""
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+set bp_location7 [gdb_get_line_number "set breakpoint 7 here"]
|
|
|
861f93 |
+set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1]
|
|
|
861f93 |
+set bp_location9 [gdb_get_line_number "set breakpoint 9 here" $srcfile1]
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Test a pending breakpoint in PIE executable does not crash later GDB.
|
|
|
861f93 |
+gdb_breakpoint "non_existent_function" allow-pending
|
|
|
861f93 |
+
|
|
|
861f93 |
+gdb_test "info break" \
|
|
|
861f93 |
+ "Num\[ \]+Type\[ \]+Disp Enb Address\[ \]+What.*
|
|
|
861f93 |
+\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$main_line.*
|
|
|
861f93 |
+\[0-9\]+\[\t \]+breakpoint keep y.* in marker2 at .*$srcfile1:($bp_location8|$bp_location9).*
|
|
|
861f93 |
+\[0-9\]+\[\t \]+breakpoint keep y.* in factorial$proto at .*$srcfile:$bp_location7.*
|
|
|
861f93 |
+\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.*
|
|
|
861f93 |
+\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location1.*
|
|
|
861f93 |
+\[0-9\]+\[\t \]+breakpoint keep y.* in main at .*$srcfile:$bp_location2.*
|
|
|
861f93 |
+\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_if_conditional at .*$srcfile:$bp_location3.*
|
|
|
861f93 |
+\[0-9\]+\[\t \]+breakpoint keep y.* in multi_line_while_conditional at .*$srcfile:$bp_location4.*
|
|
|
861f93 |
+\[0-9\]+\[\t \]+breakpoint keep y.* <PENDING> *non_existent_function" \
|
|
|
861f93 |
+ "breakpoint info"
|
|
|
861f93 |
+
|
|
|
861f93 |
+# FIXME: The rest of this test doesn't work with anything that can't
|
|
|
861f93 |
+# handle arguments.
|
|
|
861f93 |
+# Huh? There doesn't *appear* to be anything that passes arguments
|
|
|
861f93 |
+# below.
|
|
|
861f93 |
+if [istarget "mips-idt-*"] then {
|
|
|
861f93 |
+ return
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# run until the breakpoint at main is hit. For non-stubs-using targets.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+if ![target_info exists use_gdb_stub] {
|
|
|
861f93 |
+ if [istarget "*-*-vxworks*"] then {
|
|
|
861f93 |
+ send_gdb "run vxmain \"2\"\n"
|
|
|
861f93 |
+ set timeout 120
|
|
|
861f93 |
+ verbose "Timeout is now $timeout seconds" 2
|
|
|
861f93 |
+ } else {
|
|
|
861f93 |
+ send_gdb "run\n"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "The program .* has been started already.*y or n. $" {
|
|
|
861f93 |
+ send_gdb "y\n"
|
|
|
861f93 |
+ exp_continue
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\
|
|
|
861f93 |
+ { pass "run until function breakpoint" }
|
|
|
861f93 |
+ -re ".*$gdb_prompt $" { fail "run until function breakpoint" }
|
|
|
861f93 |
+ timeout { fail "run until function breakpoint (timeout)" }
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+} else {
|
|
|
861f93 |
+ if ![target_info exists gdb_stub] {
|
|
|
861f93 |
+ gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# run until the breakpoint at a line number
|
|
|
861f93 |
+#
|
|
|
861f93 |
+gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location1.*$bp_location1\[\t \]+printf.*factorial.*" \
|
|
|
861f93 |
+ "run until breakpoint set at a line number"
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# Run until the breakpoint set in a function in a file
|
|
|
861f93 |
+#
|
|
|
861f93 |
+for {set i 6} {$i >= 1} {incr i -1} {
|
|
|
861f93 |
+ gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, factorial \\(value=$i\\) at .*$srcfile:$bp_location7.*$bp_location7\[\t \]+.*if .value > 1. \{.*" \
|
|
|
861f93 |
+ "run until file:function($i) breakpoint"
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# Run until the breakpoint set at a quoted function
|
|
|
861f93 |
+#
|
|
|
861f93 |
+gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, (0x\[0-9a-f\]+ in )?marker2 \\(a=43\\) at .*$srcfile1:($bp_location8|$bp_location9).*" \
|
|
|
861f93 |
+ "run until quoted breakpoint"
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# run until the file:function breakpoint at a line number in a file
|
|
|
861f93 |
+#
|
|
|
861f93 |
+gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location2.*$bp_location2\[\t \]+argc = \\(argc == 12345\\);.*" \
|
|
|
861f93 |
+ "run until file:linenum breakpoint"
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Test break at offset +1
|
|
|
861f93 |
+set bp_location10 [gdb_get_line_number "set breakpoint 10 here"]
|
|
|
861f93 |
+
|
|
|
861f93 |
+gdb_test "break +1" \
|
|
|
861f93 |
+ "Breakpoint.*at.* file .*$srcfile, line $bp_location10\\." \
|
|
|
861f93 |
+ "breakpoint offset +1"
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Check to see if breakpoint is hit when stepped onto
|
|
|
861f93 |
+
|
|
|
861f93 |
+gdb_test "step" \
|
|
|
861f93 |
+ ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location10.*$bp_location10\[\t \]+return argc;.*breakpoint 10 here.*" \
|
|
|
861f93 |
+ "step onto breakpoint"
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# delete all breakpoints so we can start over, course this can be a test too
|
|
|
861f93 |
+#
|
|
|
861f93 |
+delete_breakpoints
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# test temporary breakpoint at function
|
|
|
861f93 |
+#
|
|
|
861f93 |
+
|
|
|
861f93 |
+gdb_test "tbreak main" "reakpoint.*at.* file .*$srcfile, line.*" "Temporary breakpoint function"
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# test break at function in file
|
|
|
861f93 |
+#
|
|
|
861f93 |
+
|
|
|
861f93 |
+gdb_test "tbreak $srcfile:factorial" "reakpoint.*at.* file .*$srcfile, line.*" \
|
|
|
861f93 |
+ "Temporary breakpoint function in file"
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# test break at line number
|
|
|
861f93 |
+#
|
|
|
861f93 |
+send_gdb "tbreak $bp_location1\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "reakpoint.*at.* file .*$srcfile, line $bp_location1.*$gdb_prompt $" { pass "Temporary breakpoint line number #1" }
|
|
|
861f93 |
+ -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number #1" }
|
|
|
861f93 |
+ timeout { fail "breakpoint line number #1 (timeout)" }
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+gdb_test "tbreak $bp_location6" "reakpoint.*at.* file .*$srcfile, line $bp_location6.*" "Temporary breakpoint line number #2"
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# test break at line number in file
|
|
|
861f93 |
+#
|
|
|
861f93 |
+send_gdb "tbreak $srcfile:$bp_location2\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "reakpoint.*at.* file .*$srcfile, line $bp_location2.*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" }
|
|
|
861f93 |
+ -re ".*$gdb_prompt $" { pass "Temporary breakpoint line number in file #1" }
|
|
|
861f93 |
+ timeout { fail "Temporary breakpoint line number in file #1 (timeout)" }
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+set bp_location11 [gdb_get_line_number "set breakpoint 11 here"]
|
|
|
861f93 |
+gdb_test "tbreak $srcfile:$bp_location11" "reakpoint.*at.* file .*$srcfile, line $bp_location11.*" "Temporary breakpoint line number in file #2"
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# check to see what breakpoints are set (temporary this time)
|
|
|
861f93 |
+#
|
|
|
861f93 |
+gdb_test "info break" "Num.*Type.*Disp Enb Address.*What.*\[\r\n\]
|
|
|
861f93 |
+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$main_line.*\[\r\n\]
|
|
|
861f93 |
+\[0-9\]+\[\t \]+breakpoint del.*y.*in factorial$proto at .*$srcfile:$bp_location7.*\[\r\n\]
|
|
|
861f93 |
+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location1.*\[\r\n\]
|
|
|
861f93 |
+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location6.*\[\r\n\]
|
|
|
861f93 |
+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location2.*\[\r\n\]
|
|
|
861f93 |
+\[0-9\]+\[\t \]+breakpoint del.*y.*in main at .*$srcfile:$bp_location11.*" \
|
|
|
861f93 |
+ "Temporary breakpoint info"
|
|
|
861f93 |
+
|
|
|
861f93 |
+
|
|
|
861f93 |
+#***********
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Verify that catchpoints for fork, vfork and exec don't trigger
|
|
|
861f93 |
+# inappropriately. (There are no calls to those system functions
|
|
|
861f93 |
+# in this test program.)
|
|
|
861f93 |
+#
|
|
|
861f93 |
+if ![runto_main] then { fail "break tests suppressed" }
|
|
|
861f93 |
+
|
|
|
861f93 |
+send_gdb "catch\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "Catch requires an event name.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "catch requires an event name"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "catch requires an event name"}
|
|
|
861f93 |
+ timeout {fail "(timeout) catch requires an event name"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+
|
|
|
861f93 |
+set name "set catch fork, never expected to trigger"
|
|
|
861f93 |
+send_gdb "catch fork\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "Catchpoint \[0-9\]* .fork..*$gdb_prompt $"
|
|
|
861f93 |
+ {pass $name}
|
|
|
861f93 |
+ -re "Catch of fork not yet implemented.*$gdb_prompt $"
|
|
|
861f93 |
+ {pass $name}
|
|
|
861f93 |
+ -re "$gdb_prompt $"
|
|
|
861f93 |
+ {fail $name}
|
|
|
861f93 |
+ timeout {fail "(timeout) $name"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+
|
|
|
861f93 |
+set name "set catch vfork, never expected to trigger"
|
|
|
861f93 |
+send_gdb "catch vfork\n"
|
|
|
861f93 |
+
|
|
|
861f93 |
+# If we are on HP-UX 10.20, we expect an error message to be
|
|
|
861f93 |
+# printed if we type "catch vfork" at the gdb gdb_prompt. This is
|
|
|
861f93 |
+# because on HP-UX 10.20, we cannot catch vfork events.
|
|
|
861f93 |
+
|
|
|
861f93 |
+if [istarget "hppa*-hp-hpux10.20"] then {
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "Catch of vfork events not supported on HP-UX 10.20..*$gdb_prompt $"
|
|
|
861f93 |
+ {pass $name}
|
|
|
861f93 |
+ -re "$gdb_prompt $"
|
|
|
861f93 |
+ {fail $name}
|
|
|
861f93 |
+ timeout {fail "(timeout) $name"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+} else {
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "Catchpoint \[0-9\]* .vfork..*$gdb_prompt $"
|
|
|
861f93 |
+ {pass $name}
|
|
|
861f93 |
+ -re "Catch of vfork not yet implemented.*$gdb_prompt $"
|
|
|
861f93 |
+ {pass $name}
|
|
|
861f93 |
+ -re "$gdb_prompt $"
|
|
|
861f93 |
+ {fail $name}
|
|
|
861f93 |
+ timeout {fail "(timeout) $name"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+set name "set catch exec, never expected to trigger"
|
|
|
861f93 |
+send_gdb "catch exec\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "Catchpoint \[0-9\]* .exec..*$gdb_prompt $"
|
|
|
861f93 |
+ {pass $name}
|
|
|
861f93 |
+ -re "Catch of exec not yet implemented.*$gdb_prompt $"
|
|
|
861f93 |
+ {pass $name}
|
|
|
861f93 |
+ -re "$gdb_prompt $" {fail $name}
|
|
|
861f93 |
+ timeout {fail "(timeout) $name"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Verify that GDB responds gracefully when asked to set a breakpoint
|
|
|
861f93 |
+# on a nonexistent source line.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+gdb_test_no_output "set breakpoint pending off"
|
|
|
861f93 |
+gdb_test "break 999" \
|
|
|
861f93 |
+ "No line 999 in the current file." \
|
|
|
861f93 |
+ "break on non-existent source line"
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Run to the desired default location. If not positioned here, the
|
|
|
861f93 |
+# tests below don't work.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+gdb_test "until $bp_location1" "main .* at .*:$bp_location1.*" "until bp_location1"
|
|
|
861f93 |
+
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Verify that GDB allows one to just say "break", which is treated
|
|
|
861f93 |
+# as the "default" breakpoint. Note that GDB gets cute when printing
|
|
|
861f93 |
+# the informational message about other breakpoints at the same
|
|
|
861f93 |
+# location. We'll hit that bird with this stone too.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+send_gdb "break\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "Breakpoint \[0-9\]*.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "break on default location, 1st time"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "break on default location, 1st time"}
|
|
|
861f93 |
+ timeout {fail "(timeout) break on default location, 1st time"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+send_gdb "break\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "Note: breakpoint \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "break on default location, 2nd time"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "break on default location, 2nd time"}
|
|
|
861f93 |
+ timeout {fail "(timeout) break on default location, 2nd time"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+send_gdb "break\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "Note: breakpoints \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "break on default location, 3rd time"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "break on default location, 3rd time"}
|
|
|
861f93 |
+ timeout {fail "(timeout) break on default location, 3rd time"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+send_gdb "break\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "Note: breakpoints \[0-9\]*, \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "break on default location, 4th time"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "break on default location, 4th time"}
|
|
|
861f93 |
+ timeout {fail "(timeout) break on default location, 4th time"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Verify that a "silent" breakpoint can be set, and that GDB is indeed
|
|
|
861f93 |
+# "silent" about its triggering.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+if ![runto_main] then { fail "break tests suppressed" }
|
|
|
861f93 |
+
|
|
|
861f93 |
+send_gdb "break $bp_location1\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "Breakpoint (\[0-9\]*) at .*, line $bp_location1.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "set to-be-silent break bp_location1"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "set to-be-silent break bp_location1"}
|
|
|
861f93 |
+ timeout {fail "(timeout) set to-be-silent break bp_location1"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+send_gdb "commands $expect_out(1,string)\n"
|
|
|
861f93 |
+send_gdb "silent\n"
|
|
|
861f93 |
+send_gdb "end\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re ".*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "set silent break bp_location1"}
|
|
|
861f93 |
+ timeout {fail "(timeout) set silent break bp_location1"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+send_gdb "info break $expect_out(1,string)\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "\[0-9\]*\[ \t\]*breakpoint.*:$bp_location1\r\n\[ \t\]*silent.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "info silent break bp_location1"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "info silent break bp_location1"}
|
|
|
861f93 |
+ timeout {fail "(timeout) info silent break bp_location1"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+send_gdb "continue\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "Continuing.\r\n$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "hit silent break bp_location1"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "hit silent break bp_location1"}
|
|
|
861f93 |
+ timeout {fail "(timeout) hit silent break bp_location1"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+send_gdb "bt\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "#0 main .* at .*:$bp_location1.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "stopped for silent break bp_location1"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "stopped for silent break bp_location1"}
|
|
|
861f93 |
+ timeout {fail "(timeout) stopped for silent break bp_location1"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Verify that GDB can at least parse a breakpoint with the
|
|
|
861f93 |
+# "thread" keyword. (We won't attempt to test here that a
|
|
|
861f93 |
+# thread-specific breakpoint really triggers appropriately.
|
|
|
861f93 |
+# The gdb.threads subdirectory contains tests for that.)
|
|
|
861f93 |
+#
|
|
|
861f93 |
+set bp_location12 [gdb_get_line_number "set breakpoint 12 here"]
|
|
|
861f93 |
+send_gdb "break $bp_location12 thread 999\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "Unknown thread 999.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "thread-specific breakpoint on non-existent thread disallowed"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "thread-specific breakpoint on non-existent thread disallowed"}
|
|
|
861f93 |
+ timeout {fail "(timeout) thread-specific breakpoint on non-existent thread disallowed"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+send_gdb "break $bp_location12 thread foo\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "Junk after thread keyword..*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "thread-specific breakpoint on bogus thread ID disallowed"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "thread-specific breakpoint on bogus thread ID disallowed"}
|
|
|
861f93 |
+ timeout {fail "(timeout) thread-specific breakpoint on bogus thread ID disallowed"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Verify that GDB responds gracefully to a breakpoint command with
|
|
|
861f93 |
+# trailing garbage.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+send_gdb "break $bp_location12 foo\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "malformed linespec error: unexpected string, \"foo\"\r\n$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "breakpoint with trailing garbage disallowed"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "breakpoint with trailing garbage disallowed"}
|
|
|
861f93 |
+ timeout {fail "(timeout) breakpoint with trailing garbage disallowed"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Verify that GDB responds gracefully to a "clear" command that has
|
|
|
861f93 |
+# no matching breakpoint. (First, get us off the current source line,
|
|
|
861f93 |
+# which we know has a breakpoint.)
|
|
|
861f93 |
+#
|
|
|
861f93 |
+send_gdb "next\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re ".*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "step over breakpoint"}
|
|
|
861f93 |
+ timeout {fail "(timeout) step over breakpoint"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+send_gdb "clear 81\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "No breakpoint at 81..*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "clear line has no breakpoint disallowed"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "clear line has no breakpoint disallowed"}
|
|
|
861f93 |
+ timeout {fail "(timeout) clear line has no breakpoint disallowed"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+send_gdb "clear\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "No breakpoint at this line..*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "clear current line has no breakpoint disallowed"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "clear current line has no breakpoint disallowed"}
|
|
|
861f93 |
+ timeout {fail "(timeout) clear current line has no breakpoint disallowed"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Verify that we can set and clear multiple breakpoints.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# We don't test that it deletes the correct breakpoints. We do at
|
|
|
861f93 |
+# least test that it deletes more than one breakpoint.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #1"
|
|
|
861f93 |
+gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #2"
|
|
|
861f93 |
+gdb_test "clear marker3" {Deleted breakpoints [0-9]+ [0-9]+.*}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Verify that a breakpoint can be set via a convenience variable.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+send_gdb "set \$foo=$bp_location11\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "set convenience variable \$foo to bp_location11"}
|
|
|
861f93 |
+ timeout {fail "(timeout) set convenience variable \$foo to bp_location11"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+send_gdb "break \$foo\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "Breakpoint (\[0-9\]*) at .*, line $bp_location11.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "set breakpoint via convenience variable"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "set breakpoint via convenience variable"}
|
|
|
861f93 |
+ timeout {fail "(timeout) set breakpoint via convenience variable"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Verify that GDB responds gracefully to an attempt to set a
|
|
|
861f93 |
+# breakpoint via a convenience variable whose type is not integer.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+send_gdb "set \$foo=81.5\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "set convenience variable \$foo to 81.5"}
|
|
|
861f93 |
+ timeout {fail "(timeout) set convenience variable \$foo to 81.5"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+send_gdb "break \$foo\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "Convenience variables used in line specs must have integer values..*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "set breakpoint via non-integer convenience variable disallowed"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "set breakpoint via non-integer convenience variable disallowed"}
|
|
|
861f93 |
+ timeout {fail "(timeout) set breakpoint via non-integer convenience variable disallowed"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Verify that we can set and trigger a breakpoint in a user-called function.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+send_gdb "break marker2\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "Breakpoint (\[0-9\]*) at .*, line ($bp_location8|$bp_location9).*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "set breakpoint on to-be-called function"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "set breakpoint on to-be-called function"}
|
|
|
861f93 |
+ timeout {fail "(timeout) set breakpoint on to-be-called function"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+send_gdb "print marker2(99)\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "The program being debugged stopped while in a function called from GDB.\r\nEvaluation of the expression containing the function\r\n.marker2$proto. will be abandoned.\r\nWhen the function is done executing, GDB will silently stop.\r\n$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "hit breakpoint on called function"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "hit breakpoint on called function"}
|
|
|
861f93 |
+ timeout {fail "(timeout) hit breakpoint on called function"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# As long as we're stopped (breakpointed) in a called function,
|
|
|
861f93 |
+# verify that we can successfully backtrace & such from here.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# In this and the following test, the _sr4export check apparently is needed
|
|
|
861f93 |
+# for hppa*-*-hpux.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+send_gdb "bt\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*_sr4export.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "backtrace while in called function"}
|
|
|
861f93 |
+ -re "#0\[ \t\]*($hex in )?marker2.*:($bp_location8|$bp_location9)\r\n#1.*function called from gdb.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "backtrace while in called function"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "backtrace while in called function"}
|
|
|
861f93 |
+ timeout {fail "(timeout) backtrace while in called function"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Return from the called function. For remote targets, it's important to do
|
|
|
861f93 |
+# this before runto_main, which otherwise may silently stop on the dummy
|
|
|
861f93 |
+# breakpoint inserted by GDB at the program's entry point.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+send_gdb "finish\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.* in _sr4export.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "finish from called function"}
|
|
|
861f93 |
+ -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*function called from gdb.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "finish from called function"}
|
|
|
861f93 |
+ -re "Run till exit from .*marker2.* at .*($bp_location8|$bp_location9)\r\n.*Value returned.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "finish from called function"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "finish from called function"}
|
|
|
861f93 |
+ timeout {fail "(timeout) finish from called function"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Verify that GDB responds gracefully to a "finish" command with
|
|
|
861f93 |
+# arguments.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+if ![runto_main] then { fail "break tests suppressed" }
|
|
|
861f93 |
+
|
|
|
861f93 |
+send_gdb "finish 123\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "The \"finish\" command does not take any arguments.\r\n$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "finish with arguments disallowed"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "finish with arguments disallowed"}
|
|
|
861f93 |
+ timeout {fail "(timeout) finish with arguments disallowed"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Verify that GDB responds gracefully to a request to "finish" from
|
|
|
861f93 |
+# the outermost frame. On a stub that never exits, this will just
|
|
|
861f93 |
+# run to the stubs routine, so we don't get this error... Thus the
|
|
|
861f93 |
+# second condition.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+
|
|
|
861f93 |
+send_gdb "finish\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "\"finish\" not meaningful in the outermost frame.\r\n$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "finish from outermost frame disallowed"}
|
|
|
861f93 |
+ -re "Run till exit from.*\r\n$gdb_prompt $" {
|
|
|
861f93 |
+ pass "finish from outermost frame disallowed"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "finish from outermost frame disallowed"}
|
|
|
861f93 |
+ timeout {fail "(timeout) finish from outermost frame disallowed"}
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Verify that we can explicitly ask GDB to stop on all shared library
|
|
|
861f93 |
+# events, and that it does so.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+if [istarget "hppa*-*-hpux*"] then {
|
|
|
861f93 |
+ if ![runto_main] then { fail "break tests suppressed" }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ send_gdb "set stop-on-solib-events 1\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "set stop-on-solib-events"}
|
|
|
861f93 |
+ timeout {fail "(timeout) set stop-on-solib-events"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ send_gdb "run\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re ".*Start it from the beginning.*y or n. $"\
|
|
|
861f93 |
+ {send_gdb "y\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re ".*Stopped due to shared library event.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "triggered stop-on-solib-events"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "triggered stop-on-solib-events"}
|
|
|
861f93 |
+ timeout {fail "(timeout) triggered stop-on-solib-events"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "rerun for stop-on-solib-events"}
|
|
|
861f93 |
+ timeout {fail "(timeout) rerun for stop-on-solib-events"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ send_gdb "set stop-on-solib-events 0\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "reset stop-on-solib-events"}
|
|
|
861f93 |
+ timeout {fail "(timeout) reset stop-on-solib-events"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Hardware breakpoints are unsupported on HP-UX. Verify that GDB
|
|
|
861f93 |
+# gracefully responds to requests to create them.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+if [istarget "hppa*-*-hpux*"] then {
|
|
|
861f93 |
+ if ![runto_main] then { fail "break tests suppressed" }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ send_gdb "hbreak\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "No hardware breakpoint support in the target.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "hw breaks disallowed"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "hw breaks disallowed"}
|
|
|
861f93 |
+ timeout {fail "(timeout) hw breaks disallowed"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ send_gdb "thbreak\n"
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "No hardware breakpoint support in the target.*$gdb_prompt $"\
|
|
|
861f93 |
+ {pass "temporary hw breaks disallowed"}
|
|
|
861f93 |
+ -re "$gdb_prompt $"\
|
|
|
861f93 |
+ {fail "temporary hw breaks disallowed"}
|
|
|
861f93 |
+ timeout {fail "(timeout) temporary hw breaks disallowed"}
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+#********
|
|
|
861f93 |
+
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# Test "next" over recursive function call.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+
|
|
|
861f93 |
+proc test_next_with_recursion {} {
|
|
|
861f93 |
+ global gdb_prompt
|
|
|
861f93 |
+ global decimal
|
|
|
861f93 |
+ global binfile
|
|
|
861f93 |
+
|
|
|
861f93 |
+ if [target_info exists use_gdb_stub] {
|
|
|
861f93 |
+ # Reload the program.
|
|
|
861f93 |
+ delete_breakpoints
|
|
|
861f93 |
+ gdb_load ${binfile};
|
|
|
861f93 |
+ } else {
|
|
|
861f93 |
+ # FIXME: should be using runto
|
|
|
861f93 |
+ gdb_test "kill" "" "kill program" "Kill the program being debugged.*y or n. $" "y"
|
|
|
861f93 |
+
|
|
|
861f93 |
+ delete_breakpoints
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ gdb_test "break factorial" "Breakpoint $decimal at .*" "break at factorial"
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Run until we call factorial with 6
|
|
|
861f93 |
+
|
|
|
861f93 |
+ if [istarget "*-*-vxworks*"] then {
|
|
|
861f93 |
+ send_gdb "run vxmain \"6\"\n"
|
|
|
861f93 |
+ } else {
|
|
|
861f93 |
+ gdb_run_cmd
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "Break.* factorial .value=6. .*$gdb_prompt $" {}
|
|
|
861f93 |
+ -re ".*$gdb_prompt $" {
|
|
|
861f93 |
+ fail "run to factorial(6)";
|
|
|
861f93 |
+ gdb_suppress_tests;
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ timeout { fail "run to factorial(6) (timeout)" ; gdb_suppress_tests }
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Continue until we call factorial recursively with 5.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ if [gdb_test "continue" \
|
|
|
861f93 |
+ "Continuing.*Break.* factorial .value=5. .*" \
|
|
|
861f93 |
+ "continue to factorial(5)"] then { gdb_suppress_tests }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Do a backtrace just to confirm how many levels deep we are.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ if [gdb_test "backtrace" \
|
|
|
861f93 |
+ "#0\[ \t\]+ factorial .value=5..*" \
|
|
|
861f93 |
+ "backtrace from factorial(5)"] then { gdb_suppress_tests }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Now a "next" should position us at the recursive call, which
|
|
|
861f93 |
+ # we will be performing with 4.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ if [gdb_test "next" \
|
|
|
861f93 |
+ ".* factorial .value - 1.;.*" \
|
|
|
861f93 |
+ "next to recursive call"] then { gdb_suppress_tests }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # Disable the breakpoint at the entry to factorial by deleting them all.
|
|
|
861f93 |
+ # The "next" should run until we return to the next line from this
|
|
|
861f93 |
+ # recursive call to factorial with 4.
|
|
|
861f93 |
+ # Buggy versions of gdb will stop instead at the innermost frame on
|
|
|
861f93 |
+ # the line where we are trying to "next" to.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ delete_breakpoints
|
|
|
861f93 |
+
|
|
|
861f93 |
+ if [istarget "mips*tx39-*"] {
|
|
|
861f93 |
+ set timeout 60
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ # We used to set timeout here for all other targets as well. This
|
|
|
861f93 |
+ # is almost certainly wrong. The proper timeout depends on the
|
|
|
861f93 |
+ # target system in use, and how we communicate with it, so there
|
|
|
861f93 |
+ # is no single value appropriate for all targets. The timeout
|
|
|
861f93 |
+ # should be established by the Dejagnu config file(s) for the
|
|
|
861f93 |
+ # board, and respected by the test suite.
|
|
|
861f93 |
+ #
|
|
|
861f93 |
+ # For example, if I'm running GDB over an SSH tunnel talking to a
|
|
|
861f93 |
+ # portmaster in California talking to an ancient 68k board running
|
|
|
861f93 |
+ # a crummy ROM monitor (a situation I can only wish were
|
|
|
861f93 |
+ # hypothetical), then I need a large timeout. But that's not the
|
|
|
861f93 |
+ # kind of knowledge that belongs in this file.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ gdb_test next "\[0-9\]*\[\t \]+return \\(value\\);.*" \
|
|
|
861f93 |
+ "next over recursive call"
|
|
|
861f93 |
+
|
|
|
861f93 |
+ # OK, we should be back in the same stack frame we started from.
|
|
|
861f93 |
+ # Do a backtrace just to confirm.
|
|
|
861f93 |
+
|
|
|
861f93 |
+ set result [gdb_test "backtrace" \
|
|
|
861f93 |
+ "#0\[ \t\]+ factorial .value=120.*\r\n#1\[ \t\]+ \[0-9a-fx\]+ in factorial .value=6..*" \
|
|
|
861f93 |
+ "backtrace from factorial(5.1)"]
|
|
|
861f93 |
+ if { $result != 0 } { gdb_suppress_tests }
|
|
|
861f93 |
+
|
|
|
861f93 |
+ if [target_info exists gdb,noresults] { gdb_suppress_tests }
|
|
|
861f93 |
+ gdb_continue_to_end "recursive next test"
|
|
|
861f93 |
+ gdb_stop_suppressing_tests;
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+test_next_with_recursion
|
|
|
861f93 |
+
|
|
|
861f93 |
+
|
|
|
861f93 |
+#********
|
|
|
861f93 |
+
|
|
|
861f93 |
+# build a new file with optimization enabled so that we can try breakpoints
|
|
|
861f93 |
+# on targets with optimized prologues
|
|
|
861f93 |
+
|
|
|
861f93 |
+set binfileo2 ${objdir}/${subdir}/${testfile}o2
|
|
|
861f93 |
+
|
|
|
861f93 |
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}O0.o" object {debug "additional_flags=-w -O2 -fpie -pie"}] != "" } {
|
|
|
861f93 |
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}O1.o" object {debug "additional_flags=-w -O2 -fpie -pie"}] != "" } {
|
|
|
861f93 |
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+if { [gdb_compile "${binfile}O0.o ${binfile}O1.o" "${binfileo2}" executable {debug "additional_flags=-w -fpie -pie"}] != "" } {
|
|
|
861f93 |
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+if [get_compiler_info ${binfileo2}] {
|
|
|
861f93 |
+ return -1
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+gdb_exit
|
|
|
861f93 |
+gdb_start
|
|
|
861f93 |
+gdb_reinitialize_dir $srcdir/$subdir
|
|
|
861f93 |
+gdb_load ${binfileo2}
|
|
|
861f93 |
+
|
|
|
861f93 |
+if [target_info exists gdb_stub] {
|
|
|
861f93 |
+ gdb_step_for_stub;
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# test break at function
|
|
|
861f93 |
+#
|
|
|
861f93 |
+gdb_test "break main" \
|
|
|
861f93 |
+ "Breakpoint.*at.* file .*$srcfile, line.*" \
|
|
|
861f93 |
+ "breakpoint function, optimized file"
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# test break at function
|
|
|
861f93 |
+#
|
|
|
861f93 |
+gdb_test "break marker4" \
|
|
|
861f93 |
+ "Breakpoint.*at.* file .*$srcfile1, line.*" \
|
|
|
861f93 |
+ "breakpoint small function, optimized file"
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# run until the breakpoint at main is hit. For non-stubs-using targets.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+if ![target_info exists use_gdb_stub] {
|
|
|
861f93 |
+ if [istarget "*-*-vxworks*"] then {
|
|
|
861f93 |
+ send_gdb "run vxmain \"2\"\n"
|
|
|
861f93 |
+ set timeout 120
|
|
|
861f93 |
+ verbose "Timeout is now $timeout seconds" 2
|
|
|
861f93 |
+ } else {
|
|
|
861f93 |
+ send_gdb "run\n"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ gdb_expect {
|
|
|
861f93 |
+ -re "The program .* has been started already.*y or n. $" {
|
|
|
861f93 |
+ send_gdb "y\n"
|
|
|
861f93 |
+ exp_continue
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $"\
|
|
|
861f93 |
+ { pass "run until function breakpoint, optimized file" }
|
|
|
861f93 |
+ -re "Starting program.*Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $"\
|
|
|
861f93 |
+ { pass "run until function breakpoint, optimized file (code motion)" }
|
|
|
861f93 |
+ -re ".*$gdb_prompt $" { fail "run until function breakpoint, optimized file" }
|
|
|
861f93 |
+ timeout { fail "run until function breakpoint, optimized file (timeout)" }
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+} else {
|
|
|
861f93 |
+ if ![target_info exists gdb_stub] {
|
|
|
861f93 |
+ gdb_test continue ".*Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.*\{.*" "stub continue, optimized file"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# run until the breakpoint at a small function
|
|
|
861f93 |
+#
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# Add a second pass pattern. The behavior differs here between stabs
|
|
|
861f93 |
+# and dwarf for one-line functions. Stabs preserves two line symbols
|
|
|
861f93 |
+# (one before the prologue and one after) with the same line number,
|
|
|
861f93 |
+# but dwarf regards these as duplicates and discards one of them.
|
|
|
861f93 |
+# Therefore the address after the prologue (where the breakpoint is)
|
|
|
861f93 |
+# has no exactly matching line symbol, and GDB reports the breakpoint
|
|
|
861f93 |
+# as if it were in the middle of a line rather than at the beginning.
|
|
|
861f93 |
+
|
|
|
861f93 |
+set bp_location13 [gdb_get_line_number "set breakpoint 13 here" $srcfile1]
|
|
|
861f93 |
+set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1]
|
|
|
861f93 |
+send_gdb "continue\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" {
|
|
|
861f93 |
+ pass "run until breakpoint set at small function, optimized file"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "Breakpoint $decimal, $hex in marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location13\[\r\n\]+$bp_location13\[\t \]+void marker4.*" {
|
|
|
861f93 |
+ pass "run until breakpoint set at small function, optimized file"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "Breakpoint $decimal, marker4 \\(d=177601976\\) at .*$srcfile1:$bp_location14\[\r\n\]+$bp_location14\[\t \]+void marker4.*" {
|
|
|
861f93 |
+ # marker4() is defined at line 46 when compiled with -DPROTOTYPES
|
|
|
861f93 |
+ pass "run until breakpoint set at small function, optimized file (line bp_location14)"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re ".*$gdb_prompt " {
|
|
|
861f93 |
+ fail "run until breakpoint set at small function, optimized file"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ timeout {
|
|
|
861f93 |
+ fail "run until breakpoint set at small function, optimized file (timeout)"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Reset the default arguments for VxWorks
|
|
|
861f93 |
+if [istarget "*-*-vxworks*"] {
|
|
|
861f93 |
+ set timeout 10
|
|
|
861f93 |
+ verbose "Timeout is now $timeout seconds" 2
|
|
|
861f93 |
+ send_gdb "set args main\n"
|
|
|
861f93 |
+ gdb_expect -re ".*$gdb_prompt $" {}
|
|
|
861f93 |
+}
|
|
|
861f93 |
Index: gdb-7.5.91.20130323/gdb/testsuite/gdb.pie/corefile.exp
|
|
|
861f93 |
===================================================================
|
|
|
861f93 |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
861f93 |
+++ gdb-7.5.91.20130323/gdb/testsuite/gdb.pie/corefile.exp 2013-03-23 19:47:24.194683332 +0100
|
|
|
861f93 |
@@ -0,0 +1,233 @@
|
|
|
861f93 |
+# Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
|
|
|
861f93 |
+# Free Software Foundation, Inc.
|
|
|
861f93 |
+
|
|
|
861f93 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
861f93 |
+# it under the terms of the GNU General Public License as published by
|
|
|
861f93 |
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
861f93 |
+# (at your option) any later version.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# This program is distributed in the hope that it will be useful,
|
|
|
861f93 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
861f93 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
861f93 |
+# GNU General Public License for more details.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# You should have received a copy of the GNU General Public License
|
|
|
861f93 |
+# along with this program; if not, write to the Free Software
|
|
|
861f93 |
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
861f93 |
+
|
|
|
861f93 |
+# This file was written by Fred Fish. (fnf@cygnus.com)
|
|
|
861f93 |
+
|
|
|
861f93 |
+# are we on a target board
|
|
|
861f93 |
+if ![isnative] then {
|
|
|
861f93 |
+ return
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+set testfile "coremaker"
|
|
|
861f93 |
+set srcfile ${testfile}.c
|
|
|
861f93 |
+set binfile ${objdir}/${subdir}/${testfile}
|
|
|
861f93 |
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug "additional_flags=-fpie -pie"}] != "" } {
|
|
|
861f93 |
+ gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Create and source the file that provides information about the compiler
|
|
|
861f93 |
+# used to compile the test case.
|
|
|
861f93 |
+if [get_compiler_info ${binfile}] {
|
|
|
861f93 |
+ return -1;
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Create a core file named "corefile" rather than just "core", to
|
|
|
861f93 |
+# avoid problems with sys admin types that like to regularly prune all
|
|
|
861f93 |
+# files named "core" from the system.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# Arbitrarily try setting the core size limit to "unlimited" since
|
|
|
861f93 |
+# this does not hurt on systems where the command does not work and
|
|
|
861f93 |
+# allows us to generate a core on systems where it does.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# Some systems append "core" to the name of the program; others append
|
|
|
861f93 |
+# the name of the program to "core"; still others (like Linux, as of
|
|
|
861f93 |
+# May 2003) create cores named "core.PID". In the latter case, we
|
|
|
861f93 |
+# could have many core files lying around, and it may be difficult to
|
|
|
861f93 |
+# tell which one is ours, so let's run the program in a subdirectory.
|
|
|
861f93 |
+set found 0
|
|
|
861f93 |
+set coredir "${objdir}/${subdir}/coredir.[getpid]"
|
|
|
861f93 |
+file mkdir $coredir
|
|
|
861f93 |
+catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\""
|
|
|
861f93 |
+# remote_exec host "${binfile}"
|
|
|
861f93 |
+foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" {
|
|
|
861f93 |
+ if [remote_file build exists $i] {
|
|
|
861f93 |
+ remote_exec build "mv $i ${objdir}/${subdir}/corefile"
|
|
|
861f93 |
+ set found 1
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+}
|
|
|
861f93 |
+# Check for "core.PID".
|
|
|
861f93 |
+if { $found == 0 } {
|
|
|
861f93 |
+ set names [glob -nocomplain -directory $coredir core.*]
|
|
|
861f93 |
+ if {[llength $names] == 1} {
|
|
|
861f93 |
+ set corefile [file join $coredir [lindex $names 0]]
|
|
|
861f93 |
+ remote_exec build "mv $corefile ${objdir}/${subdir}/corefile"
|
|
|
861f93 |
+ set found 1
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+}
|
|
|
861f93 |
+if { $found == 0 } {
|
|
|
861f93 |
+ # The braindamaged HPUX shell quits after the ulimit -c above
|
|
|
861f93 |
+ # without executing ${binfile}. So we try again without the
|
|
|
861f93 |
+ # ulimit here if we didn't find a core file above.
|
|
|
861f93 |
+ # Oh, I should mention that any "braindamaged" non-Unix system has
|
|
|
861f93 |
+ # the same problem. I like the cd bit too, it's really neat'n stuff.
|
|
|
861f93 |
+ catch "system \"(cd ${objdir}/${subdir}; ${binfile}; true) >/dev/null 2>&1\""
|
|
|
861f93 |
+ foreach i "${objdir}/${subdir}/core ${objdir}/${subdir}/core.coremaker.c ${binfile}.core" {
|
|
|
861f93 |
+ if [remote_file build exists $i] {
|
|
|
861f93 |
+ remote_exec build "mv $i ${objdir}/${subdir}/corefile"
|
|
|
861f93 |
+ set found 1
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Try to clean up after ourselves.
|
|
|
861f93 |
+remote_file build delete [file join $coredir coremmap.data]
|
|
|
861f93 |
+remote_exec build "rmdir $coredir"
|
|
|
861f93 |
+
|
|
|
861f93 |
+if { $found == 0 } {
|
|
|
861f93 |
+ warning "can't generate a core file - core tests suppressed - check ulimit -c"
|
|
|
861f93 |
+ return 0
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# Test that we can simply startup with a "-core=corefile" command line arg
|
|
|
861f93 |
+# and recognize that the core file is a valid, usable core file.
|
|
|
861f93 |
+# To do this, we must shutdown the currently running gdb and restart
|
|
|
861f93 |
+# with the -core args. We can't use gdb_start because it looks for
|
|
|
861f93 |
+# the first gdb prompt, and the message we are looking for occurs
|
|
|
861f93 |
+# before the first prompt. Also, we can't include GDBFLAGS because
|
|
|
861f93 |
+# if it is empty, this confuses gdb with an empty argument that it
|
|
|
861f93 |
+# grumbles about (said grumbling currently being ignored in gdb_start).
|
|
|
861f93 |
+# **FIXME**
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# Another problem is that on some systems (solaris for example), there
|
|
|
861f93 |
+# is apparently a limit on the length of a fully specified path to
|
|
|
861f93 |
+# the coremaker executable, at about 80 chars. For this case, consider
|
|
|
861f93 |
+# it a pass, but note that the program name is bad.
|
|
|
861f93 |
+
|
|
|
861f93 |
+gdb_exit
|
|
|
861f93 |
+if $verbose>1 then {
|
|
|
861f93 |
+ send_user "Spawning $GDB -nw $GDBFLAGS -core=$objdir/$subdir/corefile\n"
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+set oldtimeout $timeout
|
|
|
861f93 |
+set timeout [expr "$timeout + 60"]
|
|
|
861f93 |
+verbose "Timeout is now $timeout seconds" 2
|
|
|
861f93 |
+eval "spawn $GDB -nw $GDBFLAGS -core=$objdir/$subdir/corefile"
|
|
|
861f93 |
+expect {
|
|
|
861f93 |
+ -re "Couldn't find .* registers in core file.*$gdb_prompt $" {
|
|
|
861f93 |
+ fail "args: -core=corefile (couldn't find regs)"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
|
|
|
861f93 |
+ pass "args: -core=corefile"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
|
|
|
861f93 |
+ pass "args: -core=corefile (with bad program name)"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re ".*registers from core file: File in wrong format.* $" {
|
|
|
861f93 |
+ fail "args: -core=corefile (could not read registers from core file)"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re ".*$gdb_prompt $" { fail "args: -core=corefile" }
|
|
|
861f93 |
+ timeout { fail "(timeout) starting with -core" }
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+
|
|
|
861f93 |
+#
|
|
|
861f93 |
+# Test that startup with both an executable file and -core argument.
|
|
|
861f93 |
+# See previous comments above, they are still applicable.
|
|
|
861f93 |
+#
|
|
|
861f93 |
+
|
|
|
861f93 |
+close;
|
|
|
861f93 |
+
|
|
|
861f93 |
+if $verbose>1 then {
|
|
|
861f93 |
+ send_user "Spawning $GDB -nw $GDBFLAGS $binfile -core=$objdir/$subdir/corefile\n"
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+
|
|
|
861f93 |
+eval "spawn $GDB -nw $GDBFLAGS $binfile -core=$objdir/$subdir/corefile";
|
|
|
861f93 |
+expect {
|
|
|
861f93 |
+ -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
|
|
|
861f93 |
+ pass "args: execfile -core=corefile"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
|
|
|
861f93 |
+ pass "args: execfile -core=corefile (with bad program name)"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re ".*registers from core file: File in wrong format.* $" {
|
|
|
861f93 |
+ fail "args: execfile -core=corefile (could not read registers from core file)"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re ".*$gdb_prompt $" { fail "args: execfile -core=corefile" }
|
|
|
861f93 |
+ timeout { fail "(timeout) starting with -core" }
|
|
|
861f93 |
+}
|
|
|
861f93 |
+set timeout $oldtimeout
|
|
|
861f93 |
+verbose "Timeout is now $timeout seconds" 2
|
|
|
861f93 |
+
|
|
|
861f93 |
+close;
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Now restart normally.
|
|
|
861f93 |
+
|
|
|
861f93 |
+gdb_start
|
|
|
861f93 |
+gdb_reinitialize_dir $srcdir/$subdir
|
|
|
861f93 |
+gdb_load ${binfile}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Test basic corefile recognition via core-file command.
|
|
|
861f93 |
+
|
|
|
861f93 |
+send_gdb "core-file $objdir/$subdir/corefile\n"
|
|
|
861f93 |
+gdb_expect {
|
|
|
861f93 |
+ -re ".* program is being debugged already.*y or n. $" {
|
|
|
861f93 |
+ # gdb_load may connect us to a gdbserver.
|
|
|
861f93 |
+ send_gdb "y\n"
|
|
|
861f93 |
+ exp_continue;
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "Core was generated by .*coremaker.*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
|
|
|
861f93 |
+ pass "core-file command"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "Core was generated by .*\r\n\#0 .*\(\).*\r\n$gdb_prompt $" {
|
|
|
861f93 |
+ pass "core-file command (with bad program name)"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re ".*registers from core file: File in wrong format.* $" {
|
|
|
861f93 |
+ fail "core-file command (could not read registers from core file)"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re ".*$gdb_prompt $" { fail "core-file command" }
|
|
|
861f93 |
+ timeout { fail "(timeout) core-file command" }
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Test correct mapping of corefile sections by printing some variables.
|
|
|
861f93 |
+
|
|
|
861f93 |
+gdb_test "print coremaker_data" "\\\$$decimal = 202"
|
|
|
861f93 |
+gdb_test "print coremaker_bss" "\\\$$decimal = 10"
|
|
|
861f93 |
+gdb_test "print coremaker_ro" "\\\$$decimal = 201"
|
|
|
861f93 |
+
|
|
|
861f93 |
+gdb_test "print func2::coremaker_local" "\\\$$decimal = \\{0, 1, 2, 3, 4\\}"
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Somehow we better test the ability to read the registers out of the core
|
|
|
861f93 |
+# file correctly. I don't think the other tests do this.
|
|
|
861f93 |
+
|
|
|
861f93 |
+gdb_test "bt" "abort.*func2.*func1.*main.*" "backtrace in corefile.exp"
|
|
|
861f93 |
+gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp"
|
|
|
861f93 |
+
|
|
|
861f93 |
+# Test ability to read mmap'd data
|
|
|
861f93 |
+
|
|
|
861f93 |
+gdb_test "x/8bd buf1" ".*:.*0.*1.*2.*3.*4.*5.*6.*7" "accessing original mmap data in core file"
|
|
|
861f93 |
+setup_xfail "*-*-sunos*" "*-*-ultrix*" "*-*-aix*"
|
|
|
861f93 |
+set test "accessing mmapped data in core file"
|
|
|
861f93 |
+gdb_test_multiple "x/8bd buf2" "$test" {
|
|
|
861f93 |
+ -re ".*:.*0.*1.*2.*3.*4.*5.*6.*7.*$gdb_prompt $" {
|
|
|
861f93 |
+ pass "$test"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "0x\[f\]*:.*Cannot access memory at address 0x\[f\]*.*$gdb_prompt $" {
|
|
|
861f93 |
+ fail "$test (mapping failed at runtime)"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+ -re "0x.*:.*Cannot access memory at address 0x.*$gdb_prompt $" {
|
|
|
861f93 |
+ fail "$test (mapping address not found in core file)"
|
|
|
861f93 |
+ }
|
|
|
861f93 |
+}
|
|
|
861f93 |
+
|
|
|
861f93 |
+# test reinit_frame_cache
|
|
|
861f93 |
+
|
|
|
861f93 |
+gdb_load ${binfile}
|
|
|
861f93 |
+gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp (reinit)"
|
|
|
861f93 |
+
|
|
|
861f93 |
+gdb_test "core" "No core file now."
|
|
|
861f93 |
Index: gdb-7.5.91.20130323/gdb/testsuite/gdb.pie/Makefile.in
|
|
|
861f93 |
===================================================================
|
|
|
861f93 |
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
861f93 |
+++ gdb-7.5.91.20130323/gdb/testsuite/gdb.pie/Makefile.in 2013-03-23 19:47:24.194683332 +0100
|
|
|
861f93 |
@@ -0,0 +1,19 @@
|
|
|
861f93 |
+VPATH = @srcdir@
|
|
|
861f93 |
+srcdir = @srcdir@
|
|
|
861f93 |
+
|
|
|
861f93 |
+EXECUTABLES =
|
|
|
861f93 |
+MISCELLANEOUS = arch.inc
|
|
|
861f93 |
+
|
|
|
861f93 |
+all info install-info dvi install uninstall installcheck check:
|
|
|
861f93 |
+ @echo "Nothing to be done for $@..."
|
|
|
861f93 |
+
|
|
|
861f93 |
+clean mostlyclean:
|
|
|
861f93 |
+ -rm -f *~ *.o a.out *.x *.ci *.tmp
|
|
|
861f93 |
+ -rm -f core core.coremaker coremaker.core corefile $(EXECUTABLES)
|
|
|
861f93 |
+ -rm -f $(MISCELLANEOUS)
|
|
|
861f93 |
+
|
|
|
861f93 |
+distclean maintainer-clean realclean: clean
|
|
|
861f93 |
+ -rm -f *~ core
|
|
|
861f93 |
+ -rm -f Makefile config.status config.log
|
|
|
861f93 |
+ -rm -f *-init.exp
|
|
|
861f93 |
+ -rm -fr *.log summary detail *.plog *.sum *.psum site.*
|