summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/Process.cpp
diff options
context:
space:
mode:
authorAndrew Kaylor <andrew.kaylor@intel.com>2013-05-10 17:19:04 +0000
committerAndrew Kaylor <andrew.kaylor@intel.com>2013-05-10 17:19:04 +0000
commit29d65744c9290f901cc86a096be942a97a649b61 (patch)
tree09084e672f8e2950a245702058fe2a414cc1f384 /lldb/source/Target/Process.cpp
parent72a196a159b28f26f84d9afec8b2baac11d367bc (diff)
downloadbcm5719-llvm-29d65744c9290f901cc86a096be942a97a649b61.tar.gz
bcm5719-llvm-29d65744c9290f901cc86a096be942a97a649b61.zip
Adding support for setting thread stop state when a process stops.
This re-submission of this patch fixes a problem where the code sometimes caused a deadlock. The Process::SetPrivateState method was locking the Process::m_private_state variable and then later calling ThreadList::DidStop, which locks the ThreadList mutex. Other methods in ThreadList which were being called from other threads lock the ThreadList mutex and then call Process::GetPrivateState which locks the Process::m_private_state mutex. To avoid deadlocks, Process::SetPrivateState now locks the ThreadList mutex before locking the Process::m_private_state mutex. llvm-svn: 181609
Diffstat (limited to 'lldb/source/Target/Process.cpp')
-rw-r--r--lldb/source/Target/Process.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 93fd93a71de..01ee7e482d1 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1699,6 +1699,7 @@ Process::SetPrivateState (StateType new_state)
if (log)
log->Printf("Process::SetPrivateState (%s)", StateAsCString(new_state));
+ Mutex::Locker thread_locker(m_thread_list.GetMutex());
Mutex::Locker locker(m_private_state.GetMutex());
const StateType old_state = m_private_state.GetValueNoLock ();
@@ -1722,6 +1723,19 @@ Process::SetPrivateState (StateType new_state)
m_private_state.SetValueNoLock (new_state);
if (StateIsStoppedState(new_state, false))
{
+ // Note, this currently assumes that all threads in the list
+ // stop when the process stops. In the future we will want to
+ // support a debugging model where some threads continue to run
+ // while others are stopped. When that happens we will either need
+ // a way for the thread list to identify which threads are stopping
+ // or create a special thread list containing only threads which
+ // actually stopped.
+ //
+ // The process plugin is responsible for managing the actual
+ // behavior of the threads and should have stopped any threads
+ // that are going to stop before we get here.
+ m_thread_list.DidStop();
+
m_mod_id.BumpStopID();
m_memory_cache.Clear();
if (log)
OpenPOWER on IntegriCloud