Assume KERN_PROC_PATHNAME is present on FreeBSD hosts.
authorJohn Baldwin <jhb@FreeBSD.org>
Wed, 16 Sep 2020 18:40:05 +0000 (11:40 -0700)
committerJohn Baldwin <jhb@FreeBSD.org>
Wed, 16 Sep 2020 18:40:05 +0000 (11:40 -0700)
FreeBSD kernels have included this sysctl since 6.0 release.  The most
recent release without support is 5.5 which was released in May of
2006.

Both the sysctl and the /proc/<pid>/exe file call the same function in
the kernel to obtain the path (vn_fullpath).  If the sysctl fails, the
readlink call will also fail, so there is no need to keep the readlink
fallback.

gdb/ChangeLog:

* fbsd-nat.c (fbsd_nat_target::pid_to_exec_file): Always use
sysctl and remove procfs fallback.

gdb/ChangeLog
gdb/fbsd-nat.c

index 8cfe3491595a5836b969aec837dca020175d1e68..68ecbf01b9618cf0c0ab9785d72d3c5cec079eda 100644 (file)
@@ -1,3 +1,8 @@
+2020-09-16  John Baldwin  <jhb@FreeBSD.org>
+
+       * fbsd-nat.c (fbsd_nat_target::pid_to_exec_file): Always use
+       sysctl and remove procfs fallback.
+
 2020-09-16  John Baldwin  <jhb@FreeBSD.org>
 
        * fbsd-nat.c: Assume PT_LWPINFO is always defined.
index fc7136a97c7de995be8332618d2ba4afcdea636d..6193e0fbde00413f0bb9e0d3085259e92a5c688b 100644 (file)
 char *
 fbsd_nat_target::pid_to_exec_file (int pid)
 {
-  ssize_t len;
   static char buf[PATH_MAX];
-  char name[PATH_MAX];
-
-#ifdef KERN_PROC_PATHNAME
   size_t buflen;
   int mib[4];
 
@@ -71,15 +67,6 @@ fbsd_nat_target::pid_to_exec_file (int pid)
        for processes without an associated executable such as kernel
        processes.  */
     return buflen == 0 ? NULL : buf;
-#endif
-
-  xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid);
-  len = readlink (name, buf, PATH_MAX - 1);
-  if (len != -1)
-    {
-      buf[len] = '\0';
-      return buf;
-    }
 
   return NULL;
 }
This page took 0.035328 seconds and 4 git commands to generate.