summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Wilson <wilsons@start.ca>2011-01-15 00:12:41 +0000
committerStephen Wilson <wilsons@start.ca>2011-01-15 00:12:41 +0000
commit57740ecedbc8e6eda7cd74659204a35b5a190d00 (patch)
tree9d6d6fc10c3db38ab2f470cd5392ea8d903a901a
parentb68ec5c339903ea05caaac13c37be9a21318239e (diff)
downloadbcm5719-llvm-57740ecedbc8e6eda7cd74659204a35b5a190d00.tar.gz
bcm5719-llvm-57740ecedbc8e6eda7cd74659204a35b5a190d00.zip
Miscellaneous cleanups in ProcessMonitor.
Propagate the environment if one is not provided. Also, do not allocate the monitor threads launch arguments on the stack. llvm-svn: 123502
-rw-r--r--lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp
index 15222631017..f21cb00e7fc 100644
--- a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp
+++ b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp
@@ -463,8 +463,10 @@ ProcessMonitor::ProcessMonitor(ProcessLinux *process,
m_client_fd(-1),
m_server_fd(-1)
{
- LaunchArgs args(this, module, argv, envp,
- stdin_path, stdout_path, stderr_path);
+ std::auto_ptr<LaunchArgs> args;
+
+ args.reset(new LaunchArgs(this, module, argv, envp,
+ stdin_path, stdout_path, stderr_path));
// Server/client descriptors.
if (!EnableIPC())
@@ -473,13 +475,13 @@ ProcessMonitor::ProcessMonitor(ProcessLinux *process,
error.SetErrorString("Monitor failed to initialize.");
}
- StartOperationThread(&args, error);
+ StartOperationThread(args.get(), error);
if (!error.Success())
return;
WAIT_AGAIN:
// Wait for the operation thread to initialize.
- if (sem_wait(&args.m_semaphore))
+ if (sem_wait(&args->m_semaphore))
{
if (errno == EINTR)
goto WAIT_AGAIN;
@@ -491,16 +493,17 @@ WAIT_AGAIN:
}
// Check that the launch was a success.
- if (!args.m_error.Success())
+ if (!args->m_error.Success())
{
StopOperationThread();
- error = args.m_error;
+ error = args->m_error;
return;
}
// Finally, start monitoring the child process for change in state.
- if (!(m_monitor_thread = Host::StartMonitoringChildProcess(
- ProcessMonitor::MonitorCallback, this, GetPID(), true)))
+ m_monitor_thread = Host::StartMonitoringChildProcess(
+ ProcessMonitor::MonitorCallback, this, GetPID(), true);
+ if (m_monitor_thread == LLDB_INVALID_HOST_THREAD)
{
error.SetErrorToGenericError();
error.SetErrorString("Process launch failed.");
@@ -574,6 +577,10 @@ ProcessMonitor::Launch(LaunchArgs *args)
lldb::ThreadSP inferior;
+ // Propagate the environment if one is not supplied.
+ if (envp == NULL || envp[0] == NULL)
+ envp = const_cast<const char **>(environ);
+
// Pseudo terminal setup.
if (!terminal.OpenFirstAvailableMaster(O_RDWR | O_NOCTTY, err_str, err_len))
{
OpenPOWER on IntegriCloud