public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  gbenson/rtld-probes: Bump copyright years
@ 2013-05-16 13:13 gary
  0 siblings, 0 replies; only message in thread
From: gary @ 2013-05-16 13:13 UTC (permalink / raw)
  To: archer-commits

The branch, gbenson/rtld-probes has been updated
       via  ed85b65d8fb34d863d9a2cb816223dba457d9bc3 (commit)
       via  814ab0967138856230d6c27998b10f09f6be54bd (commit)
       via  07a5cedc2ef21597493d1f0fe7d8059990b69e0d (commit)
       via  b74c156c02cac7fb90ea19bc7a5de78457987a85 (commit)
      from  e68b85cf908240cf301f9b627ed02d716e629c29 (commit)

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

- Log -----------------------------------------------------------------
commit ed85b65d8fb34d863d9a2cb816223dba457d9bc3
Author: Gary Benson <gbenson@redhat.com>
Date:   Thu May 16 14:13:21 2013 +0100

    Bump copyright years

commit 814ab0967138856230d6c27998b10f09f6be54bd
Merge: 07a5ced b74c156
Author: Gary Benson <gbenson@redhat.com>
Date:   Thu May 16 14:12:10 2013 +0100

    Merge remote branch 'gdb/master' into gbenson/rtld-probes

commit 07a5cedc2ef21597493d1f0fe7d8059990b69e0d
Author: Gary Benson <gbenson@redhat.com>
Date:   Thu May 16 12:52:13 2013 +0100

    s/svr4_current_sos_1/svr4_current_sos_direct/g

commit b74c156c02cac7fb90ea19bc7a5de78457987a85
Author: Joel Brobecker <brobecker@gnat.com>
Date:   Wed May 15 12:26:13 2013 +0000

    ppc-aix core file relocation.
    
    The current code attempts to provide relocation support when debugging
    core files via the rs6000_xfer_partial method of the rs6000-nat
    target_ops vector. However, this target_ops vector does not get pushed
    on the target stack at all when debugging core files, thus bypassing
    completely that part of the code.
    
    This patch fixes the problem by extending corelow's core_xfer_partial
    into handling the TARGET_OBJECT_LIBRARIES_AIX object.
    
    gdb/ChangeLog:
    
    	* gdbarch.sh (core_xfer_shared_libraries_aix): New method.
    	* gdbarch.h, gdbarch.c: Regenerate.
    	* corelow.c (core_xfer_partial): Add TARGET_OBJECT_LIBRARIES_AIX
    	handling.
    
    	* rs6000-aix-tdep.h: New file.
    	* Makefile.in (HFILES_NO_SRCDIR): Add rs6000-aix-tdep.h.
    	* rs6000-aix-tdep.c: Include "rs6000-aix-tdep.h" and
    	"xml-utils.h".
    	(struct field_info, struct ld_info_desc): New types.
    	(ld_info32_desc, ld_info64_desc): New static constants.
    	(struct ld_info): New type.
    	(rs6000_aix_extract_ld_info): New function.
    	(rs6000_aix_shared_library_to_xml): Likewise.
    	(rs6000_aix_ld_info_to_xml): Likewise.
    	(rs6000_aix_core_xfer_shared_libraries_aix): Likewise.
    	(rs6000_aix_init_osabi): Add call to
    	set_gdbarch_core_xfer_shared_libraries_aix.
    	* rs6000-nat.c: Add "rs6000-aix-tdep.h" include.
    	Remove "xml-utils.h" include.
    	(LdInfo): Delete typedef.
    	(ARCH64_DECL, LDI_FIELD, LDI_NEXT, LDI_FD, LDI_FILENAME):
    	Delete macros.
    	(rs6000_ptrace_ldinfo): Change return type to gdb_byte *.
    	Adjust code accordingly.
    	(rs6000_core_ldinfo): Delete, folded into
    	rs6000_aix_core_xfer_shared_libraries_aix.
    	(rs6000_xfer_shared_library): Delete.
    	(rs6000_xfer_shared_libraries): Reimplement.

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

