[Lldb-commits] [lldb] r312430 - FreeBSD: attach to pid from different cwd
Ed Maste via lldb-commits
lldb-commits at lists.llvm.org
Sat Sep 2 18:41:31 PDT 2017
Author: emaste
Date: Sat Sep 2 18:41:31 2017
New Revision: 312430
URL: http://llvm.org/viewvc/llvm-project?rev=312430&view=rev
Log:
FreeBSD: attach to pid from different cwd
attach by pid worked when running from the directory from which the
target was launched, but failed from a different directory. Use the
kern.proc.pathname sysctl to locate the target, falling back to the
original case of the target's argv[0] if that fails. Based on a patch
from Vignesh Balu.
Differential Revision: https://reviews.llvm.org/D32271
Modified:
lldb/trunk/source/Host/freebsd/Host.cpp
Modified: lldb/trunk/source/Host/freebsd/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/freebsd/Host.cpp?rev=312430&r1=312429&r2=312430&view=diff
==============================================================================
--- lldb/trunk/source/Host/freebsd/Host.cpp (original)
+++ lldb/trunk/source/Host/freebsd/Host.cpp Sat Sep 2 18:41:31 2017
@@ -73,7 +73,14 @@ GetFreeBSDProcessArgs(const ProcessInsta
if (!cstr)
return false;
- process_info.GetExecutableFile().SetFile(cstr, false);
+ // Get pathname for pid. If that fails fall back to argv[0].
+ char pathname[MAXPATHLEN];
+ size_t pathname_len = sizeof(pathname);
+ mib[2] = KERN_PROC_PATHNAME;
+ if (::sysctl(mib, 4, pathname, &pathname_len, NULL, 0) == 0)
+ process_info.GetExecutableFile().SetFile(pathname, false);
+ else
+ process_info.GetExecutableFile().SetFile(cstr, false);
if (!(match_info_ptr == NULL ||
NameMatches(process_info.GetExecutableFile().GetFilename().GetCString(),
More information about the lldb-commits
mailing list