[llvm] r361671 - [dwarfdump] Add flag to limit the number of parents DIEs
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Fri May 24 14:11:28 PDT 2019
Author: jdevlieghere
Date: Fri May 24 14:11:28 2019
New Revision: 361671
URL: http://llvm.org/viewvc/llvm-project?rev=361671&view=rev
Log:
[dwarfdump] Add flag to limit the number of parents DIEs
This adds `-parent-recurse-depth` which limits the number of parent DIEs
being dumped.
Differential revision: https://reviews.llvm.org/D62359
Modified:
llvm/trunk/include/llvm/DebugInfo/DIContext.h
llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp
llvm/trunk/test/tools/llvm-dwarfdump/X86/enum.s
llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test
llvm/trunk/tools/dsymutil/DwarfLinker.cpp
llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/DIContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DIContext.h?rev=361671&r1=361670&r2=361671&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DIContext.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DIContext.h Fri May 24 14:11:28 2019
@@ -97,11 +97,10 @@ public:
void addFrame(const DILineInfo &Frame) {
Frames.push_back(Frame);
}
-
+
void resize(unsigned i) {
Frames.resize(i);
}
-
};
/// Container for description of a global variable.
@@ -157,7 +156,8 @@ enum DIDumpType : unsigned {
/// dumped.
struct DIDumpOptions {
unsigned DumpType = DIDT_All;
- unsigned RecurseDepth = -1U;
+ unsigned ChildRecurseDepth = -1U;
+ unsigned ParentRecurseDepth = -1U;
uint16_t Version = 0; // DWARF version to assume when extracting.
uint8_t AddrSize = 4; // Address byte size to assume when extracting.
bool ShowAddresses = true;
@@ -171,15 +171,18 @@ struct DIDumpOptions {
/// Return default option set for printing a single DIE without children.
static DIDumpOptions getForSingleDIE() {
DIDumpOptions Opts;
- Opts.RecurseDepth = 0;
+ Opts.ChildRecurseDepth = 0;
+ Opts.ParentRecurseDepth = 0;
return Opts;
}
/// Return the options with RecurseDepth set to 0 unless explicitly required.
DIDumpOptions noImplicitRecursion() const {
DIDumpOptions Opts = *this;
- if (RecurseDepth == -1U && !ShowChildren)
- Opts.RecurseDepth = 0;
+ if (ChildRecurseDepth == -1U && !ShowChildren)
+ Opts.ChildRecurseDepth = 0;
+ if (ParentRecurseDepth == -1U && !ShowParents)
+ Opts.ParentRecurseDepth = 0;
return Opts;
}
};
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp?rev=361671&r1=361670&r2=361671&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp Fri May 24 14:11:28 2019
@@ -553,10 +553,12 @@ void DWARFDie::getCallerFrame(uint32_t &
/// 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.ParentRecurseDepth > 0 && Depth >= DumpOpts.ParentRecurseDepth)
+ return Indent;
+ Indent = dumpParentChain(Die.getParent(), OS, Indent, DumpOpts, Depth + 1);
Die.dump(OS, Indent, DumpOpts);
return Indent + 2;
}
@@ -604,8 +606,8 @@ void DWARFDie::dump(raw_ostream &OS, uns
}
DWARFDie child = getFirstChild();
- if (DumpOpts.ShowChildren && DumpOpts.RecurseDepth > 0 && child) {
- DumpOpts.RecurseDepth--;
+ if (DumpOpts.ShowChildren && DumpOpts.ChildRecurseDepth > 0 && child) {
+ DumpOpts.ChildRecurseDepth--;
DIDumpOptions ChildDumpOpts = DumpOpts;
ChildDumpOpts.ShowParents = false;
while (child) {
Modified: llvm/trunk/test/tools/llvm-dwarfdump/X86/enum.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/enum.s?rev=361671&r1=361670&r2=361671&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/enum.s (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/enum.s Fri May 24 14:11:28 2019
@@ -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 -parent-recurse-depth 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")
Modified: llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test?rev=361671&r1=361670&r2=361671&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/cmdline.test Fri May 24 14:11:28 2019
@@ -13,6 +13,7 @@ HELP: -find
HELP: -ignore-case
HELP: -lookup
HELP: -name
+HELP: -parent-recurse-depth=<N>
HELP: -recurse-depth=<N>
HELP: -regex
HELP: -show-children
Modified: llvm/trunk/tools/dsymutil/DwarfLinker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=361671&r1=361670&r2=361671&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/DwarfLinker.cpp (original)
+++ llvm/trunk/tools/dsymutil/DwarfLinker.cpp Fri May 24 14:11:28 2019
@@ -227,7 +227,7 @@ void DwarfLinker::reportWarning(const Tw
return;
DIDumpOptions DumpOpts;
- DumpOpts.RecurseDepth = 0;
+ DumpOpts.ChildRecurseDepth = 0;
DumpOpts.Verbose = Options.Verbose;
WithColor::note() << " in DIE:\n";
@@ -649,7 +649,7 @@ unsigned DwarfLinker::shouldKeepVariable
if (Options.Verbose) {
DIDumpOptions DumpOpts;
- DumpOpts.RecurseDepth = 0;
+ DumpOpts.ChildRecurseDepth = 0;
DumpOpts.Verbose = Options.Verbose;
DIE.dump(outs(), 8 /* Indent */, DumpOpts);
}
@@ -685,7 +685,7 @@ unsigned DwarfLinker::shouldKeepSubprogr
if (Options.Verbose) {
DIDumpOptions DumpOpts;
- DumpOpts.RecurseDepth = 0;
+ DumpOpts.ChildRecurseDepth = 0;
DumpOpts.Verbose = Options.Verbose;
DIE.dump(outs(), 8 /* Indent */, DumpOpts);
}
@@ -2096,8 +2096,10 @@ void DwarfLinker::DIECloner::copyAbbrev(
Linker.AssignAbbrev(Copy);
}
-uint32_t DwarfLinker::DIECloner::hashFullyQualifiedName(
- DWARFDie DIE, CompileUnit &U, const DebugMapObject &DMO, int RecurseDepth) {
+uint32_t
+DwarfLinker::DIECloner::hashFullyQualifiedName(DWARFDie DIE, CompileUnit &U,
+ const DebugMapObject &DMO,
+ int ChildRecurseDepth) {
const char *Name = nullptr;
DWARFUnit *OrigUnit = &U.getOrigUnit();
CompileUnit *CU = &U;
@@ -2131,13 +2133,13 @@ uint32_t DwarfLinker::DIECloner::hashFul
// FIXME: dsymutil-classic compatibility. Ignore modules.
CU->getOrigUnit().getDIEAtIndex(CU->getInfo(Idx).ParentIdx).getTag() ==
dwarf::DW_TAG_module)
- return djbHash(Name ? Name : "", djbHash(RecurseDepth ? "" : "::"));
+ return djbHash(Name ? Name : "", djbHash(ChildRecurseDepth ? "" : "::"));
DWARFDie Die = OrigUnit->getDIEAtIndex(CU->getInfo(Idx).ParentIdx);
return djbHash(
(Name ? Name : ""),
djbHash((Name ? "::" : ""),
- hashFullyQualifiedName(Die, *CU, DMO, ++RecurseDepth)));
+ hashFullyQualifiedName(Die, *CU, DMO, ++ChildRecurseDepth)));
}
static uint64_t getDwoId(const DWARFDie &CUDie, const DWARFUnit &Unit) {
@@ -2656,7 +2658,7 @@ bool DwarfLinker::link(const DebugMap &M
if (Options.Verbose) {
outs() << "Input compilation unit:";
DIDumpOptions DumpOpts;
- DumpOpts.RecurseDepth = 0;
+ DumpOpts.ChildRecurseDepth = 0;
DumpOpts.Verbose = Options.Verbose;
CUDie.dump(outs(), 0, DumpOpts);
}
Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=361671&r1=361670&r2=361671&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Fri May 24 14:11:28 2019
@@ -192,13 +192,18 @@ static opt<bool>
cat(DwarfDumpCategory));
static alias ShowFormAlias("F", desc("Alias for -show-form."),
aliasopt(ShowForm), cat(DwarfDumpCategory));
-static opt<unsigned> RecurseDepth(
- "recurse-depth",
- desc("Only recurse to a depth of N when displaying debug info entries."),
- cat(DwarfDumpCategory), init(-1U), value_desc("N"));
-static alias RecurseDepthAlias("r", desc("Alias for -recurse-depth."),
- aliasopt(RecurseDepth));
-
+static opt<unsigned>
+ ChildRecurseDepth("recurse-depth",
+ desc("Only recurse to a depth of N when displaying "
+ "children of debug info entries."),
+ cat(DwarfDumpCategory), init(-1U), value_desc("N"));
+static alias ChildRecurseDepthAlias("r", desc("Alias for -recurse-depth."),
+ aliasopt(ChildRecurseDepth));
+static opt<unsigned>
+ ParentRecurseDepth("parent-recurse-depth",
+ desc("Only recurse to a depth of N when displaying "
+ "parents of debug info entries."),
+ cat(DwarfDumpCategory), init(-1U), value_desc("N"));
static opt<bool>
SummarizeTypes("summarize-types",
desc("Abbreviate the description of type unit entries."),
@@ -233,7 +238,8 @@ static void error(StringRef Prefix, std:
static DIDumpOptions getDumpOpts() {
DIDumpOptions DumpOpts;
DumpOpts.DumpType = DumpType;
- DumpOpts.RecurseDepth = RecurseDepth;
+ DumpOpts.ChildRecurseDepth = ChildRecurseDepth;
+ DumpOpts.ParentRecurseDepth = ParentRecurseDepth;
DumpOpts.ShowAddresses = !Diff;
DumpOpts.ShowChildren = ShowChildren;
DumpOpts.ShowParents = ShowParents;
@@ -389,7 +395,7 @@ static bool lookup(ObjectFile &Obj, DWAR
return false;
DIDumpOptions DumpOpts = getDumpOpts();
- DumpOpts.RecurseDepth = 0;
+ DumpOpts.ChildRecurseDepth = 0;
DIEsForAddr.CompileUnit->dump(OS, DumpOpts);
if (DIEsForAddr.FunctionDIE) {
DIEsForAddr.FunctionDIE.dump(OS, 2, DumpOpts);
More information about the llvm-commits
mailing list