<div dir="ltr"><div><a href="http://llvm.org/bugs/show_bug.cgi?id=16443"><b>Bug 16443</b></a> -<span id="summary_alias_container"> 
      <span id="short_desc_nonedit_display">target create doesn't expand ~ on Linux</span>
        <br><br></span>I created a bug for this, but it wasn't as complex to fix as I had thought.  Though I'm not exactly sure what the effects this change could have.  The test suite runs the same on Linux with or without it, but I'm not sure that's enough.  It does seem like the code went out of its way to set the arg0 to be whatever the user typed, rather than the resolved path.  Perhaps there is a reason for this I don't understand?<br>
<br><br></div>Here's the bug summary:<br><pre class="" id="comment_text_0">If you start lldb and do a target create on a path with a ~ as part of the path, it is accepted but when trying to run the process the launch fails.

Here's an example where the test binary is ~/a.out  it is also /home/matthews/a.out which works fine.  Both paths work fine when used on the command line (most likely due to shell expansion)

matthews@matthews-linux:~/work/llvm/llvm/build$ bin/lldb
(lldb) version
lldb version 3.4 ( <a href="http://llvm.org/svn/llvm-project/lldb/trunk">http://llvm.org/svn/llvm-project/lldb/trunk</a> revision 184861)
(lldb) target create ~/a.out
Current executable set to '~/a.out' (x86_64).
(lldb) run
error: process launch failed: Child exec failed.


(lldb) target create /home/matthews/a.out
Current executable set to '/home/matthews/a.out' (x86_64).
(lldb) run
Process 4493 launched: '/home/matthews/a.out' (x86_64)
Hello world!
Function 106
Process 4493 exited with status = 13 (0x0000000d) 
(lldb) 

The target list command shows the full path to the file, but that full path isn't being used when the process is started with run.

(lldb) target create ~/a.out
Current executable set to '~/a.out' (x86_64).
(lldb) target list
Current targets:
* target #0: /home/matthews/a.out ( arch=x86_64--linux, platform=localhost )<br><br></pre><div>Here's a possible patch:<br></div><div><div><br>Index: source/Target/TargetList.cpp<br>===================================================================<br>
--- source/Target/TargetList.cpp    (revision 184861)<br>+++ source/Target/TargetList.cpp    (working copy)<br>@@ -304,8 +304,8 @@<br>             }<br>             else<br>             {<br>-                // Just use what the user typed<br>
-                target_sp->SetArg0 (user_exe_path);<br>+                // Use resolved path<br>+                target_sp->SetArg0 (file.GetPath().c_str());<br>             }<br>         }<br>         if (file.GetDirectory())<br>
<br></div></div></div>