aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2020-09-16 11:40:05 -0700
committerJohn Baldwin <jhb@FreeBSD.org>2020-09-16 11:40:05 -0700
commitbcb1da7fb70f543b3e0c489e5ab7dd7c38142eb4 (patch)
treed20cbbd165246645e87b53b8d922c00b2ebcb84f /gdb
parent5515f729737520b465d57d18581ba91a83ca63e7 (diff)
downloadfsf-binutils-gdb-bcb1da7fb70f543b3e0c489e5ab7dd7c38142eb4.zip
fsf-binutils-gdb-bcb1da7fb70f543b3e0c489e5ab7dd7c38142eb4.tar.gz
fsf-binutils-gdb-bcb1da7fb70f543b3e0c489e5ab7dd7c38142eb4.tar.bz2
Assume KERN_PROC_PATHNAME is present on FreeBSD hosts.
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/fbsd-nat.c13
2 files changed, 5 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8cfe349..68ecbf0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
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.
* fbsd-nat.h: Likewise.
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index fc7136a..6193e0f 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -53,11 +53,7 @@
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;
}