summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2017-09-18 21:27:44 +0000
committerAdrian Prantl <aprantl@apple.com>2017-09-18 21:27:44 +0000
commitc2bc71702877756d16aa7e1e40fa858779bd7d13 (patch)
tree5af775f5061f73d1b6369095c89d01e242413fbd /llvm/lib/DebugInfo/DWARF
parentf077b5b885a5374bda8ccca3c3294f2f1d19fb91 (diff)
downloadbcm5719-llvm-c2bc71702877756d16aa7e1e40fa858779bd7d13.tar.gz
bcm5719-llvm-c2bc71702877756d16aa7e1e40fa858779bd7d13.zip
llvm-dwarfdump: add a --show-parents options when selectively dumping DIEs.
llvm-svn: 313567
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDie.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index 57734984d75..f588f2599c2 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -367,6 +367,16 @@ void DWARFDie::getCallerFrame(uint32_t &CallFile, uint32_t &CallLine,
CallDiscriminator = toUnsigned(find(DW_AT_GNU_discriminator), 0);
}
+/// Helper to dump a DIE with all of its parents, but no siblings.
+static unsigned dumpParentChain(DWARFDie Die, raw_ostream &OS, unsigned Indent,
+ DIDumpOptions DumpOpts) {
+ if (!Die)
+ return Indent;
+ Indent = dumpParentChain(Die.getParent(), OS, Indent, DumpOpts);
+ Die.dump(OS, 0, Indent, DumpOpts);
+ return Indent + 2;
+}
+
void DWARFDie::dump(raw_ostream &OS, unsigned RecurseDepth, unsigned Indent,
DIDumpOptions DumpOpts) const {
if (!isValid())
@@ -374,7 +384,12 @@ void DWARFDie::dump(raw_ostream &OS, unsigned RecurseDepth, unsigned Indent,
DWARFDataExtractor debug_info_data = U->getDebugInfoExtractor();
const uint32_t Offset = getOffset();
uint32_t offset = Offset;
- RecurseDepth += DumpOpts.ShowChildren ? 1 : 0;
+ if (DumpOpts.ShowChildren)
+ RecurseDepth++;
+ if (DumpOpts.ShowParents) {
+ DumpOpts.ShowParents = false;
+ Indent = dumpParentChain(getParent(), OS, Indent, DumpOpts);
+ }
if (debug_info_data.isValidOffset(offset)) {
uint32_t abbrCode = debug_info_data.getULEB128(&offset);
OpenPOWER on IntegriCloud