[Lldb-commits] [lldb] r127651 - in /lldb/branches/apple/calcite/lldb: include/lldb/Core/ModuleList.h source/Core/ModuleList.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp

Greg Clayton gclayton at apple.com
Mon Mar 14 19:31:39 PDT 2011


Author: gclayton
Date: Mon Mar 14 21:31:39 2011
New Revision: 127651

URL: http://llvm.org/viewvc/llvm-project?rev=127651&view=rev
Log:
Added a fix to not re-use object files when doing DWARF with debug map.


Modified:
    lldb/branches/apple/calcite/lldb/include/lldb/Core/ModuleList.h
    lldb/branches/apple/calcite/lldb/source/Core/ModuleList.cpp
    lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp

Modified: lldb/branches/apple/calcite/lldb/include/lldb/Core/ModuleList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/include/lldb/Core/ModuleList.h?rev=127651&r1=127650&r2=127651&view=diff
==============================================================================
--- lldb/branches/apple/calcite/lldb/include/lldb/Core/ModuleList.h (original)
+++ lldb/branches/apple/calcite/lldb/include/lldb/Core/ModuleList.h Mon Mar 14 21:31:39 2011
@@ -373,7 +373,11 @@
                      off_t object_offset,
                      lldb::ModuleSP &module_sp,
                      lldb::ModuleSP *old_module_sp_ptr,
-                     bool *did_create_ptr);
+                     bool *did_create_ptr,
+                     bool always_create = false);
+
+    static bool
+    RemoveSharedModule (lldb::ModuleSP &module_sp);
 
     static size_t
     FindSharedModules (const FileSpec& in_file_spec,

Modified: lldb/branches/apple/calcite/lldb/source/Core/ModuleList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Core/ModuleList.cpp?rev=127651&r1=127650&r2=127651&view=diff
==============================================================================
--- lldb/branches/apple/calcite/lldb/source/Core/ModuleList.cpp (original)
+++ lldb/branches/apple/calcite/lldb/source/Core/ModuleList.cpp Mon Mar 14 21:31:39 2011
@@ -540,7 +540,6 @@
 )
 {
     ModuleList &shared_module_list = GetSharedModuleList ();
-    Mutex::Locker locker(shared_module_list.m_modules_mutex);
     return shared_module_list.FindModules (&in_file_spec, &arch, uuid_ptr, object_name_ptr, matching_module_list);
 }
 
@@ -554,10 +553,12 @@
     off_t object_offset,
     ModuleSP &module_sp,
     ModuleSP *old_module_sp_ptr,
