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