public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  gdb_7_1-branch:  * linux-nat.c (linux_nat_detach): Check debug_linux_nat.
@ 2010-03-17 18:04 jkratoch
  0 siblings, 0 replies; only message in thread
From: jkratoch @ 2010-03-17 18:04 UTC (permalink / raw)
  To: archer-commits

The branch, gdb_7_1-branch has been updated
       via  cdea4348c35d7f505e69e8c1d98d8cd6292197e6 (commit)
       via  33c7ec4119bea6fd13313a001ed0407df0e95184 (commit)
       via  019c5244c13e98c0ad6fb2e5221c0a62a8558962 (commit)
       via  c81cbc4d93cf35f46561767accb8635c4ff7259c (commit)
       via  ea962ff4691f3fcdb63ed7374e1594481f8889df (commit)
       via  9cf706844b5105af5b28bd164e9188ac0874d834 (commit)
       via  dfc745b474d9213b7138ec9b20fac486f08184f9 (commit)
       via  dc8d50f521a40ce282439442a3c6f58139320e45 (commit)
       via  16e85fa7f052beee2353c0f87534895ef3d4a34f (commit)
       via  00af017ad059e1de53875a7e73531d7301dbc6c7 (commit)
       via  966f748087ac1a8be0383d2b34fd7e64c13fdc4e (commit)
       via  4d83949b145cdbb926a90d9e143b33575d73291d (commit)
      from  198dec8b44858c766a8d8ac44e265e3663f452cc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit cdea4348c35d7f505e69e8c1d98d8cd6292197e6
Author: Tom Tromey <tromey@redhat.com>
Date:   Wed Mar 17 17:27:13 2010 +0000

    	* linux-nat.c (linux_nat_detach): Check debug_linux_nat.

commit 33c7ec4119bea6fd13313a001ed0407df0e95184
Author: Daniel Jacobowitz <dan@debian.org>
Date:   Wed Mar 17 00:05:23 2010 +0000

    	* symfile.c (generic_load): Reset breakpoints after loading.

commit 019c5244c13e98c0ad6fb2e5221c0a62a8558962
Author: gdbadmin <gdbadmin@sourceware.org>
Date:   Wed Mar 17 00:00:03 2010 +0000

    *** empty log message ***

commit c81cbc4d93cf35f46561767accb8635c4ff7259c
Author: Hui Zhu <teawater@gmail.com>
Date:   Tue Mar 16 17:06:39 2010 +0000

    2010-03-16  Holger Hans Peter Freyther  <zecke@selfish.org>
    
    	* linux-record.c (record_linux_msghdr): Remove unintended semicolons.

commit ea962ff4691f3fcdb63ed7374e1594481f8889df
Author: gdbadmin <gdbadmin@sourceware.org>
Date:   Tue Mar 16 00:00:34 2010 +0000

    *** empty log message ***

commit 9cf706844b5105af5b28bd164e9188ac0874d834
Author: Joel Brobecker <brobecker@gnat.com>
Date:   Mon Mar 15 17:33:30 2010 +0000

    Requalify Ralf Corsepius' change as a tiny change.

commit dfc745b474d9213b7138ec9b20fac486f08184f9
Author: Joel Brobecker <brobecker@gnat.com>
Date:   Mon Mar 15 17:06:12 2010 +0000

    Fail gdb/configure if target is not supported.
    
            * configure.ac: Exit if ${gdb_target_obs}" is not set.
            * configure: Regenerate.

commit dc8d50f521a40ce282439442a3c6f58139320e45
Author: gdbadmin <gdbadmin@sourceware.org>
Date:   Mon Mar 15 00:00:33 2010 +0000

    *** empty log message ***

commit 16e85fa7f052beee2353c0f87534895ef3d4a34f
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Sun Mar 14 08:51:49 2010 +0000

    gdb/
    	* solib-svr4.c (svr4_exec_displacement): Return now success, new
    	parameter displacementp.  Update comment.
    	(svr4_relocate_main_executable): Return if non-zero SECTION_OFFSETS
    	element exists.  Return if svr4_exec_displacement was not successful.
    	Update comment.

commit 00af017ad059e1de53875a7e73531d7301dbc6c7
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Sun Mar 14 08:50:51 2010 +0000

    gdb/
    	* solib-svr4.c (read_program_header): Support type == -1 to read
    	all program headers.
    	(read_program_headers_from_bfd): New function.
    	(svr4_static_exec_displacement): Remove and move the comment ...
    	(svr4_exec_displacement): ... here.  Remove variable found.  New
    	variable displacement.  Check also DYNAMIC.  Verify DISPLACEMENT
    	alignment for ELF targets.  Compare target vs. exec_bfd PHDRs for ELF
    	targets using read_program_headers_from_bfd.  Remove the call of
    	svr4_static_exec_displacement.

commit 966f748087ac1a8be0383d2b34fd7e64c13fdc4e
Author: gdbadmin <gdbadmin@sourceware.org>
Date:   Sun Mar 14 00:00:33 2010 +0000

    *** empty log message ***

commit 4d83949b145cdbb926a90d9e143b33575d73291d
Author: gdbadmin <gdbadmin@sourceware.org>
Date:   Sat Mar 13 00:00:03 2010 +0000

    *** empty log message ***

-----------------------------------------------------------------------

Summary of changes:
 gdb/ChangeLog      |   38 ++++++++++
 gdb/configure      |    4 +
 gdb/configure.ac   |    3 +
 gdb/linux-nat.c    |    9 ++-
 gdb/linux-record.c |    4 +-
 gdb/solib-svr4.c   |  191 +++++++++++++++++++++++++++++++++++----------------
 gdb/symfile.c      |   10 +++
 gdb/version.in     |    2 +-
 8 files changed, 194 insertions(+), 67 deletions(-)

First 500 lines of diff:
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 3334cec..b4149ff 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,41 @@
+2010-03-17  Tom Tromey  <tromey@redhat.com>
+
+	* linux-nat.c (linux_nat_detach): Check debug_linux_nat.
+
+2010-03-16  Daniel Jacobowitz  <dan@codesourcery.com>
+
+	* symfile.c (generic_load): Reset breakpoints after loading.
+
+2010-03-16  Holger Hans Peter Freyther  <zecke@selfish.org>
+
+	* linux-record.c (record_linux_msghdr): Remove unintended semicolons.
+
+2010-03-15  Ralf Corsepius  <ralf.corsepius@rtems.org>  (tiny change)
+
+	* configure.ac: Exit if ${gdb_target_obs}" is not set.
+	* configure: Regenerate.
+
+2010-03-14  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* solib-svr4.c (svr4_exec_displacement): Return now success, new
+	parameter displacementp.  Update comment.
+	(svr4_relocate_main_executable): Return if non-zero SECTION_OFFSETS
+	element exists.  Return if svr4_exec_displacement was not successful.
+	Update comment.
+
+2010-03-14  Jan Kratochvil  <jan.kratochvil@redhat.com>
+	    Daniel Jacobowitz  <dan@codesourcery.com>
+
+	* solib-svr4.c (read_program_header): Support type == -1 to read
+	all program headers.
+	(read_program_headers_from_bfd): New function.
+	(svr4_static_exec_displacement): Remove and move the comment ...
+	(svr4_exec_displacement): ... here.  Remove variable found.  New
+	variable displacement.  Check also DYNAMIC.  Verify DISPLACEMENT
+	alignment for ELF targets.  Compare target vs. exec_bfd PHDRs for ELF
+	targets using read_program_headers_from_bfd.  Remove the call of
+	svr4_static_exec_displacement.
+
 2010-03-12  Pedro Alves  <pedro@codesourcery.com>
 
 	* target.c (memory_xfer_partial): Don't use the stack cache if
diff --git a/gdb/configure b/gdb/configure
index 1983d04..78c1c92 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -6927,6 +6927,10 @@ do
 
     . ${srcdir}/configure.tgt
 
+    if test -z "${gdb_target_obs}"; then :
+  as_fn_error "configuration ${targ} is unsupported." "$LINENO" 5
+fi
+
     # Target-specific object files
     for i in ${gdb_target_obs}; do
         case " $TARGET_OBS " in
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 6f873b5..5be44fa 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -161,6 +161,9 @@ do
 
     . ${srcdir}/configure.tgt
 
