summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/Process.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2013-04-11 22:26:47 +0000
committerGreg Clayton <gclayton@apple.com>2013-04-11 22:26:47 +0000
commit3342b9b2c98eb3d2f16dad26ccb9eef4efd9b70c (patch)
tree5c95595f9b46818800a1b6cff773581e001ca807 /lldb/source/Target/Process.cpp
parent269c6e350742a3337de090fc6de444e69cdec444 (diff)
downloadbcm5719-llvm-3342b9b2c98eb3d2f16dad26ccb9eef4efd9b70c.tar.gz
bcm5719-llvm-3342b9b2c98eb3d2f16dad26ccb9eef4efd9b70c.zip
<rdar://problem/13370286>
Fixed a case there the OperatingSystemPython would try to access and play with SBValue objects when the process' public run lock was taken. Prior to this fix, all attempts to run any SBValue functions would fail if run from the private state thread (like updating the thread list). Now we have two run locks, one for public (all threads except the private state thread) and one for private. llvm-svn: 179329
Diffstat (limited to 'lldb/source/Target/Process.cpp')
-rw-r--r--lldb/source/Target/Process.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index fcb8c0fba38..d60930ecb8d 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1019,7 +1019,8 @@ Process::Process(Target &target, Listener &listener) :
m_allocated_memory_cache (*this),
m_should_detach (false),
m_next_event_action_ap(),
- m_run_lock (),
+ m_public_run_lock (),
+ m_private_run_lock (),
m_currently_handling_event(false),
m_finalize_called(false),
m_last_broadcast_state (eStateInvalid),
@@ -1138,6 +1139,8 @@ Process::Finalize()
// contain events that have ProcessSP values in them which can keep this
// process around forever. These events need to be cleared out.
m_private_state_listener.Clear();
+ m_public_run_lock.WriteUnlock();
+ m_private_run_lock.WriteUnlock();
m_finalize_called = true;
}
@@ -1610,7 +1613,7 @@ Process::SetPublicState (StateType new_state)
{
if (log)
log->Printf("Process::SetPublicState (%s) -- unlocking run lock for detach", StateAsCString(new_state));
- m_run_lock.WriteUnlock();
+ m_public_run_lock.WriteUnlock();
}
else
{
@@ -1622,7 +1625,7 @@ Process::SetPublicState (StateType new_state)
{
if (log)
log->Printf("Process::SetPublicState (%s) -- unlocking run lock", StateAsCString(new_state));
- m_run_lock.WriteUnlock();
+ m_public_run_lock.WriteUnlock();
}
}
}
@@ -1635,7 +1638,7 @@ Process::Resume ()
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STATE | LIBLLDB_LOG_PROCESS));
if (log)
log->Printf("Process::Resume -- locking run lock");
- if (!m_run_lock.WriteTryLock())
+ if (!m_public_run_lock.WriteTryLock())
{
Error error("Resume request failed - process still running.");
if (log)
@@ -2757,7 +2760,7 @@ Process::Launch (const ProcessLaunchInfo &launch_info)
SetPublicState (eStateLaunching);
m_should_detach = false;
- if (m_run_lock.WriteTryLock())
+ if (m_public_run_lock.WriteTryLock())
{
// Now launch using these arguments.
error = DoLaunch (exe_module, launch_info);
@@ -2941,7 +2944,7 @@ Process::Attach (ProcessAttachInfo &attach_info)
error = WillAttachToProcessWithName(process_name, wait_for_launch);
if (error.Success())
{
- if (m_run_lock.WriteTryLock())
+ if (m_public_run_lock.WriteTryLock())
{
m_should_detach = true;
SetPublicState (eStateAttaching);
@@ -3018,7 +3021,7 @@ Process::Attach (ProcessAttachInfo &attach_info)
if (error.Success())
{
- if (m_run_lock.WriteTryLock())
+ if (m_public_run_lock.WriteTryLock())
{
// Now attach using these arguments.
m_should_detach = true;
@@ -3186,6 +3189,7 @@ Process::PrivateResume ()
else
{
m_mod_id.BumpResumeID();
+ m_private_run_lock.WriteLock();
error = DoResume();
if (error.Success())
{
@@ -3194,6 +3198,10 @@ Process::PrivateResume ()
if (log)
log->Printf ("Process thinks the process has resumed.");
}
+ else
+ {
+ m_private_run_lock.WriteUnlock();
+ }
}
}
else
@@ -3401,7 +3409,7 @@ Process::Detach ()
// the last events through the event system, in which case we might strand the write lock. Unlock
// it here so when we do to tear down the process we don't get an error destroying the lock.
- m_run_lock.WriteUnlock();
+ m_public_run_lock.WriteUnlock();
return error;
}
@@ -3459,7 +3467,7 @@ Process::Destroy ()
// If we have been interrupted (to kill us) in the middle of running, we may not end up propagating
// the last events through the event system, in which case we might strand the write lock. Unlock
// it here so when we do to tear down the process we don't get an error destroying the lock.
- m_run_lock.WriteUnlock();
+ m_public_run_lock.WriteUnlock();
}
m_destroy_in_process = false;
@@ -3562,6 +3570,8 @@ Process::ShouldBroadcastEvent (Event *event_ptr)
// If we aren't going to stop, let the thread plans decide if we're going to report this event.
// If no thread has an opinion, we don't report it.
+ m_private_run_lock.WriteUnlock();
+
RefreshStateAfterStop ();
if (ProcessEventData::GetInterruptedFromEvent (event_ptr))
{
@@ -3925,6 +3935,7 @@ Process::RunPrivateStateThread ()
if (log)
log->Printf ("Process::%s (arg = %p, pid = %" PRIu64 ") thread exiting...", __FUNCTION__, this, GetID());
+ m_public_run_lock.WriteUnlock();
m_private_state_control_wait.SetValue (true, eBroadcastAlways);
m_private_state_thread = LLDB_INVALID_HOST_THREAD;
return NULL;
OpenPOWER on IntegriCloud