[dwarfdump] Make -c and -p work together
When requesting to dump both the parent chain and children, we used to
print the DIE more than once because we propagated the dump options to
the parent without clearing the respective flags. This commit fixes this
oversight and adds a test.
rdar://39415292
Differential revision: https://reviews.llvm.org/D47263
llvm-svn: 333350
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index 64fa6e2..a471d97 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -475,8 +475,10 @@
const uint32_t Offset = getOffset();
uint32_t offset = Offset;
if (DumpOpts.ShowParents) {
- DumpOpts.ShowParents = false;
- Indent = dumpParentChain(getParent(), OS, Indent, DumpOpts);
+ DIDumpOptions ParentDumpOpts = DumpOpts;
+ ParentDumpOpts.ShowParents = false;
+ ParentDumpOpts.ShowChildren = false;
+ Indent = dumpParentChain(getParent(), OS, Indent, ParentDumpOpts);
}
if (debug_info_data.isValidOffset(offset)) {
@@ -510,8 +512,10 @@
DWARFDie child = getFirstChild();
if (DumpOpts.ShowChildren && DumpOpts.RecurseDepth > 0 && child) {
DumpOpts.RecurseDepth--;
+ DIDumpOptions ChildDumpOpts = DumpOpts;
+ ChildDumpOpts.ShowParents = false;
while (child) {
- child.dump(OS, Indent + 2, DumpOpts);
+ child.dump(OS, Indent + 2, ChildDumpOpts);
child = child.getSibling();
}
}