[llvm] r319271 - llvm-dwarfdump: honor the --show-children option when dumping a specific DIE.
Adrian Prantl via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 28 17:12:23 PST 2017
Author: adrian
Date: Tue Nov 28 17:12:22 2017
New Revision: 319271
URL: http://llvm.org/viewvc/llvm-project?rev=319271&view=rev
Log:
llvm-dwarfdump: honor the --show-children option when dumping a specific DIE.
Modified:
llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp
llvm/trunk/test/tools/llvm-dwarfdump/X86/name.test
llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp?rev=319271&r1=319270&r2=319271&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp Tue Nov 28 17:12:22 2017
@@ -488,7 +488,7 @@ void DWARFDie::dump(raw_ostream &OS, uns
}
DWARFDie child = getFirstChild();
- if (DumpOpts.RecurseDepth > 0 && child) {
+ if (DumpOpts.ShowChildren && DumpOpts.RecurseDepth > 0 && child) {
DumpOpts.RecurseDepth--;
while (child) {
child.dump(OS, Indent + 2, DumpOpts);
Modified: llvm/trunk/test/tools/llvm-dwarfdump/X86/name.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwarfdump/X86/name.test?rev=319271&r1=319270&r2=319271&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwarfdump/X86/name.test (original)
+++ llvm/trunk/test/tools/llvm-dwarfdump/X86/name.test Tue Nov 28 17:12:22 2017
@@ -61,3 +61,9 @@ RUN: | FileCheck %s --check-prefix=MUL
RUN: llvm-dwarfdump %S/../../dsymutil/Inputs/libfat-test.a \
RUN: -x -name=.*86.*_var \
RUN: | FileCheck %s --check-prefix=MULTI
+
+Test the -show-children behavior.
+RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
+RUN: | llvm-dwarfdump -name="brief.c" - | FileCheck %s -check-prefix=NOCHILDREN
+NOCHILDREN: DW_AT_name ("brief.c")
+NOCHILDREN-NOT: DW_TAG
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=319271&r1=319270&r2=319271&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original)
+++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Tue Nov 28 17:12:22 2017
@@ -536,14 +536,17 @@ int main(int argc, char **argv) {
}
raw_ostream &OS = OutputFile ? OutputFile->os() : outs();
+ bool OffsetRequested = false;
// Defaults to dumping all sections, unless brief mode is specified in which
// case only the .debug_info section in dumped.
#define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME) \
if (Dump##ENUM_NAME.IsRequested) { \
DumpType |= DIDT_##ENUM_NAME; \
- if (Dump##ENUM_NAME.HasValue) \
+ if (Dump##ENUM_NAME.HasValue) { \
DumpOffsets[DIDT_ID_##ENUM_NAME] = Dump##ENUM_NAME.Val; \
+ OffsetRequested = true; \
+ } \
}
#include "llvm/BinaryFormat/Dwarf.def"
#undef HANDLE_DWARF_SECTION
@@ -558,6 +561,10 @@ int main(int argc, char **argv) {
DumpType = DIDT_DebugInfo;
}
+ // Unless dumping a specific DIE, default to --show-children.
+ if (!ShowChildren && !Verify && !OffsetRequested && Name.empty() && Find.empty())
+ ShowChildren = true;
+
// Defaults to a.out if no filenames specified.
if (InputFilenames.size() == 0)
InputFilenames.push_back("a.out");
More information about the llvm-commits
mailing list