Summary of changes:
 gdb/ChangeLog                                      |   32 ++
 gdb/Makefile.in                                    |    3 +-
 gdb/corelow.c                                      |   12 +
 gdb/gdbarch.c                                      |   33 +++
 gdb/gdbarch.h                                      |    9 +
 gdb/gdbarch.sh                                     |    4 +
 gdb/rs6000-aix-tdep.c                              |  297 ++++++++++++++++++++
 .../gdb.base/break-probes.c => rs6000-aix-tdep.h}  |   22 +-
 gdb/rs6000-nat.c                                   |  210 ++-------------
 gdb/solib-svr4.c                                   |   11 +-
 gdb/testsuite/gdb.base/break-probes-solib.c        |    2 +-
 gdb/testsuite/gdb.base/break-probes.c              |    2 +-
 gdb/testsuite/gdb.base/break-probes.exp            |    2 +-
 gdb/testsuite/gdb.base/info-shared-solib1.c        |    2 +-
 gdb/testsuite/gdb.base/info-shared-solib2.c        |    2 +-
 gdb/testsuite/gdb.base/info-shared.c               |    2 +-
 gdb/testsuite/gdb.base/info-shared.exp             |    2 +-
 17 files changed, 432 insertions(+), 215 deletions(-)
 copy gdb/{testsuite/gdb.base/break-probes.c => rs6000-aix-tdep.h} (64%)

First 500 lines of diff:
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7c6e1f0..13bdc3d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,35 @@
+2013-05-15  Joel Brobecker  <brobecker@adacore.com>
+
+	* gdbarch.sh (core_xfer_shared_libraries_aix): New method.
+	* gdbarch.h, gdbarch.c: Regenerate.
+	* corelow.c (core_xfer_partial): Add TARGET_OBJECT_LIBRARIES_AIX
+	handling.
+
+	* rs6000-aix-tdep.h: New file.
+	* Makefile.in (HFILES_NO_SRCDIR): Add rs6000-aix-tdep.h.
+	* rs6000-aix-tdep.c: Include "rs6000-aix-tdep.h" and
+	"xml-utils.h".
+	(struct field_info, struct ld_info_desc): New types.
+	(ld_info32_desc, ld_info64_desc): New static constants.
+	(struct ld_info): New type.
+	(rs6000_aix_extract_ld_info): New function.
+	(rs6000_aix_shared_library_to_xml): Likewise.
+	(rs6000_aix_ld_info_to_xml): Likewise.
+	(rs6000_aix_core_xfer_shared_libraries_aix): Likewise.
+	(rs6000_aix_init_osabi): Add call to
+	set_gdbarch_core_xfer_shared_libraries_aix.
+	* rs6000-nat.c: Add "rs6000-aix-tdep.h" include.
+	Remove "xml-utils.h" include.
+	(LdInfo): Delete typedef.
+	(ARCH64_DECL, LDI_FIELD, LDI_NEXT, LDI_FD, LDI_FILENAME):
+	Delete macros.
+	(rs6000_ptrace_ldinfo): Change return type to gdb_byte *.
+	Adjust code accordingly.
+	(rs6000_core_ldinfo): Delete, folded into
+	rs6000_aix_core_xfer_shared_libraries_aix.
+	(rs6000_xfer_shared_library): Delete.
+	(rs6000_xfer_shared_libraries): Reimplement.
+
 2013-05-15  Markus Metzger  <markus.t.metzger@intel.com>
 
 	* record.c (record_goto_cmdlist): New.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 9127894..69ec68b 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -820,7 +820,8 @@ amd64-linux-tdep.h linespec.h i387-tdep.h mn10300-tdep.h \
 sparc64-tdep.h monitor.h ppcobsd-tdep.h srec.h solib-pa64.h \
 coff-pe-read.h parser-defs.h gdb_ptrace.h mips-linux-tdep.h \
 m68k-tdep.h spu-tdep.h jv-lang.h environ.h solib-irix.h amd64-tdep.h \
-doublest.h regset.h hppa-tdep.h ppc-linux-tdep.h ppc64-tdep.h rs6000-tdep.h \
+doublest.h regset.h hppa-tdep.h ppc-linux-tdep.h ppc64-tdep.h \
+rs6000-tdep.h rs6000-aix-tdep.h \
 common/gdb_locale.h common/gdb_dirent.h arch-utils.h trad-frame.h gnu-nat.h \
 language.h nbsd-tdep.h solib-svr4.h \
 macroexp.h ui-file.h regcache.h tracepoint.h i386-tdep.h \
diff --git a/gdb/corelow.c b/gdb/corelow.c
index de940fc..0bfa743 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -756,6 +756,18 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
 	}
       /* FALL THROUGH */
 
