[PATCH] D62359: [dwarfdump] Make recursion affect the parent chain

Jonas Devlieghere via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 23 17:16:38 PDT 2019


JDevlieghere created this revision.
JDevlieghere added reviewers: aprantl, dblaikie, probinson.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

Currently, `-r` (recursion depth) doesn't affect `-p` (show parents). This patch fixes that and adds a test case.


Repository:
  rL LLVM

https://reviews.llvm.org/D62359

Files:
  llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
  llvm/test/tools/llvm-dwarfdump/X86/enum.s


Index: llvm/test/tools/llvm-dwarfdump/X86/enum.s
===================================================================
--- llvm/test/tools/llvm-dwarfdump/X86/enum.s
+++ llvm/test/tools/llvm-dwarfdump/X86/enum.s
@@ -2,11 +2,16 @@
 # RUN: llvm-dwarfdump --debug-info=0x0000002a -p %t | FileCheck %s --check-prefix=PARENTS
 # RUN: llvm-dwarfdump --debug-info=0x0000002a -c %t | FileCheck %s --check-prefix=CHILDREN
 # RUN: llvm-dwarfdump --debug-info=0x0000002a -p -c %t | FileCheck %s --check-prefix=BOTH
+# RUN: llvm-dwarfdump  --debug-info=0x00000032 -p -r 1 -c %t | FileCheck %s --check-prefix=ONEPARENT
 
 # PARENTS: DW_TAG_compile_unit
 # PARENTS: DW_TAG_enumeration_type
 # PARENTS-NOT: DW_TAG_enumerator
 
+# ONEPARENT-NOT: DW_TAG_compile_unit
+# ONEPARENT: DW_TAG_enumeration_type
+# ONEPARENT: DW_TAG_enumerator
+
 # CHILDREN-NOT: DW_TAG_compile_unit
 # CHILDREN:   DW_TAG_enumerator
 # CHILDREN:     DW_AT_name	("first")
Index: llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -553,10 +553,13 @@
 
 /// 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) {
+                                DIDumpOptions DumpOpts, unsigned Depth = 0) {
   if (!Die)
     return Indent;
-  Indent = dumpParentChain(Die.getParent(), OS, Indent, DumpOpts);
+  if (DumpOpts.RecurseDepth > 0 && Depth >= DumpOpts.RecurseDepth)
+    return Indent;
+  Depth += 1;
+  Indent = dumpParentChain(Die.getParent(), OS, Indent, DumpOpts, Depth);
   Die.dump(OS, Indent, DumpOpts);
   return Indent + 2;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62359.201102.patch
Type: text/x-patch
Size: 1774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190524/18ced7fd/attachment.bin>


More information about the llvm-commits mailing list