[Lldb-commits] [lldb] r166055 - in /lldb/trunk/source/Plugins/Process/Linux: ProcessMonitor.cpp ProcessMonitor.h
Greg Clayton
gclayton at apple.com
Tue Oct 16 13:20:18 PDT 2012
Author: gclayton
Date: Tue Oct 16 15:20:18 2012
New Revision: 166055
URL: http://llvm.org/viewvc/llvm-project?rev=166055&view=rev
Log:
Patch from Matt Kopec:
This patch fixes an issue where if lldb fails to attach to a process (ie. invalid pid) on Linux, the process monitor thread gets stuck waiting for a signal from the attach thread, which never comes due to not being signaled. It also implements StopOpThread which is used for both attach/launch cases as I'm not aware of any special handling needed for the attach case. Also, propagate 'Error' from the Detach function instead of using a bool.
Modified:
lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h
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=166055&r1=166054&r2=166055&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Tue Oct 16 15:20:18 2012
@@ -843,7 +843,7 @@
// Check that the launch was a success.
if (!args->m_error.Success())
{
- StopLaunchOpThread();
+ StopOpThread();
error = args->m_error;
return;
}
@@ -898,10 +898,10 @@
}
}
- // Check that the launch was a success.
+ // Check that the attach was a success.
if (!args->m_error.Success())
{
- StopAttachOpThread();
+ StopOpThread();
error = args->m_error;
return;
}
@@ -936,18 +936,6 @@
Host::ThreadCreate(g_thread_name, LaunchOpThread, args, &error);
}
-void
-ProcessMonitor::StopLaunchOpThread()
-{
- lldb::thread_result_t result;
-
- if (!IS_VALID_LLDB_HOST_THREAD(m_operation_thread))
- return;
-
- Host::ThreadCancel(m_operation_thread, NULL);
- Host::ThreadJoin(m_operation_thread, &result, NULL);
-}
-
void *
ProcessMonitor::LaunchOpThread(void *arg)
{
@@ -1142,19 +1130,15 @@
Host::ThreadCreate(g_thread_name, AttachOpThread, args, &error);
}
-void
-ProcessMonitor::StopAttachOpThread()
-{
- assert(!"Not implemented yet!!!");
-}
-
void *
ProcessMonitor::AttachOpThread(void *arg)
{
AttachArgs *args = static_cast<AttachArgs*>(arg);
- if (!Attach(args))
+ if (!Attach(args)) {
+ sem_post(&args->m_semaphore);
return NULL;
+ }
ServeOperation(args);
return NULL;
@@ -1665,16 +1649,16 @@
return result;
}
-bool
+lldb_private::Error
ProcessMonitor::Detach()
{
- bool result;
lldb_private::Error error;
- DetachOperation op(error);
- result = error.Success();
- DoOperation(&op);
+ if (m_pid != LLDB_INVALID_PROCESS_ID) {
+ DetachOperation op(error);
+ DoOperation(&op);
+ }
StopMonitor();
- return result;
+ return error;
}
bool
@@ -1705,13 +1689,25 @@
ProcessMonitor::StopMonitor()
{
StopMonitoringChildProcess();
- StopLaunchOpThread();
+ StopOpThread();
CloseFD(m_terminal_fd);
CloseFD(m_client_fd);
CloseFD(m_server_fd);
}
void
+ProcessMonitor::StopOpThread()
+{
+ lldb::thread_result_t result;
+
+ if (!IS_VALID_LLDB_HOST_THREAD(m_operation_thread))
+ return;
+
+ Host::ThreadCancel(m_operation_thread, NULL);
+ Host::ThreadJoin(m_operation_thread, &result, NULL);
+}
+
+void
ProcessMonitor::CloseFD(int &fd)
{
if (fd != -1)
Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h?rev=166055&r1=166054&r2=166055&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h Tue Oct 16 15:20:18 2012
@@ -158,7 +158,7 @@
bool
BringProcessIntoLimbo();
- bool
+ lldb_private::Error
Detach();
@@ -213,9 +213,6 @@
void
StartLaunchOpThread(LaunchArgs *args, lldb_private::Error &error);
- void
- StopLaunchOpThread();
-
static void *
LaunchOpThread(void *arg);
@@ -238,9 +235,6 @@
void
StartAttachOpThread(AttachArgs *args, lldb_private::Error &error);
- void
- StopAttachOpThread();
-
static void *
AttachOpThread(void *args);
@@ -287,6 +281,10 @@
void
StopMonitor();
+ /// Stops the operation thread used to attach/launch a process.
+ void
+ StopOpThread();
+
void
CloseFD(int &fd);
};
More information about the lldb-commits
mailing list