+    case TARGET_OBJECT_LIBRARIES_AIX:
+      if (core_gdbarch
+	  && gdbarch_core_xfer_shared_libraries_aix_p (core_gdbarch))
+	{
+	  if (writebuf)
+	    return -1;
+	  return
+	    gdbarch_core_xfer_shared_libraries_aix (core_gdbarch,
+						    readbuf, offset, len);
+	}
+      /* FALL THROUGH */
+
     case TARGET_OBJECT_SPU:
       if (readbuf && annex)
 	{
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 129268f..db35b40 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -241,6 +241,7 @@ struct gdbarch
   gdbarch_elfcore_write_linux_prpsinfo_ftype *elfcore_write_linux_prpsinfo;
   gdbarch_find_memory_regions_ftype *find_memory_regions;
   gdbarch_core_xfer_shared_libraries_ftype *core_xfer_shared_libraries;
+  gdbarch_core_xfer_shared_libraries_aix_ftype *core_xfer_shared_libraries_aix;
   gdbarch_core_pid_to_str_ftype *core_pid_to_str;
   const char * gcore_bfd_target;
   int vtable_function_descriptors;
@@ -412,6 +413,7 @@ struct gdbarch startup_gdbarch =
   0,  /* elfcore_write_linux_prpsinfo */
   0,  /* find_memory_regions */
   0,  /* core_xfer_shared_libraries */
+  0,  /* core_xfer_shared_libraries_aix */
   0,  /* core_pid_to_str */
   0,  /* gcore_bfd_target */
   0,  /* vtable_function_descriptors */
@@ -714,6 +716,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of elfcore_write_linux_prpsinfo, has predicate.  */
   /* Skip verify of find_memory_regions, has predicate.  */
   /* Skip verify of core_xfer_shared_libraries, has predicate.  */
+  /* Skip verify of core_xfer_shared_libraries_aix, has predicate.  */
   /* Skip verify of core_pid_to_str, has predicate.  */
   /* Skip verify of gcore_bfd_target, has predicate.  */
   /* Skip verify of vtable_function_descriptors, invalid_p == 0 */
@@ -904,6 +907,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
                       "gdbarch_dump: core_xfer_shared_libraries = <%s>\n",
                       host_address_to_string (gdbarch->core_xfer_shared_libraries));
   fprintf_unfiltered (file,
+                      "gdbarch_dump: gdbarch_core_xfer_shared_libraries_aix_p() = %d\n",
+                      gdbarch_core_xfer_shared_libraries_aix_p (gdbarch));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: core_xfer_shared_libraries_aix = <%s>\n",
+                      host_address_to_string (gdbarch->core_xfer_shared_libraries_aix));
+  fprintf_unfiltered (file,
                       "gdbarch_dump: decr_pc_after_break = %s\n",
                       core_addr_to_string_nz (gdbarch->decr_pc_after_break));
   fprintf_unfiltered (file,
@@ -3449,6 +3458,30 @@ set_gdbarch_core_xfer_shared_libraries (struct gdbarch *gdbarch,
 }
 
 int
+gdbarch_core_xfer_shared_libraries_aix_p (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  return gdbarch->core_xfer_shared_libraries_aix != NULL;
+}
+
+LONGEST
+gdbarch_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, LONGEST len)
+{
+  gdb_assert (gdbarch != NULL);
+  gdb_assert (gdbarch->core_xfer_shared_libraries_aix != NULL);
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_core_xfer_shared_libraries_aix called\n");
+  return gdbarch->core_xfer_shared_libraries_aix (gdbarch, readbuf, offset, len);
+}
+
+void
+set_gdbarch_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch,
+                                            gdbarch_core_xfer_shared_libraries_aix_ftype core_xfer_shared_libraries_aix)
+{
+  gdbarch->core_xfer_shared_libraries_aix = core_xfer_shared_libraries_aix;
+}
+
+int
 gdbarch_core_pid_to_str_p (struct gdbarch *gdbarch)
 {
   gdb_assert (gdbarch != NULL);
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 464c4b6..e1959c3 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -766,6 +766,15 @@ typedef LONGEST (gdbarch_core_xfer_shared_libraries_ftype) (struct gdbarch *gdba
 extern LONGEST gdbarch_core_xfer_shared_libraries (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, LONGEST len);
 extern void set_gdbarch_core_xfer_shared_libraries (struct gdbarch *gdbarch, gdbarch_core_xfer_shared_libraries_ftype *core_xfer_shared_libraries);
 
+/* Read offset OFFSET of TARGET_OBJECT_LIBRARIES_AIX formatted shared
+   libraries list from core file into buffer READBUF with length LEN. */
+
+extern int gdbarch_core_xfer_shared_libraries_aix_p (struct gdbarch *gdbarch);
+
+typedef LONGEST (gdbarch_core_xfer_shared_libraries_aix_ftype) (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, LONGEST len);
+extern LONGEST gdbarch_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, LONGEST len);
+extern void set_gdbarch_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch, gdbarch_core_xfer_shared_libraries_aix_ftype *core_xfer_shared_libraries_aix);
+
 /* How the core target converts a PTID from a core file to a string. */
 
 extern int gdbarch_core_pid_to_str_p (struct gdbarch *gdbarch);
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 92d4f0f..c92a857 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -655,6 +655,10 @@ M:int:find_memory_regions:find_memory_region_ftype func, void *data:func, data
 # core file into buffer READBUF with length LEN.
 M:LONGEST:core_xfer_shared_libraries:gdb_byte *readbuf, ULONGEST offset, LONGEST len:readbuf, offset, len
 
