[Lldb-commits] [PATCH] D32271: Patch to Attach pid successfully from different dir

Ed Maste via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sat Sep 2 18:43:16 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL312430: FreeBSD: attach to pid from different cwd (authored by emaste).

Changed prior to commit:
  https://reviews.llvm.org/D32271?vs=113664&id=113669#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32271

Files:
  lldb/trunk/source/Host/freebsd/Host.cpp


Index: lldb/trunk/source/Host/freebsd/Host.cpp
===================================================================
--- lldb/trunk/source/Host/freebsd/Host.cpp
+++ lldb/trunk/source/Host/freebsd/Host.cpp
@@ -73,7 +73,14 @@
   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(),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32271.113669.patch
Type: text/x-patch
Size: 799 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20170903/4e982360/attachment.bin>


More information about the lldb-commits mailing list