+    AS_IF([test -z "${gdb_target_obs}"],
+      [AC_MSG_ERROR([configuration ${targ} is unsupported.])])
+
     # Target-specific object files
     for i in ${gdb_target_obs}; do
         case " $TARGET_OBS " in
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index e55d958..b184945 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1810,10 +1810,11 @@ linux_nat_detach (struct target_ops *ops, char *args, int from_tty)
 	 pass it along with PTRACE_DETACH.  */
       args = alloca (8);
       sprintf (args, "%d", (int) WSTOPSIG (status));
-      fprintf_unfiltered (gdb_stdlog,
-			  "LND: Sending signal %s to %s\n",
-			  args,
- 			  target_pid_to_str (main_lwp->ptid));
+      if (debug_linux_nat)
+	fprintf_unfiltered (gdb_stdlog,
+			    "LND: Sending signal %s to %s\n",
+			    args,
+			    target_pid_to_str (main_lwp->ptid));
     }
 
   delete_lwp (main_lwp->ptid);
diff --git a/gdb/linux-record.c b/gdb/linux-record.c
index 1c6aa9f..74ef9bd 100644
--- a/gdb/linux-record.c
+++ b/gdb/linux-record.c
@@ -192,7 +192,7 @@ record_linux_msghdr (struct regcache *regcache,
           tmpint = (int) extract_unsigned_integer (iov + tdep->size_pointer,
                                                    tdep->size_size_t,
                                                    byte_order);
-          if (record_arch_list_add_mem (tmpaddr, tmpint));
+          if (record_arch_list_add_mem (tmpaddr, tmpint))
             return -1;
           addr += tdep->size_iovec;
         }
