forked from OSchip/llvm-project
Revert of r179378 and r179329, which introduce a private thread lock around thread enumeration,
in order to prevent consistent hangs on all 3 LLDB buildbots. llvm-svn: 179759
This commit is contained in:
parent
f5a0ae82e9
commit
cf7c55ebcc
|
@ -3457,10 +3457,7 @@ public:
|
||||||
ReadWriteLock &
|
ReadWriteLock &
|
||||||
GetRunLock ()
|
GetRunLock ()
|
||||||
{
|
{
|
||||||
if (Host::GetCurrentThread() == m_private_state_thread)
|
return m_run_lock;
|
||||||
return m_private_run_lock;
|
|
||||||
else
|
|
||||||
return m_public_run_lock;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -3599,8 +3596,7 @@ protected:
|
||||||
LanguageRuntimeCollection m_language_runtimes;
|
LanguageRuntimeCollection m_language_runtimes;
|
||||||
std::auto_ptr<NextEventAction> m_next_event_action_ap;
|
std::auto_ptr<NextEventAction> m_next_event_action_ap;
|
||||||
std::vector<PreResumeCallbackAndBaton> m_pre_resume_actions;
|
std::vector<PreResumeCallbackAndBaton> m_pre_resume_actions;
|
||||||
ReadWriteLock m_public_run_lock;
|
ReadWriteLock m_run_lock;
|
||||||
ReadWriteLock m_private_run_lock;
|
|
||||||
Predicate<bool> m_currently_handling_event;
|
Predicate<bool> m_currently_handling_event;
|
||||||
bool m_finalize_called;
|
bool m_finalize_called;
|
||||||
lldb::StateType m_last_broadcast_state; /// This helps with the Public event coalescing in ShouldBroadcastEvent.
|
lldb::StateType m_last_broadcast_state; /// This helps with the Public event coalescing in ShouldBroadcastEvent.
|
||||||
|
|
|
@ -1019,8 +1019,7 @@ Process::Process(Target &target, Listener &listener) :
|
||||||
m_allocated_memory_cache (*this),
|
m_allocated_memory_cache (*this),
|
||||||
m_should_detach (false),
|
m_should_detach (false),
|
||||||
m_next_event_action_ap(),
|
m_next_event_action_ap(),
|
||||||
m_public_run_lock (),
|
m_run_lock (),
|
||||||
m_private_run_lock (),
|
|
||||||
m_currently_handling_event(false),
|
m_currently_handling_event(false),
|
||||||
m_finalize_called(false),
|
m_finalize_called(false),
|
||||||
m_last_broadcast_state (eStateInvalid),
|
m_last_broadcast_state (eStateInvalid),
|
||||||
|
@ -1139,8 +1138,6 @@ Process::Finalize()
|
||||||
// contain events that have ProcessSP values in them which can keep this
|
// contain events that have ProcessSP values in them which can keep this
|
||||||
// process around forever. These events need to be cleared out.
|
// process around forever. These events need to be cleared out.
|
||||||
m_private_state_listener.Clear();
|
m_private_state_listener.Clear();
|
||||||
m_public_run_lock.WriteUnlock();
|
|
||||||
m_private_run_lock.WriteUnlock();
|
|
||||||
m_finalize_called = true;
|
m_finalize_called = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1622,7 +1619,7 @@ Process::SetPublicState (StateType new_state)
|
||||||
{
|
{
|
||||||
if (log)
|
if (log)
|
||||||
log->Printf("Process::SetPublicState (%s) -- unlocking run lock for detach", StateAsCString(new_state));
|
log->Printf("Process::SetPublicState (%s) -- unlocking run lock for detach", StateAsCString(new_state));
|
||||||
m_public_run_lock.WriteUnlock();
|
m_run_lock.WriteUnlock();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1634,7 +1631,7 @@ Process::SetPublicState (StateType new_state)
|
||||||
{
|
{
|
||||||
if (log)
|
if (log)
|
||||||
log->Printf("Process::SetPublicState (%s) -- unlocking run lock", StateAsCString(new_state));
|
log->Printf("Process::SetPublicState (%s) -- unlocking run lock", StateAsCString(new_state));
|
||||||
m_public_run_lock.WriteUnlock();
|
m_run_lock.WriteUnlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1647,7 +1644,7 @@ Process::Resume ()
|
||||||
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STATE | LIBLLDB_LOG_PROCESS));
|
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STATE | LIBLLDB_LOG_PROCESS));
|
||||||
if (log)
|
if (log)
|
||||||
log->Printf("Process::Resume -- locking run lock");
|
log->Printf("Process::Resume -- locking run lock");
|
||||||
if (!m_public_run_lock.WriteTryLock())
|
if (!m_run_lock.WriteTryLock())
|
||||||
{
|
{
|
||||||
Error error("Resume request failed - process still running.");
|
Error error("Resume request failed - process still running.");
|
||||||
if (log)
|
if (log)
|
||||||
|
@ -2769,7 +2766,7 @@ Process::Launch (const ProcessLaunchInfo &launch_info)
|
||||||
SetPublicState (eStateLaunching);
|
SetPublicState (eStateLaunching);
|
||||||
m_should_detach = false;
|
m_should_detach = false;
|
||||||
|
|
||||||
if (m_public_run_lock.WriteTryLock())
|
if (m_run_lock.WriteTryLock())
|
||||||
{
|
{
|
||||||
// Now launch using these arguments.
|
// Now launch using these arguments.
|
||||||
error = DoLaunch (exe_module, launch_info);
|
error = DoLaunch (exe_module, launch_info);
|
||||||
|
@ -2953,9 +2950,8 @@ Process::Attach (ProcessAttachInfo &attach_info)
|
||||||
error = WillAttachToProcessWithName(process_name, wait_for_launch);
|
error = WillAttachToProcessWithName(process_name, wait_for_launch);
|
||||||
if (error.Success())
|
if (error.Success())
|
||||||
{
|
{
|
||||||
if (m_public_run_lock.WriteTryLock())
|
if (m_run_lock.WriteTryLock())
|
||||||
{
|
{
|
||||||
m_private_run_lock.WriteLock();
|
|
||||||
m_should_detach = true;
|
m_should_detach = true;
|
||||||
SetPublicState (eStateAttaching);
|
SetPublicState (eStateAttaching);
|
||||||
// Now attach using these arguments.
|
// Now attach using these arguments.
|
||||||
|
@ -3031,9 +3027,8 @@ Process::Attach (ProcessAttachInfo &attach_info)
|
||||||
if (error.Success())
|
if (error.Success())
|
||||||
{
|
{
|
||||||
|
|
||||||
if (m_public_run_lock.WriteTryLock())
|
if (m_run_lock.WriteTryLock())
|
||||||
{
|
{
|
||||||
m_private_run_lock.WriteLock();
|
|
||||||
// Now attach using these arguments.
|
// Now attach using these arguments.
|
||||||
m_should_detach = true;
|
m_should_detach = true;
|
||||||
SetPublicState (eStateAttaching);
|
SetPublicState (eStateAttaching);
|
||||||
|
@ -3200,7 +3195,6 @@ Process::PrivateResume ()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_mod_id.BumpResumeID();
|
m_mod_id.BumpResumeID();
|
||||||
m_private_run_lock.WriteLock();
|
|
||||||
error = DoResume();
|
error = DoResume();
|
||||||
if (error.Success())
|
if (error.Success())
|
||||||
{
|
{
|
||||||
|
@ -3209,10 +3203,6 @@ Process::PrivateResume ()
|
||||||
if (log)
|
if (log)
|
||||||
log->Printf ("Process thinks the process has resumed.");
|
log->Printf ("Process thinks the process has resumed.");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
m_private_run_lock.WriteUnlock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3420,7 +3410,7 @@ Process::Detach ()
|
||||||
// the last events through the event system, in which case we might strand the write lock. Unlock
|
// 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.
|
// it here so when we do to tear down the process we don't get an error destroying the lock.
|
||||||
|
|
||||||
m_public_run_lock.WriteUnlock();
|
m_run_lock.WriteUnlock();
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3478,7 +3468,7 @@ Process::Destroy ()
|
||||||
// If we have been interrupted (to kill us) in the middle of running, we may not end up propagating
|
// 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
|
// 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.
|
// it here so when we do to tear down the process we don't get an error destroying the lock.
|
||||||
m_public_run_lock.WriteUnlock();
|
m_run_lock.WriteUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_destroy_in_process = false;
|
m_destroy_in_process = false;
|
||||||
|
@ -3581,8 +3571,6 @@ 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 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.
|
// If no thread has an opinion, we don't report it.
|
||||||
|
|
||||||
m_private_run_lock.WriteUnlock();
|
|
||||||
|
|
||||||
RefreshStateAfterStop ();
|
RefreshStateAfterStop ();
|
||||||
if (ProcessEventData::GetInterruptedFromEvent (event_ptr))
|
if (ProcessEventData::GetInterruptedFromEvent (event_ptr))
|
||||||
{
|
{
|
||||||
|
@ -3946,7 +3934,6 @@ Process::RunPrivateStateThread ()
|
||||||
if (log)
|
if (log)
|
||||||
log->Printf ("Process::%s (arg = %p, pid = %" PRIu64 ") thread exiting...", __FUNCTION__, this, GetID());
|
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_control_wait.SetValue (true, eBroadcastAlways);
|
||||||
m_private_state_thread = LLDB_INVALID_HOST_THREAD;
|
m_private_state_thread = LLDB_INVALID_HOST_THREAD;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -4088,11 +4075,8 @@ Process::ProcessEventData::DoOnRemoval (Event *event_ptr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const lldb::StateType state = m_process_sp->GetPrivateState();
|
|
||||||
if (state != eStateRunning &&
|
if (m_process_sp->GetPrivateState() != eStateRunning)
|
||||||
state != eStateCrashed &&
|
|
||||||
state != eStateDetached &&
|
|
||||||
state != eStateExited)
|
|
||||||
{
|
{
|
||||||
if (!still_should_stop)
|
if (!still_should_stop)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue