diff options
author | Adrian Prantl <aprantl@apple.com> | 2017-09-18 21:27:44 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2017-09-18 21:27:44 +0000 |
commit | c2bc71702877756d16aa7e1e40fa858779bd7d13 (patch) | |
tree | 5af775f5061f73d1b6369095c89d01e242413fbd /llvm/lib/DebugInfo | |
parent | f077b5b885a5374bda8ccca3c3294f2f1d19fb91 (diff) | |
download | bcm5719-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')
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDie.cpp | 17 |
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); |