-    bool *did_create_ptr
+    bool *did_create_ptr,
+    bool always_create
 )
 {
     ModuleList &shared_module_list = GetSharedModuleList ();
+    Mutex::Locker locker(shared_module_list.m_modules_mutex);
     char path[PATH_MAX];
     char uuid_cstr[64];
 
@@ -579,31 +580,43 @@
         // Make sure no one else can try and get or create a module while this
         // function is actively working on it by doing an extra lock on the
         // global mutex list.
-        ModuleList matching_module_list;
-        Mutex::Locker locker(shared_module_list.m_modules_mutex);
-        if (shared_module_list.FindModules (&in_file_spec, &arch, uuid_ptr, object_name_ptr, matching_module_list) > 0)
+        if (always_create == false)
         {
-            module_sp = matching_module_list.GetModuleAtIndex(0);
-
-            // If we didn't have a UUID in mind when looking for the object file,
-            // then we should make sure the modification time hasn't changed!
-            if (uuid_ptr == NULL)
+            ModuleList matching_module_list;
+            const size_t num_matching_modules = shared_module_list.FindModules (&in_file_spec, &arch, NULL, object_name_ptr, matching_module_list);
+            if (num_matching_modules > 0)
             {
-                TimeValue file_spec_mod_time(in_file_spec.GetModificationTime());
-                if (file_spec_mod_time.IsValid())
+                for (uint32_t module_idx = 0; module_idx < num_matching_modules; ++module_idx)
                 {
-                    if (file_spec_mod_time != module_sp->GetModificationTime())
+                    module_sp = matching_module_list.GetModuleAtIndex(module_idx);
+                    if (uuid_ptr && uuid_ptr->IsValid())
                     {
-                        if (old_module_sp_ptr)
-                            *old_module_sp_ptr = module_sp;
-                        shared_module_list.Remove (module_sp);
-                        module_sp.reset();
+                        // We found the module we were looking for.
+                        if (module_sp->GetUUID() == *uuid_ptr)
+                            return error;
+                    }
+                    else
+                    {
+                        // If we didn't have a UUID in mind when looking for the object file,
+                        // then we should make sure the modification time hasn't changed!
+                        TimeValue file_spec_mod_time(in_file_spec.GetModificationTime());
+                        if (file_spec_mod_time.IsValid())
+                        {
+                            if (file_spec_mod_time == module_sp->GetModificationTime())
+                                return error;
+                        }
                     }
+                    if (old_module_sp_ptr && !old_module_sp_ptr->get())
+                        *old_module_sp_ptr = module_sp;
+                    shared_module_list.Remove (module_sp);
+                    module_sp.reset();
                 }
             }
         }
 
-        if (module_sp.get() == NULL)
+        if (module_sp)
+            return error;
+        else
         {
             module_sp.reset (new Module (in_file_spec, arch, object_name_ptr, object_offset));
             if (module_sp)
@@ -666,7 +679,6 @@
         // Make sure no one else can try and get or create a module while this
         // function is actively working on it by doing an extra lock on the
         // global mutex list.
-        Mutex::Locker locker(shared_module_list.m_modules_mutex);
         ModuleList matching_module_list;
         if (shared_module_list.FindModules (&file_spec, &arch, uuid_ptr, object_name_ptr, matching_module_list) > 0)
         {
@@ -730,3 +742,10 @@
     return error;
 }
 
+bool
+ModuleList::RemoveSharedModule (lldb::ModuleSP &module_sp)
+{
+    return GetSharedModuleList ().Remove (module_sp);
+}
+
+

Modified: lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=127651&r1=127650&r2=127651&view=diff
==============================================================================
--- lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
+++ lldb/branches/apple/calcite/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Mon Mar 14 21:31:39 2011
@@ -72,6 +72,14 @@
 
 SymbolFileDWARFDebugMap::~SymbolFileDWARFDebugMap()
 {
+    // Release all .o files so they don't persist in the shared cache
+    std::vector<CompileUnitInfo>::iterator pos, end;
+    for (pos = m_compile_unit_infos.begin(), end = m_compile_unit_infos.end();
+         pos != end;
+         ++pos)
+    {
+        ModuleList::RemoveSharedModule (pos->oso_module_sp);
+    }
 }
 
 void
@@ -166,6 +174,11 @@
         {
             FileSpec oso_file_spec(oso_symbol->GetMangled().GetName().AsCString(), true);
 
+            // Don't allow cached .o files since we dress up each .o file with
+            // new sections. We want them to be in the module list so we can 
+            // always find a shared pointer to the module (in Module::GetSP()),
+            // but just don't share them.
+            const bool always_create = true;
             ModuleList::GetSharedModule (oso_file_spec,
                                          m_obj_file->GetModule()->GetArchitecture(),
                                          NULL,  // UUID pointer
@@ -173,7 +186,8 @@
                                          0,     // object offset
                                          comp_unit_info->oso_module_sp,
                                          NULL,
-                                         NULL);
+                                         NULL,
+                                         always_create);
             //comp_unit_info->oso_module_sp.reset(new Module (oso_file_spec, m_obj_file->GetModule()->GetArchitecture()));
         }
     }





More information about the lldb-commits mailing list