Fix /proc pathname sizes on Solaris
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Wed, 19 Sep 2018 09:21:32 +0000 (11:21 +0200)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Wed, 19 Sep 2018 09:21:32 +0000 (11:21 +0200)
I'm slowly working my way through the gdb patches from the
solaris-userland repo

https://github.com/oracle/solaris-userland/tree/master/components/gdb/patches

This one (001-fix-proc-name-size.patch) should be obvious given the
patches' comment:

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

Tested on i386-pc-solaris2.11.

2018-09-19  Stefan Teleman <stefan.teleman@oracle.com>
    April Chin <april.chin@oracle.com>
    Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

* procfs.c (MAX_PROC_NAME_SIZE): Allow for 6-digit PID_MAX and
uint_t lwpid_t.
(create_procinfo): Print pids in /proc without leading zeros.

gdb/ChangeLog
gdb/procfs.c

index 40d9f0d87e2e6eef1ea9bf10f5557772ca1d0079..0fe15efe69bc8b3ffe4e852a3faa0db9cb6469ab 100644 (file)
@@ -1,3 +1,11 @@
+2018-09-19  Stefan Teleman <stefan.teleman@oracle.com>
+           April Chin <april.chin@oracle.com>
+           Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+       * procfs.c (MAX_PROC_NAME_SIZE): Allow for 6-digit PID_MAX and
+       uint_t lwpid_t.
+       (create_procinfo): Print pids in /proc without leading zeros.
+
 2018-09-18  Sandra Loosemore  <sandra@codesourcery.com>
 
        * nios2-tdep.c (nios2_gcc_target_options): New.
index 66a3197b1fc215ea91bb6b0bb0b9d9ca1d9286df..e66c46992affda3337679646be26764485c8cddf 100644 (file)
@@ -231,7 +231,7 @@ enum { READ_WATCHFLAG  = WA_READ,
 #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/999999/lwp/0123456789/lwpstatus")
 
 typedef struct procinfo {
   struct procinfo *next;
@@ -480,7 +480,7 @@ create_procinfo (int pid, int tid)
     }
   else
     {
-      sprintf (pi->pathname, "/proc/%05d/lwp/%d", pid, tid);
+      sprintf (pi->pathname, "/proc/%d/lwp/%d", pid, tid);
       pi->next = parent->thread_list;
       parent->thread_list = pi;
     }