krytarowski created this revision. krytarowski added a project: LLDB. 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> Repository: rL LLVM https://reviews.llvm.org/D29089 Files: source/Host/netbsd/HostInfoNetBSD.cpp Index: source/Host/netbsd/HostInfoNetBSD.cpp =================================================================== --- source/Host/netbsd/HostInfoNetBSD.cpp +++ source/Host/netbsd/HostInfoNetBSD.cpp @@ -85,15 +85,15 @@ static FileSpec g_program_filespec; if (!g_program_filespec) { - ssize_t len; - static char buf[PATH_MAX]; - char name[PATH_MAX]; - - ::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); + static const int name[] = { + CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME, + }; + char path[MAXPATHLEN]; + size_t len; + + len = sizeof(path); + if (sysctl(name, __arraycount(name), path, &len, NULL, 0) != -1) { + g_program_filespec.SetFile(path, false); } } return g_program_filespec;
Index: source/Host/netbsd/HostInfoNetBSD.cpp =================================================================== --- source/Host/netbsd/HostInfoNetBSD.cpp +++ source/Host/netbsd/HostInfoNetBSD.cpp @@ -85,15 +85,15 @@ static FileSpec g_program_filespec; if (!g_program_filespec) { - ssize_t len; - static char buf[PATH_MAX]; - char name[PATH_MAX]; - - ::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); + static const int name[] = { + CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME, + }; + char path[MAXPATHLEN]; + size_t len; + + len = sizeof(path); + if (sysctl(name, __arraycount(name), path, &len, NULL, 0) != -1) { + g_program_filespec.SetFile(path, false); } } return g_program_filespec;
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits