rpms/gdb/F-12 gdb-archer-pie-addons.patch, NONE, 1.1 gdb-archer-pie.patch, NONE, 1.1 gdb-readline-6.0-signal.patch, NONE, 1.1 gdb-x86_64-i386-syscall-restart.patch, NONE, 1.1 gdb-6.3-test-pie-20050107.patch, 1.11, 1.12 gdb-7.0-upstream.patch, 1.1, 1.2 gdb-archer.patch, 1.37, 1.38 gdb.spec, 1.399, 1.400 gdb-6.3-nonthreaded-wp-20050117.patch, 1.8, NONE gdb-6.3-pie-20050110.patch, 1.26, NONE

Jan Kratochvil jkratoch at fedoraproject.org
Mon Dec 7 18:39:27 UTC 2009


Author: jkratoch

Update of /cvs/pkgs/rpms/gdb/F-12
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv27834

Modified Files:
	gdb-6.3-test-pie-20050107.patch gdb-7.0-upstream.patch 
	gdb-archer.patch gdb.spec 
Added Files:
	gdb-archer-pie-addons.patch gdb-archer-pie.patch 
	gdb-readline-6.0-signal.patch 
	gdb-x86_64-i386-syscall-restart.patch 
Removed Files:
	gdb-6.3-nonthreaded-wp-20050117.patch 
	gdb-6.3-pie-20050110.patch 
Log Message:
* Mon Dec  7 2009 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.0-9.fc12
- Replace the PIE (Position Indepdent Executable) support patch by a new one.
- Drop gdb-6.3-nonthreaded-wp-20050117.patch as fuzzy + redundant.
- Fix callback-mode readline-6.0 regression for CTRL-C.
- Fix syscall restarts for amd64->i386 biarch.
- Various testsuite results stability fixes.
- Fix crash on reading stabs on 64bit (BZ 537837).
- archer-jankratochvil-fedora12 commit: 16276c1aad1366b92e687c72cab30192280e1906
- archer-jankratochvil-pie-fedora12 ct: 2ae60b5156d43aabfe5757940eaf7b4370fb05d2


gdb-archer-pie-addons.patch:
 dwarf2read.c |   17 +++++++++++++----
 exec.c       |   20 ++++++++++++++++++--
 gdbtypes.h   |    3 +++
 jv-lang.c    |    6 ++++--
 solib-svr4.c |    8 ++++++--
 solib.c      |   13 +++++++++++++
 solib.h      |    2 ++
 solist.h     |    3 +++
 symfile.c    |   35 ++++++++++++++++++++++++++++-------
 value.c      |    6 ++++--
 10 files changed, 94 insertions(+), 19 deletions(-)

--- NEW FILE gdb-archer-pie-addons.patch ---
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -5754,7 +5754,12 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
 {
   struct attribute *attr;
   struct symbol *sym;
-  CORE_ADDR base = (CORE_ADDR) 0;
+  struct objfile *objfile = cu->objfile;
+  CORE_ADDR baseaddr = ANOFFSET (objfile->section_offsets,
+				 SECT_OFF_TEXT (objfile));
+  /* This is used only for DW_AT_data_member_location entries.  */
+  CORE_ADDR base = 0;
+  int base_p = 0;
 
   attr = dwarf2_attr (die, DW_AT_location, cu);
   if (attr)
@@ -5763,6 +5768,7 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
       if (attr_form_is_block (attr))
 	{
 	  base = decode_locdesc (DW_BLOCK (attr), cu);
+	  base_p = 1;
 	}
       else if (attr_form_is_section_offset (attr))
 	{
@@ -5824,12 +5830,15 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
 	      else
 		dwarf2_complex_location_expr_complaint ();
 
-	      SYMBOL_VALUE_ADDRESS (sym) = base + byte_offset;
+	      if (!base_p)
+		dwarf2_invalid_attrib_class_complaint
+		  ("DW_AT_data_member_location", "common block member");
+	      SYMBOL_VALUE_ADDRESS (sym) = base + byte_offset + baseaddr;
 	      add_symbol_to_list (sym, &global_symbols);
 	    }
 
 	  if (SYMBOL_CLASS (sym) == LOC_STATIC)
-	    SET_FIELD_PHYSADDR (*field, SYMBOL_VALUE_ADDRESS (sym));
+	    SET_FIELD_PHYSADDR (*field, SYMBOL_VALUE_ADDRESS (sym) - baseaddr);
 	  else
 	    SET_FIELD_PHYSNAME (*field, SYMBOL_LINKAGE_NAME (sym));
 	  FIELD_TYPE (*field) = SYMBOL_TYPE (sym);
@@ -5843,7 +5852,7 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
 
       sym = new_symbol (die, type, cu);
       /* SYMBOL_VALUE_ADDRESS never gets used as all its fields are static.  */
-      SYMBOL_VALUE_ADDRESS (sym) = base;
+      SYMBOL_VALUE_ADDRESS (sym) = base + baseaddr;
 
       set_die_type (die, type, cu);
     }
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -32,6 +32,7 @@
 #include "exec.h"
 #include "observer.h"
 #include "arch-utils.h"
+#include "solib.h"
 
 #include <fcntl.h>
 #include "readline/readline.h"
@@ -220,6 +221,10 @@ exec_file_attach (char *filename, int from_tty)
       char *scratch_pathname;
       int scratch_chan;
       struct target_section *sections = NULL, *sections_end = NULL;
+      struct target_section *p;
+      int addr_bit;
+      CORE_ADDR mask = CORE_ADDR_MAX;
+      CORE_ADDR displacement;
 
       scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, filename,
 		   write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY,
@@ -288,12 +293,23 @@ exec_file_attach (char *filename, int from_tty)
 		 scratch_pathname, bfd_errmsg (bfd_get_error ()));
 	}
 
+      set_gdbarch_from_file (exec_bfd);
+
+      addr_bit = gdbarch_addr_bit (target_gdbarch);
+      if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
+	mask = ((CORE_ADDR) 1 << addr_bit) - 1;
+
+      displacement = solib_exec_displacement ();
+      for (p = sections; p < sections_end; p++)
+	{
+	  p->addr = (p->addr + displacement) & mask;
+	  p->endaddr = (p->endaddr + displacement) & mask;
+	}
+
       exec_bfd_mtime = bfd_get_mtime (exec_bfd);
 
       validate_files ();
 
-      set_gdbarch_from_file (exec_bfd);
-
       /* Add the executable's sections to the current address spaces'
 	 list of sections.  */
       add_target_sections (sections, sections_end);
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -966,6 +966,7 @@ extern void allocate_cplus_struct_type (struct type *);
 #define FIELD_LOC_KIND(thisfld) ((thisfld).loc_kind)
 #define FIELD_BITPOS(thisfld) ((thisfld).loc.bitpos)
 #define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc.physname)
+/* This address is unrelocated by the objfile's ANOFFSET.  */
 #define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc.physaddr)
 #define FIELD_DWARF_BLOCK(thisfld) ((thisfld).loc.dwarf_block)
 #define SET_FIELD_BITPOS(thisfld, bitpos)			\
@@ -974,6 +975,7 @@ extern void allocate_cplus_struct_type (struct type *);
 #define SET_FIELD_PHYSNAME(thisfld, name)			\
   (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSNAME,		\
    FIELD_STATIC_PHYSNAME (thisfld) = (name))
+/* This address is unrelocated by the objfile's ANOFFSET.  */
 #define SET_FIELD_PHYSADDR(thisfld, addr)			\
   (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSADDR,		\
    FIELD_STATIC_PHYSADDR (thisfld) = (addr))
@@ -989,6 +991,7 @@ extern void allocate_cplus_struct_type (struct type *);
 #define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND (TYPE_FIELD (thistype, n))
 #define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS (TYPE_FIELD (thistype, n))
 #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME (TYPE_FIELD (thistype, n))
+/* This address is unrelocated by the objfile's ANOFFSET.  */
 #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR (TYPE_FIELD (thistype, n))
 #define TYPE_FIELD_DWARF_BLOCK(thistype, n) FIELD_DWARF_BLOCK (TYPE_FIELD (thistype, n))
 #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL(TYPE_FIELD(thistype,n))
--- a/gdb/jv-lang.c
+++ b/gdb/jv-lang.c
@@ -416,7 +416,8 @@ java_link_class_type (struct gdbarch *gdbarch,
 
   fields = NULL;
   nfields--;			/* First set up dummy "class" field. */
-  SET_FIELD_PHYSADDR (TYPE_FIELD (type, nfields), value_address (clas));
+  SET_FIELD_PHYSADDR (TYPE_FIELD (type, nfields), value_address (clas)
+    - (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type)))));
   TYPE_FIELD_NAME (type, nfields) = "class";
   TYPE_FIELD_TYPE (type, nfields) = value_type (clas);
   SET_TYPE_FIELD_PRIVATE (type, nfields);
@@ -462,7 +463,8 @@ java_link_class_type (struct gdbarch *gdbarch,
 	  SET_TYPE_FIELD_PROTECTED (type, i);
 	}
       if (accflags & 0x0008)	/* ACC_STATIC */
-	SET_FIELD_PHYSADDR (TYPE_FIELD (type, i), boffset);
+	SET_FIELD_PHYSADDR (TYPE_FIELD (type, i), boffset
+	  - (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type)))));
       else
 	TYPE_FIELD_BITPOS (type, i) = 8 * boffset;
       if (accflags & 0x8000)	/* FIELD_UNRESOLVED_FLAG */
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1621,7 +1621,10 @@ svr4_exec_displacement (void)
   if (target_auxv_search (&current_target, AT_ENTRY, &entry_point) == 1)
     return entry_point - exec_entry_point (exec_bfd, &current_target);
 
