diff options
-rw-r--r-- | lldb/include/lldb/Core/ModuleList.h | 4 | ||||
-rw-r--r-- | lldb/source/API/SBDebugger.cpp | 10 | ||||
-rw-r--r-- | lldb/source/Commands/CommandObjectTarget.cpp | 3 | ||||
-rw-r--r-- | lldb/source/Core/Module.cpp | 3 | ||||
-rw-r--r-- | lldb/source/Core/ModuleList.cpp | 19 |
5 files changed, 29 insertions, 10 deletions
diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h index 75d93c7c7ca..afe6dcb696f 100644 --- a/lldb/include/lldb/Core/ModuleList.h +++ b/lldb/include/lldb/Core/ModuleList.h @@ -356,7 +356,7 @@ public: Remove (ModuleList &module_list); size_t - RemoveOrphans (); + RemoveOrphans (bool mandatory); bool ResolveFileAddress (lldb::addr_t vm_addr, @@ -418,7 +418,7 @@ public: ModuleList &matching_module_list); static uint32_t - RemoveOrphanSharedModules (); + RemoveOrphanSharedModules (bool mandatory); protected: //------------------------------------------------------------------ diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index b61acd75f62..4c62ffb2c02 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -143,7 +143,12 @@ SBDebugger::Destroy (SBDebugger &debugger) void SBDebugger::MemoryPressureDetected () { - ModuleList::RemoveOrphanSharedModules(); + // Since this function can be call asynchronously, we allow it to be + // non-mandatory. We have seen deadlocks with this function when called + // so we need to safeguard against this until we can determine what is + // causing the deadlocks. + const bool mandatory = false; + ModuleList::RemoveOrphanSharedModules(mandatory); } SBDebugger::SBDebugger () : @@ -648,7 +653,8 @@ SBDebugger::DeleteTarget (lldb::SBTarget &target) result = m_opaque_sp->GetTargetList().DeleteTarget (target_sp); target_sp->Destroy(); target.Clear(); - ModuleList::RemoveOrphanSharedModules(); + const bool mandatory = true; + ModuleList::RemoveOrphanSharedModules(mandatory); } } diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index 17d5fd53b1c..ec48de6960d 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -520,7 +520,8 @@ public: // the global shared module list if (m_cleanup_option.GetOptionValue ()) { - ModuleList::RemoveOrphanSharedModules(); + const bool mandatory = true; + ModuleList::RemoveOrphanSharedModules(mandatory); } result.GetOutputStream().Printf("%u targets deleted.\n", (uint32_t)num_targets_to_delete); result.SetStatus(eReturnStatusSuccessFinishResult); diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 8ef4430119c..89325762d48 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -86,7 +86,8 @@ namespace lldb { void ClearModuleInfo (void) { - ModuleList::RemoveOrphanSharedModules(); + const bool mandatory = true; + ModuleList::RemoveOrphanSharedModules(mandatory); } void diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp index 69245fb1a95..5e4f660dd28 100644 --- a/lldb/source/Core/ModuleList.cpp +++ b/lldb/source/Core/ModuleList.cpp @@ -112,9 +112,20 @@ ModuleList::Remove (const ModuleSP &module_sp) size_t -ModuleList::RemoveOrphans () +ModuleList::RemoveOrphans (bool mandatory) { - Mutex::Locker locker(m_modules_mutex); + Mutex::Locker locker; + + if (mandatory) + { + locker.Reset (m_modules_mutex.GetMutex()); + } + else + { + // Not mandatory, remove orphans if we can get the mutex + if (!locker.TryLock(m_modules_mutex.GetMutex())) + return 0; + } collection::iterator pos = m_modules.begin(); size_t remove_count = 0; while (pos != m_modules.end()) @@ -587,9 +598,9 @@ ModuleList::FindSharedModules (const ModuleSpec &module_spec, ModuleList &matchi } uint32_t -ModuleList::RemoveOrphanSharedModules () +ModuleList::RemoveOrphanSharedModules (bool mandatory) { - return GetSharedModuleList ().RemoveOrphans(); + return GetSharedModuleList ().RemoveOrphans(mandatory); } Error |