[llvm] r313464 - llvm-dwarfdump: support a --show-children option
Adrian Prantl via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 16 10:28:00 PDT 2017
Author: adrian
Date: Sat Sep 16 10:28:00 2017
New Revision: 313464
URL: http://llvm.org/viewvc/llvm-project?rev=313464&view=rev
Log:
llvm-dwarfdump: support a --show-children option
This will print all children of a DIE when selectively printing only
one DIE at a given offset.
Modified:
llvm/trunk/include/llvm/DebugInfo/DIContext.h
llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_info_offset.test
llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_type_offset.test
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=313464&r1=313463&r2=313464&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DIContext.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DIContext.h Sat Sep 16 10:28:00 2017
@@ -139,6 +139,7 @@ enum DIDumpType : unsigned {
struct DIDumpOptions {
unsigned DumpType = DIDT_All;
bool DumpEH = false;
+ bool ShowChildren = false;
bool SummarizeTypes = false;
bool Verbose = false;
};
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=313464&r1=313463&r2=313464&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Sat Sep 16 10:28:00 2017
@@ -223,6 +223,8 @@ void DWARFContext::dump(
Optional<uint64_t> DumpOffset;
uint64_t DumpType = DumpOpts.DumpType;
bool DumpEH = DumpOpts.DumpEH;
+ unsigned RecDepth =
+ DumpOpts.ShowChildren ? std::numeric_limits<unsigned>::max() : 0;
StringRef Extension = sys::path::extension(DObj->getFileName());
bool IsDWO = (Extension == ".dwo") || (Extension == ".dwp");
@@ -260,7 +262,7 @@ void DWARFContext::dump(
if (shouldDump(IsExplicit, Name, DIDT_ID_DebugInfo, Section.Data)) {
for (const auto &CU : CUs)
if (DumpOffset)
- CU->getDIEForOffset(DumpOffset.getValue()).dump(OS, 0);
+ CU->getDIEForOffset(DumpOffset.getValue()).dump(OS, RecDepth);
else
CU->dump(OS, DumpOpts);
}
@@ -277,7 +279,7 @@ void DWARFContext::dump(
for (const auto &TUS : TUSections)
for (const auto &TU : TUS)
if (DumpOffset)
- TU->getDIEForOffset(*DumpOffset).dump(OS, 0);
+ TU->getDIEForOffset(*DumpOffset).dump(OS, RecDepth);
else
TU->dump(OS, DumpOpts);
};
Modified: llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_info_offset.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_info_offset.test?rev=313464&r1=313463&r2=313464&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_info_offset.test (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_info_offset.test Sat Sep 16 10:28:00 2017
@@ -6,5 +6,17 @@ CHECK: DW_AT_name
CHECK-NOT: {{:}}
RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
-RUN: | llvm-dwarfdump -debug-info=0 - | FileCheck --allow-empty --check-prefix=EMPTY %s
+RUN: | llvm-dwarfdump -debug-info=0 - \
+RUN: | FileCheck --allow-empty --check-prefix=EMPTY %s
EMPTY-NOT: DW_TAG
+
+RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
+RUN: | llvm-dwarfdump -debug-info=0x0000000b -c - \
+RUN: | FileCheck %s --check-prefix=CHILDREN
+
+UN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
+UN: | llvm-dwarfdump -debug-info=0x0000000b --show-children - \
+UN: | FileCheck %s --check-prefix=CHILDREN
+CHILDREN: .debug_info contents:
+CHILDREN: 0x0000000b: DW_TAG_compile_unit
+CHILDREN: DW_TAG_subprogram
Modified: llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_type_offset.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_type_offset.test?rev=313464&r1=313463&r2=313464&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_type_offset.test (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/debug_type_offset.test Sat Sep 16 10:28:00 2017
@@ -6,3 +6,12 @@ CHECK: .debug_types contents:
CHECK: 0x00000019: DW_TAG_structure_type
CHECK: DW_AT_visibility
CHECK-NOT: {{:}}
+
+RUN: llvm-mc %S/../../../DebugInfo/Inputs/typeunit-header.s -filetype obj \
+RUN: -triple x86_64-unknown-elf -o - \
+RUN: | llvm-dwarfdump -c -debug-types=0x0000017 - \
+RUN: | FileCheck %s --check-prefix=CHILDREN
+CHILDREN: .debug_types contents:
+CHILDREN: 0x00000017: DW_TAG_type_unit
+CHILDREN: 0x00000019: DW_TAG_structure_type
+CHECK-NOT: {{:}}
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=313464&r1=313463&r2=313464&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Sat Sep 16 10:28:00 2017
@@ -127,6 +127,12 @@ static opt<bool> DumpUUID("uuid", desc("
static alias DumpUUIDAlias("u", desc("Alias for -uuid"), aliasopt(DumpUUID));
static opt<bool>
+ ShowChildren("show-children",
+ desc("Show a debug info entry's children when selectively "
+ "printing with the =<Offset> option"));
+static alias ShowChildrenAlias("c", desc("Alias for -show-children"),
+ aliasopt(ShowChildren));
+static opt<bool>
SummarizeTypes("summarize-types",
desc("Abbreviate the description of type unit entries"));
static opt<bool> Verify("verify", desc("Verify the DWARF debug info"),
@@ -153,6 +159,7 @@ static void error(StringRef Filename, st
static DIDumpOptions getDumpOpts() {
DIDumpOptions DumpOpts;
DumpOpts.DumpType = DumpType;
+ DumpOpts.ShowChildren = ShowChildren;
DumpOpts.SummarizeTypes = SummarizeTypes;
DumpOpts.Verbose = Verbose;
return DumpOpts;
More information about the llvm-commits
mailing list