diff options
author | Alexey Samsonov <samsonov@google.com> | 2012-09-04 08:12:33 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2012-09-04 08:12:33 +0000 |
commit | c942e6b781040187516ccf10be2bc83d1c097b59 (patch) | |
tree | 452f309be0e5163ca8bf2d134400066b6057a4bc /llvm/lib/DebugInfo/DWARFCompileUnit.cpp | |
parent | 01cfbfe9d00ceed2074fb5e3c296d506afe63a36 (diff) | |
download | bcm5719-llvm-c942e6b781040187516ccf10be2bc83d1c097b59.tar.gz bcm5719-llvm-c942e6b781040187516ccf10be2bc83d1c097b59.zip |
Add support for fetching inlining context (stack of source code locations)
by instruction address from DWARF.
Add --inlining flag to llvm-dwarfdump to demonstrate and test this functionality,
so that "llvm-dwarfdump --inlining --address=0x..." now works much like
"addr2line -i 0x...", provided that the binary has debug info
(Clang's -gline-tables-only *is* enough).
llvm-svn: 163128
Diffstat (limited to 'llvm/lib/DebugInfo/DWARFCompileUnit.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/DWARFCompileUnit.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/llvm/lib/DebugInfo/DWARFCompileUnit.cpp b/llvm/lib/DebugInfo/DWARFCompileUnit.cpp index d32fd6dd7e2..bdd65b77e4b 100644 --- a/llvm/lib/DebugInfo/DWARFCompileUnit.cpp +++ b/llvm/lib/DebugInfo/DWARFCompileUnit.cpp @@ -75,6 +75,15 @@ DWARFCompileUnit::extract(uint32_t offset, DataExtractor debug_info_data, return 0; } +bool DWARFCompileUnit::extractRangeList(uint32_t RangeListOffset, + DWARFDebugRangeList &RangeList) const { + // Require that compile unit is extracted. + assert(DieArray.size() > 0); + DataExtractor RangesData(Context.getRangeSection(), + Context.isLittleEndian(), AddrSize); + return RangeList.extract(RangesData, &RangeListOffset); +} + void DWARFCompileUnit::clear() { Offset = 0; Length = 0; @@ -246,12 +255,21 @@ DWARFCompileUnit::buildAddressRangeTable(DWARFDebugAranges *debug_aranges, clearDIEs(true); } -const DWARFDebugInfoEntryMinimal* -DWARFCompileUnit::getFunctionDIEForAddress(int64_t address) { +DWARFDebugInfoEntryMinimal::InlinedChain +DWARFCompileUnit::getInlinedChainForAddress(uint64_t Address) { + // First, find a subprogram that contains the given address (the root + // of inlined chain). extractDIEsIfNeeded(false); + const DWARFDebugInfoEntryMinimal *SubprogramDIE = 0; for (size_t i = 0, n = DieArray.size(); i != n; i++) { - if (DieArray[i].addressRangeContainsAddress(this, address)) - return &DieArray[i]; + if (DieArray[i].isSubprogramDIE() && + DieArray[i].addressRangeContainsAddress(this, Address)) { + SubprogramDIE = &DieArray[i]; + break; + } } - return 0; + // Get inlined chain rooted at this subprogram DIE. + if (!SubprogramDIE) + return DWARFDebugInfoEntryMinimal::InlinedChain(); + return SubprogramDIE->getInlinedChainForAddress(this, Address); } |