-  return svr4_static_exec_displacement ();
+  if (!ptid_equal (inferior_ptid, null_ptid))
+    return svr4_static_exec_displacement ();
+
+  return 0;
 }
 
 /* Relocate the main executable.  This function should be called upon
@@ -1632,7 +1635,7 @@ svr4_exec_displacement (void)
 static void
 svr4_relocate_main_executable (void)
 {
-  CORE_ADDR displacement = svr4_exec_displacement ();
+  CORE_ADDR displacement = solib_exec_displacement ();
 
   /* Even if DISPLACEMENT is 0 still try to relocate it as this is a new
      difference of in-memory vs. in-file addresses and we could already
@@ -1975,6 +1978,7 @@ _initialize_svr4_solib (void)
   svr4_so_ops.free_so = svr4_free_so;
   svr4_so_ops.clear_solib = svr4_clear_solib;
   svr4_so_ops.solib_create_inferior_hook = svr4_solib_create_inferior_hook;
+  svr4_so_ops.exec_displacement = svr4_exec_displacement;
   svr4_so_ops.special_symbol_handling = svr4_special_symbol_handling;
   svr4_so_ops.current_sos = svr4_current_sos;
   svr4_so_ops.open_symbol_file_object = open_symbol_file_object;
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -1014,6 +1014,19 @@ solib_create_inferior_hook (int from_tty)
   ops->solib_create_inferior_hook (from_tty);
 }
 
+/* Query the difference of in-memory VMA addresses vs. exec_bfd VMAs.  */
+
+CORE_ADDR
+solib_exec_displacement (void)
+{
+  struct target_so_ops *ops = solib_ops (target_gdbarch);
+
+  if (ops->exec_displacement != NULL)
+    return (*ops->exec_displacement) ();
+  else
+    return 0;
+}
+
 /* GLOBAL FUNCTION
 
    in_solib_dynsym_resolve_code -- check to see if an address is in
--- a/gdb/solib.h
+++ b/gdb/solib.h
@@ -43,6 +43,8 @@ extern int solib_read_symbols (struct so_list *, int);
 
 extern void solib_create_inferior_hook (int from_tty);
 
+extern CORE_ADDR solib_exec_displacement (void);
+
 /* If ADDR lies in a shared library, return its name.  */
 
 extern char *solib_name_from_address (CORE_ADDR);
--- a/gdb/solist.h
+++ b/gdb/solist.h
@@ -89,6 +89,9 @@ struct target_so_ops
     /* Target dependent code to run after child process fork.  */
     void (*solib_create_inferior_hook) (int from_tty);
 
+    /* Query the difference of in-memory VMA addresses vs. exec_bfd VMAs.  */
+    CORE_ADDR (*exec_displacement) (void);
+
     /* Do additional symbol handling, lookup, etc. after symbols
        for a shared object have been loaded.  */
     void (*special_symbol_handling) (void);
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -873,15 +873,36 @@ syms_from_objfile (struct objfile *objfile,
      if an error occurs during symbol reading.  */
   old_chain = make_cleanup_free_objfile (objfile);
 
-  /* If ADDRS and OFFSETS are both NULL, put together a dummy address
-     list.  We now establish the convention that an addr of zero means
-     no load address was specified. */
+  /* If ADDRS and OFFSETS are both NULL, put together a dummy offset list.  */
+
   if (! addrs && ! offsets)
     {
-      local_addr
-	= alloc_section_addr_info (bfd_count_sections (objfile->obfd));
-      make_cleanup (xfree, local_addr);
-      addrs = local_addr;
+      /* Relocateble files have an exception in default_symfile_offsets which
+	 applies only for ADDRS.  But calling solib_exec_displacement is more
+	 suitable for OFFSETS.  Fortunately we never need the both
+	 functionalities simultaneously and in other cases zeroed ADDRS and
+	 zeroed OFFSETS are equivalent.  */
+
+      if ((bfd_get_file_flags (objfile->obfd) & (EXEC_P | DYNAMIC)) == 0)
+	{
+	  local_addr
+		 = alloc_section_addr_info (bfd_count_sections (objfile->obfd));
+	  make_cleanup (xfree, local_addr);
+	  addrs = local_addr;
+	}
+      else
+	{
+	  CORE_ADDR displacement = 0;
+	  int i;
+
+	  if (mainline)
+	    displacement = solib_exec_displacement ();
+
+	  num_offsets = bfd_count_sections (objfile->obfd);
+	  offsets = alloca (SIZEOF_N_SECTION_OFFSETS (num_offsets));
+	  for (i = 0; i < num_offsets; i++)
+	    offsets->offsets[i] = displacement;
+	}
     }
 
   /* Now either addrs or offsets is non-zero.  */
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1890,7 +1890,8 @@ value_static_field (struct type *type, int fieldno)
   if (TYPE_FIELD_LOC_KIND (type, fieldno) == FIELD_LOC_KIND_PHYSADDR)
     {
       retval = value_at (TYPE_FIELD_TYPE (type, fieldno),
-			 TYPE_FIELD_STATIC_PHYSADDR (type, fieldno));
+			 TYPE_FIELD_STATIC_PHYSADDR (type, fieldno)
+			   + (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type)))));
     }
   else
     {
@@ -1920,7 +1921,8 @@ value_static_field (struct type *type, int fieldno)
  	}
       if (retval && VALUE_LVAL (retval) == lval_memory)
 	SET_FIELD_PHYSADDR (TYPE_FIELD (type, fieldno),
-			    value_address (retval));
+			    value_address (retval)
+			      - (TYPE_OBJFILE (type) == NULL ? 0 : ANOFFSET (TYPE_OBJFILE (type)->section_offsets, SECT_OFF_TEXT (TYPE_OBJFILE (type)))));
     }
   return retval;
 }

gdb-archer-pie.patch:
 b/gdb/auxv.c                                    |  162 ++++++-
 b/gdb/auxv.h                                    |    6 
 b/gdb/breakpoint.c                              |    3 
 b/gdb/defs.h                                    |   15 
 b/gdb/exec.c                                    |   29 +
 b/gdb/infcmd.c                                  |   36 -
 b/gdb/infrun.c                                  |    2 
 b/gdb/linux-nat.c                               |    2 
 b/gdb/linux-tdep.c                              |   31 -
 b/gdb/nto-procfs.c                              |    4 
 b/gdb/objfiles.c                                |   54 ++
 b/gdb/procfs.c                                  |    2 
 b/gdb/solib-darwin.c                            |    2 
 b/gdb/solib-frv.c                               |    2 
 b/gdb/solib-irix.c                              |    4 
 b/gdb/solib-null.c                              |    2 
 b/gdb/solib-osf.c                               |    2 
 b/gdb/solib-pa64.c                              |    2 
 b/gdb/solib-som.c                               |    2 
 b/gdb/solib-spu.c                               |   26 -
 b/gdb/solib-sunos.c                             |    2 
 b/gdb/solib-svr4.c                              |  247 ++++++----
 b/gdb/solib-target.c                            |    2 
 b/gdb/solib.c                                   |   19 
 b/gdb/solib.h                                   |    2 
 b/gdb/solist.h                                  |    2 
 b/gdb/symfile.c                                 |  234 ++++++----
 b/gdb/symfile.h                                 |   10 
 b/gdb/symtab.c                                  |    7 
 b/gdb/testsuite/gdb.base/break-interp-lib.c     |   40 +
 b/gdb/testsuite/gdb.base/break-interp-main.c    |   30 +
 b/gdb/testsuite/gdb.base/break-interp.exp       |  545 ++++++++++++++++++++++++
 b/gdb/testsuite/gdb.base/corefile.exp           |   89 ---
 b/gdb/testsuite/gdb.base/valgrind-db-attach.c   |   30 +
 b/gdb/testsuite/gdb.base/valgrind-db-attach.exp |   74 +++
 b/gdb/testsuite/gdb.dwarf2/dw2-ranges.exp       |    6 
 b/gdb/testsuite/lib/gdb.exp                     |   79 +++
 gdb/testsuite/gdb.base/pie-support.c            |   34 -
 gdb/testsuite/gdb.base/pie-support.exp          |   58 --
 39 files changed, 1430 insertions(+), 468 deletions(-)

--- NEW FILE gdb-archer-pie.patch ---
http://sourceware.org/gdb/wiki/ProjectArcher
http://sourceware.org/gdb/wiki/ArcherBranchManagement

archer-jankratochvil-pie-fedora12
GIT snapshot:
commit 2ae60b5156d43aabfe5757940eaf7b4370fb05d2


diff --git a/gdb/auxv.c b/gdb/auxv.c
index 7b4ecbe..7df8eb5 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -25,6 +25,7 @@
 #include "inferior.h"
 #include "valprint.h"
 #include "gdb_assert.h"
+#include "gdbcore.h"
 
 #include "auxv.h"
 #include "elf/common.h"
@@ -33,15 +34,11 @@
 #include <fcntl.h>
 
 
-/* This function is called like a to_xfer_partial hook, but must be
-   called with TARGET_OBJECT_AUXV.  It handles access via
-   /proc/PID/auxv, which is a common method for native targets.  */
+/* This function handles access via /proc/PID/auxv, which is a common method
+   for native targets.  */
 