+# Read offset OFFSET of TARGET_OBJECT_LIBRARIES_AIX formatted shared
+# libraries list from core file into buffer READBUF with length LEN.
+M:LONGEST:core_xfer_shared_libraries_aix:gdb_byte *readbuf, ULONGEST offset, LONGEST len:readbuf, offset, len
+
 # How the core target converts a PTID from a core file to a string.
 M:char *:core_pid_to_str:ptid_t ptid:ptid
 
diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c
index 0d4fec5..9956eb3 100644
--- a/gdb/rs6000-aix-tdep.c
+++ b/gdb/rs6000-aix-tdep.c
@@ -34,10 +34,12 @@
 #include "breakpoint.h"
 #include "rs6000-tdep.h"
 #include "ppc-tdep.h"
+#include "rs6000-aix-tdep.h"
 #include "exceptions.h"
 #include "xcoffread.h"
 #include "solib.h"
 #include "solib-aix.h"
+#include "xml-utils.h"
 
 /* If the kernel has to deliver a signal, it pushes a sigcontext
    structure on the stack and then calls the signal handler, passing
@@ -747,6 +749,299 @@ rs6000_aix_osabi_sniffer (bfd *abfd)
   return GDB_OSABI_AIX;
 }
 
+/* A structure encoding the offset and size of a field within
+   a struct.  */
+
+struct field_info
+{
+  int offset;
+  int size;
+};
+
+/* A structure describing the layout of all the fields of interest
+   in AIX's struct ld_info.  Each field in this struct corresponds
+   to the field of the same name in struct ld_info.  */
+
+struct ld_info_desc
+{
+  struct field_info ldinfo_next;
+  struct field_info ldinfo_fd;
+  struct field_info ldinfo_textorg;
+  struct field_info ldinfo_textsize;
+  struct field_info ldinfo_dataorg;
+  struct field_info ldinfo_datasize;
+  struct field_info ldinfo_filename;
+};
+
+/* The following data has been generated by compiling and running
+   the following program on AIX 5.3.  */
+
+#if 0
+    #include <stddef.h>
+    #include <stdio.h>
+    #define __LDINFO_PTRACE32__
+    #define __LDINFO_PTRACE64__
+    #include <sys/ldr.h>
+
+    #define pinfo(type,member)              \
+      {                                         \
+        struct type ldi = {0};                  \
+                                                \
+        printf ("  {%d, %d},\t/* %s */\n",      \
+                offsetof (struct type, member), \
+                sizeof (ldi.member),            \
+                #member);                       \
+      }                                         \
+      while (0)
+
+    int
+    main (void)
+    {
+      printf ("static const struct ld_info_desc ld_info32_desc =\n{\n");
+      pinfo (__ld_info32, ldinfo_next);
+      pinfo (__ld_info32, ldinfo_fd);
+      pinfo (__ld_info32, ldinfo_textorg);
+      pinfo (__ld_info32, ldinfo_textsize);
+      pinfo (__ld_info32, ldinfo_dataorg);
+      pinfo (__ld_info32, ldinfo_datasize);
+      pinfo (__ld_info32, ldinfo_filename);
+      printf ("};\n");
+
+      printf ("\n");
+
+      printf ("static const struct ld_info_desc ld_info64_desc =\n{\n");
+      pinfo (__ld_info64, ldinfo_next);
+      pinfo (__ld_info64, ldinfo_fd);
+      pinfo (__ld_info64, ldinfo_textorg);
+      pinfo (__ld_info64, ldinfo_textsize);
+      pinfo (__ld_info64, ldinfo_dataorg);
+      pinfo (__ld_info64, ldinfo_datasize);
+      pinfo (__ld_info64, ldinfo_filename);
+      printf ("};\n");
+
+      return 0;
+    }
+#endif /* 0 */
+
+/* Layout of the 32bit version of struct ld_info.  */
+
+static const struct ld_info_desc ld_info32_desc =
+{
+  {0, 4},       /* ldinfo_next */
+  {4, 4},       /* ldinfo_fd */
+  {8, 4},       /* ldinfo_textorg */
+  {12, 4},      /* ldinfo_textsize */
+  {16, 4},      /* ldinfo_dataorg */
+  {20, 4},      /* ldinfo_datasize */
+  {24, 2},      /* ldinfo_filename */
+};
+
+/* Layout of the 64bit version of struct ld_info.  */
+
+static const struct ld_info_desc ld_info64_desc =
+{
+  {0, 4},       /* ldinfo_next */
+  {8, 4},       /* ldinfo_fd */
+  {16, 8},      /* ldinfo_textorg */
+  {24, 8},      /* ldinfo_textsize */
+  {32, 8},      /* ldinfo_dataorg */
+  {40, 8},      /* ldinfo_datasize */
+  {48, 2},      /* ldinfo_filename */
+};
+
+/* A structured representation of one entry read from the ld_info
+   binary data provided by the AIX loader.  */
+
+struct ld_info
+{
+  ULONGEST next;
+  int fd;
+  CORE_ADDR textorg;
+  ULONGEST textsize;
+  CORE_ADDR dataorg;
+  ULONGEST datasize;
+  char *filename;
+  char *member_name;
+};
+
+/* Return a struct ld_info object corresponding to the entry at
+   LDI_BUF.
+
+   Note that the filename and member_name strings still point
+   to the data in LDI_BUF.  So LDI_BUF must not be deallocated
+   while the struct ld_info object returned is in use.  */
+
+static struct ld_info
+rs6000_aix_extract_ld_info (struct gdbarch *gdbarch,
+			    const gdb_byte *ldi_buf)
+{
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+  struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
+  const struct ld_info_desc desc
+    = tdep->wordsize == 8 ? ld_info64_desc : ld_info32_desc;
+  struct ld_info info;
+
+  info.next = extract_unsigned_integer (ldi_buf + desc.ldinfo_next.offset,
+					desc.ldinfo_next.size,
+					byte_order);
+  info.fd = extract_signed_integer (ldi_buf + desc.ldinfo_fd.offset,
+				    desc.ldinfo_fd.size,
+				    byte_order);
+  info.textorg = extract_typed_address (ldi_buf + desc.ldinfo_textorg.offset,
+					ptr_type);
+  info.textsize
+    = extract_unsigned_integer (ldi_buf + desc.ldinfo_textsize.offset,
+				desc.ldinfo_textsize.size,
+				byte_order);
+  info.dataorg = extract_typed_address (ldi_buf + desc.ldinfo_dataorg.offset,
+					ptr_type);
+  info.datasize
+    = extract_unsigned_integer (ldi_buf + desc.ldinfo_datasize.offset,
+				desc.ldinfo_datasize.size,
+				byte_order);
+  info.filename = (char *) ldi_buf + desc.ldinfo_filename.offset;
+  info.member_name = info.filename + strlen (info.filename) + 1;
+
+  return info;
+}
+
+/* Append to OBJSTACK an XML string description of the shared library
+   corresponding to LDI, following the TARGET_OBJECT_LIBRARIES_AIX
+   format.  */
+
+static void
+rs6000_aix_shared_library_to_xml (struct ld_info *ldi,
+				  struct obstack *obstack)
+{
+  char *p;
+
+  obstack_grow_str (obstack, "<library name=\"");
+  p = xml_escape_text (ldi->filename);
+  obstack_grow_str (obstack, p);
+  xfree (p);
+  obstack_grow_str (obstack, "\"");
+
+  if (ldi->member_name[0] != '\0')
+    {
+      obstack_grow_str (obstack, " member=\"");
+      p = xml_escape_text (ldi->member_name);
+      obstack_grow_str (obstack, p);
+      xfree (p);
+      obstack_grow_str (obstack, "\"");
+    }
+
+  obstack_grow_str (obstack, " text_addr=\"");
+  obstack_grow_str (obstack, core_addr_to_string (ldi->textorg));
+  obstack_grow_str (obstack, "\"");
+
+  obstack_grow_str (obstack, " text_size=\"");
+  obstack_grow_str (obstack, pulongest (ldi->textsize));
+  obstack_grow_str (obstack, "\"");
+
+  obstack_grow_str (obstack, " data_addr=\"");
+  obstack_grow_str (obstack, core_addr_to_string (ldi->dataorg));
+  obstack_grow_str (obstack, "\"");
+
+  obstack_grow_str (obstack, " data_size=\"");
+  obstack_grow_str (obstack, pulongest (ldi->datasize));
+  obstack_grow_str (obstack, "\"");
+
+  obstack_grow_str (obstack, "></library>");
+}
+
+/* Convert the ld_info binary data provided by the AIX loader into
+   an XML representation following the TARGET_OBJECT_LIBRARIES_AIX
+   format.
+
+   LDI_BUF is a buffer containing the ld_info data.
+   READBUF, OFFSET and LEN follow the same semantics as target_ops'
+   to_xfer_partial target_ops method.
+
+   If CLOSE_LDINFO_FD is nonzero, then this routine also closes
+   the ldinfo_fd file descriptor.  This is useful when the ldinfo
+   data is obtained via ptrace, as ptrace opens a file descriptor
+   for each and every entry; but we cannot use this descriptor
+   as the consumer of the XML library list might live in a different
+   process.  */
+
+LONGEST
+rs6000_aix_ld_info_to_xml (struct gdbarch *gdbarch, const gdb_byte *ldi_buf,
+			   gdb_byte *readbuf, ULONGEST offset, LONGEST len,
+			   int close_ldinfo_fd)
+{
+  struct obstack obstack;
+  const char *buf;
+  LONGEST len_avail;
+
+  obstack_init (&obstack);
+  obstack_grow_str (&obstack, "<library-list-aix version=\"1.0\">\n");
+
+  while (1)
+    {
+      struct ld_info ldi = rs6000_aix_extract_ld_info (gdbarch, ldi_buf);
+
+      rs6000_aix_shared_library_to_xml (&ldi, &obstack);
+      if (close_ldinfo_fd)
+	close (ldi.fd);
+
+      if (!ldi.next)
+	break;
+      ldi_buf = ldi_buf + ldi.next;
+    }
+
+  obstack_grow_str0 (&obstack, "</library-list-aix>\n");
+
+  buf = obstack_finish (&obstack);
+  len_avail = strlen (buf);
+  if (offset >= len_avail)
+    len= 0;
+  else
+    {
+      if (len > len_avail - offset)
+        len = len_avail - offset;
+      memcpy (readbuf, buf + offset, len);
+    }
+
+  obstack_free (&obstack, NULL);
+  return len;
+}
+
+/* Implement the core_xfer_shared_libraries_aix gdbarch method.  */
+
+static LONGEST
+rs6000_aix_core_xfer_shared_libraries_aix (struct gdbarch *gdbarch,
+					   gdb_byte *readbuf,
+					   ULONGEST offset,
+					   LONGEST len)
+{
+  struct bfd_section *ldinfo_sec;
+  int ldinfo_size;
+  gdb_byte *ldinfo_buf;
+  struct cleanup *cleanup;
+  LONGEST result;
+
+  ldinfo_sec = bfd_get_section_by_name (core_bfd, ".ldinfo");
+  if (ldinfo_sec == NULL)
+    error (_("cannot find .ldinfo section from core file: %s"),
+	   bfd_errmsg (bfd_get_error ()));
+  ldinfo_size = bfd_get_section_size (ldinfo_sec);
+
+  ldinfo_buf = xmalloc (ldinfo_size);
+  cleanup = make_cleanup (xfree, ldinfo_buf);
+
+  if (! bfd_get_section_contents (core_bfd, ldinfo_sec,
+				  ldinfo_buf, 0, ldinfo_size))
+    error (_("unable to read .ldinfo section from core file: %s"),
+	  bfd_errmsg (bfd_get_error ()));
+
+  result = rs6000_aix_ld_info_to_xml (gdbarch, ldinfo_buf, readbuf,
+				      offset, len, 0);
+
+  do_cleanups (cleanup);
+  return result;
+}
+
 static void
 rs6000_aix_init_osabi (struct gdbarch_info info, struct gdbarch *gdbarch)


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


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

only message in thread, other threads:[~2013-05-16 13:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-16 13:13 [SCM] gbenson/rtld-probes: Bump copyright years gary

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).