summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARFDebugInfoEntry.cpp
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-07-02 05:54:45 +0000
committerAlexey Samsonov <samsonov@google.com>2012-07-02 05:54:45 +0000
commitf4462fa3ca8c709b46604bcbcdc2641c23c078b7 (patch)
treebc51d87c935ba7216a6ef85fa84b62d06ae3d43b /llvm/lib/DebugInfo/DWARFDebugInfoEntry.cpp
parent03afad8f1e750dad3d1241f511429f4337cf8282 (diff)
downloadbcm5719-llvm-f4462fa3ca8c709b46604bcbcdc2641c23c078b7.tar.gz
bcm5719-llvm-f4462fa3ca8c709b46604bcbcdc2641c23c078b7.zip
This patch extends the libLLVMDebugInfo which contains a minimalistic DWARF parser:
1) DIContext is now able to return function name for a given instruction address (besides file/line info). 2) llvm-dwarfdump accepts flag --functions that prints the function name (if address is specified by --address flag). 3) test case that checks the basic functionality of llvm-dwarfdump added llvm-svn: 159512
Diffstat (limited to 'llvm/lib/DebugInfo/DWARFDebugInfoEntry.cpp')
-rw-r--r--llvm/lib/DebugInfo/DWARFDebugInfoEntry.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/DWARFDebugInfoEntry.cpp b/llvm/lib/DebugInfo/DWARFDebugInfoEntry.cpp
index 236db97c44a..1024b452551 100644
--- a/llvm/lib/DebugInfo/DWARFDebugInfoEntry.cpp
+++ b/llvm/lib/DebugInfo/DWARFDebugInfoEntry.cpp
@@ -440,3 +440,51 @@ DWARFDebugInfoEntryMinimal::buildAddressRangeTable(const DWARFCompileUnit *cu,
}
}
}
+
+bool
+DWARFDebugInfoEntryMinimal::addressRangeContainsAddress(
+ const DWARFCompileUnit *cu, const uint64_t address) const {
+ if (!isNULL() && getTag() == DW_TAG_subprogram) {
+ uint64_t hi_pc = -1ULL;
+ uint64_t lo_pc = getAttributeValueAsUnsigned(cu, DW_AT_low_pc, -1ULL);
+ if (lo_pc != -1ULL)
+ hi_pc = getAttributeValueAsUnsigned(cu, DW_AT_high_pc, -1ULL);
+ if (hi_pc != -1ULL) {
+ return (lo_pc <= address && address < hi_pc);
+ }
+ }
+ 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);
+ }
+ }
+ return name;
+}
OpenPOWER on IntegriCloud