[Lldb-commits] [lldb] r155638 - in /lldb/trunk: include/lldb/Symbol/SymbolFile.h source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp source/Symbol/SymbolFile.cpp

Greg Clayton gclayton at apple.com
Thu Apr 26 09:53:43 PDT 2012


Author: gclayton
Date: Thu Apr 26 11:53:42 2012
New Revision: 155638

URL: http://llvm.org/viewvc/llvm-project?rev=155638&view=rev
Log:
Save more memory by not parsing the symbol table for stand alone DWARF files. We currently have SymbolFile plug-ins which all get the chance to say what they can parse in a symbol file. Prior to this fix we would ask the SymbolFileDWARF plug-in what abilities it had, and it would answer with "everything", and then we would check the SymbolFileSymtab plug-in what abilities it had, in case it had more abilities. The checking that SymbolFileSymtab does is a bit expensive as it pulls in the entire symbol table just to see if it can offer a few scraps of debug information. This causes all stand along DWARF files to pull in their symbol tables even though those symbols will never be used. This fix will check all SymbolFile plug-ins for their abilities and if any plug-in responds with "everything", then we stop the search.


Modified:
    lldb/trunk/include/lldb/Symbol/SymbolFile.h
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
    lldb/trunk/source/Symbol/SymbolFile.cpp

Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=155638&r1=155637&r2=155638&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Thu Apr 26 11:53:42 2012
@@ -22,23 +22,24 @@
     public PluginInterface
 {
 public:
+    //------------------------------------------------------------------
+    // Symbol file ability bits.
+    //
+    // Each symbol file can claim to support one or more symbol file
+    // abilities. These get returned from SymbolFile::GetAbilities().
+    // These help us to determine which plug-in will be best to load
+    // the debug information found in files.    
+    //------------------------------------------------------------------
     enum Abilities
     {
-        Labels                              = (1 << 0),
-        AddressAcceleratorTable             = (1 << 1),
-        FunctionAcceleratorTable            = (1 << 2),
-        TypeAcceleratorTable                = (1 << 3),
-        MacroInformation                    = (1 << 4),
-        CallFrameInformation                = (1 << 5),
-        RuntimeTypes                        = (1 << 6),
-        CompileUnits                        = (1 << 7),
-        LineTables                          = (1 << 8),
-        LineColumns                         = (1 << 9),
-        Functions                           = (1 << 10),
-        Blocks                              = (1 << 11),
-        GlobalVariables                     = (1 << 12),
-        LocalVariables                      = (1 << 13),
-        VariableTypes                       = (1 << 14)
+        CompileUnits                        = (1u << 0),
+        LineTables                          = (1u << 1),
+        Functions                           = (1u << 2),
+        Blocks                              = (1u << 3),
+        GlobalVariables                     = (1u << 4),
+        LocalVariables                      = (1u << 5),
+        VariableTypes                       = (1u << 6),
+        kAllAbilities                       =((1u << 7) - 1u)
     };
 
     static SymbolFile *

Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp?rev=155638&r1=155637&r2=155638&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp Thu Apr 26 11:53:42 2012
@@ -61,7 +61,12 @@
         
         SymbolFile *symbol_file = image->GetSymbolVendor()->GetSymbolFile();
         
-        if (!symbol_file || !(symbol_file->GetAbilities() & SymbolFile::RuntimeTypes))
+        // Don't use a symbol file if it actually has types. We are specifically
+        // looking for something in runtime information, not from debug information,
+        // as the data in debug information will get parsed by the debug info
+        // symbol files. So we veto any symbol file that has actual variable
+        // type parsing abilities.
+        if (symbol_file == NULL || (symbol_file->GetAbilities() & SymbolFile::VariableTypes))
             continue;
         
         const bool inferior_append = true;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=155638&r1=155637&r2=155638&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Apr 26 11:53:42 2012
@@ -508,21 +508,6 @@
 
         if (debug_line_file_size > 0)
             abilities |= LineTables;
-
-        if (debug_aranges_file_size > 0)
-            abilities |= AddressAcceleratorTable;
-
-        if (debug_pubnames_file_size > 0)
-            abilities |= FunctionAcceleratorTable;
-
-        if (debug_pubtypes_file_size > 0)
-            abilities |= TypeAcceleratorTable;
-
-        if (debug_macinfo_file_size > 0)
-            abilities |= MacroInformation;
-
-        if (debug_frame_file_size > 0)
-            abilities |= CallFrameInformation;
     }
     return abilities;
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=155638&r1=155637&r2=155638&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Thu Apr 26 11:53:42 2012
@@ -106,7 +106,6 @@
             if (symtab->AppendSymbolIndexesWithType(eSymbolTypeCode, Symtab::eDebugNo, Symtab::eVisibilityAny, m_code_indexes))
             {
                 symtab->SortSymbolIndexesByValue(m_code_indexes, true);
-                abilities |= Labels;
             }
 
             if (symtab->AppendSymbolIndexesWithType(eSymbolTypeData, m_data_indexes))
@@ -118,7 +117,6 @@
             lldb_private::Symtab::IndexCollection objc_class_indexes;
             if (symtab->AppendSymbolIndexesWithType (eSymbolTypeObjCClass, objc_class_indexes))
             {
-                abilities |= RuntimeTypes;
                 symtab->AppendSymbolNamesToMap (objc_class_indexes,
                                                 true,
                                                 true,
@@ -150,14 +148,7 @@
 
     // If we don't have any source file symbols we will just have one compile unit for
     // the entire object file
-//    if (m_source_indexes.empty())
-//    {
-//        const FileSpec &obj_file_spec = m_obj_file->GetFileSpec();
-//        if (obj_file_spec)
-//            cu_sp.reset(new CompileUnit(m_obj_file->GetModule(), NULL, obj_file_spec, 0, eLanguageTypeUnknown));
-//
-//    }
-    /* else */ if (idx < m_source_indexes.size())
+    if (idx < m_source_indexes.size())
     {
         const Symbol *cu_symbol = m_obj_file->GetSymtab()->SymbolAtIndex(m_source_indexes[idx]);
         if (cu_symbol)

Modified: lldb/trunk/source/Symbol/SymbolFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolFile.cpp?rev=155638&r1=155637&r2=155638&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolFile.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolFile.cpp Thu Apr 26 11:53:42 2012
@@ -27,9 +27,6 @@
         // TODO: Load any plug-ins in the appropriate plug-in search paths and
         // iterate over all of them to find the best one for the job.
 
-        //----------------------------------------------------------------------
-        // We currently only have one debug symbol parser...
-        //----------------------------------------------------------------------
         uint32_t best_symfile_abilities = 0;
 
         SymbolFileCreateInstance create_callback;
@@ -39,11 +36,15 @@
 
             if (curr_symfile_ap.get())
             {
-                uint32_t sym_file_abilities = curr_symfile_ap->GetAbilities();
+                const uint32_t sym_file_abilities = curr_symfile_ap->GetAbilities();
                 if (sym_file_abilities > best_symfile_abilities)
                 {
                     best_symfile_abilities = sym_file_abilities;
                     best_symfile_ap = curr_symfile_ap;
+                    // If any symbol file parser has all of the abilities, then
+                    // we should just stop looking.
+                    if ((kAllAbilities & sym_file_abilities) == kAllAbilities)
+                        break;
                 }
             }
         }





More information about the lldb-commits mailing list