-LONGEST
-procfs_xfer_auxv (struct target_ops *ops,
-		  enum target_object object,
-		  const char *annex,
-		  gdb_byte *readbuf,
+static LONGEST
+procfs_xfer_auxv (gdb_byte *readbuf,
 		  const gdb_byte *writebuf,
 		  ULONGEST offset,
 		  LONGEST len)
@@ -50,9 +47,6 @@ procfs_xfer_auxv (struct target_ops *ops,
   int fd;
   LONGEST n;
 
-  gdb_assert (object == TARGET_OBJECT_AUXV);
-  gdb_assert (readbuf || writebuf);
-
   pathname = xstrprintf ("/proc/%d/auxv", PIDGET (inferior_ptid));
   fd = open (pathname, writebuf != NULL ? O_WRONLY : O_RDONLY);
   xfree (pathname);
@@ -72,6 +66,152 @@ procfs_xfer_auxv (struct target_ops *ops,
   return n;
 }
 
+/* This function handles access via ld.so's symbol `_dl_auxv'.  */
+
+static LONGEST
+ld_so_xfer_auxv (gdb_byte *readbuf,
+		 const gdb_byte *writebuf,
+		 ULONGEST offset,
+		 LONGEST len)
+{
+  struct minimal_symbol *msym;
+  CORE_ADDR data_address, pointer_address;
+  struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+  size_t ptr_size = TYPE_LENGTH (ptr_type);
+  size_t auxv_pair_size = 2 * ptr_size;
+  gdb_byte *ptr_buf = alloca (ptr_size);
+  LONGEST retval;
+  size_t block;
+
+  msym = lookup_minimal_symbol ("_dl_auxv", NULL, NULL);
+  if (msym == NULL)
+    return -1;
+
+  if (MSYMBOL_SIZE (msym) != ptr_size)
+    return -1;
+
+  /* POINTER_ADDRESS is a location where the `_dl_auxv' variable resides.
+     DATA_ADDRESS is the inferior value present in `_dl_auxv', therefore the
+     real inferior AUXV address.  */
+
+  pointer_address = SYMBOL_VALUE_ADDRESS (msym);
+
+  data_address = read_memory_typed_address (pointer_address, ptr_type);
+
+  /* Possibly still not initialized such as during an inferior startup.  */
+  if (data_address == 0)
+    return -1;
+
+  data_address += offset;
+
+  if (writebuf != NULL)
+    {
+      if (target_write_memory (data_address, writebuf, len) == 0)
+	return len;
+      else
+	return -1;
+    }
+
+  /* Stop if trying to read past the existing AUXV block.  The final AT_NULL
+     was already returned before.  */
+
+  if (offset >= auxv_pair_size)
+    {
+      if (target_read_memory (data_address - auxv_pair_size, ptr_buf,
+			      ptr_size) != 0)
+	return -1;
+
+      if (extract_typed_address (ptr_buf, ptr_type) == AT_NULL)
+	return 0;
+    }
+
+  retval = 0;
+  block = 0x400;
+  gdb_assert (block % auxv_pair_size == 0);
+
+  while (len > 0)
+    {
+      if (block > len)
+	block = len;
+
+      /* Reading sizes smaller than AUXV_PAIR_SIZE is not supported.  Tails
+	 unaligned to AUXV_PAIR_SIZE will not be read during a call (they
+	 should be completed during next read with new/extended buffer).  */
+
+      block &= -auxv_pair_size;
+      if (block == 0)
+	return retval;
+
+      if (target_read_memory (data_address, readbuf, block) != 0)
+	{
+	  if (block <= auxv_pair_size)
+	    return retval;
+
+	  block = auxv_pair_size;
+	  continue;
+	}
+
+      data_address += block;
+      len -= block;
+
+      /* Check terminal AT_NULL.  This function is being called indefinitely
+         being extended its READBUF until it returns EOF (0).  */
+
+      while (block >= auxv_pair_size)
+	{
+	  retval += auxv_pair_size;
+
+	  if (extract_typed_address (readbuf, ptr_type) == AT_NULL)
+	    return retval;
+
+	  readbuf += auxv_pair_size;
+	  block -= auxv_pair_size;
+	}
+    }
+
+  return retval;
+}
+
+/* This function is called like a to_xfer_partial hook, but must be
+   called with TARGET_OBJECT_AUXV.  It handles access to AUXV.  */
+
+LONGEST
+memory_xfer_auxv (struct target_ops *ops,
+		  enum target_object object,
+		  const char *annex,
+		  gdb_byte *readbuf,
+		  const gdb_byte *writebuf,
+		  ULONGEST offset,
+		  LONGEST len)
+{
+  /* Workaround gdb-7.0 bug where linux_nat_xfer_partial() does
+       inferior_ptid = pid_to_ptid (GET_LWP (inferior_ptid));
+     and current_inferior() assertion fails not finding the LWP->PID.
+     It got fixed post-gdb-7.0 by:
+       Add base multi-executable/process support to GDB.
+       40ff0a289e6165aa930af284df5c52162cb0cd5f
+     by introducing `current_inferior_'.  */
+  struct inferior *inf = find_inferior_pid (ptid_get_pid (inferior_ptid));
+
+  gdb_assert (object == TARGET_OBJECT_AUXV);
+  gdb_assert (readbuf || writebuf);
+
+   /* ld_so_xfer_auxv is the only function safe for virtual executables being
+      executed by valgrind's memcheck.  As using ld_so_xfer_auxv is problematic
+      during inferior startup GDB does call it only for attached processes.  */
+
+  if (inf == NULL || inf->attach_flag != 0)
+    {
+      LONGEST retval;
+
+      retval = ld_so_xfer_auxv (readbuf, writebuf, offset, len);
+      if (retval != -1)
+	return retval;
+    }
+
+  return procfs_xfer_auxv (readbuf, writebuf, offset, len);
+}
[...2248 lines suppressed...]
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.base/valgrind-db-attach.exp b/gdb/testsuite/gdb.base/valgrind-db-attach.exp
new file mode 100644
index 0000000..ac06fd3
--- /dev/null
+++ b/gdb/testsuite/gdb.base/valgrind-db-attach.exp
@@ -0,0 +1,74 @@
+# Copyright 2009 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+set test valgrind-db-attach
+set srcfile $test.c
+set executable $test
+set binfile ${objdir}/${subdir}/${executable}
+if {[build_executable $test.exp $executable $srcfile {debug}] == -1} {
+    return -1
+}
+
+gdb_exit
+
+# remote_spawn breaks the command on each whitespace despite possible quoting.
+# Use backslash-escaped whitespace there instead:
+
+set db_command "--db-command=$GDB $INTERNAL_GDBFLAGS $GDBFLAGS [host_info gdb_opts] %f %p"
+regsub -all " " $db_command "\\ " db_command
+
+set test "spawn valgrind"
+set cmd "valgrind --db-attach=yes $db_command $binfile"
+set res [remote_spawn host $cmd];
+if { $res < 0 || $res == "" } {
+    verbose -log "Spawning $cmd failed."
+    setup_xfail *-*-*
+    fail $test
+    return -1
+}
+pass $test
+# Declare GDB now as running.
+set gdb_spawn_id -1
+
+set test "valgrind started"
+# The trailing '.' differs for different memcheck versions.
+gdb_test_multiple "" $test {
+    -re "Memcheck, a memory error detector\\.?\r\n" {
+	pass $test
+    }
+    -re "valgrind: failed to start tool 'memcheck' for platform '.*': No such file or directory" {
+	setup_xfail *-*-*
+	fail $test
+	return -1
+    }
+}
+
+set double_free [gdb_get_line_number "double-free"]
+
+gdb_test_multiple "" $test {
+    -re "Invalid free\\(\\) / delete / delete\\\[\\\]\r\n.*: main \\(${srcfile}:$double_free\\)\r\n.*---- Attach to debugger \\? --- \[^\r\n\]* ---- " {
+	send_gdb "y\r"
+    }
+    -re "---- Attach to debugger \\? --- \[^\r\n\]* ---- " {
+	send_gdb "n\r"
+	exp_continue
+    }
+}
+
+# Initialization from default_gdb_start.
+gdb_test "set height 0"
+gdb_test "set width 0"
+
+gdb_test "bt" "in main \\(.*\\) at .*${srcfile}:$double_free"
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-ranges.exp b/gdb/testsuite/gdb.dwarf2/dw2-ranges.exp
index 61e1fe4..9109030 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-ranges.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-ranges.exp
@@ -55,6 +55,12 @@ gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
 gdb_load ${binfile}
 
+# Test also objfile->psymtabs_addrmap relocations for -fPIE -pie builds below.
+# On some targets it may possibly fail but the program is being started only
+# for the PIE build so try it anyway.
+
+runto_main
+
 # Correct output:
 # 	Line 39 of "../.././gdb/testsuite/gdb.dwarf2/dw2-ranges.S" starts at address 0x4 and ends at 0x8.
 # Wrong output:
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index d0c3493..fbf9124 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -2778,6 +2778,11 @@ proc gdb_gnu_strip_debug { dest args } {
       return 1
     }
 
+    # Workaround PR binutils/10802:
+    # Preserve the 'x' bit also for PIEs (Position Independent Executables).
+    set perm [file attributes ${dest} -permissions]
+    file attributes ${stripped_file} -permissions $perm
+
     # Get rid of everything but the debug info, and store result in debug_file
     # This will be in the .debug subdirectory, see above.
     set result [catch "exec $strip_to_file_program --only-keep-debug ${dest} -o ${debug_file}" output]
@@ -2814,7 +2819,12 @@ proc gdb_gnu_strip_debug { dest args } {
       return 1
     }
 
-   return 0
+    # Workaround PR binutils/10802:
+    # Preserve the 'x' bit also for PIEs (Position Independent Executables).
+    set perm [file attributes ${stripped_file} -permissions]
+    file attributes ${dest} -permissions $perm
+
+    return 0
 }
 
 # Test the output of GDB_COMMAND matches the pattern obtained
@@ -3043,3 +3053,70 @@ if {[info exists TRANSCRIPT]} {
     return [uplevel real_send_gdb $args]
   }
 }
+
+proc core_find {binfile {deletefiles {}} {arg ""}} {
+    global objdir subdir
+
+    set destcore "$binfile.core"
+    file delete $destcore
+
+    # Create a core file named "$destcore" rather than just "core", to
+    # avoid problems with sys admin types that like to regularly prune all
+    # files named "core" from the system.
+    #
+    # Arbitrarily try setting the core size limit to "unlimited" since
+    # this does not hurt on systems where the command does not work and
+    # allows us to generate a core on systems where it does.
+    #
+    # Some systems append "core" to the name of the program; others append
+    # the name of the program to "core"; still others (like Linux, as of
+    # May 2003) create cores named "core.PID".  In the latter case, we
+    # could have many core files lying around, and it may be difficult to
+    # tell which one is ours, so let's run the program in a subdirectory.
+    set found 0
+    set coredir "${objdir}/${subdir}/coredir.[getpid]"
+    file mkdir $coredir
+    catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile} ${arg}; true) >/dev/null 2>&1\""
+    #      remote_exec host "${binfile}"
+    foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" {
+	if [remote_file build exists $i] {
+	    remote_exec build "mv $i $destcore"
+	    set found 1
+	}
+    }
+    # Check for "core.PID".
+    if { $found == 0 } {
+	set names [glob -nocomplain -directory $coredir core.*]
+	if {[llength $names] == 1} {
+	    set corefile [file join $coredir [lindex $names 0]]
+	    remote_exec build "mv $corefile $destcore"
+	    set found 1
+	}
+    }
+    if { $found == 0 } {
+	# The braindamaged HPUX shell quits after the ulimit -c above
+	# without executing ${binfile}.  So we try again without the
+	# ulimit here if we didn't find a core file above.
+	# Oh, I should mention that any "braindamaged" non-Unix system has
+	# the same problem. I like the cd bit too, it's really neat'n stuff.
+	catch "system \"(cd ${objdir}/${subdir}; ${binfile}; true) >/dev/null 2>&1\""
+	foreach i "${objdir}/${subdir}/core ${objdir}/${subdir}/core.coremaker.c ${binfile}.core" {
+	    if [remote_file build exists $i] {
+		remote_exec build "mv $i $destcore"
+		set found 1
+	    }
+	}
+    }
+
+    # Try to clean up after ourselves. 
+    foreach deletefile $deletefiles {
+	remote_file build delete [file join $coredir $deletefile]
+    }
+    remote_exec build "rmdir $coredir"
+	
+    if { $found == 0  } {
+	warning "can't generate a core file - core tests suppressed - check ulimit -c"
+	return ""
+    }
+    return $destcore
+}

gdb-readline-6.0-signal.patch:
 config.in                      |    3 +
 configure                      |   72 +++++++++++++++++++----------------------
 configure.ac                   |   12 +++++-
 event-loop.c                   |   14 +++++++
 testsuite/gdb.gdb/selftest.exp |   40 +++++++++++++---------
 5 files changed, 85 insertions(+), 56 deletions(-)

--- NEW FILE gdb-readline-6.0-signal.patch ---
http://sourceware.org/ml/gdb-patches/2009-11/msg00596.html
Subject: [gdb FYI-patch] callback-mode readline-6.0 regression

