<a href="http://lists.cs.uiuc.edu/pipermail/lldb-dev/2014-October/005551.html">http://lists.cs.uiuc.edu/pipermail/lldb-dev/2014-October/005551.html</a><br><br>Here's a thread that provides some context for why this was changed.<br><br>Your failure mode mentions invoking "lldb ls".  If FileSpec::Resolve just ends up returning "ls" unchanged, who actually resolves it?  In the thread i linked above, it seems  i was also dealing with the same issue.  Perhaps it's time to add a function to resolve an executable using PATH?  We could put it in llvm::sys::fs and call it llvm::sys::resolve_executable(StringRef Exe, bool use_path).  Seems generally useful outside of lldb.  The LLDB could just always call this function before constructing a FileSpec to a target executable.<br><br><div class="gmail_quote">On Fri, Feb 6, 2015 at 5:35 PM Zachary Turner <<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Could we add a test that verifies the behavior of this function?  Greg created an SBFileSpec test recently in lldb/test/functionalities/<u></u>path<u></u>s/TestPaths.py.  As long as we don't use a builtin command like ls or something like it should be fine.  Instead you could use something like sys.executable, then the os.path module to get out the filename, then verify that after you resolve it, it matches sys.executable.<br>
<br>
<br>
================<br>
Comment at: source/Host/common/FileSpec.<u></u>cp<u></u>p:167-173<br>
@@ -166,1 +166,9 @@<br>
<br>
+    // Save a copy of the original path that's passed in<br>
+    char original_path[PATH_MAX];<br>
+    ::strncpy (original_path, path.data(), sizeof (original_path));<br>
+    if (path.size() < sizeof (original_path))<br>
+        original_path[path.size()] = '\0';<br>
+    else<br>
+        original_path[sizeof (original_path) - 1] = '\0';<br>
+<br>
----------------<br>
You can write this like this:<br>
<br>
llvm::SmallString<PATH_MAX> original_path(path.begin(),  path.end());<br>
<br>
================<br>
Comment at: source/Host/common/FileSpec.<u></u>cp<u></u>p:177-183<br>
@@ +176,9 @@<br>
+<br>
+    // Get the resolved path as a char*, call stat() to see if it exists<br>
+    char resolved_path[PATH_MAX];<br>
+    ::strncpy (resolved_path, path.data(), sizeof (resolved_path));<br>
+    if (path.size() < sizeof (original_path))<br>
+        resolved_path[path.size()] = '\0';<br>
+    else<br>
+        resolved_path[sizeof (resolved_path) - 1] = '\0';<br>
+<br>
----------------<br>
I'm preeeety sure that make_absolute() guarantees the result will be null terminated.  But not quite 100%.  If you can determine that it's guaranteed to be null terminated, you can replace all of this with path.data(), which returns a char*.  If you want to be extra certain though, you can still make this shorter by writing this instead:<br>
<br>
path.push_back(0);<br>
path.pop_back();<br>
if (stat(path.data())) // path.data() is now definitely null terminated.<br>
<br>
================<br>
Comment at: source/Host/common/FileSpec.<u></u>cp<u></u>p:190-191<br>
@@ +189,4 @@<br>
+        // Return the original path instead<br>
+        path.resize (strlen (original_path) + 1);<br>
+        memcpy (path.data(), original_path, strlen (original_path) + 1);<br>
+    }<br>
----------------<br>
This can just be path = original_path;<br>
<br>
<a href="http://reviews.llvm.org/D7477" target="_blank">http://reviews.llvm.org/D7477</a><br>
<br>
EMAIL PREFERENCES<br>
  <a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank">http://reviews.llvm.org/<u></u>settin<u></u>gs/panel/<u></u>emailpreferences/</a><br>
<br>
<br>
</blockquote></div>