m_comm("lldb.process.kdp-remote.communication"),
m_async_broadcaster (NULL, "lldb.process.kdp-remote.async-broadcaster"),
m_async_thread (LLDB_INVALID_HOST_THREAD),
- m_destroy_in_process (false),
m_dyld_plugin_name (),
m_kernel_load_addr (LLDB_INVALID_ADDRESS),
m_command_sp()
}
Error
-ProcessKDP::WillDestroy ()
-{
- Error error;
- m_destroy_in_process = true;
- return error;
-}
-
-Error
ProcessKDP::DoDestroy ()
{
// For KDP there really is no difference between destroy and detach
m_currently_handling_event(false),
m_finalize_called(false),
m_last_broadcast_state (eStateInvalid),
- m_can_jit(eCanJITDontKnow)
+ m_can_jit(eCanJITDontKnow),
+ m_destroy_in_process (false)
{
CheckInWithManager ();
// thread list, but only update if "true" is returned
if (UpdateThreadList (m_thread_list, new_thread_list))
{
- OperatingSystem *os = GetOperatingSystem ();
- if (os)
- os->UpdateThreadList (m_thread_list, new_thread_list);
- m_thread_list.Update (new_thread_list);
- m_thread_list.SetStopID (stop_id);
+ // Don't call into the OperatingSystem to update the thread list if we are shutting down, since
+ // that may call back into the SBAPI's, requiring the API lock which is already held by whoever is
+ // shutting us down, causing a deadlock.
+ if (!m_destroy_in_process)
+ {
+ OperatingSystem *os = GetOperatingSystem ();
+ if (os)
+ os->UpdateThreadList (m_thread_list, new_thread_list);
+ m_thread_list.Update (new_thread_list);
+ m_thread_list.SetStopID (stop_id);
+ }
}
}
}
Error
Process::Destroy ()
{
+
+ // Tell ourselves we are in the process of destroying the process, so that we don't do any unnecessary work
+ // that might hinder the destruction. Remember to set this back to false when we are done. That way if the attempt
+ // failed and the process stays around for some reason it won't be in a confused state.
+
+ m_destroy_in_process = true;
+
Error error (WillDestroy());
if (error.Success())
{
{
// If we exited when we were waiting for a process to stop, then
// forward the event here so we don't lose the event
+ m_destroy_in_process = false;
return error;
}
}
{
if (log)
log->Printf("Process::Destroy() Halt got error: %s", error.AsCString());
+ m_destroy_in_process = false;
return error;
}
}
// 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_destroy_in_process = false;
+
return error;
}