From f6324abed0f4c0340be6cd8e435c68019debacfc Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Sat, 16 Sep 2017 16:58:18 +0000 Subject: [PATCH] llvm-dwarfdump: Add support for -debug-types=. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313463 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/DebugInfo/DWARF/DWARFContext.cpp | 27 ++++++++++--------- .../llvm-dwarfdump/X86/debug_type_offset.test | 8 ++++++ 2 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 test/tools/llvm-dwarfdump/X86/debug_type_offset.test diff --git a/lib/DebugInfo/DWARF/DWARFContext.cpp b/lib/DebugInfo/DWARF/DWARFContext.cpp index 3914b5a441a..02d37f21c38 100644 --- a/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -270,19 +270,22 @@ void DWARFContext::dump( dumpDebugInfo(ExplicitDWO, ".debug_info.dwo", DObj->getInfoDWOSection(), dwo_compile_units()); - if ((DumpType & DIDT_DebugTypes)) { - if (Explicit || getNumTypeUnits()) { - OS << "\n.debug_types contents:\n"; - for (const auto &TUS : type_unit_sections()) - for (const auto &TU : TUS) + auto dumpDebugType = [&](const char *Name, + tu_section_iterator_range TUSections) { + OS << '\n' << Name << " contents:\n"; + DumpOffset = DumpOffsets[DIDT_ID_DebugTypes]; + for (const auto &TUS : TUSections) + for (const auto &TU : TUS) + if (DumpOffset) + TU->getDIEForOffset(*DumpOffset).dump(OS, 0); + else TU->dump(OS, DumpOpts); - } - if (ExplicitDWO || getNumDWOTypeUnits()) { - OS << "\n.debug_types.dwo contents:\n"; - for (const auto &DWOTUS : dwo_type_unit_sections()) - for (const auto &DWOTU : DWOTUS) - DWOTU->dump(OS, DumpOpts); - } + }; + if ((DumpType & DIDT_DebugTypes)) { + if (Explicit || getNumTypeUnits()) + dumpDebugType(".debug_types", type_unit_sections()); + if (ExplicitDWO || getNumDWOTypeUnits()) + dumpDebugType(".debug_types.dwo", dwo_type_unit_sections()); } if (shouldDump(Explicit, ".debug_loc", DIDT_ID_DebugLoc, diff --git a/test/tools/llvm-dwarfdump/X86/debug_type_offset.test b/test/tools/llvm-dwarfdump/X86/debug_type_offset.test new file mode 100644 index 00000000000..b1fcad4312d --- /dev/null +++ b/test/tools/llvm-dwarfdump/X86/debug_type_offset.test @@ -0,0 +1,8 @@ +RUN: llvm-mc %S/../../../DebugInfo/Inputs/typeunit-header.s -filetype obj \ +RUN: -triple x86_64-unknown-elf -o - \ +RUN: | llvm-dwarfdump -debug-types=0x00000019 - | FileCheck %s +CHECK: .debug_types contents: +:CHECK-NOT: {{:}} +CHECK: 0x00000019: DW_TAG_structure_type +CHECK: DW_AT_visibility +CHECK-NOT: {{:}} -- 2.40.0