[Lldb-commits] [lldb] r252023 - Try a little harder to provide a legit CWD to argdumper if

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 3 17:02:06 PST 2015


Author: jingham
Date: Tue Nov  3 19:02:06 2015
New Revision: 252023

URL: http://llvm.org/viewvc/llvm-project?rev=252023&view=rev
Log:
Try a little harder to provide a legit CWD to argdumper if 
the user hasn't provided one.

Modified:
    lldb/trunk/source/Host/macosx/Host.mm

Modified: lldb/trunk/source/Host/macosx/Host.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=252023&r1=252022&r2=252023&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Host.mm (original)
+++ lldb/trunk/source/Host/macosx/Host.mm Tue Nov  3 19:02:06 2015
@@ -45,6 +45,7 @@
 #include <pwd.h>
 #include <spawn.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <sys/proc.h>
 #include <sys/stat.h>
 #include <sys/sysctl.h>
@@ -1371,7 +1372,24 @@ Host::ShellExpandArguments (ProcessLaunc
         
         int status;
         std::string output;
-        RunShellCommand(expand_command, launch_info.GetWorkingDirectory(), &status, nullptr, &output, 10);
+        FileSpec cwd(launch_info.GetWorkingDirectory());
+        if (!cwd.Exists())
+        {
+            char *wd = getcwd(nullptr, 0);
+            if (wd == nullptr)
+            {
+                error.SetErrorStringWithFormat("cwd does not exist; cannot launch with shell argument expansion");
+                return error;
+            }
+            else
+            {
+                FileSpec working_dir(wd, false);
+                free(wd);
+                launch_info.SetWorkingDirectory(working_dir);
+
+            }
+        }
+        RunShellCommand(expand_command, cwd, &status, nullptr, &output, 10);
         
         if (status != 0)
         {




More information about the lldb-commits mailing list