@@ -203,7 +203,7 @@ record_linux_msghdr (struct regcache *regcache,
   addr = extract_unsigned_integer (a, tdep->size_pointer, byte_order);
   a += tdep->size_pointer;
   tmpint = (int) extract_unsigned_integer (a, tdep->size_size_t, byte_order);
-  if (record_arch_list_add_mem ((CORE_ADDR) addr, tmpint));
+  if (record_arch_list_add_mem ((CORE_ADDR) addr, tmpint))
     return -1;
 
   return 0;
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 8edc889..4dd3761 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -451,6 +451,9 @@ bfd_lookup_symbol (bfd *abfd, char *symname)
 /* Read program header TYPE from inferior memory.  The header is found
    by scanning the OS auxillary vector.
 
+   If TYPE == -1, return the program headers instead of the contents of
+   one program header.
+
    Return a pointer to allocated memory holding the program header contents,
    or NULL on failure.  If sucessful, and unless P_SECT_SIZE is NULL, the
    size of those contents is returned to P_SECT_SIZE.  Likewise, the target
@@ -483,8 +486,13 @@ read_program_header (int type, int *p_sect_size, int *p_arch_size)
   else
     return 0;
 
-  /* Find .dynamic section via the PT_DYNAMIC PHDR.  */
-  if (arch_size == 32)
+  /* Find the requested segment.  */
+  if (type == -1)
+    {
+      sect_addr = at_phdr;
+      sect_size = at_phent * at_phnum;
+    }
+  else if (arch_size == 32)
     {
       Elf32_External_Phdr phdr;
       int i;
@@ -1622,58 +1630,36 @@ svr4_special_symbol_handling (void)
   svr4_relocate_main_executable ();
 }
 
-/* Decide if the objfile needs to be relocated.  As indicated above,
-   we will only be here when execution is stopped at the beginning
-   of the program.  Relocation is necessary if the address at which
-   we are presently stopped differs from the start address stored in
-   the executable AND there's no interpreter section.  The condition
-   regarding the interpreter section is very important because if
-   there *is* an interpreter section, execution will begin there
-   instead.  When there is an interpreter section, the start address
-   is (presumably) used by the interpreter at some point to start
-   execution of the program.
-
-   If there is an interpreter, it is normal for it to be set to an
-   arbitrary address at the outset.  The job of finding it is
-   handled in enable_break().
-
-   So, to summarize, relocations are necessary when there is no
-   interpreter section and the start address obtained from the
-   executable is different from the address at which GDB is
-   currently stopped.
-   
-   [ The astute reader will note that we also test to make sure that
-     the executable in question has the DYNAMIC flag set.  It is my
-     opinion that this test is unnecessary (undesirable even).  It
-     was added to avoid inadvertent relocation of an executable
-     whose e_type member in the ELF header is not ET_DYN.  There may
-     be a time in the future when it is desirable to do relocations
-     on other types of files as well in which case this condition
-     should either be removed or modified to accomodate the new file
-     type.  (E.g, an ET_EXEC executable which has been built to be
-     position-independent could safely be relocated by the OS if
-     desired.  It is true that this violates the ABI, but the ABI
-     has been known to be bent from time to time.)  - Kevin, Nov 2000. ]
-   */
+/* Read the ELF program headers from ABFD.  Return the contents and
+   set *PHDRS_SIZE to the size of the program headers.  */
 
-static CORE_ADDR
-svr4_static_exec_displacement (void)
+static gdb_byte *
+read_program_headers_from_bfd (bfd *abfd, int *phdrs_size)
 {
-  asection *interp_sect;
-  struct regcache *regcache
-    = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
-  CORE_ADDR pc = regcache_read_pc (regcache);
+  Elf_Internal_Ehdr *ehdr;
+  gdb_byte *buf;
 
-  interp_sect = bfd_get_section_by_name (exec_bfd, ".interp");
-  if (interp_sect == NULL 
-      && (bfd_get_file_flags (exec_bfd) & DYNAMIC) != 0
-      && (exec_entry_point (exec_bfd, &exec_ops) != pc))
-    return pc - exec_entry_point (exec_bfd, &exec_ops);
+  ehdr = elf_elfheader (abfd);
 
-  return 0;
+  *phdrs_size = ehdr->e_phnum * ehdr->e_phentsize;
+  if (*phdrs_size == 0)
+    return NULL;
+
+  buf = xmalloc (*phdrs_size);
+  if (bfd_seek (abfd, ehdr->e_phoff, SEEK_SET) != 0
+      || bfd_bread (buf, *phdrs_size, abfd) != *phdrs_size)
+    {
+      xfree (buf);
+      return NULL;
+    }
+
+  return buf;
 }
 
-/* We relocate all of the sections by the same amount.  This
+/* Return 1 and fill *DISPLACEMENTP with detected PIE offset of inferior
+   exec_bfd.  Otherwise return 0.
+
+   We relocate all of the sections by the same amount.  This
    behavior is mandated by recent editions of the System V ABI. 
    According to the System V Application Binary Interface,
    Edition 4.1, page 5-5:
@@ -1692,23 +1678,94 @@ svr4_static_exec_displacement (void)
      memory image of the program during dynamic linking.
 
    The same language also appears in Edition 4.0 of the System V
-   ABI and is left unspecified in some of the earlier editions.  */
+   ABI and is left unspecified in some of the earlier editions.
 
-static CORE_ADDR
-svr4_exec_displacement (void)
+   Decide if the objfile needs to be relocated.  As indicated above, we will
+   only be here when execution is stopped.  But during attachment PC can be at
+   arbitrary address therefore regcache_read_pc can be misleading (contrary to
+   the auxv AT_ENTRY value).  Moreover for executable with interpreter section
+   regcache_read_pc would point to the interpreter and not the main executable.
+
+   So, to summarize, relocations are necessary when the start address obtained
+   from the executable is different from the address in auxv AT_ENTRY entry.
+   
+   [ The astute reader will note that we also test to make sure that
+     the executable in question has the DYNAMIC flag set.  It is my
+     opinion that this test is unnecessary (undesirable even).  It
+     was added to avoid inadvertent relocation of an executable
+     whose e_type member in the ELF header is not ET_DYN.  There may
+     be a time in the future when it is desirable to do relocations
+     on other types of files as well in which case this condition
+     should either be removed or modified to accomodate the new file
+     type.  - Kevin, Nov 2000. ]  */
+
+static int
+svr4_exec_displacement (CORE_ADDR *displacementp)
 {
-  int found;
   /* ENTRY_POINT is a possible function descriptor - before
      a call to gdbarch_convert_from_func_ptr_addr.  */
-  CORE_ADDR entry_point;
+  CORE_ADDR entry_point, displacement;
 
   if (exec_bfd == NULL)
     return 0;
 
-  if (target_auxv_search (&current_target, AT_ENTRY, &entry_point) == 1)
-    return entry_point - bfd_get_start_address (exec_bfd);
+  /* Therefore for ELF it is ET_EXEC and not ET_DYN.  Both shared libraries
+     being executed themselves and PIE (Position Independent Executable)
+     executables are ET_DYN.  */
+
+  if ((bfd_get_file_flags (exec_bfd) & DYNAMIC) == 0)
+    return 0;
+
+  if (target_auxv_search (&current_target, AT_ENTRY, &entry_point) <= 0)
+    return 0;
+
+  displacement = entry_point - bfd_get_start_address (exec_bfd);
 
-  return svr4_static_exec_displacement ();
+  /* Verify the DISPLACEMENT candidate complies with the required page
+     alignment.  It is cheaper than the program headers comparison below.  */
+
+  if (bfd_get_flavour (exec_bfd) == bfd_target_elf_flavour)
+    {
+      const struct elf_backend_data *elf = get_elf_backend_data (exec_bfd);
+
+      /* p_align of PT_LOAD segments does not specify any alignment but
+	 only congruency of addresses:
+	   p_offset % p_align == p_vaddr % p_align
+	 Kernel is free to load the executable with lower alignment.  */
+
+      if ((displacement & (elf->minpagesize - 1)) != 0)
+	return 0;
+    }
+
+  /* Verify that the auxilliary vector describes the same file as exec_bfd, by
+     comparing their program headers.  If the program headers in the auxilliary
+     vector do not match the program headers in the executable, then we are
+     looking at a different file than the one used by the kernel - for
+     instance, "gdb program" connected to "gdbserver :PORT ld.so program".  */
+
+  if (bfd_get_flavour (exec_bfd) == bfd_target_elf_flavour)
+    {
+      /* Be optimistic and clear OK only if GDB was able to verify the headers
+	 really do not match.  */
+      int phdrs_size, phdrs2_size, ok = 1;
+      gdb_byte *buf, *buf2;
+
+      buf = read_program_header (-1, &phdrs_size, NULL);
+      buf2 = read_program_headers_from_bfd (exec_bfd, &phdrs2_size);
+      if (buf != NULL && buf2 != NULL
+	  && (phdrs_size != phdrs2_size
+	      || memcmp (buf, buf2, phdrs_size) != 0))
+	ok = 0;
+
+      xfree (buf);
+      xfree (buf2);
+
+      if (!ok)
+	return 0;
+    }
+
+  *displacementp = displacement;
+  return 1;
 }
 
 /* Relocate the main executable.  This function should be called upon
@@ -1719,11 +1776,25 @@ svr4_exec_displacement (void)
 static void
 svr4_relocate_main_executable (void)
 {
-  CORE_ADDR displacement = svr4_exec_displacement ();
+  CORE_ADDR displacement;
+
+  if (symfile_objfile)
+    {
+      int i;
+
+      /* Remote target may have already set specific offsets by `qOffsets'
+	 which should be preferred.  */
+
+      for (i = 0; i < symfile_objfile->num_sections; i++)
+	if (ANOFFSET (symfile_objfile->section_offsets, i) != 0)
+	  return;
+    }
+
+  if (! svr4_exec_displacement (&displacement))
+    return;
 
