From 926cce7619b0b42fe05b9523f3618b89a51a37aa Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Fri, 12 Oct 2012 16:10:12 +0000 Subject: [PATCH] Modified patch from Matt Kopec that makes sure the run lock is acquired when attaching and makes sure the pid is being set on linux in the process info. llvm-svn: 165804 --- .../Plugins/Process/Linux/ProcessMonitor.cpp | 2 ++ lldb/source/Target/Process.cpp | 31 +++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp index eaecf339094a..67054054fab6 100644 --- a/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp +++ b/lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp @@ -1193,6 +1193,8 @@ ProcessMonitor::Attach(AttachArgs *args) goto FINISH; } + monitor->m_pid = pid; + // Update the process thread list with the attached thread. inferior.reset(new POSIXThread(processSP, pid)); if (log) diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 2dbe88f76dd8..077b9709924a 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -2750,10 +2750,19 @@ Process::Attach (ProcessAttachInfo &attach_info) error = WillAttachToProcessWithName(process_name, wait_for_launch); if (error.Success()) { - m_should_detach = true; + if (m_run_lock.WriteTryLock()) + { + m_should_detach = true; + SetPublicState (eStateAttaching); + // Now attach using these arguments. + error = DoAttachToProcessWithName (process_name, wait_for_launch, attach_info); + } + else + { + // This shouldn't happen + error.SetErrorString("failed to acquire process run lock"); + } - SetPublicState (eStateAttaching); - error = DoAttachToProcessWithName (process_name, wait_for_launch, attach_info); if (error.Fail()) { if (GetID() != LLDB_INVALID_PROCESS_ID) @@ -2817,10 +2826,20 @@ Process::Attach (ProcessAttachInfo &attach_info) error = WillAttachToProcessWithID(attach_pid); if (error.Success()) { - m_should_detach = true; - SetPublicState (eStateAttaching); - error = DoAttachToProcessWithID (attach_pid, attach_info); + if (m_run_lock.WriteTryLock()) + { + // Now attach using these arguments. + m_should_detach = true; + SetPublicState (eStateAttaching); + error = DoAttachToProcessWithID (attach_pid, attach_info); + } + else + { + // This shouldn't happen + error.SetErrorString("failed to acquire process run lock"); + } + if (error.Success()) {