forked from OSchip/llvm-project
Fixed an issue where we might not find global variables by name when we have
a debug map with DWARF in the .o files due to the attemted shortcut that was being taken where the global variables were being searched for by looking in the symbol table. The problem with the symbols in the symbol table is we don't break apart the symbol names for symbols when they are mangled into basename and the fully mangled name since this would take a lot of CPU time to chop up the mangled names and try and find the basenames. The DWARF info typically has this broken up for us where the basename of the variable is in a the DW_AT_name attribute, and the mangled name is in the DW_AT_MIPS_linkage_name attribute. Now we correctly find globals by searching all OSO's for the information so we can take advantage of this split information. llvm-svn: 119012
This commit is contained in:
parent
e988bdac44
commit
ba2d22d8ee
|
@ -2452,7 +2452,6 @@
|
|||
isa = PBXProject;
|
||||
buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */;
|
||||
compatibilityVersion = "Xcode 3.1";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 1;
|
||||
knownRegions = (
|
||||
en,
|
||||
|
|
|
@ -1086,7 +1086,10 @@ SymbolFileDWARF::ParseChildMembers
|
|||
case DW_TAG_member:
|
||||
{
|
||||
DWARFDebugInfoEntry::Attributes attributes;
|
||||
const size_t num_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes);
|
||||
const size_t num_attributes = die->GetAttributes (this,
|
||||
dwarf_cu,
|
||||
fixed_form_sizes,
|
||||
attributes);
|
||||
if (num_attributes > 0)
|
||||
{
|
||||
Declaration decl;
|
||||
|
@ -1158,7 +1161,11 @@ SymbolFileDWARF::ParseChildMembers
|
|||
accessibility = default_accessibility;
|
||||
member_accessibilities.push_back(accessibility);
|
||||
|
||||
GetClangASTContext().AddFieldToRecordType (class_clang_type, name, member_type->GetClangLayoutType(), accessibility, bit_size);
|
||||
GetClangASTContext().AddFieldToRecordType (class_clang_type,
|
||||
name,
|
||||
member_type->GetClangLayoutType(),
|
||||
accessibility,
|
||||
bit_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1176,7 +1183,10 @@ SymbolFileDWARF::ParseChildMembers
|
|||
default_accessibility = eAccessPrivate;
|
||||
// TODO: implement DW_TAG_inheritance type parsing
|
||||
DWARFDebugInfoEntry::Attributes attributes;
|
||||
const size_t num_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes);
|
||||
const size_t num_attributes = die->GetAttributes (this,
|
||||
dwarf_cu,
|
||||
fixed_form_sizes,
|
||||
attributes);
|
||||
if (num_attributes > 0)
|
||||
{
|
||||
Declaration decl;
|
||||
|
@ -1207,7 +1217,17 @@ SymbolFileDWARF::ParseChildMembers
|
|||
const DataExtractor& debug_info_data = get_debug_info_data();
|
||||
uint32_t block_length = form_value.Unsigned();
|
||||
uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart();
|
||||
if (DWARFExpression::Evaluate(NULL, NULL, debug_info_data, NULL, NULL, block_offset, block_length, eRegisterKindDWARF, &initialValue, memberOffset, NULL))
|
||||
if (DWARFExpression::Evaluate (NULL,
|
||||
NULL,
|
||||
debug_info_data,
|
||||
NULL,
|
||||
NULL,
|
||||
block_offset,
|
||||
block_length,
|
||||
eRegisterKindDWARF,
|
||||
&initialValue,
|
||||
memberOffset,
|
||||
NULL))
|
||||
{
|
||||
member_offset = memberOffset.ResolveValue(NULL, NULL).UInt();
|
||||
}
|
||||
|
@ -1235,7 +1255,10 @@ SymbolFileDWARF::ParseChildMembers
|
|||
}
|
||||
else
|
||||
{
|
||||
base_classes.push_back (GetClangASTContext().CreateBaseClassSpecifier (base_class_type->GetClangType(), accessibility, is_virtual, is_base_of_class));
|
||||
base_classes.push_back (GetClangASTContext().CreateBaseClassSpecifier (base_class_type->GetClangType(),
|
||||
accessibility,
|
||||
is_virtual,
|
||||
is_base_of_class));
|
||||
assert(base_classes.back());
|
||||
}
|
||||
}
|
||||
|
@ -1776,15 +1799,14 @@ SymbolFileDWARF::Index ()
|
|||
GetObjectFile()->GetModule()->GetArchitecture().AsCString(),
|
||||
GetObjectFile()->GetFileSpec().GetDirectory().AsCString(),
|
||||
GetObjectFile()->GetFileSpec().GetFilename().AsCString());
|
||||
// s.Printf("\nFunction basenames:\n"); m_function_basename_index.Dump (&s);
|
||||
// s.Printf("\nFunction fullnames:\n"); m_function_fullname_index.Dump (&s);
|
||||
// s.Printf("\nFunction methods:\n"); m_function_method_index.Dump (&s);
|
||||
// s.Printf("\nFunction selectors:\n"); m_function_selector_index.Dump (&s);
|
||||
// s.Printf("\nObjective C class selectors:\n"); m_objc_class_selectors_index.Dump (&s);
|
||||
// s.Printf("\nGlobals and statics:\n"); m_global_index.Dump (&s);
|
||||
s.Printf("\nFunction basenames:\n"); m_function_basename_index.Dump (&s);
|
||||
s.Printf("\nFunction fullnames:\n"); m_function_fullname_index.Dump (&s);
|
||||
s.Printf("\nFunction methods:\n"); m_function_method_index.Dump (&s);
|
||||
s.Printf("\nFunction selectors:\n"); m_function_selector_index.Dump (&s);
|
||||
s.Printf("\nObjective C class selectors:\n"); m_objc_class_selectors_index.Dump (&s);
|
||||
s.Printf("\nGlobals and statics:\n"); m_global_index.Dump (&s);
|
||||
s.Printf("\nTypes:\n"); m_type_index.Dump (&s);
|
||||
// s.Printf("\nNamepaces:\n"); m_namespace_index.Dump (&s);
|
||||
|
||||
s.Printf("\nNamepaces:\n"); m_namespace_index.Dump (&s);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -716,14 +716,29 @@ SymbolFileDWARFDebugMap::FindGlobalVariables (const ConstString &name, bool appe
|
|||
// we are appending the results to a variable list.
|
||||
const uint32_t original_size = variables.GetSize();
|
||||
|
||||
Symtab* symtab = m_obj_file->GetSymtab();
|
||||
if (symtab)
|
||||
uint32_t total_matches = 0;
|
||||
SymbolFileDWARF *oso_dwarf;
|
||||
for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx)
|
||||
{
|
||||
std::vector<uint32_t> indexes;
|
||||
const size_t match_count = m_obj_file->GetSymtab()->FindAllSymbolsWithNameAndType (name, eSymbolTypeData, Symtab::eDebugYes, Symtab::eVisibilityAny, indexes);
|
||||
if (match_count)
|
||||
const uint32_t oso_matches = oso_dwarf->FindGlobalVariables (name,
|
||||
true,
|
||||
max_matches,
|
||||
variables);
|
||||
if (oso_matches > 0)
|
||||
{
|
||||
PrivateFindGlobalVariables (name, indexes, max_matches, variables);
|
||||
total_matches += oso_matches;
|
||||
|
||||
// Are we getting all matches?
|
||||
if (max_matches == UINT32_MAX)
|
||||
continue; // Yep, continue getting everything
|
||||
|
||||
// If we have found enough matches, lets get out
|
||||
if (max_matches >= total_matches)
|
||||
break;
|
||||
|
||||
// Update the max matches for any subsequent calls to find globals
|
||||
// in any other object files with DWARF
|
||||
max_matches -= oso_matches;
|
||||
}
|
||||
}
|
||||
// Return the number of variable that were appended to the list
|
||||
|
@ -734,7 +749,41 @@ SymbolFileDWARFDebugMap::FindGlobalVariables (const ConstString &name, bool appe
|
|||
uint32_t
|
||||
SymbolFileDWARFDebugMap::FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables)
|
||||
{
|
||||
return 0;
|
||||
// If we aren't appending the results to this list, then clear the list
|
||||
if (!append)
|
||||
variables.Clear();
|
||||
|
||||
// Remember how many variables are in the list before we search in case
|
||||
// we are appending the results to a variable list.
|
||||
const uint32_t original_size = variables.GetSize();
|
||||
|
||||
uint32_t total_matches = 0;
|
||||
SymbolFileDWARF *oso_dwarf;
|
||||
for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx)
|
||||
{
|
||||
const uint32_t oso_matches = oso_dwarf->FindGlobalVariables (regex,
|
||||
true,
|
||||
max_matches,
|
||||
variables);
|
||||
if (oso_matches > 0)
|
||||
{
|
||||
total_matches += oso_matches;
|
||||
|
||||
// Are we getting all matches?
|
||||
if (max_matches == UINT32_MAX)
|
||||
continue; // Yep, continue getting everything
|
||||
|
||||
// If we have found enough matches, lets get out
|
||||
if (max_matches >= total_matches)
|
||||
break;
|
||||
|
||||
// Update the max matches for any subsequent calls to find globals
|
||||
// in any other object files with DWARF
|
||||
max_matches -= oso_matches;
|
||||
}
|
||||
}
|
||||
// Return the number of variable that were appended to the list
|
||||
return variables.GetSize() - original_size;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue