summaryrefslogtreecommitdiff
path: root/lldb/source/Target/Platform.cpp
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2015-02-20 21:48:38 +0000
committerEnrico Granata <egranata@apple.com>2015-02-20 21:48:38 +0000
commit83a1437646bcb916fdd3101a4234f0bc3475c347 (patch)
tree09fbf3def28ec2e9122ea792865f6e7fbe3e8c93 /lldb/source/Target/Platform.cpp
parentbc35fbe43a6a37877d5421a25616fe7858e7dfe0 (diff)
Start the refactoring of globbing
- Add Host::GlobArguments() to perform local-globbing I implemented this on OSX and Windows in terms of argdumper (Windows implementation is essentially the same as the OSX version + a change in binary name and some string magic) Other platforms did not specifically chime in, so I left it unimplemented for them for the time being. Please feel free to fill in the blanks - Add Platform::GlobArguments() to support remote-globbing For now, no feature change here - but now we have infrastructure to help GDBRemote targets to support globbing - and patches to that effect will follow No visible feature change llvm-svn: 230065
Diffstat (limited to 'lldb/source/Target/Platform.cpp')
-rw-r--r--lldb/source/Target/Platform.cpp90
1 files changed, 10 insertions, 80 deletions
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index c64559920811..669799f9df3f 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -1116,87 +1116,9 @@ Platform::LaunchProcess (ProcessLaunchInfo &launch_info)
}
else if (launch_info.GetFlags().Test(eLaunchFlagGlobArguments))
{
- FileSpec glob_tool_spec;
- if (!HostInfo::GetLLDBPath(lldb::ePathTypeSupportExecutableDir, glob_tool_spec))
- {
- error.SetErrorString("could not find argdumper tool");
- return error;
- }
-#if defined(_WIN32)
- glob_tool_spec.AppendPathComponent("argdumper.exe");
-#else
- glob_tool_spec.AppendPathComponent("argdumper");
-#endif
- if (!glob_tool_spec.Exists())
- {
- error.SetErrorString("could not find argdumper tool");
+ error = GlobArguments(launch_info);
+ if (error.Fail())
return error;
- }
-
- std::string quoted_cmd_string;
- launch_info.GetArguments().GetQuotedCommandString(quoted_cmd_string);
-#if defined(_WIN32)
- std::replace(quoted_cmd_string.begin(), quoted_cmd_string.end(), '\\', '/');
-#endif
- StreamString glob_command;
-
- glob_command.Printf("%s %s",
- glob_tool_spec.GetPath().c_str(),
- quoted_cmd_string.c_str());
-
- int status;
- std::string output;
- RunShellCommand(glob_command.GetData(), launch_info.GetWorkingDirectory(), &status, nullptr, &output, 10);
-
- if (status != 0)
- {
- error.SetErrorStringWithFormat("argdumper exited with error %d", status);
- return error;
- }
-
- auto data_sp = StructuredData::ParseJSON(output);
- if (!data_sp)
- {
- error.SetErrorString("invalid JSON");
- return error;
- }
-
- auto dict_sp = data_sp->GetAsDictionary();
- if (!data_sp)
- {
- error.SetErrorString("invalid JSON");
- return error;
- }
-
- auto args_sp = dict_sp->GetObjectForDotSeparatedPath("arguments");
- if (!args_sp)
- {
- error.SetErrorString("invalid JSON");
- return error;
- }
-
- auto args_array_sp = args_sp->GetAsArray();
- if (!args_array_sp)
- {
- error.SetErrorString("invalid JSON");
- return error;
- }
-
- launch_info.GetArguments().Clear();
-
- for (size_t i = 0;
- i < args_array_sp->GetSize();
- i++)
- {
- auto item_sp = args_array_sp->GetItemAtIndex(i);
- if (!item_sp)
- continue;
- auto str_sp = item_sp->GetAsString();
- if (!str_sp)
- continue;
-
- launch_info.GetArguments().AppendArgument(str_sp->GetValue().c_str());
- }
}
if (log)
@@ -1210,6 +1132,14 @@ Platform::LaunchProcess (ProcessLaunchInfo &launch_info)
}
Error
+Platform::GlobArguments (ProcessLaunchInfo &launch_info)
+{
+ if (IsHost())
+ return Host::GlobArguments(launch_info);
+ return Error("base lldb_private::Platform class can't glob arguments");
+}
+
+Error
Platform::KillProcess (const lldb::pid_t pid)
{
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));