summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Plugins/Process/Linux/ProcessMonitor.cpp2
-rw-r--r--lldb/source/Target/Process.cpp31
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 eaecf339094..67054054fab 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 2dbe88f76dd..077b9709924 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())
{
OpenPOWER on IntegriCloud