components/gdb/patches/gdb.procfs.c.patch
author April Chin <april.chin@oracle.com>
Fri, 15 Jul 2016 07:22:25 -0700
changeset 6420 65948e9e205b
parent 1511 4d3b0b480760
permissions -rw-r--r--
22928258 update gdb to 7.11 20745970 need to investigate if gdb tests can be added to Makefile test target

# Patch required for Solaris.
# Will contribute upstream if possible; if so, may need to #ifdef SOLARIS.

--- gdb-7.11-orig/gdb/procfs.c	Tue Feb  9 19:19:39 2016
+++ gdb-7.11/gdb/procfs.c	Thu Mar 10 13:12:47 2016
@@ -158,21 +158,34 @@
 		   gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
+  const int sizeof_auxv_field = sizeof (void *);
   gdb_byte *ptr = *readptr;
 
   if (endptr == ptr)
     return 0;
 
-  if (endptr - ptr < 8 * 2)
+  if (endptr - ptr < sizeof_auxv_field * 2)
     return -1;
 
-  *typep = extract_unsigned_integer (ptr, 4, byte_order);
-  ptr += 8;
+  /*
+   * On 64 bit Solaris SPARC, i.e. big endian, the type will be in
+   * the left 4 bytes for 32 bit processes and the right 4 bytes
+   * for 64 bit processes.  The padding is 0.
+   */
+  if ((sizeof_auxv_field == 8) && (byte_order == BFD_ENDIAN_BIG)) {
+    if (*typep == 0)
+      *typep = extract_unsigned_integer (ptr + 4, 4, byte_order);
+  } else
+    *typep = extract_unsigned_integer (ptr, sizeof_auxv_field , byte_order);
+
+  ptr += sizeof_auxv_field;
+
   /* The size of data is always 64-bit.  If the application is 32-bit,
      it will be zero extended, as expected.  */
-  *valp = extract_unsigned_integer (ptr, 8, byte_order);
-  ptr += 8;
 
+  *valp = extract_unsigned_integer (ptr, sizeof_auxv_field, byte_order);
+  ptr += sizeof_auxv_field;
+
   *readptr = ptr;
   return 1;
 }
@@ -341,7 +354,7 @@
 #  define AS_PROC_NAME_FMT     "/proc/%d/as"
 #  define MAP_PROC_NAME_FMT    "/proc/%d/map"
 #  define STATUS_PROC_NAME_FMT "/proc/%d/status"
-#  define MAX_PROC_NAME_SIZE sizeof("/proc/99999/lwp/8096/lstatus")
+#  define MAX_PROC_NAME_SIZE sizeof("/proc/012345679/lwp/0123456789/lstatus")
 # endif
 /* the name of the proc status struct depends on the implementation */
 typedef pstatus_t   gdb_prstatus_t;
@@ -349,11 +362,11 @@
 #else /* ! NEW_PROC_API */
 /* format strings for /proc paths */
 # ifndef CTL_PROC_NAME_FMT
-#  define MAIN_PROC_NAME_FMT   "/proc/%05d"
-#  define CTL_PROC_NAME_FMT    "/proc/%05d"
-#  define AS_PROC_NAME_FMT     "/proc/%05d"
-#  define MAP_PROC_NAME_FMT    "/proc/%05d"
-#  define STATUS_PROC_NAME_FMT "/proc/%05d"
+#  define MAIN_PROC_NAME_FMT   "/proc/%06d"
+#  define CTL_PROC_NAME_FMT    "/proc/%06d"
+#  define AS_PROC_NAME_FMT     "/proc/%06d"
+#  define MAP_PROC_NAME_FMT    "/proc/%06d"
+#  define STATUS_PROC_NAME_FMT "/proc/%06d"
 #  define MAX_PROC_NAME_SIZE sizeof("/proc/ttttppppp")
 # endif
 /* The name of the proc status struct depends on the implementation.  */