diff options
author | Jim Ingham <jingham@apple.com> | 2015-11-04 01:02:06 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2015-11-04 01:02:06 +0000 |
commit | 6d9880a6b4b2ef284664debe056cc29422240972 (patch) | |
tree | 5f3072552205314767efcab336d5ab5306466e6e | |
parent | 5365a01dc7af87a9bbf78f484bbbc969056faea3 (diff) | |
download | bcm5719-llvm-6d9880a6b4b2ef284664debe056cc29422240972.tar.gz bcm5719-llvm-6d9880a6b4b2ef284664debe056cc29422240972.zip |
Try a little harder to provide a legit CWD to argdumper if
the user hasn't provided one.
llvm-svn: 252023
-rw-r--r-- | lldb/source/Host/macosx/Host.mm | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lldb/source/Host/macosx/Host.mm b/lldb/source/Host/macosx/Host.mm index 57be7d862d7..65e698149c6 100644 --- a/lldb/source/Host/macosx/Host.mm +++ b/lldb/source/Host/macosx/Host.mm @@ -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 (ProcessLaunchInfo &launch_info) 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) { |