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.

llvm-svn: 155638
This commit is contained in:
Greg Clayton 2012-04-26 16:53:42 +00:00
parent 11b1f41662
commit 9efa076aa6
5 changed files with 28 additions and 45 deletions

View File

@ -22,23 +22,24 @@ class SymbolFile :
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 *

View File

@ -61,7 +61,12 @@ AppleObjCSymbolVendor::FindTypes (const SymbolContext& sc,
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;

View File

@ -508,21 +508,6 @@ SymbolFileDWARF::CalculateAbilities ()
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;
}

View File

@ -106,7 +106,6 @@ SymbolFileSymtab::CalculateAbilities ()
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 @@ SymbolFileSymtab::CalculateAbilities ()
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 @@ SymbolFileSymtab::ParseCompileUnitAtIndex(uint32_t idx)
// 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)

View File

@ -27,9 +27,6 @@ SymbolFile::FindPlugin (ObjectFile* obj_file)
// 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 @@ SymbolFile::FindPlugin (ObjectFile* obj_file)
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;
}
}
}