-  /* 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
-     relocate the executable at this function to improper address before.  */
+  /* Even DISPLACEMENT 0 is a valid new difference of in-memory vs. in-file
+     addresses.  */
 
   if (symfile_objfile)
     {
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 3cb40f7..9c28fb0 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1920,6 +1920,16 @@ generic_load (char *args, int from_tty)
      for other targets too.  */
   regcache_write_pc (get_current_regcache (), entry);
 
+  /* Reset breakpoints, now that we have changed the load image.  For
+     instance, breakpoints may have been set (or reset, by
+     post_create_inferior) while connected to the target but before we
+     loaded the program.  In that case, the prologue analyzer could
+     have read instructions from the target to find the right
+     breakpoint locations.  Loading has changed the contents of that
+     memory.  */
+
+  breakpoint_re_set ();
+
   /* FIXME: are we supposed to call symbol_file_add or not?  According
      to a comment from remote-mips.c (where a call to symbol_file_add
      was commented out), making the call confuses GDB if more than one
diff --git a/gdb/version.in b/gdb/version.in
index 67de8da..6450758 100644
--- a/gdb/version.in
+++ b/gdb/version.in
@@ -1 +1 @@
-7.0.90.20100312-cvs
+7.0.90.20100317-cvs


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-03-17 18:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-17 18:04 [SCM] gdb_7_1-branch: * linux-nat.c (linux_nat_detach): Check debug_linux_nat jkratoch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).