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.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@155638 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/lldb/Symbol/SymbolFile.h b/include/lldb/Symbol/SymbolFile.h
index 39f5da7..13d02bd 100644
--- a/include/lldb/Symbol/SymbolFile.h
+++ b/include/lldb/Symbol/SymbolFile.h
@@ -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 *
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp
index 129ef6c..ff13580 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp
@@ -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;
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 93f86bb..9a386f4 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -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;
}
diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
index b21343d..5404ab0 100644
--- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
+++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
@@ -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)
diff --git a/source/Symbol/SymbolFile.cpp b/source/Symbol/SymbolFile.cpp
index 92af5f2..808830e 100644
--- a/source/Symbol/SymbolFile.cpp
+++ b/source/Symbol/SymbolFile.cpp
@@ -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;
}
}
}