[Lldb-commits] [lldb] r123502 - /lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
Stephen Wilson
wilsons at start.ca
Fri Jan 14 16:12:41 PST 2011
Author: wilsons
Date: Fri Jan 14 18:12:41 2011
New Revision: 123502
URL: http://llvm.org/viewvc/llvm-project?rev=123502&view=rev
Log:
Miscellaneous cleanups in ProcessMonitor.
Propagate the environment if one is not provided. Also, do not allocate the
monitor threads launch arguments on the stack.
Modified:
lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=123502&r1=123501&r2=123502&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Fri Jan 14 18:12:41 2011
@@ -463,8 +463,10 @@
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 @@
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 @@
}
// 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 @@
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))
{
More information about the lldb-commits
mailing list