virtual ~DIContext() {}
virtual void dump(raw_ostream &OS, DIDumpType DumpType = DIDT_All,
- bool DumpEH = false) = 0;
+ bool DumpEH = false, bool SummarizeTypes = false) = 0;
virtual DILineInfo getLineInfoForAddress(uint64_t Address,
DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
}
void dump(raw_ostream &OS, DIDumpType DumpType = DIDT_All,
- bool DumpEH = false) override;
+ bool DumpEH = false, bool SummarizeTypes = false) override;
typedef DWARFUnitSection<DWARFCompileUnit>::iterator_range cu_iterator_range;
typedef DWARFUnitSection<DWARFTypeUnit>::iterator_range tu_iterator_range;
uint32_t getHeaderSize() const override {
return DWARFUnit::getHeaderSize() + 12;
}
- void dump(raw_ostream &OS);
+ void dump(raw_ostream &OS, bool Brief = false);
static const DWARFSectionKind Section = DW_SECT_TYPES;
protected:
/// unit's DIE vector.
///
/// The unit needs to have its DIEs extracted for this method to work.
- const DWARFDebugInfoEntryMinimal *getDIEForOffset(uint32_t Offset) const {
+ const DWARFDebugInfoEntryMinimal *getDIEForOffset(uint32_t Offset) {
+ extractDIEsIfNeeded(false);
assert(!DieArray.empty());
auto it = std::lower_bound(
DieArray.begin(), DieArray.end(), Offset,
}
void dump(raw_ostream &OS, DIDumpType DumpType = DIDT_All,
- bool DumpEH = false) override;
+ bool DumpEH = false, bool SummarizeTypes = false) override;
DILineInfo getLineInfoForAddress(
uint64_t Address,
Accel.dump(OS);
}
-void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType, bool DumpEH) {
+void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType, bool DumpEH,
+ bool SummarizeTypes) {
if (DumpType == DIDT_All || DumpType == DIDT_Abbrev) {
OS << ".debug_abbrev contents:\n";
getDebugAbbrev()->dump(OS);
OS << "\n.debug_types contents:\n";
for (const auto &TUS : type_unit_sections())
for (const auto &TU : TUS)
- TU->dump(OS);
+ TU->dump(OS, SummarizeTypes);
}
if ((DumpType == DIDT_All || DumpType == DIDT_TypesDwo) &&
OS << "\n.debug_types.dwo contents:\n";
for (const auto &DWOTUS : dwo_type_unit_sections())
for (const auto &DWOTU : DWOTUS)
- DWOTU->dump(OS);
+ DWOTU->dump(OS, SummarizeTypes);
}
if (DumpType == DIDT_All || DumpType == DIDT_Loc) {
//===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
+#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
+#include "llvm/Support/Dwarf.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"
return TypeOffset < getLength();
}
-void DWARFTypeUnit::dump(raw_ostream &OS) {
+void DWARFTypeUnit::dump(raw_ostream &OS, bool SummarizeTypes) {
+ const DWARFDebugInfoEntryMinimal *TD =
+ getDIEForOffset(TypeOffset + getOffset());
+ DWARFFormValue NameVal;
+ const char *Name = "";
+ if (TD->getAttributeValue(this, llvm::dwarf::DW_AT_name, NameVal))
+ if (auto ON = NameVal.getAsCString(this))
+ Name = *ON;
+
+ if (SummarizeTypes) {
+ OS << "name = '" << Name << "'"
+ << " type_signature = " << format("0x%16" PRIx64, TypeHash)
+ << " length = " << format("0x%08x", getLength()) << '\n';
+ return;
+ }
+
OS << format("0x%08x", getOffset()) << ": Type Unit:"
<< " length = " << format("0x%08x", getLength())
<< " version = " << format("0x%04x", getVersion())
<< " addr_size = " << format("0x%02x", getAddressByteSize())
<< " type_signature = " << format("0x%16" PRIx64, TypeHash)
<< " type_offset = " << format("0x%04x", TypeOffset)
- << " (next unit at " << format("0x%08x", getNextUnitOffset())
- << ")\n";
+ << " (next unit at " << format("0x%08x", getNextUnitOffset()) << ")\n";
if (const DWARFDebugInfoEntryMinimal *TU = getUnitDIE(false))
TU->dump(OS, this, -1U);
Session->setLoadAddress(ImageBase.get());
}
-void PDBContext::dump(raw_ostream &OS, DIDumpType DumpType,
- bool DumpEH) {}
+void PDBContext::dump(raw_ostream &OS, DIDumpType DumpType, bool DumpEH,
+ bool SummarizeTypes) {}
DILineInfo PDBContext::getLineInfoForAddress(uint64_t Address,
DILineInfoSpecifier Specifier) {
-RUN: llvm-dwarfdump %p/Inputs/dwarfdump-type-units.elf-x86-64 > %t
-RUN: cat %t | FileCheck -check-prefix=FOO %s
-RUN: cat %t | FileCheck -check-prefix=BAR %s
+RUN: llvm-dwarfdump %p/Inputs/dwarfdump-type-units.elf-x86-64 | FileCheck -check-prefix=CHECK -check-prefix=LONG %s
+RUN: llvm-dwarfdump %p/Inputs/dwarfdump-type-units.elf-x86-64 -summarize-types | FileCheck -check-prefix=CHECK -check-prefix=SHORT %s
RUN: llvm-dwarfdump -debug-dump=types %p/Inputs/dwarfdump-type-units.elf-x86-64 | FileCheck -check-prefix=TYPES %s
-FOO: debug_info contents:
-FOO: DW_TAG_variable
-FOO-NEXT: DW_AT_name {{.*}}"f"
-FOO: DW_AT_type [DW_FORM_ref_sig8] ([[FOO_SIG:0x[0-9a-f]*]])
-
-FOO: debug_types contents:
-FOO: 0x00000000: Type Unit: {{.*}} type_signature = [[FOO_SIG]] type_offset = 0x[[FOO_OFF:[0-9a-f]*]] (next unit at
-FOO: DW_TAG_type_unit
-FOO-NOT: NULL
-FOO: 0x0000[[FOO_OFF]]: DW_TAG_structure_type
-FOO-NEXT: DW_AT_name {{.*}}"foo"
-
-BAR: debug_info contents:
-BAR: DW_TAG_variable
-BAR: DW_TAG_variable
-BAR-NEXT: DW_AT_name {{.*}}"b"
-BAR: DW_AT_type [DW_FORM_ref_sig8] ([[BAR_SIG:0x[0-9a-f]*]])
-
-BAR: debug_types contents:
-BAR: 0x00000000: Type Unit: {{.*}} type_signature = [[BAR_SIG]] type_offset = 0x[[BAR_OFF:[0-9a-f]*]] (next unit at
-BAR: DW_TAG_type_unit
-BAR-NOT: NULL
-BAR: 0x0000[[BAR_OFF]]: DW_TAG_structure_type
-BAR-NEXT: DW_AT_name {{.*}}"bar"
+CHECK: debug_info contents:
+
+CHECK: DW_TAG_variable
+CHECK-NEXT: DW_AT_name {{.*}}"f"
+CHECK: DW_AT_type [DW_FORM_ref_sig8] ([[FOO_SIG:0x[0-9a-f]*]])
+
+CHECK: DW_TAG_variable
+CHECK-NEXT: DW_AT_name {{.*}}"b"
+CHECK: DW_AT_type [DW_FORM_ref_sig8] ([[BAR_SIG:0x[0-9a-f]*]])
+
+
+CHECK: debug_types contents:
+
+LONG: 0x00000000: Type Unit: {{.*}} name =
+SHORT-NOT: Type Unit
+SHORT: name =
+CHECK-SAME: 'bar' type_signature = [[BAR_SIG]]
+SHORT-SAME: length =
+LONG-SAME: type_offset = 0x[[BAR_OFF:[0-9a-f]*]] (next unit at
+LONG: DW_TAG_type_unit
+LONG-NOT: NULL
+LONG: 0x0000[[BAR_OFF]]: DW_TAG_structure_type
+LONG-NEXT: DW_AT_name {{.*}}"bar"
+
+LONG: 0x00000000: Type Unit: {{.*}} name =
+SHORT: name =
+CHECK-SAME: 'foo' type_signature = [[FOO_SIG]]
+LONG-SAME: type_offset = 0x[[FOO_OFF:[0-9a-f]*]] (next unit at
+LONG: DW_TAG_type_unit
+LONG-NOT: NULL
+LONG: 0x0000[[FOO_OFF]]: DW_TAG_structure_type
+LONG-NEXT: DW_AT_name {{.*}}"foo"
TYPES-NOT: debug_info contents:
TYPES: debug_types contents:
CHECK-LABEL: .debug_types.dwo contents:
CHECK: [[COMMONUOFF:0x[0-9a-f]*]]:
CHECK-LABEL: Type Unit: length = 0x00000020 version = 0x0004 abbr_offset =
-CHECK: 0x0000 addr_size = 0x08 type_signature = [[COMMONSIG:0x[0-9a-f]*]] type_offset = 0x[[COMMONOFF:.*]] (next unit at [[AUOFF:.*]])
+CHECK: 0x0000 addr_size = 0x08 name = 'common' type_signature = [[COMMONSIG:0x[0-9a-f]*]] type_offset = 0x[[COMMONOFF:.*]] (next unit at [[AUOFF:.*]])
CHECK: DW_TAG_type_unit
CHECK: [[COMMONOFF]]: DW_TAG_structure_type
CHECK: DW_AT_name {{.*}} "common"
CHECK: [[AUOFF]]:
CHECK-LABEL: Type Unit: length = 0x00000020 version = 0x0004 abbr_offset =
-CHECK: 0x0000 addr_size = 0x08 type_signature = [[ASIG:0x[0-9a-f]*]] type_offset = 0x[[AOFF:.*]] (next unit at [[BUOFF:.*]])
+CHECK: 0x0000 addr_size = 0x08 name = 'adistinct' type_signature = [[ASIG:0x[0-9a-f]*]] type_offset = 0x[[AOFF:.*]] (next unit at [[BUOFF:.*]])
CHECK: DW_TAG_type_unit
CHECK: 0x00000042: DW_TAG_structure_type
CHECK: DW_AT_name {{.*}} "adistinct"
CHECK: [[BUOFF]]:
CHECK-LABEL: Type Unit: length = 0x00000020 version = 0x0004 abbr_offset =
-CHECK: 0x{{.*}} addr_size = 0x08 type_signature = [[BSIG:0x[0-9a-f]*]] type_offset = 0x[[BOFF:.*]] (next unit at [[XUOFF:.*]])
+CHECK: 0x{{.*}} addr_size = 0x08 name = 'bdistinct' type_signature = [[BSIG:0x[0-9a-f]*]] type_offset = 0x[[BOFF:.*]] (next unit at [[XUOFF:.*]])
CHECK: DW_TAG_type_unit
CHECK: 0x00000066: DW_TAG_structure_type
CHECK: DW_AT_name {{.*}} "bdistinct"
clEnumValN(DIDT_GdbIndex, "gdb_index", ".gdb_index"),
clEnumValN(DIDT_TUIndex, "tu_index", ".debug_tu_index")));
+static cl::opt<bool>
+ SummarizeTypes("summarize-types",
+ cl::desc("Abbreviate the description of type unit entries"));
+
static void error(StringRef Filename, std::error_code EC) {
if (!EC)
return;
outs() << Filename.str() << ":\tfile format " << Obj.getFileFormatName()
<< "\n\n";
// Dump the complete DWARF structure.
- DICtx->dump(outs(), DumpType);
+ DICtx->dump(outs(), DumpType, false, SummarizeTypes);
}
static void DumpInput(StringRef Filename) {