mirror of
https://github.com/intel/llvm.git
synced 2026-01-20 19:07:53 +08:00
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 llvm-svn: 312430
This commit is contained in:
@@ -73,7 +73,14 @@ GetFreeBSDProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr,
|
||||
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(),
|
||||
|
||||
Reference in New Issue
Block a user