[Lldb-commits] [lldb] r293392 - Switch HostInfoNetBSD::GetProgramFileSpec to sysctl(7)
Kamil Rytarowski via lldb-commits
lldb-commits at lists.llvm.org
Sat Jan 28 12:04:53 PST 2017
Author: kamil
Date: Sat Jan 28 14:04:53 2017
New Revision: 293392
URL: http://llvm.org/viewvc/llvm-project?rev=293392&view=rev
Log:
Switch HostInfoNetBSD::GetProgramFileSpec to sysctl(7)
Summary:
Remove dependency on the proc (/proc) filesystem, which is optional.
KERN_PROC_PATHNAME is available in NetBSD-current and will land NetBSD 8.0.
Older stable versions of NetBSD will not be supported.
Sponsored by <The NetBSD Foundation>
Reviewers: emaste, joerg, labath, clayborg
Reviewed By: clayborg
Subscribers: #lldb
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D29089
Modified:
lldb/trunk/source/Host/netbsd/HostInfoNetBSD.cpp
Modified: lldb/trunk/source/Host/netbsd/HostInfoNetBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/netbsd/HostInfoNetBSD.cpp?rev=293392&r1=293391&r2=293392&view=diff
==============================================================================
--- lldb/trunk/source/Host/netbsd/HostInfoNetBSD.cpp (original)
+++ lldb/trunk/source/Host/netbsd/HostInfoNetBSD.cpp Sat Jan 28 14:04:53 2017
@@ -85,15 +85,15 @@ FileSpec HostInfoNetBSD::GetProgramFileS
static FileSpec g_program_filespec;
if (!g_program_filespec) {
- ssize_t len;
- static char buf[PATH_MAX];
- char name[PATH_MAX];
+ static const int name[] = {
+ CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME,
+ };
+ char path[MAXPATHLEN];
+ size_t len;
- ::snprintf(name, PATH_MAX, "/proc/%d/exe", ::getpid());
- len = ::readlink(name, buf, PATH_MAX - 1);
- if (len != -1) {
- buf[len] = '\0';
- g_program_filespec.SetFile(buf, false);
+ len = sizeof(path);
+ if (sysctl(name, __arraycount(name), path, &len, NULL, 0) != -1) {
+ g_program_filespec.SetFile(path, false);
}
}
return g_program_filespec;
More information about the lldb-commits
mailing list