aboutsummaryrefslogtreecommitdiff
path: root/lib/DebugInfo/DWARFDebugInfoEntry.cpp
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-07-17 15:28:35 +0000
committerAlexey Samsonov <samsonov@google.com>2012-07-17 15:28:35 +0000
commit9d26b0ba06479d9debadebce19344169f72407dd (patch)
tree45245cc51de114c3919becf1b93ac1447d8483c1 /lib/DebugInfo/DWARFDebugInfoEntry.cpp
parent4f0c69623c10a3a49f6926fd53694ee532e06a85 (diff)
Improve behavior of DebugInfoEntryMinimal::getSubprogramName() introduced in r159512.
To fetch a subprogram name we should not only inspect the DIE for this subprogram, but optionally inspect its specification, or its abstract origin (even if there is no inlining), or even specification of an abstract origin. Reviewed by Benjamin Kramer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160365 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/DebugInfo/DWARFDebugInfoEntry.cpp')
-rw-r--r--lib/DebugInfo/DWARFDebugInfoEntry.cpp51
1 files changed, 27 insertions, 24 deletions
diff --git a/lib/DebugInfo/DWARFDebugInfoEntry.cpp b/lib/DebugInfo/DWARFDebugInfoEntry.cpp
index 1024b45255..429a36c087 100644
--- a/lib/DebugInfo/DWARFDebugInfoEntry.cpp
+++ b/lib/DebugInfo/DWARFDebugInfoEntry.cpp
@@ -456,35 +456,38 @@ DWARFDebugInfoEntryMinimal::addressRangeContainsAddress(
return false;
}
-static inline const char*
-getSubprogramNameFromDie(const DWARFCompileUnit *cu,
- const DWARFDebugInfoEntryMinimal *die) {
- const char *result = 0;
- if (!die->isNULL() && die->getTag() == DW_TAG_subprogram) {
- // Try to get mangled name if possible.
- result = die->getAttributeValueAsString(cu, DW_AT_MIPS_linkage_name, 0);
- if (result == 0)
- result = die->getAttributeValueAsString(cu, DW_AT_linkage_name, 0);
- if (result == 0)
- result = die->getAttributeValueAsString(cu, DW_AT_name, 0);
- }
- return result;
-}
-
const char*
DWARFDebugInfoEntryMinimal::getSubprogramName(
const DWARFCompileUnit *cu) const {
if (isNULL() || getTag() != DW_TAG_subprogram)
return 0;
- const char *name = getSubprogramNameFromDie(cu, this);
- if (name == 0) {
- // Try to get name from specification DIE.
- uint32_t ref = getAttributeValueAsReference(cu, DW_AT_specification, -1U);
- if (ref != -1U) {
- DWARFDebugInfoEntryMinimal spec_die;
- if (spec_die.extract(cu, &ref))
- name = getSubprogramNameFromDie(cu, &spec_die);
+ // Try to get mangled name if possible.
+ if (const char *name =
+ getAttributeValueAsString(cu, DW_AT_MIPS_linkage_name, 0))
+ return name;
+ if (const char *name = getAttributeValueAsString(cu, DW_AT_linkage_name, 0))
+ return name;
+ if (const char *name = getAttributeValueAsString(cu, DW_AT_name, 0))
+ return name;
+ // Try to get name from specification DIE.
+ uint32_t spec_ref =
+ getAttributeValueAsReference(cu, DW_AT_specification, -1U);
+ if (spec_ref != -1U) {
+ DWARFDebugInfoEntryMinimal spec_die;
+ if (spec_die.extract(cu, &spec_ref)) {
+ if (const char *name = spec_die.getSubprogramName(cu))
+ return name;
}
}
- return name;
+ // Try to get name from abstract origin DIE.
+ uint32_t abs_origin_ref =
+ getAttributeValueAsReference(cu, DW_AT_abstract_origin, -1U);
+ if (abs_origin_ref != -1U) {
+ DWARFDebugInfoEntryMinimal abs_origin_die;
+ if (abs_origin_die.extract(cu, &abs_origin_ref)) {
+ if (const char *name = abs_origin_die.getSubprogramName(cu))
+ return name;
+ }
+ }
+ return 0;
}