diff options
author | Frederic Riss <friss@apple.com> | 2014-09-22 12:35:53 +0000 |
---|---|---|
committer | Frederic Riss <friss@apple.com> | 2014-09-22 12:35:53 +0000 |
commit | 58ed53cfcd974e7f062346325a9a42d949944b93 (patch) | |
tree | cc9b3aa18340f9ab85a2037c8656ec058fed8f1a /llvm/lib/DebugInfo/DWARFDebugInfoEntry.cpp | |
parent | f947218862e92ccdd5c0618ddafa79709f1ac484 (diff) | |
download | bcm5719-llvm-58ed53cfcd974e7f062346325a9a42d949944b93.tar.gz bcm5719-llvm-58ed53cfcd974e7f062346325a9a42d949944b93.zip |
Allow DWARFDebugInfoEntryMinimal::getSubroutineName to resolve cross-unit references.
Summary: getSubroutineName is currently only used by llvm-symbolizer, thus add a binary test containing a cross-cu inlining example.
Reviewers: samsonov, dblaikie
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D5394
llvm-svn: 218245
Diffstat (limited to 'llvm/lib/DebugInfo/DWARFDebugInfoEntry.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/DWARFDebugInfoEntry.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/llvm/lib/DebugInfo/DWARFDebugInfoEntry.cpp b/llvm/lib/DebugInfo/DWARFDebugInfoEntry.cpp index aaca666be84..192cd3cdacf 100644 --- a/llvm/lib/DebugInfo/DWARFDebugInfoEntry.cpp +++ b/llvm/lib/DebugInfo/DWARFDebugInfoEntry.cpp @@ -20,6 +20,17 @@ using namespace llvm; using namespace dwarf; typedef DILineInfoSpecifier::FunctionNameKind FunctionNameKind; +// Small helper to extract a DIE pointed by a reference +// attribute. It looks up the Unit containing the DIE and calls +// DIE.extractFast with the right unit. Returns new unit on success, +// nullptr otherwise. +static const DWARFUnit *findUnitAndExtractFast(DWARFDebugInfoEntryMinimal &DIE, + const DWARFUnit *Unit, + uint32_t *Offset) { + Unit = Unit->getUnitSection().getUnitForOffset(*Offset); + return (Unit && DIE.extractFast(Unit, Offset)) ? Unit : nullptr; +} + void DWARFDebugInfoEntryMinimal::dump(raw_ostream &OS, const DWARFUnit *u, unsigned recurseDepth, unsigned indent) const { @@ -315,8 +326,8 @@ DWARFDebugInfoEntryMinimal::getSubroutineName(const DWARFUnit *U, getAttributeValueAsReference(U, DW_AT_specification, -1U); if (spec_ref != -1U) { DWARFDebugInfoEntryMinimal spec_die; - if (spec_die.extractFast(U, &spec_ref)) { - if (const char *name = spec_die.getSubroutineName(U, Kind)) + if (const DWARFUnit *RefU = findUnitAndExtractFast(spec_die, U, &spec_ref)) { + if (const char *name = spec_die.getSubroutineName(RefU, Kind)) return name; } } @@ -325,8 +336,9 @@ DWARFDebugInfoEntryMinimal::getSubroutineName(const DWARFUnit *U, getAttributeValueAsReference(U, DW_AT_abstract_origin, -1U); if (abs_origin_ref != -1U) { DWARFDebugInfoEntryMinimal abs_origin_die; - if (abs_origin_die.extractFast(U, &abs_origin_ref)) { - if (const char *name = abs_origin_die.getSubroutineName(U, Kind)) + if (const DWARFUnit *RefU = findUnitAndExtractFast(abs_origin_die, U, + &abs_origin_ref)) { + if (const char *name = abs_origin_die.getSubroutineName(RefU, Kind)) return name; } } |