Hi Chet,

FSF GDB currently ships bundled with readline-5.2 which works fine.
But using --with-system-readline and readline-6.0-patchlevel4 has
a regression:

readline-5.2: Run `gdb -nx -q' and type CTRL-C:
(gdb) Quit
(gdb) _

readline-6.0: Run `gdb -nx -q' and type CTRL-C:
(gdb) _
 = nothing happens (it gets buffered and executed later)
	(It does also FAIL on gdb.gdb/selftest.exp.)

It is because GDB waits in its own poll() mainloop and readline uses via
rl_callback_handler_install and rl_callback_handler_remove.  This way the
readline internal variable _rl_interrupt_immediately remains 0 and CTRL-C gets
only stored to _rl_caught_signal but not executed.

Seen in rl_signal_handler even if _rl_interrupt_immediately is set and
_rl_handle_signal is called then the signal is still stored to
_rl_caught_signal.  In the _rl_interrupt_immediately case it should not be
stored when it was already processed.

rl_signal_handler does `_rl_interrupt_immediately = 0;' - while I am not aware
of its meaning it breaks the nest-counting of other routines which do
`_rl_interrupt_immediately++;' and `_rl_interrupt_immediately--;' possibly
creating problematic `_rl_interrupt_immediately == -1'.

`_rl_interrupt_immediately' is an internal variable, how it could be accessed
by a readline application? (OK, maybe it should not be used.)

Attaching a current GDB-side patch but it must access readline internal
variable _rl_caught_signal and it is generally just a workaround.  Could you
please include support for signals in this asynchronous mode in readline-6.1?
I find it would be enough to make RL_CHECK_SIGNALS public?


GDB: No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu.
But this is not a patch intended to be accepted.


Thanks,
Jan


gdb/
2009-11-29  Jan Kratochvil  <jan.kratochvil at redhat.com>

	* config.in, configure: Regenerate.
	* configure.ac (for readline_echoing_p): Move inside $LIBS change.
	(for _rl_caught_signal): New.
	* event-loop.c: Include readline/readline.h.
	(gdb_do_one_event) [HAVE_READLINE_CAUGHT_SIGNAL]: New.

gdb/testsuite/
2009-11-29  Jan Kratochvil  <jan.kratochvil at redhat.com>

	* gdb.gdb/selftest.exp (backtrace through signal handler): Move before
	SIGINT pass, drop the timeout case.
	(send SIGINT signal to child process): Use gdb_test.
	(backtrace through readline handler): New.

--- a/gdb/config.in
+++ b/gdb/config.in
@@ -351,6 +351,9 @@
 /* Define if Python interpreter is being linked in. */
 #undef HAVE_PYTHON
 
+/* readline-6.0 workaround of blocked signals. */
+#undef HAVE_READLINE_CAUGHT_SIGNAL
+
 /* Define to 1 if you have the `realpath' function. */
 #undef HAVE_REALPATH
 
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -539,17 +539,25 @@ if test "$with_system_readline" = yes; then
   # readline-6.0 started to use the name `_rl_echoing_p'.
   # `$(READLINE_DIR)/' of bundled readline would not resolve in configure.
 
-  AC_MSG_CHECKING([for readline_echoing_p])
   save_LIBS=$LIBS
   LIBS="$LIBS $READLINE"
+  AC_MSG_CHECKING([for readline_echoing_p])
   AC_LINK_IFELSE(AC_LANG_PROGRAM(,[[extern int readline_echoing_p;
 				    return readline_echoing_p;]]),
 		 [READLINE_ECHOING_P=yes],
 		 [READLINE_ECHOING_P=no
 		  AC_DEFINE([readline_echoing_p], [_rl_echoing_p],
 			    [readline-6.0 started to use different name.])])
-  LIBS="$save_LIBS"
   AC_MSG_RESULT([$READLINE_ECHOING_P])
+  AC_MSG_CHECKING([for _rl_caught_signal])
+  AC_LINK_IFELSE(AC_LANG_PROGRAM(,[[extern int volatile _rl_caught_signal;
+				    return _rl_caught_signal;]]),
+		 [READLINE_CAUGHT_SIGNAL=yes
+		  AC_DEFINE([HAVE_READLINE_CAUGHT_SIGNAL],,
+			    [readline-6.0 workaround of blocked signals.])],
+		 [READLINE_CAUGHT_SIGNAL=no])
+  AC_MSG_RESULT([$READLINE_CAUGHT_SIGNAL])
+  LIBS="$save_LIBS"
 else
   READLINE='$(READLINE_DIR)/libreadline.a'
   READLINE_DEPS='$(READLINE)'
--- a/gdb/event-loop.c
+++ b/gdb/event-loop.c
@@ -37,6 +37,7 @@
 #include "exceptions.h"
 #include "gdb_assert.h"
 #include "gdb_select.h"
+#include "readline/readline.h"
 
 /* Data point to pass to the event handler.  */
 typedef union event_data
@@ -411,6 +412,9 @@ gdb_do_one_event (void *data)
   static int event_source_head = 0;
   const int number_of_sources = 3;
   int current = 0;
+#ifdef HAVE_READLINE_CAUGHT_SIGNAL
+  extern int volatile _rl_caught_signal;
+#endif
 
   /* Any events already waiting in the queue?  */
   if (process_event ())
@@ -455,6 +459,16 @@ gdb_do_one_event (void *data)
   if (gdb_wait_for_event (1) < 0)
     return -1;
 
+#ifdef HAVE_READLINE_CAUGHT_SIGNAL
+  if (async_command_editing_p && RL_ISSTATE (RL_STATE_CALLBACK)
+      && _rl_caught_signal)
+    {
+      /* Call RL_CHECK_SIGNALS this way.  */
+      rl_callback_handler_remove ();
+      rl_callback_handler_install (NULL, input_handler);
+    }
+#endif
+
   /* Handle any new events occurred while waiting.  */
   if (process_event ())
     return 1;
--- a/gdb/testsuite/gdb.gdb/selftest.exp
+++ b/gdb/testsuite/gdb.gdb/selftest.exp
@@ -464,31 +464,42 @@ GDB.*Copyright \[0-9\]+ Free Software Foundation, Inc..*$gdb_prompt $"\
 	    fail "$description (timeout)"
 	}
     }
-    
-    set description "send SIGINT signal to child process"
-    send_gdb "signal SIGINT\n"
-    gdb_expect {
-	-re "Continuing with signal SIGINT.*$gdb_prompt $" {
+
+    # get a stack trace with the poll function
+    #
+    # This fails on some linux systems for unknown reasons.  On the
+    # systems where it fails, sometimes it works fine when run manually.
+    # The testsuite failures may not be limited to just aout systems.
+    setup_xfail "i*86-pc-linuxaout-gnu"
+    set description "backtrace through signal handler"
+    gdb_test_multiple "backtrace" $description {
+	-re "#0.*(read|poll).*in main \\(.*\\) at .*gdb\\.c.*$gdb_prompt $" {
 	    pass "$description"
 	}
 	-re ".*$gdb_prompt $" {
+	    # On the alpha, we hit the infamous problem about gdb
+	    # being unable to get the frame pointer (mentioned in
+	    # gdb/README).  As it is intermittent, there is no way to
+	    # XFAIL it which will give us an XPASS if the problem goes
+	    # away.
+	    setup_xfail "alpha*-*-osf*"
 	    fail "$description"
 	}
-	timeout {
-	    fail "$description (timeout)"
-	}
     }
     
-    # get a stack trace
+    gdb_test "signal SIGINT" "Continuing with signal SIGINT.*" \
+	     "send SIGINT signal to child process"
+    
+    # get a stack trace being redelivered by readline
     #
     # This fails on some linux systems for unknown reasons.  On the
     # systems where it fails, sometimes it works fine when run manually.
     # The testsuite failures may not be limited to just aout systems.
+    # Optional system readline may not have symbols to be shown.
     setup_xfail "i*86-pc-linuxaout-gnu"
-    set description "backtrace through signal handler"
-    send_gdb "backtrace\n"
-    gdb_expect {
-	-re "#0.*(read|poll).*in main \\(.*\\) at .*gdb\\.c.*$gdb_prompt $" {
+    set description "backtrace through readline handler"
+    gdb_test_multiple "backtrace" $description {
+	-re "#0.*gdb_do_one_event.*in main \\(.*\\) at .*gdb\\.c.*$gdb_prompt $" {
 	    pass "$description"
 	}
 	-re ".*$gdb_prompt $" {
@@ -500,9 +510,6 @@ GDB.*Copyright \[0-9\]+ Free Software Foundation, Inc..*$gdb_prompt $"\
 	    setup_xfail "alpha*-*-osf*"
 	    fail "$description"
 	}
-	timeout {
-	    fail "$description (timeout)"
-	}
     }
 
 
--- gdb-7.0/gdb/configure	2009-12-07 18:53:30.000000000 +0100
+++ gdb-7.0-x/gdb/configure	2009-12-07 18:53:14.000000000 +0100
@@ -9201,15 +9201,11 @@ if test "$with_system_readline" = yes; t
   # readline-6.0 started to use the name `_rl_echoing_p'.
   # `$(READLINE_DIR)/' of bundled readline would not resolve in configure.
 
-  echo "$as_me:$LINENO: checking for readline_echoing_p" >&5
-echo $ECHO_N "checking for readline_echoing_p... $ECHO_C" >&6
   save_LIBS=$LIBS
   LIBS="$LIBS $READLINE"
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for readline_echoing_p" >&5
+$as_echo_n "checking for readline_echoing_p... " >&6; }
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
@@ -9221,45 +9217,45 @@ extern int readline_echoing_p;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
+if ac_fn_c_try_link "$LINENO"; then :
   READLINE_ECHOING_P=yes
 else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
+  READLINE_ECHOING_P=no
 
-READLINE_ECHOING_P=no
+$as_echo "#define readline_echoing_p _rl_echoing_p" >>confdefs.h
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $READLINE_ECHOING_P" >&5
+$as_echo "$READLINE_ECHOING_P" >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _rl_caught_signal" >&5
+$as_echo_n "checking for _rl_caught_signal... " >&6; }
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-cat >>confdefs.h <<\_ACEOF
-#define readline_echoing_p _rl_echoing_p
+int
+main ()
+{
+extern int volatile _rl_caught_signal;
+				    return _rl_caught_signal;
+  ;
+  return 0;
+}
 _ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  READLINE_CAUGHT_SIGNAL=yes
+
+$as_echo "#define HAVE_READLINE_CAUGHT_SIGNAL /**/" >>confdefs.h
 
+else
+  READLINE_CAUGHT_SIGNAL=no
 fi
-rm -f conftest.err conftest.$ac_objext \
-      conftest$ac_exeext conftest.$ac_ext
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $READLINE_CAUGHT_SIGNAL" >&5
+$as_echo "$READLINE_CAUGHT_SIGNAL" >&6; }
   LIBS="$save_LIBS"
-  echo "$as_me:$LINENO: result: $READLINE_ECHOING_P" >&5
-echo "${ECHO_T}$READLINE_ECHOING_P" >&6
 else
   READLINE='$(READLINE_DIR)/libreadline.a'
   READLINE_DEPS='$(READLINE)'

gdb-x86_64-i386-syscall-restart.patch:
 amd64-nat.c |   20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

--- NEW FILE gdb-x86_64-i386-syscall-restart.patch ---
http://sourceware.org/ml/gdb-patches/2009-11/msg00592.html
Subject: [patch] Fix syscall restarts for amd64->i386 biarch

Hi,

tested only on recent Linux kernels, it should apply also on vanilla ones.
There were various changes of the kernels behavior in the past.

FSF GDB HEAD state:
kernel debugger inferior state
x86_64 x86_64   x86_64   PASS
x86_64 x86_64   i386     FAIL without this patch, PASS with this patch
x86_64 i386     i386     PASS on recent kernels
                         (FAIL: kernel-2.6.31.5-127.fc12.x86_64 - Fedora 12)
                         (PASS: kernel-2.6.32-0.55.rc8.git1.fc13.x86_64)
i386   i386     i386     PASS


Currently gdb.base/interrupt.exp fails on amd64 host running under
--target_board unix/-m32 with:
	continue
	Continuing.
	Unknown error 512

<linux/errno.h>:
/*
 * These should never be seen by user programs.  To return one of ERESTART*
 * codes, signal_pending() MUST be set.  Note that ptrace can observe these
 * at syscall exit tracing, but they will never be left for the debugged user
 * process to see.
 */
#define ERESTARTSYS     512

"Unknown error 512" printed above is printed by the inferior itself, not by GDB.

It is because GDB reads it as 0xfffffffffffffe00 but writes it back as
0xfffffe00.
+      /* Sign-extend %eax as during return from a syscall it is being checked
+	 for -ERESTART* values -512 being above 0xfffffffffffffe00; tested by
+	 interrupt.exp.  */


Quote of Roland McGrath from IRC:

roland: in the user_regset model, there are 64-bit user_regset flavors and
32-bit user_regset flavors, so at the kabi level the (kernel) caller can say
what it means: calls on the 32-bit user_regset flavor will behave as if on
a 32-bit kernel/userland.  in ptrace, there is no way for x86_64 ptrace calls
to say "i think of the inferior as being 32 bits, so act accordingly" (tho ppc
and/or sparc have ptr
roland: ace requests that do that iirc)
roland: ergo 64-bit ptrace callers must either save/restore full 64-bits so
the kernel's sign-extension choices are preserved, or else grok magic ways to
expand stored 32-bit register contents to 64-bit values to stuff via 64-bit
ptrace
[...]
roland: there is a "32-bit-flavored task", but it's not really true that it
has 32-bit registers.  there is no 32-bit-only userland condition.  any task
can always ljmp to the 64-bit code segment and run 64-bit insns including
a 64-bit syscall
roland: so a 64-bit debugger should see and be able to fiddle the full
registers.  it can even change cs via ptrace to force the inferior into
running 32 or 64 bit code.


Saving whole 64bits for i386 targets on x86_64 hosts does not much match the
GDB architecture as `struct type' for these registers still should be 32bit
etc.   Therefore provided just this exception.

The problem is reproducible only if one does an inferior call during the
interruption to do full inferior save/restore from GDB regcache.

Regression tested on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu.


Thanks,
Jan


gdb/
2009-11-29  Jan Kratochvil  <jan.kratochvil at redhat.com>

	* amd64-nat.c (amd64_collect_native_gregset): Do not pre-clear %eax.
	Sign extend it afterwards.

--- a/gdb/amd64-nat.c
+++ b/gdb/amd64-nat.c
@@ -131,9 +131,9 @@ amd64_collect_native_gregset (const struct regcache *regcache,
     {
       num_regs = amd64_native_gregset32_num_regs;
 
-      /* Make sure %eax, %ebx, %ecx, %edx, %esi, %edi, %ebp, %esp and
+      /* Make sure %ebx, %ecx, %edx, %esi, %edi, %ebp, %esp and
          %eip get zero-extended to 64 bits.  */
-      for (i = 0; i <= I386_EIP_REGNUM; i++)
+      for (i = I386_ECX_REGNUM; i <= I386_EIP_REGNUM; i++)
 	{
 	  if (regnum == -1 || regnum == i)
 	    memset (regs + amd64_native_gregset_reg_offset (gdbarch, i), 0, 8);
@@ -159,4 +159,20 @@ amd64_collect_native_gregset (const struct regcache *regcache,
 	    regcache_raw_collect (regcache, i, regs + offset);
 	}
     }
+
+  if (gdbarch_ptr_bit (gdbarch) == 32)
+    {
+      /* Sign-extend %eax as during return from a syscall it is being checked
+	 for -ERESTART* values -512 being above 0xfffffffffffffe00; tested by
+	 interrupt.exp.  */
+
+      int i = I386_EAX_REGNUM;
+
+      if (regnum == -1 || regnum == i)
+	{
+	  void *ptr = regs + amd64_native_gregset_reg_offset (gdbarch, i);
+
+	  *(int64_t *) ptr = *(int32_t *) ptr;
+	}
+    }
 }


gdb-6.3-test-pie-20050107.patch:
 configure            |    3 
 configure.ac         |    2 
 gdb.pie/Makefile.in  |   19 
 gdb.pie/attach.c     |   20 +
 gdb.pie/attach.exp   |  433 ++++++++++++++++++++++
 gdb.pie/attach2.c    |   24 +
 gdb.pie/break.c      |  146 +++++++
 gdb.pie/break.exp    |  977 +++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb.pie/break1.c     |   44 ++
 gdb.pie/corefile.exp |  243 ++++++++++++
 gdb.pie/coremaker.c  |  142 +++++++
 11 files changed, 2051 insertions(+), 2 deletions(-)

Index: gdb-6.3-test-pie-20050107.patch
===================================================================
RCS file: /cvs/pkgs/rpms/gdb/F-12/gdb-6.3-test-pie-20050107.patch,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -p -r1.11 -r1.12
--- gdb-6.3-test-pie-20050107.patch	10 Sep 2009 21:37:39 -0000	1.11
+++ gdb-6.3-test-pie-20050107.patch	7 Dec 2009 18:39:26 -0000	1.12
@@ -436,7 +436,7 @@ Index: gdb-6.8.50.20090909/gdb/testsuite
 ===================================================================
 --- /dev/null	1970-01-01 00:00:00.000000000 +0000
 +++ gdb-6.8.50.20090909/gdb/testsuite/gdb.pie/attach.exp	2009-09-09 19:06:01.000000000 +0200
-@@ -0,0 +1,432 @@
+@@ -0,0 +1,433 @@
 +#   Copyright 1997, 1999, 2002 Free Software Foundation, Inc.
 +
 +# This program is free software; you can redistribute it and/or modify
@@ -817,7 +817,8 @@ Index: gdb-6.8.50.20090909/gdb/testsuite
 +      -re ".*warning: reading register.*I.*O error.*$gdb_prompt $" {
 +         fail "attach call, read register 3 error"
 +     }
-+     -re "Attaching to.*process $testpid.*libc.*$gdb_prompt $" {
++     -re "Attaching to.*process $testpid.*$gdb_prompt $" {
++         # libc is relocated, not relocated, therefore not printed.
 +         pass "attach call"
 +     }
 +      -re "$gdb_prompt $" {fail "attach call"}

gdb-7.0-upstream.patch:
 ./gdb/amd64fbsd-nat.c                |    3 +
 ./gdb/dwarf2-frame.c                 |    8 ++++
 ./gdb/elfread.c                      |    3 +
 ./gdb/objfiles.c                     |   16 ++++++++
 ./gdb/score-tdep.c                   |   52 ---------------------------
 ./gdb/score-tdep.h                   |   66 -----------------------------------
 gdb/dbxread.c                        |    5 +-
 gdb/testsuite/gdb.base/bigcore.exp   |    6 +--
 gdb/testsuite/gdb.base/foll-fork.c   |    3 +
 gdb/testsuite/gdb.base/foll-fork.exp |    3 +
 gdb/testsuite/gdb.base/structs.c     |    6 +++
 gdb/testsuite/gdb.base/structs.exp   |   65 ++++++++++++++++++++++------------
 12 files changed, 89 insertions(+), 147 deletions(-)

Index: gdb-7.0-upstream.patch
===================================================================
RCS file: /cvs/pkgs/rpms/gdb/F-12/gdb-7.0-upstream.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- gdb-7.0-upstream.patch	30 Oct 2009 19:52:27 -0000	1.1
+++ gdb-7.0-upstream.patch	7 Dec 2009 18:39:26 -0000	1.2
@@ -262,3 +262,366 @@
 ## -1 +1 @@
 -7.0
 +7.0.0.20091030-cvs
+
+
+
+http://sourceware.org/ml/gdb-patches/2009-11/msg00594.html
+http://sourceware.org/ml/gdb-cvs/2009-11/msg00233.html
+Subject: [patch] testsuite: bigcore.exp fuzzy PASS message fix
+
+Hi,
+
+seen needlessly fuzzy results:
+	-PASS: gdb.base/bigcore.exp: extract next heap (stop at 50)
+	-PASS: gdb.base/bigcore.exp: extract prev heap (stop at 50)
+	+PASS: gdb.base/bigcore.exp: extract next heap
+	+PASS: gdb.base/bigcore.exp: extract prev heap
+
+but the .exp file just is not patient enough:
+	-Total of 4292375328 (0xffd87320) bytes bytes 53 chunks
+	+Total of 4292422432 (0xffd92b20) bytes bytes 41 chunks
+
+Increased to 200.  Tested on {x86_64,x86_64-m32}-fedora12-linux-gnu.
+
+
+Thanks,
+Jan
+
+
+gdb/testsuite/
+2009-11-29  Jan Kratochvil  <jan.kratochvil at redhat.com>
+
+	* gdb.base/bigcore.exp (extract_heap): Set $lim limit to 200.
+
+--- a/gdb/testsuite/gdb.base/bigcore.exp
++++ b/gdb/testsuite/gdb.base/bigcore.exp
+@@ -96,7 +96,7 @@ proc extract_heap { dir } {
+ 	}
+ 	-re " = \\(struct list \\*\\) (0x\[0-9a-f\]*).*$gdb_prompt $" {
+ 	    set heap [concat $heap $expect_out(1,string)]
+-	    if { $lim >= 50 } {
++	    if { $lim >= 200 } {
+ 		pass "$test (stop at $lim)"
+ 	    } else {
+ 		incr lim
+
+
+
+http://sourceware.org/ml/gdb-patches/2009-11/msg00593.html
+http://sourceware.org/ml/gdb-cvs/2009-12/msg00013.html
+Subject: [patch] testcase: Fix spurious structs.exp FAILs
+
+Hi,
+
+There were some rare unreproducible fuzzy FAILs seen on i386 (32-bit) inferiors:
+
+ return foo2
+ The location at which to store the function's return value is unknown.
+ If you continue, the return value that you specified will be ignored.
+ Make fun2 return now? (y or n) y
+ #0  main () at /rpmbuild/BUILD/gdb-7.0/gdb/testsuite/gdb.base/structs.c:435
+ 435          L2  = fun2();     
+ (gdb) next
+ 436          L3  = fun3();     
+ (gdb) PASS: gdb.base/structs.exp: return foo<n>; return 2 structs-tf-td
+ p/c L2
+-$4 = {a = -16 '\360', b = 0 '\000'}
+-(gdb) PASS: gdb.base/structs.exp: value foo<n> returned; return 2 structs-tf-td
++$4 = {a = 44 ',', b = 0 '\000'}
++(gdb) FAIL: gdb.base/structs.exp: value foo<n> returned; return 2 structs-tf-td
+
+Apparently
+	a = 44 ',',
+does not match
+	a = \[^,\}\]*,
+which is needed for cases where L2 (L*) remains uninitialized with random
+content.
+
+Alternative patch would just use regex `.*' and the whole new `chartest' and
+`anychar_re' parts can be dropped.
+
+Formerly 9s, now 11s, without the $first optimization it would cost 47s.
+
+Testcase has been run on {x86_64,x86_64-m32}-fedora12-linux-gnu.
+
+
+Thanks,
+Jan
+
+
+gdb/testsuite/
+2009-11-29  Jan Kratochvil  <jan.kratochvil at redhat.com>
+
+	Fix spurious false FAILs.
+	* gdb.base/structs.c (chartest): New.
+	(main): Fill-in chartest.
+	* gdb.base/structs.exp (anychar_re, first): New.
+	(start_structs_test): Import global anychar_re and first.
+	New gdb_test call "set print elements 300; ${testfile}"
+	(start_structs_test <$first>): New block.
+	(any): Import global anychar_re.  New variable ac.  Use ${ac}.
+
+--- a/gdb/testsuite/gdb.base/structs.c
++++ b/gdb/testsuite/gdb.base/structs.c
+@@ -396,6 +396,8 @@ zed ()
+   L18.r = 'Z';
+ }
+ 
++static struct { char c; } chartest[256];
++
+ int main()
+ {
+ #ifdef usestubs
+@@ -404,6 +406,10 @@ int main()
+ #endif
+   int i;
+ 
++  for (i = 0; i < 256; i++)
++    chartest[i].c = i;
++  chartest[0].c = 0;  /* chartest-done */
++
+   Fun1(foo1);	
+   Fun2(foo2);	
+   Fun3(foo3);	
+--- a/gdb/testsuite/gdb.base/structs.exp
++++ b/gdb/testsuite/gdb.base/structs.exp
+@@ -36,6 +36,9 @@ set testfile "structs"
+ set srcfile ${testfile}.c
+ set binfile ${objdir}/${subdir}/${testfile}
+ 
++# Regex matching any value of `char' type like: a = 65 'A'
++set anychar_re {-?[0-9]{1,3} '(.|\\([0-7]{3}|[a-z]|\\|'))'}
++
+ # Create and source the file that provides information about the
+ # compiler used to compile the test case.
+ 
+@@ -48,6 +51,7 @@ if [get_compiler_info ${binfile}] {
+ # the last TYPES field).  Run the compmiled program up to "main".
+ # Also updates the global "testfile" to reflect the most recent build.
+ 
++set first 1
+ proc start_structs_test { types } {
+     global testfile
+     global srcfile
+@@ -56,6 +60,8 @@ proc start_structs_test { types } {
+     global subdir
+     global srcdir
+     global gdb_prompt
++    global anychar_re
++    global first
+ 
+     # Create the additional flags
+     set flags "debug"
+@@ -91,6 +97,8 @@ proc start_structs_test { types } {
+ 	    "set print address off; ${testfile}"
+     gdb_test "set width 0" "" \
+ 	    "set width 0; ${testfile}"
++    gdb_test "set print elements 300" "" \
++	    "set print elements 300; ${testfile}"
+ 
+     # Advance to main
+     if { ![runto_main] } then {
+@@ -100,6 +108,16 @@ proc start_structs_test { types } {
+     # Get the debug format
+     get_debug_format
+ 
++    # Limit the slow $anychar_re{256} matching for better performance.
++    if $first {
++	set first 0
++
++	# Verify $anychar_re can match all the values of `char' type.
++	gdb_breakpoint [gdb_get_line_number "chartest-done"]
++	gdb_continue_to_breakpoint "chartest-done" ".*chartest-done.*"
++	gdb_test "p chartest" "= {({c = ${anychar_re}}, ){255}{c = ${anychar_re}}}"
++    }
++
+     # check that at the struct containing all the relevant types is correct
+     set foo_t "type = struct struct[llength ${types}] \{"
+     for {set n 0} {$n<[llength ${types}]} {incr n} {
+@@ -161,26 +179,28 @@ proc zed { n } {
+ }
+ 
+ proc any { n } {
+-    return [lindex {
+-	"{}"
+-	"{a = \[^,\}\]*}"
+-	"{a = \[^,\}\]*, b = \[^,\}\]*}"
+-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*}"
+-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*}"
+-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*}"
+-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*}"
+-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*}"
+-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*}"
+-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*}"
+-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*}"
+-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*}"
+-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*}"
+-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*}"
+-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*, n = \[^,\}\]*}"
+-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*, n = \[^,\}\]*, o = \[^,\}\]*}"
+-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*, n = \[^,\}\]*, o = \[^,\}\]*, p = \[^,\}\]*}"
+-	"{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*, n = \[^,\}\]*, o = \[^,\}\]*, p = \[^,\}\]*, q = \[^,\}\]*}"
+-    } $n]
++    global anychar_re
++    set ac $anychar_re
++    return [lindex [list \
++	"{}" \
++	"{a = ${ac}}" \
++	"{a = ${ac}, b = ${ac}}" \
++	"{a = ${ac}, b = ${ac}, c = ${ac}}" \
++	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}}" \
++	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}}" \
++	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}}" \
++	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}}" \
++	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}}" \
++	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}}" \
++	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}}" \
++	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}}" \
++	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}, l = ${ac}}" \
++	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}, l = ${ac}, m = ${ac}}" \
++	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}, l = ${ac}, m = ${ac}, n = ${ac}}" \
++	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}, l = ${ac}, m = ${ac}, n = ${ac}, o = ${ac}}" \
++	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}, l = ${ac}, m = ${ac}, n = ${ac}, o = ${ac}, p = ${ac}}" \
++	"{a = ${ac}, b = ${ac}, c = ${ac}, d = ${ac}, e = ${ac}, f = ${ac}, g = ${ac}, h = ${ac}, i = ${ac}, j = ${ac}, k = ${ac}, l = ${ac}, m = ${ac}, n = ${ac}, o = ${ac}, p = ${ac}, q = ${ac}}" \
++    ] $n]
+ }
+ 
+ # Given N (0..25), return the corresponding alphabetic letter in lower
+
+
+
+http://sourceware.org/ml/gdb-patches/2009-11/msg00573.html
+http://sourceware.org/ml/gdb-cvs/2009-11/msg00232.html
+Subject: [patch] testsuite fuzzy results fixup: foll-fork.exp
+
+Hi,
+
+one occasional timeout:
+
+ (gdb) PASS: gdb.base/foll-fork.exp: default show parent follow, no catchpoints
+ next 2
+-callee: 9949
+ 25       if (pid == 0) /* set breakpoint here */
+-(gdb) PASS: gdb.base/foll-fork.exp: default parent follow, no catchpoints
++(gdb) callee: 18747
++FAIL: gdb.base/foll-fork.exp: (timeout) default parent follow, no catchpoints
+
+Dropped the strings as there is no "callee" string expectation in
+foll-fork.exp.
+
+
+and with glibc-debuginfo installed one gets:
+
+(gdb) break 39
+Reading in symbols for ../nptl/sysdeps/unix/sysv/linux/fork.c...done.
+Breakpoint 12 at 0x3ad22a4876: file ../nptl/sysdeps/unix/sysv/linux/fork.c, line 39.
+(gdb) FAIL: gdb.base/foll-fork.exp: unpatch child, breakpoint at exit call
++
+Breakpoint 12, __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:158
+158           fresetlockfiles ();
+(gdb) FAIL: gdb.base/foll-fork.exp: unpatch child, unpatched parent breakpoints from child (unknown output)
+
+
+Thanks,
+Jan
+
+
+gdb/testsuite/
+2009-11-26  Jan Kratochvil  <jan.kratochvil at redhat.com>
+
+	* gdb.base/foll-fork.exp (unpatch child, breakpoint at exit call):
+	Force $srcfile file.
+	* gdb.base/foll-fork.c (callee): Comment out the printf call.
+
+--- a/gdb/testsuite/gdb.base/foll-fork.c
++++ b/gdb/testsuite/gdb.base/foll-fork.c
+@@ -9,7 +9,8 @@ void callee (i)
+   int  i;
+ #endif
+ {
+-  printf("callee: %d\n", i);
++  /* Any output corrupts GDB CLI expect strings.
++     printf("callee: %d\n", i);  */
+ }
+ 
+ #ifdef PROTOTYPES
+--- a/gdb/testsuite/gdb.base/foll-fork.exp
++++ b/gdb/testsuite/gdb.base/foll-fork.exp
+@@ -240,7 +240,8 @@ proc catch_fork_unpatch_child {} {
+    # Delete all breakpoints and catchpoints.
+    delete_breakpoints
+ 
+-   gdb_test "break $bp_exit" \
++   # Force $srcfile as the current GDB source can be in glibc sourcetree.
++   gdb_test "break $srcfile:$bp_exit" \
+        "Breakpoint .*file .*$srcfile, line .*" \
+        "unpatch child, breakpoint at exit call"
+ 
+
+
+
+http://sourceware.org/ml/gdb-patches/2009-11/msg00388.html
+http://sourceware.org/ml/gdb-cvs/2009-11/msg00156.html
+Subject: [patch] Fix crash on reading stabs
+
+Hi,
+
+there is a crash on reading stabs fpc binary:
+	https://bugzilla.redhat.com/show_bug.cgi?id=537837
+
+Program received signal SIGSEGV, Segmentation fault.
+0x000000000069db3d in read_dbx_symtab (objfile=0x1daf5f0) at dbxread.c:1369
+1369              if ((namestring[0] == '-' && namestring[1] == 'l')
+
+(gdb) p/x nlist.n_strx
+$7 = 0xfffffff8
+(gdb) p sizeof(nlist.n_strx)
+$10 = 8
+
+Below the patch context is:
+    namestring = (nlist->n_strx + file_string_table_offset
+                  + DBX_STRINGTAB (objfile));
+
+so IMO the `(unsigned)' cast is excessive as it does not match the expression
+below.  Such cast is there since the GDB "Initial revision" (1999).
+
+`n_strx' type:
+struct internal_nlist
+{
+  unsigned long n_strx;                 /* Index into string table of name.  */
+...
+};
+
+Regression tested on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu which does not
+mean anything with the default DWARF debug info.  It was hanging for stabs so
+tried just a large part of gdb.base/*.exp on x86_64-m32 - `unix/-gstabs+/-m32'.
+
+If it isn't obviously approved please feel free to drop it as one should not
+use STABS in the first place.
+
+
+Regards,
+Jan
+
+
+gdb/
+2009-11-17  Jan Kratochvil  <jan.kratochvil at redhat.com>
+
+	* dbxread.c (set_namestring): Remove cast to unsigned.  Check N_STRX
+	overflow.
+
+--- a/gdb/dbxread.c
++++ b/gdb/dbxread.c
+@@ -965,8 +965,9 @@ set_namestring (struct objfile *objfile, const struct internal_nlist *nlist)
+ {
+   char *namestring;
+ 
+-  if (((unsigned) nlist->n_strx + file_string_table_offset)
+-      >= DBX_STRINGTAB_SIZE (objfile))
++  if (nlist->n_strx + file_string_table_offset
++      >= DBX_STRINGTAB_SIZE (objfile)
++      || nlist->n_strx + file_string_table_offset < nlist->n_strx)
+     {
+       complaint (&symfile_complaints, _("bad string table offset in symbol %d"),
+ 		 symnum);
+

gdb-archer.patch:
 Makefile.in                                              |   92 
 NEWS                                                     |    7 
 ada-lang.c                                               |   43 
 amd64-linux-nat.c                                        |   45 
 block.c                                                  |   24 
 block.h                                                  |   12 
 breakpoint.c                                             |  773 ++++--
 breakpoint.h                                             |   21 
 c-exp.y                                                  |  240 ++
 c-lang.c                                                 |    6 
 c-typeprint.c                                            |   47 
 cli/cli-cmds.c                                           |   72 
 coffread.c                                               |    3 
 config.in                                                |    8 
 config/i386/nm-i386.h                                    |  125 +
 config/i386/nm-linux64.h                                 |   54 
 config/mips/nm-irix5.h                                   |   44 
 configure                                                |   76 
 configure.ac                                             |   47 
 cp-name-parser.y                                         |    5 
 cp-namespace.c                                           |  294 +-
 cp-support.c                                             |  123 +
 cp-support.h                                             |   50 
 dbxread.c                                                |    1 
 doc/gdb.texinfo                                          |  438 +++
 doc/gdbint.texinfo                                       |   62 
 doc/observer.texi                                        |    5 
 dwarf2-frame.c                                           |    9 
 dwarf2expr.c                                             |    7 
 dwarf2expr.h                                             |    2 
 dwarf2loc.c                                              |  227 +
 dwarf2loc.h                                              |    6 
 dwarf2read.c                                             | 1761 ++++++++++-----
 elfread.c                                                |   11 
 eval.c                                                   |  170 +
 expression.h                                             |   11 
 f-exp.y                                                  |    4 
 f-lang.c                                                 |  457 ---
 f-lang.h                                                 |   45 
 f-typeprint.c                                            |   36 
 f-valprint.c                                             |  267 --
 findcmd.c                                                |  111 
 findvar.c                                                |  126 -
 frame.c                                                  |    8 
 gdbinit.in                                               |   10 
 gdbserver/linux-i386-low.c                               |  210 +
 gdbserver/linux-x86-64-low.c                             |  184 +
 gdbthread.h                                              |    7 
 gdbtypes.c                                               |  599 ++++-
 gdbtypes.h                                               |  146 +
 gnu-v3-abi.c                                             |   18 
 i386-linux-nat.c                                         |   47 
 i386-nat.c                                               |   49 
 i386-nat.h                                               |   17 
 infcall.c                                                |    8 
 infcmd.c                                                 |   34 
 inferior.h                                               |    2 
 infrun.c                                                 |  190 +
 jv-lang.c                                                |    1 
 language.h                                               |    1 
 linespec.c                                               |   73 
 linux-nat.c                                              |   88 
 linux-nat.h                                              |    6 
 m2-lang.c                                                |    1 
 machoread.c                                              |    1 
 main.c                                                   |   80 
 maint.c                                                  |    8 
 mdebugread.c                                             |    2 
 mi/mi-cmd-var.c                                          |    1 
 mi/mi-main.c                                             |    2 
 mipsread.c                                               |    1 
 objfiles.c                                               |   19 
 objfiles.h                                               |   21 
 parse.c                                                  |  154 +
 parser-defs.h                                            |   25 
 ppc-linux-nat.c                                          |   19 
 printcmd.c                                               |   90 
 python/lib/gdb/FrameIterator.py                          |   33 
 python/lib/gdb/FrameWrapper.py                           |  112 
 python/lib/gdb/__init__.py                               |   19 
 python/lib/gdb/backtrace.py                              |   42 
 python/lib/gdb/command/__init__.py                       |    1 
 python/lib/gdb/command/alias.py                          |   59 
 python/lib/gdb/command/backtrace.py                      |  106 
 python/lib/gdb/command/ignore_errors.py                  |   37 
 python/lib/gdb/command/pahole.py                         |   75 
 python/lib/gdb/command/require.py                        |   57 
 python/lib/gdb/command/save_breakpoints.py               |   65 
 python/lib/gdb/command/upto.py                           |  129 +
 python/lib/gdb/function/__init__.py                      |    1 
 python/lib/gdb/function/caller_is.py                     |   58 
 python/lib/gdb/function/in_scope.py                      |   47 
 python/py-block.c                                        |  265 ++
 python/py-breakpoint.c                                   |  665 +++++
 python/py-cmd.c                                          |   17 
 python/py-frame.c                                        |  116 
 python/py-hooks.c                                        |   50 
 python/py-inferior.c                                     |  926 +++++++
 python/py-infthread.c                                    |  285 ++
 python/py-membuf.c                                       |  268 ++
 python/py-param.c                                        |  606 +++++
 python/py-prettyprint.c                                  |   21 
 python/py-symbol.c                                       |  336 ++
 python/py-symtab.c                                       |  322 ++
 python/py-type.c                                         |  170 +
 python/py-utils.c                                        |   46 
 python/py-value.c                                        |   55 
 python/python-internal.h                                 |   69 
 python/python.c                                          |  384 +++
 python/python.h                                          |    4 
 scm-lang.c                                               |    1 
 scm-valprint.c                                           |    4 
 solib-darwin.c                                           |    1 
 solib-spu.c                                              |    7 
 solib-svr4.c                                             |    4 
 solib.c                                                  |    3 
 solist.h                                                 |    2 
 somread.c                                                |    1 
 spu-tdep.c                                               |    2 
 stabsread.c                                              |    4 
 stack.c                                                  |   38 
 symfile.c                                                |   37 
 symfile.h                                                |   12 
 symmisc.c                                                |    4 
 symtab.c                                                 |  321 +-
 symtab.h                                                 |   20 
 target.c                                                 |   20 
 target.h                                                 |   41 
 testsuite/gdb.arch/powerpc-power7.exp                    |  175 +
 testsuite/gdb.arch/powerpc-power7.s                      |  107 
 testsuite/gdb.arch/x86_64-vla-typedef-foo.S              |  455 +++
 testsuite/gdb.arch/x86_64-vla-typedef.c                  |   43 
 testsuite/gdb.arch/x86_64-vla-typedef.exp                |   64 
 testsuite/gdb.base/arrayidx.c                            |    7 
 testsuite/gdb.base/arrayidx.exp                          |   10 
 testsuite/gdb.base/help.exp                              |    2 
 testsuite/gdb.base/lineno-makeup-func.c                  |   21 
 testsuite/gdb.base/lineno-makeup.c                       |   35 
 testsuite/gdb.base/lineno-makeup.exp                     |   78 
 testsuite/gdb.base/macscp.exp                            |    8 
 testsuite/gdb.base/radix.exp                             |    7 
 testsuite/gdb.base/valgrind-attach.c                     |   28 
 testsuite/gdb.base/valgrind-attach.exp                   |   94 
 testsuite/gdb.base/valgrind-attach.sh                    |   20 
 testsuite/gdb.base/vla-overflow.c                        |   30 
 testsuite/gdb.base/vla-overflow.exp                      |  108 
 testsuite/gdb.base/vla.c                                 |   55 
 testsuite/gdb.base/vla.exp                               |   62 
 testsuite/gdb.base/watchpoint-hw.c                       |    6 
 testsuite/gdb.base/watchpoint-hw.exp                     |   45 
 testsuite/gdb.cp/Makefile.in                             |    2 
 testsuite/gdb.cp/cp-relocate.exp                         |    6 
 testsuite/gdb.cp/cplusfuncs.cc                           |   10 
 testsuite/gdb.cp/cplusfuncs.exp                          |  225 +
 testsuite/gdb.cp/expand-sals.exp                         |    2 
 testsuite/gdb.cp/gdb9593.cc                              |  180 +
 testsuite/gdb.cp/gdb9593.exp                             |  185 +
 testsuite/gdb.cp/member-ptr.cc                           |   17 
 testsuite/gdb.cp/member-ptr.exp                          |   34 
 testsuite/gdb.cp/namespace-multiple-imports.cc           |   20 
 testsuite/gdb.cp/namespace-multiple-imports.exp          |   49 
 testsuite/gdb.cp/namespace-nested-imports.cc             |   36 
 testsuite/gdb.cp/namespace-nested-imports.exp            |   57 
 testsuite/gdb.cp/namespace-no-imports.cc                 |   37 
 testsuite/gdb.cp/namespace-no-imports.exp                |   76 
 testsuite/gdb.cp/namespace-recursive.cc                  |   47 
 testsuite/gdb.cp/namespace-recursive.exp                 |   75 
 testsuite/gdb.cp/namespace-stress-declarations.cc        |   93 
 testsuite/gdb.cp/namespace-stress-declarations.exp       |   50 
 testsuite/gdb.cp/namespace-stress.cc                     |   60 
 testsuite/gdb.cp/namespace-stress.exp                    |   50 
 testsuite/gdb.cp/namespace-using.cc                      |  128 -
 testsuite/gdb.cp/namespace-using.exp                     |  132 +
 testsuite/gdb.cp/namespace.exp                           |   23 
 testsuite/gdb.cp/overload.exp                            |    8 
 testsuite/gdb.cp/ovldbreak.exp                           |   46 
 testsuite/gdb.cp/shadowing.cc                            |   48 
 testsuite/gdb.cp/shadowing.exp                           |   91 
 testsuite/gdb.dwarf2/dw2-aranges.S                       |  140 +
 testsuite/gdb.dwarf2/dw2-aranges.exp                     |   40 
 testsuite/gdb.dwarf2/dw2-stripped.c                      |   42 
 testsuite/gdb.dwarf2/dw2-stripped.exp                    |   79 
 testsuite/gdb.dwarf2/dw2-struct-member-data-location.S   |   83 
 testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp |   37 
 testsuite/gdb.fortran/common-block.exp                   |  101 
 testsuite/gdb.fortran/common-block.f90                   |   67 
 testsuite/gdb.fortran/dwarf-stride.exp                   |   42 
 testsuite/gdb.fortran/dwarf-stride.f90                   |   40 
 testsuite/gdb.fortran/dynamic.exp                        |  145 +
 testsuite/gdb.fortran/dynamic.f90                        |   98 
 testsuite/gdb.fortran/library-module-lib.f90             |   28 
 testsuite/gdb.fortran/library-module-main.f90            |   23 
 testsuite/gdb.fortran/library-module.exp                 |   53 
 testsuite/gdb.fortran/logical.exp                        |   44 
 testsuite/gdb.fortran/logical.f90                        |   33 
 testsuite/gdb.fortran/module.exp                         |   28 
 testsuite/gdb.fortran/module.f90                         |   37 
 testsuite/gdb.fortran/string.exp                         |   59 
 testsuite/gdb.fortran/string.f90                         |   37 
 testsuite/gdb.gdb/selftest.exp                           |    4 
 testsuite/gdb.java/jnpe.exp                              |   77 
 testsuite/gdb.java/jnpe.java                             |   38 
 testsuite/gdb.opt/array-from-register-func.c             |   22 
 testsuite/gdb.opt/array-from-register.c                  |   28 
 testsuite/gdb.opt/array-from-register.exp                |   33 
 testsuite/gdb.opt/fortran-string.exp                     |   41 
 testsuite/gdb.opt/fortran-string.f90                     |   28 
 testsuite/gdb.python/py-cmd.exp                          |   27 
 testsuite/gdb.python/py-frame.exp                        |   48 
 testsuite/gdb.python/py-function.exp                     |   27 
 testsuite/gdb.python/py-inferior.c                       |   49 
 testsuite/gdb.python/py-inferior.exp                     |  201 +
 testsuite/gdb.python/py-infthread.c                      |   14 
 testsuite/gdb.python/py-infthread.exp                    |   58 
 testsuite/gdb.python/py-prettyprint.exp                  |   22 
 testsuite/gdb.python/py-template.exp                     |   25 
 testsuite/gdb.python/py-value.exp                        |   31 
 testsuite/gdb.python/python.exp                          |   27 
 testsuite/gdb.threads/watchpoint-fork-forkoff.c          |  175 +
 testsuite/gdb.threads/watchpoint-fork-mt.c               |  157 +
 testsuite/gdb.threads/watchpoint-fork.c                  |   57 
 testsuite/gdb.threads/watchpoint-fork.exp                |  130 +
 testsuite/gdb.threads/watchthreads-reorder.c             |  366 +++
 testsuite/gdb.threads/watchthreads-reorder.exp           |  105 
 testsuite/lib/cp-support.exp                             |    3 
 testsuite/lib/gdb.exp                                    |    1 
 testsuite/lib/python-support.exp                         |   53 
 thread.c                                                 |   18 
 top.c                                                    |    1 
 typeprint.c                                              |   14 
 typeprint.h                                              |    3 
 ui-file.c                                                |   20 
 ui-file.h                                                |    6 
 utils.c                                                  |    7 
 valarith.c                                               |   45 
 valops.c                                                 |  258 +-
 valprint.c                                               |    4 
 value.c                                                  |  150 +
 value.h                                                  |    8 
 varobj.c                                                 |   76 
 xcoffread.c                                              |    1 
 241 files changed, 18578 insertions(+), 2440 deletions(-)

Index: gdb-archer.patch
===================================================================
RCS file: /cvs/pkgs/rpms/gdb/F-12/gdb-archer.patch,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -p -r1.37 -r1.38
--- gdb-archer.patch	3 Dec 2009 16:26:36 -0000	1.37
+++ gdb-archer.patch	7 Dec 2009 18:39:26 -0000	1.38
@@ -2,7 +2,7 @@ http://sourceware.org/gdb/wiki/ProjectAr
 http://sourceware.org/gdb/wiki/ArcherBranchManagement
 
 GIT snapshot:
-commit 6817a81cd411acc9579f04dcc105e9bce72859ff
+commit 16276c1aad1366b92e687c72cab30192280e1906
 
 branch `archer' - the merge of branches:
 archer-tromey-call-frame-cfa
@@ -12245,10 +12245,22 @@ index a84003f..924c1c5 100644
    default_symfile_offsets,	/* sym_offsets: dummy FIXME til implem sym reloc */
    default_symfile_segments,	/* sym_segments: Get segment information from
 diff --git a/gdb/objfiles.c b/gdb/objfiles.c
-index 8dcca70..4b25a5a 100644
+index 8dcca70..e5442ca 100644
 --- a/gdb/objfiles.c
 +++ b/gdb/objfiles.c
-@@ -731,6 +731,20 @@ have_partial_symbols (void)
+@@ -634,6 +634,11 @@ objfile_relocate (struct objfile *objfile, struct section_offsets *new_offsets)
+     }
+   }
+ 
++  /* Alread QUICK_ADDRMAP tiself assumes all sections have the same offset.  */
++  if (objfile->quick_addrmap)
++    addrmap_relocate (objfile->quick_addrmap,
++		      ANOFFSET (delta, SECT_OFF_TEXT (objfile)));
++
+   {
+     struct partial_symbol **psym;
+ 
+@@ -731,6 +736,20 @@ have_partial_symbols (void)
      if (objfile_has_partial_symbols (ofp))
        return 1;
    }


Index: gdb.spec
===================================================================
RCS file: /cvs/pkgs/rpms/gdb/F-12/gdb.spec,v
retrieving revision 1.399
retrieving revision 1.400
diff -u -p -r1.399 -r1.400
--- gdb.spec	3 Dec 2009 16:26:37 -0000	1.399
+++ gdb.spec	7 Dec 2009 18:39:26 -0000	1.400
@@ -14,7 +14,7 @@ Version: 7.0
 
 # The release always contains a leading reserved number, start it at 1.
 # `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
-Release: 8%{?_with_upstream:.upstream}%{?dist}
+Release: 9%{?_with_upstream:.upstream}%{?dist}
 
 License: GPLv3+
 Group: Development/Debuggers
@@ -92,14 +92,12 @@ Patch118: gdb-6.3-gstack-20050411.patch
 
 # VSYSCALL and PIE
 Patch122: gdb-6.3-test-pie-20050107.patch
-Patch124: gdb-6.3-pie-20050110.patch
+Patch124: gdb-archer-pie.patch
+Patch389: gdb-archer-pie-addons.patch
 
 # Get selftest working with sep-debug-info
 Patch125: gdb-6.3-test-self-20050110.patch
 
-# Fix for non-threaded watchpoints.
-Patch128: gdb-6.3-nonthreaded-wp-20050117.patch
-
 # Test support of multiple destructors just like multiple constructors
 Patch133: gdb-6.3-test-dtorfix-20050121.patch
 
@@ -377,6 +375,12 @@ Patch387: gdb-bz539590-gnu-ifunc.patch
 # Fix bp conditionals [bp_location-accel] regression (Phil Muldoon, BZ 538626).
 Patch388: gdb-bz538626-bp_location-accel-bp-cond.patch
 
+# Fix callback-mode readline-6.0 regression for CTRL-C.
+Patch390: gdb-readline-6.0-signal.patch
+
+# Fix syscall restarts for amd64->i386 biarch.
+Patch391: gdb-x86_64-i386-syscall-restart.patch
+
 BuildRequires: ncurses-devel texinfo gettext flex bison expat-devel
 Requires: readline
 BuildRequires: readline-devel
@@ -475,6 +479,7 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc
 %patch383 -p1
 %patch384 -p1
 %patch385 -p1
+%patch124 -p1
 %patch1 -p1
 %patch3 -p1
 
@@ -486,7 +491,6 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc
 %patch118 -p1
 %patch122 -p1
 %patch125 -p1
-%patch128 -p1
 %patch133 -p1
 %patch136 -p1
 %patch140 -p1
@@ -579,7 +583,9 @@ rm -f gdb/jv-exp.c gdb/m2-exp.c gdb/objc
 %patch382 -p1
 %patch387 -p1
 %patch388 -p1
-%patch124 -p1
+%patch389 -p1
+%patch390 -p1
+%patch391 -p1
 
 find -name "*.orig" | xargs rm -f
 ! find -name "*.rej"	# Should not happen.
@@ -884,6 +890,16 @@ fi
 %endif
 
 %changelog
+* Mon Dec  7 2009 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.0-9.fc12
+- Replace the PIE (Position Indepdent Executable) support patch by a new one.
+- Drop gdb-6.3-nonthreaded-wp-20050117.patch as fuzzy + redundant.
+- Fix callback-mode readline-6.0 regression for CTRL-C.
+- Fix syscall restarts for amd64->i386 biarch.
+- Various testsuite results stability fixes.
+- Fix crash on reading stabs on 64bit (BZ 537837).
+- archer-jankratochvil-fedora12 commit: 16276c1aad1366b92e687c72cab30192280e1906
+- archer-jankratochvil-pie-fedora12 ct: 2ae60b5156d43aabfe5757940eaf7b4370fb05d2
+
 * Thu Dec  3 2009 Jan Kratochvil <jan.kratochvil at redhat.com> - 7.0-8.fc12
 - Fix slowness/hang when printing some variables (Sami Wagiaalla, BZ 541093).
 - archer-jankratochvil-fedora12 commit: 6817a81cd411acc9579f04dcc105e9bce72859ff


--- gdb-6.3-nonthreaded-wp-20050117.patch DELETED ---


--- gdb-6.3-pie-20050110.patch DELETED ---




More information about the fedora-extras-commits mailing list