25137614 gdb is not able to debug PIE executables on sparc
authorApril Chin <april.chin@oracle.com>
Wed, 19 Apr 2017 14:37:55 -0700
changeset 7939 a0c0b8aac8d4
parent 7923 5df54a6ef074
child 7940 f9c043c82323
25137614 gdb is not able to debug PIE executables on sparc
components/gdb/patches/001-fix-proc-name-size.patch
components/gdb/patches/gdb.procfs.c.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/gdb/patches/001-fix-proc-name-size.patch	Wed Apr 19 14:37:55 2017 -0700
@@ -0,0 +1,28 @@
+#
+# Fix the size of the pathname for /proc files.
+# In Solaris, PID_MAX is 999999 (6 digit pid).
+# In Solaris, lwpid_t is an unsigned int, so theoretically the lwp id
+# could be 10 digits.
+# Patch will be submitted upstream.
+#
+
+--- gdb-7.12.1-orig/gdb/procfs.c	2017-01-21 05:48:42.000000000 -0800
++++ gdb-7.12.1/gdb/procfs.c	2017-04-19 10:28:43.395097240 -0700
+@@ -341,7 +341,7 @@ typedef siginfo_t gdb_siginfo_t;
+ #  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/0123456789/lwp/0123456789/lwpstatus")
+ # endif
+ /* the name of the proc status struct depends on the implementation */
+ typedef pstatus_t   gdb_prstatus_t;
+@@ -712,7 +712,7 @@ create_procinfo (int pid, int tid)
+   else
+     {
+ #ifdef NEW_PROC_API
+-      sprintf (pi->pathname, "/proc/%05d/lwp/%d", pid, tid);
++      sprintf (pi->pathname, "/proc/%d/lwp/%d", pid, tid);
+ #else
+       sprintf (pi->pathname, MAIN_PROC_NAME_FMT, pid);
+ #endif
--- a/components/gdb/patches/gdb.procfs.c.patch	Thu Apr 20 23:00:38 2017 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-# 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.  */