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

2017-04-23 Thread Ed Maste via Phabricator via lldb-commits
emaste updated this revision to Diff 96334.
emaste added a comment.

Slightly simpler approach after early returns added in 
https://reviews.llvm.org/rL301100


https://reviews.llvm.org/D32271

Files:
  source/Host/freebsd/Host.cpp


Index: source/Host/freebsd/Host.cpp
===
--- source/Host/freebsd/Host.cpp
+++ source/Host/freebsd/Host.cpp
@@ -76,7 +76,14 @@
   if (!cstr)
 return false;
 
-  process_info.GetExecutableFile().SetFile(cstr, false);
+  // Get pathname for pid. If that fails fall back go argv[0].
+  char pathname[MAXPATHLEN];
+  size_t pathname_len = sizeof(pathname);
+  mib[2] = KERN_PROC_PATHNAME;
+  if (::sysctl(mib, 4, 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(),


Index: source/Host/freebsd/Host.cpp
===
--- source/Host/freebsd/Host.cpp
+++ source/Host/freebsd/Host.cpp
@@ -76,7 +76,14 @@
   if (!cstr)
 return false;
 
-  process_info.GetExecutableFile().SetFile(cstr, false);
+  // Get pathname for pid. If that fails fall back go argv[0].
+  char pathname[MAXPATHLEN];
+  size_t pathname_len = sizeof(pathname);
+  mib[2] = KERN_PROC_PATHNAME;
+  if (::sysctl(mib, 4, 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(),
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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

2017-04-23 Thread vignesh balu via Phabricator via lldb-commits
vbalu accepted this revision.
vbalu added a comment.
This revision is now accepted and ready to land.

Fine. This will work. Thanks for the update.


https://reviews.llvm.org/D32271



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits