[Lldb-commits] [lldb] r154339 - in /lldb/trunk: include/lldb/Core/ModuleList.h source/API/SBDebugger.cpp source/Commands/CommandObjectTarget.cpp source/Core/Module.cpp source/Core/ModuleList.cpp

Greg Clayton gclayton at apple.com
Mon Apr 9 13:22:01 PDT 2012


Author: gclayton
Date: Mon Apr  9 15:22:01 2012
New Revision: 154339

URL: http://llvm.org/viewvc/llvm-project?rev=154339&view=rev
Log:
<rdar://problem/11202426> 

Work around a deadlocking issue where "SBDebugger::MemoryPressureDetected ()" is being called and is causing a deadlock. We now just try and get the lock when trying to trim down the unique modules so we don't deadlock debugger GUI programs until we can find the root cause.


Modified:
    lldb/trunk/include/lldb/Core/ModuleList.h
    lldb/trunk/source/API/SBDebugger.cpp
    lldb/trunk/source/Commands/CommandObjectTarget.cpp
    lldb/trunk/source/Core/Module.cpp
    lldb/trunk/source/Core/ModuleList.cpp

Modified: lldb/trunk/include/lldb/Core/ModuleList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleList.h?rev=154339&r1=154338&r2=154339&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ModuleList.h (original)
+++ lldb/trunk/include/lldb/Core/ModuleList.h Mon Apr  9 15:22:01 2012
@@ -356,7 +356,7 @@
     Remove (ModuleList &module_list);
     
     size_t
-    RemoveOrphans ();
+    RemoveOrphans (bool mandatory);
 
     bool
     ResolveFileAddress (lldb::addr_t vm_addr,
@@ -418,7 +418,7 @@
                        ModuleList &matching_module_list);
 
     static uint32_t
-    RemoveOrphanSharedModules ();
+    RemoveOrphanSharedModules (bool mandatory);
 
 protected:
     //------------------------------------------------------------------

Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=154339&r1=154338&r2=154339&view=diff
==============================================================================
--- lldb/trunk/source/API/SBDebugger.cpp (original)
+++ lldb/trunk/source/API/SBDebugger.cpp Mon Apr  9 15:22:01 2012
@@ -143,7 +143,12 @@
 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 @@
             result = m_opaque_sp->GetTargetList().DeleteTarget (target_sp);
             target_sp->Destroy();
             target.Clear();
-            ModuleList::RemoveOrphanSharedModules();
+            const bool mandatory = true;
+            ModuleList::RemoveOrphanSharedModules(mandatory);
         }
     }
 

Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=154339&r1=154338&r2=154339&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Mon Apr  9 15:22:01 2012
@@ -520,7 +520,8 @@
             // 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);

Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=154339&r1=154338&r2=154339&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Mon Apr  9 15:22:01 2012
@@ -86,7 +86,8 @@
     void
     ClearModuleInfo (void)
     {
-        ModuleList::RemoveOrphanSharedModules();
+        const bool mandatory = true;
+        ModuleList::RemoveOrphanSharedModules(mandatory);
     }
     
     void

Modified: lldb/trunk/source/Core/ModuleList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=154339&r1=154338&r2=154339&view=diff
==============================================================================
--- lldb/trunk/source/Core/ModuleList.cpp (original)
+++ lldb/trunk/source/Core/ModuleList.cpp Mon Apr  9 15:22:01 2012
@@ -112,9 +112,20 @@
 
 
 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 @@
 }
 
 uint32_t
-ModuleList::RemoveOrphanSharedModules ()
+ModuleList::RemoveOrphanSharedModules (bool mandatory)
 {
-    return GetSharedModuleList ().RemoveOrphans();    
+    return GetSharedModuleList ().RemoveOrphans(mandatory);
 }
 
 Error





More information about the lldb-commits mailing list