summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2011-10-13 00:59:38 +0000
committerGreg Clayton <gclayton@apple.com>2011-10-13 00:59:38 +0000
commitaa044960b5bd799909b8d96ad6a4fc6b46a771f4 (patch)
tree7a1a6eddf61ea2f90d9047687d29e8ab5e31c114
parent84882259847e72335b2e5700848b9d200a768cec (diff)
downloadbcm5719-llvm-aa044960b5bd799909b8d96ad6a4fc6b46a771f4.tar.gz
bcm5719-llvm-aa044960b5bd799909b8d96ad6a4fc6b46a771f4.zip
Add a version of ResolveFunction that takes a "const DWARFDebugInfoEntry *"
and a "DWARFCompileUnit *" to avoid doing a DIE lookup twice and to prepare for using namespaces in the lookups. llvm-svn: 141843
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp142
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h13
2 files changed, 85 insertions, 70 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 96472b8a484..11400b55bcf 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2149,21 +2149,27 @@ SymbolFileDWARF::FindGlobalVariables(const RegularExpression& regex, bool append
return variables.GetSize() - original_size;
}
+
bool
SymbolFileDWARF::ResolveFunction (dw_offset_t die_offset,
DWARFCompileUnit *&dwarf_cu,
SymbolContextList& sc_list)
{
- SymbolContext sc;
-
- DWARFDebugInfo* info = DebugInfo();
- bool resolved_it = false;
-
- if (info == NULL)
- return resolved_it;
-
- DWARFDebugInfoEntry *die = info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu);
+ const DWARFDebugInfoEntry *die = DebugInfo()->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu);
+ return ResolveFunction (dwarf_cu, die, sc_list);
+}
+
+bool
+SymbolFileDWARF::ResolveFunction (DWARFCompileUnit *cu,
+ const DWARFDebugInfoEntry *die,
+ SymbolContextList& sc_list)
+{
+ SymbolContext sc;
+
+ if (die == NULL)
+ return false;
+
// If we were passed a die that is not a function, just return false...
if (die->Tag() != DW_TAG_subprogram && die->Tag() != DW_TAG_inlined_subroutine)
return false;
@@ -2180,7 +2186,7 @@ SymbolFileDWARF::ResolveFunction (dw_offset_t die_offset,
}
}
assert (die->Tag() == DW_TAG_subprogram);
- if (GetFunction (dwarf_cu, die, sc))
+ if (GetFunction (cu, die, sc))
{
Address addr;
// Parse all blocks if needed
@@ -2212,11 +2218,11 @@ SymbolFileDWARF::ResolveFunction (dw_offset_t die_offset,
line_table->FindLineEntryByAddress (addr, sc.line_entry);
sc_list.Append(sc);
- resolved_it = true;
+ return true;
}
}
- return resolved_it;
+ return false;
}
void
@@ -2418,6 +2424,7 @@ SymbolFileDWARF::FindFunctions (const ConstString &name,
if (info == NULL)
return 0;
+ DWARFCompileUnit *dwarf_cu = NULL;
if (m_apple_names_ap.get())
{
DIEArray die_offsets;
@@ -2429,15 +2436,18 @@ SymbolFileDWARF::FindFunctions (const ConstString &name,
// If they asked for the full name, match what they typed. At some point we may
// want to canonicalize this (strip double spaces, etc. For now, we just add all the
// dies that we find by exact match.
- DWARFCompileUnit *dwarf_cu = NULL;
num_matches = m_apple_names_ap->FindByName (name_cstr, die_offsets);
for (uint32_t i = 0; i < num_matches; i++)
- ResolveFunction (die_offsets[i], dwarf_cu, sc_list);
+ {
+ const DWARFDebugInfoEntry *die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu);
+ if (die)
+ {
+ ResolveFunction (dwarf_cu, die, sc_list);
+ }
+ }
}
else
{
- DWARFCompileUnit* dwarf_cu = NULL;
-
if (effective_name_type_mask & eFunctionNameTypeSelector)
{
num_matches = m_apple_names_ap->FindByName (name_cstr, die_offsets);
@@ -2447,11 +2457,12 @@ SymbolFileDWARF::FindFunctions (const ConstString &name,
for (uint32_t i = 0; i < num_matches; i++)
{
const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu);
- assert (die);
-
- const char *die_name = die->GetName(this, dwarf_cu);
- if (ObjCLanguageRuntime::IsPossibleObjCMethodName(die_name))
- ResolveFunction (die_offsets[i], dwarf_cu, sc_list);
+ if (die)
+ {
+ const char *die_name = die->GetName(this, dwarf_cu);
+ if (ObjCLanguageRuntime::IsPossibleObjCMethodName(die_name))
+ ResolveFunction (dwarf_cu, die, sc_list);
+ }
}
die_offsets.clear();
}
@@ -2469,19 +2480,20 @@ SymbolFileDWARF::FindFunctions (const ConstString &name,
for (uint32_t i = 0; i < num_matches; i++)
{
- dw_offset_t offset = die_offsets[i];
- const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (offset, &dwarf_cu);
- assert (die);
- if (!FunctionDieMatchesPartialName(die,
- dwarf_cu,
- effective_name_type_mask,
- name_cstr,
- base_name_start,
- base_name_end))
- continue;
-
- // If we get to here, the die is good, and we should add it:
- ResolveFunction (offset, dwarf_cu, sc_list);
+ const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu);
+ if (die)
+ {
+ if (!FunctionDieMatchesPartialName(die,
+ dwarf_cu,
+ effective_name_type_mask,
+ name_cstr,
+ base_name_start,
+ base_name_end))
+ continue;
+
+ // If we get to here, the die is good, and we should add it:
+ ResolveFunction (dwarf_cu, die, sc_list);
+ }
}
die_offsets.clear();
}
@@ -2505,23 +2517,22 @@ SymbolFileDWARF::FindFunctions (const ConstString &name,
if (effective_name_type_mask & eFunctionNameTypeBase)
{
uint32_t num_base = m_function_basename_index.Find(base_name_const, die_offsets);
+ for (uint32_t i = 0; i < num_base; i++)
{
- for (uint32_t i = 0; i < num_base; i++)
- {
- dw_offset_t offset = die_offsets[i];
- const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (offset, &dwarf_cu);
- assert (die);
- if (!FunctionDieMatchesPartialName(die,
- dwarf_cu,
- effective_name_type_mask,
- name_cstr,
- base_name_start,
- base_name_end))
- continue;
+ const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu);
+ if (die)
+ {
+ if (!FunctionDieMatchesPartialName(die,
+ dwarf_cu,
+ effective_name_type_mask,
+ name_cstr,
+ base_name_start,
+ base_name_end))
+ continue;
- // If we get to here, the die is good, and we should add it:
- ResolveFunction (offset, dwarf_cu, sc_list);
- }
+ // If we get to here, the die is good, and we should add it:
+ ResolveFunction (dwarf_cu, die, sc_list);
+ }
}
die_offsets.clear();
}
@@ -2530,22 +2541,23 @@ SymbolFileDWARF::FindFunctions (const ConstString &name,
{
uint32_t num_base = m_function_method_index.Find(base_name_const, die_offsets);
{
- for (uint32_t i = 0; i < num_base; i++)
- {
- dw_offset_t offset = die_offsets[i];
- const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (offset, &dwarf_cu);
- assert (die);
- if (!FunctionDieMatchesPartialName(die,
- dwarf_cu,
- effective_name_type_mask,
- name_cstr,
- base_name_start,
- base_name_end))
- continue;
-
- // If we get to here, the die is good, and we should add it:
- ResolveFunction (offset, dwarf_cu, sc_list);
- }
+ for (uint32_t i = 0; i < num_base; i++)
+ {
+ const DWARFDebugInfoEntry* die = info->GetDIEPtrWithCompileUnitHint (die_offsets[i], &dwarf_cu);
+ if (die)
+ {
+ if (!FunctionDieMatchesPartialName(die,
+ dwarf_cu,
+ effective_name_type_mask,
+ name_cstr,
+ base_name_start,
+ base_name_end))
+ continue;
+
+ // If we get to here, the die is good, and we should add it:
+ ResolveFunction (dwarf_cu, die, sc_list);
+ }
+ }
}
die_offsets.clear();
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 7c1595317b6..4a9080c0960 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -329,11 +329,14 @@ protected:
uint32_t& bit_stride);
// Given a die_offset, figure out the symbol context representing that die.
- bool ResolveFunction (
- dw_offset_t offset,
- DWARFCompileUnit *&dwarf_cu,
- lldb_private::SymbolContextList& sc_list);
-
+ bool ResolveFunction (dw_offset_t offset,
+ DWARFCompileUnit *&dwarf_cu,
+ lldb_private::SymbolContextList& sc_list);
+
+ bool ResolveFunction (DWARFCompileUnit *cu,
+ const DWARFDebugInfoEntry *die,
+ lldb_private::SymbolContextList& sc_list);
+
bool FunctionDieMatchesPartialName (
const DWARFDebugInfoEntry* die,
const DWARFCompileUnit *dwarf_cu,
OpenPOWER on IntegriCloud