summaryrefslogtreecommitdiffstats
path: root/lldb/source/Target/Process.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Target/Process.cpp')
-rw-r--r--lldb/source/Target/Process.cpp54
1 files changed, 28 insertions, 26 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 7f7b3eb69a5..9c3be2cf071 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -4088,7 +4088,7 @@ Process::ResumePrivateStateThread ()
void
Process::StopPrivateStateThread ()
{
- if (PrivateStateThreadIsValid ())
+ if (m_private_state_thread.IsJoinable ())
ControlPrivateStateThread (eBroadcastInternalStateControlStop);
else
{
@@ -4110,21 +4110,23 @@ Process::ControlPrivateStateThread (uint32_t signal)
if (log)
log->Printf ("Process::%s (signal = %d)", __FUNCTION__, signal);
- // Signal the private state thread. First we should copy this is case the
- // thread starts exiting since the private state thread will NULL this out
- // when it exits
+ // Signal the private state thread
+ if (m_private_state_thread.IsJoinable())
{
- HostThread private_state_thread(m_private_state_thread);
- if (private_state_thread.IsJoinable())
- {
- if (log)
- log->Printf ("Sending control event of type: %d.", signal);
- // Send the control event and wait for the receipt or for the private state
- // thread to exit
- std::shared_ptr<EventDataReceipt> event_receipt_sp(new EventDataReceipt());
- m_private_state_control_broadcaster.BroadcastEvent(signal, event_receipt_sp);
+ // Broadcast the event.
+ // It is important to do this outside of the if below, because
+ // it's possible that the thread state is invalid but that the
+ // thread is waiting on a control event instead of simply being
+ // on its way out (this should not happen, but it apparently can).
+ if (log)
+ log->Printf ("Sending control event of type: %d.", signal);
+ std::shared_ptr<EventDataReceipt> event_receipt_sp(new EventDataReceipt());
+ m_private_state_control_broadcaster.BroadcastEvent(signal, event_receipt_sp);
- bool receipt_received = false;
+ // Wait for the event receipt or for the private state thread to exit
+ bool receipt_received = false;
+ if (PrivateStateThreadIsValid())
+ {
while (!receipt_received)
{
bool timed_out = false;
@@ -4137,23 +4139,24 @@ Process::ControlPrivateStateThread (uint32_t signal)
if (!receipt_received)
{
// Check if the private state thread is still around. If it isn't then we are done waiting
- if (!m_private_state_thread.IsJoinable())
- break; // Private state thread exited, we are done
+ if (!PrivateStateThreadIsValid())
+ break; // Private state thread exited or is exiting, we are done
}
}
-
- if (signal == eBroadcastInternalStateControlStop)
- {
- thread_result_t result = NULL;
- private_state_thread.Join(&result);
- }
}
- else
+
+ if (signal == eBroadcastInternalStateControlStop)
{
- if (log)
- log->Printf ("Private state thread already dead, no need to signal it to stop.");
+ thread_result_t result = NULL;
+ m_private_state_thread.Join(&result);
+ m_private_state_thread.Reset();
}
}
+ else
+ {
+ if (log)
+ log->Printf("Private state thread already dead, no need to signal it to stop.");
+ }
}
void
@@ -4446,7 +4449,6 @@ Process::RunPrivateStateThread (bool is_secondary_thread)
// try to change it on the way out.
if (!is_secondary_thread)
m_public_run_lock.SetStopped();
- m_private_state_thread.Reset();
return NULL;
}
OpenPOWER on IntegriCloud