Sun Dec 10 05:36:25 2017 UTC ()
PR/52799: Martin Husemann: Correct sysctl args to find executable.


(christos)
diff -r1.4 -r1.5 src/external/gpl3/gdb/dist/gdb/nbsd-nat.c

cvs diff -r1.4 -r1.5 src/external/gpl3/gdb/dist/gdb/nbsd-nat.c (expand / switch to unified diff)

--- src/external/gpl3/gdb/dist/gdb/nbsd-nat.c 2017/12/01 22:22:40 1.4
+++ src/external/gpl3/gdb/dist/gdb/nbsd-nat.c 2017/12/10 05:36:25 1.5
@@ -40,29 +40,29 @@ @@ -40,29 +40,29 @@
40 40
41static char * 41static char *
42nbsd_pid_to_exec_file (struct target_ops *self, int pid) 42nbsd_pid_to_exec_file (struct target_ops *self, int pid)
43{ 43{
44 ssize_t len; 44 ssize_t len;
45 static char buf[PATH_MAX]; 45 static char buf[PATH_MAX];
46 char name[PATH_MAX]; 46 char name[PATH_MAX];
47 47
48#ifdef KERN_PROC_PATHNAME 48#ifdef KERN_PROC_PATHNAME
49 size_t buflen; 49 size_t buflen;
50 int mib[4]; 50 int mib[4];
51 51
52 mib[0] = CTL_KERN; 52 mib[0] = CTL_KERN;
53 mib[1] = KERN_PROC; 53 mib[1] = KERN_PROC_ARGS;
54 mib[2] = KERN_PROC_PATHNAME; 54 mib[2] = pid;
55 mib[3] = pid; 55 mib[3] = KERN_PROC_PATHNAME;
56 buflen = sizeof buf; 56 buflen = sizeof buf;
57 if (sysctl (mib, 4, buf, &buflen, NULL, 0) == 0) 57 if (sysctl (mib, 4, buf, &buflen, NULL, 0) == 0)
58 return buf; 58 return buf;
59#endif 59#endif
60 60
61 xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid); 61 xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid);
62 len = readlink (name, buf, PATH_MAX - 1); 62 len = readlink (name, buf, PATH_MAX - 1);
63 if (len != -1) 63 if (len != -1)
64 { 64 {
65 buf[len] = '\0'; 65 buf[len] = '\0';
66 return buf; 66 return buf;
67 } 67 }
68 68