diff options
author | David Blaikie <dblaikie@gmail.com> | 2016-10-18 21:09:48 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2016-10-18 21:09:48 +0000 |
commit | 50cc27ecb931c0ffeace0da054848fee62d95e96 (patch) | |
tree | c4e042b5211715b3db71b3643062baf902e8802c /llvm/lib/DebugInfo | |
parent | c0a717ba5bf41ad90ba1ad8151f2b15b79c65998 (diff) | |
download | bcm5719-llvm-50cc27ecb931c0ffeace0da054848fee62d95e96.tar.gz bcm5719-llvm-50cc27ecb931c0ffeace0da054848fee62d95e96.zip |
dwarfdump: -summarize-types: print a short summary (unqualified type name, hash, length) of type units rather than dumping contents
This is just a quick utility handy for getting rough summaries of types
in a given object or dwo file. I've been using it to investigate the
amount of type info redundancy across a project build, for example.
llvm-svn: 284537
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 7 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp | 22 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/PDB/PDBContext.cpp | 4 |
3 files changed, 25 insertions, 8 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index c2602ba2196..adcbff78d1c 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -77,7 +77,8 @@ static void dumpAccelSection(raw_ostream &OS, StringRef Name, 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); @@ -106,7 +107,7 @@ void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType, bool DumpEH) { 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) && @@ -114,7 +115,7 @@ void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType, bool DumpEH) { 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) { diff --git a/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp index 766e8ac16f0..8c8aea3c1fd 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFTypeUnit.cpp @@ -8,6 +8,8 @@ //===----------------------------------------------------------------------===// #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" @@ -22,7 +24,22 @@ bool DWARFTypeUnit::extractImpl(DataExtractor debug_info, 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()) @@ -30,8 +47,7 @@ void DWARFTypeUnit::dump(raw_ostream &OS) { << " 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); diff --git a/llvm/lib/DebugInfo/PDB/PDBContext.cpp b/llvm/lib/DebugInfo/PDB/PDBContext.cpp index 773230263da..94b81ecf561 100644 --- a/llvm/lib/DebugInfo/PDB/PDBContext.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBContext.cpp @@ -29,8 +29,8 @@ PDBContext::PDBContext(const COFFObjectFile &Object, 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) { |