Author: enrico
Date: Thu Apr 16 20:50:11 2015
New Revision: 235157
URL: http://llvm.org/viewvc/llvm-project?rev=235157&view=rev
Log:
Fix a bug where argdumper would not launch inferiors correctly in the presence
of arguments of the form word1\ word2 (vs. the quoted form "word1 word2")
Fixes rdar://20493444
Modified:
lldb/trunk/include/lldb/Host/Host.h
lldb/trunk/source/Host/common/Host.cpp
lldb/trunk/source/Host/macosx/Host.mm
lldb/trunk/test/functionalities/launch_with_shellexpand/TestLaunchWithShellExpand.py
Modified: lldb/trunk/include/lldb/Host/Host.h
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=235157&r1=235156&r2=235157&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Host.h (original)
+++ lldb/trunk/include/lldb/Host/Host.h Thu Apr 16 20:50:11 2015
@@ -268,6 +268,15 @@ public:
std::string *command_output, // Pass NULL if you don't
want the command output
uint32_t timeout_sec,
bool run_in_default_shell = true);
+
+ static Error
+ RunShellCommand (const Args& args,
+ const char *working_dir, // Pass NULL to use the
current working directory
+ int *status_ptr, // Pass NULL if you don't
want the process exit status
+ int *signo_ptr, // Pass NULL if you don't
want the signal that caused the process to exit
+ std::string *command_output, // Pass NULL if you don't
want the command output
+ uint32_t timeout_sec,
+ bool run_in_default_shell = true);
static lldb::DataBufferSP
GetAuxvData (lldb_private::Process *process);
Modified: lldb/trunk/source/Host/common/Host.cpp
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=235157&r1=235156&r2=235157&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Host.cpp (original)
+++ lldb/trunk/source/Host/common/Host.cpp Thu Apr 16 20:50:11 2015
@@ -552,6 +552,18 @@ Host::RunShellCommand (const char *comma
uint32_t timeout_sec,
bool run_in_default_shell)
{
+ return RunShellCommand(Args(command), working_dir, status_ptr, signo_ptr,
command_output_ptr, timeout_sec, run_in_default_shell);
+}
+
+Error
+Host::RunShellCommand (const Args &args,
+ const char *working_dir,
+ int *status_ptr,
+ int *signo_ptr,
+ std::string *command_output_ptr,
+ uint32_t timeout_sec,
+ bool run_in_default_shell)
+{
Error error;
ProcessLaunchInfo launch_info;
launch_info.SetArchitecture(HostInfo::GetArchitecture());
@@ -559,10 +571,10 @@ Host::RunShellCommand (const char *comma
{
// Run the command in a shell
launch_info.SetShell(HostInfo::GetDefaultShell());
- launch_info.GetArguments().AppendArgument(command);
+ launch_info.GetArguments().AppendArguments(args);
const bool localhost = true;
const bool will_debug = false;
- const bool first_arg_is_full_shell_command = true;
+ const bool first_arg_is_full_shell_command = false;
launch_info.ConvertArgumentsForLaunchingInShell (error,
localhost,
will_debug,
@@ -572,7 +584,6 @@ Host::RunShellCommand (const char *comma
else
{
// No shell, just run it
- Args args (command);
const bool first_arg_is_executable = true;
launch_info.SetArguments(args, first_arg_is_executable);
}
@@ -580,7 +591,7 @@ Host::RunShellCommand (const char *comma
if (working_dir)
launch_info.SetWorkingDirectory(working_dir);
llvm::SmallString<PATH_MAX> output_file_path;
-
+
if (command_output_ptr)
{
// Create a temporary file to get the stdout/stderr and redirect the
@@ -618,10 +629,10 @@ Host::RunShellCommand (const char *comma
error = LaunchProcess (launch_info);
const lldb::pid_t pid = launch_info.GetProcessID();
-
+
if (error.Success() && pid == LLDB_INVALID_PROCESS_ID)
error.SetErrorString("failed to get process ID");
-
+
if (error.Success())
{
// The process successfully launched, so we can defer ownership of
@@ -640,7 +651,7 @@ Host::RunShellCommand (const char *comma
if (timed_out)
{
error.SetErrorString("timed out waiting for shell command to
complete");
-
+
// Kill the process since it didn't complete within the timeout
specified
Kill (pid, SIGKILL);
// Wait for the monitor callback to get the message
@@ -653,10 +664,10 @@ Host::RunShellCommand (const char *comma
{
if (status_ptr)
*status_ptr = shell_info->status;
-
+
if (signo_ptr)
*signo_ptr = shell_info->signo;
-
+
if (command_output_ptr)
{
command_output_ptr->clear();
@@ -678,7 +689,7 @@ Host::RunShellCommand (const char *comma
}
shell_info->can_delete.SetValue(true, eBroadcastAlways);
}
-
+
FileSpec output_file_spec(output_file_path.c_str(), false);
if (FileSystem::GetFileExists(output_file_spec))
FileSystem::Unlink(output_file_path.c_str());
@@ -688,7 +699,6 @@ Host::RunShellCommand (const char *comma
return error;
}
-
// LaunchProcessPosixSpawn for Apple, Linux, FreeBSD and other GLIBC
// systems
Modified: lldb/trunk/source/Host/macosx/Host.mm
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=235157&r1=235156&r2=235157&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Host.mm (original)
+++ lldb/trunk/source/Host/macosx/Host.mm Thu Apr 16 20:50:11 2015
@@ -1352,18 +1352,13 @@ Host::ShellExpandArguments (ProcessLaunc
error.SetErrorString("could not find argdumper tool");
return error;
}
-
- std::string quoted_cmd_string;
- launch_info.GetArguments().GetQuotedCommandString(quoted_cmd_string);
- StreamString expand_command;
-
- expand_command.Printf("%s %s",
- expand_tool_spec.GetPath().c_str(),
- quoted_cmd_string.c_str());
+
+ Args expand_command(expand_tool_spec.GetPath().c_str());
+ expand_command.AppendArguments (launch_info.GetArguments());
int status;
std::string output;
- RunShellCommand(expand_command.GetData(),
launch_info.GetWorkingDirectory(), &status, nullptr, &output, 10);
+ RunShellCommand(expand_command, launch_info.GetWorkingDirectory(),
&status, nullptr, &output, 10);
if (status != 0)
{
Modified:
lldb/trunk/test/functionalities/launch_with_shellexpand/TestLaunchWithShellExpand.py
URL:
http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/launch_with_shellexpand/TestLaunchWithShellExpand.py?rev=235157&r1=235156&r2=235157&view=diff
==============================================================================
---
lldb/trunk/test/functionalities/launch_with_shellexpand/TestLaunchWithShellExpand.py
(original)
+++
lldb/trunk/test/functionalities/launch_with_shellexpand/TestLaunchWithShellExpand.py
Thu Apr 16 20:50:11 2015
@@ -84,6 +84,27 @@ class LaunchWithShellExpandTestCase(Test
self.expect("frame variable argv[1]", substrs=['foo bar'])
+ self.runCmd("process kill")
+
+ self.runCmd('process launch -X true -w %s -- foo\ bar' % (os.getcwd()))
+
+ process = self.process()
+
+ self.assertTrue(process.GetState() == lldb.eStateStopped,
+ STOPPED_DUE_TO_BREAKPOINT)
+
+ thread = process.GetThreadAtIndex (0)
+
+ self.assertTrue (thread.IsValid(),
+ "Process stopped at 'main' should have a valid
thread");
+
+ stop_reason = thread.GetStopReason()
+
+ self.assertTrue (stop_reason == lldb.eStopReasonBreakpoint,
+ "Thread in process stopped in 'main' should have a
stop reason of eStopReasonBreakpoint");
+
+ self.expect("frame variable argv[1]", substrs=['foo bar'])
+
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits