[llvm] r343884 - dwarfdump: Avoid parsing units unnecessarily
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 5 13:55:20 PDT 2018
Author: dblaikie
Date: Fri Oct 5 13:55:20 2018
New Revision: 343884
URL: http://llvm.org/viewvc/llvm-project?rev=343884&view=rev
Log:
dwarfdump: Avoid parsing units unnecessarily
NFC-ish (the parsing of the units is not a functional change - no
errors/warnings are emitted during the shallow parsing - though without
parsing them here, the "max version" would be wrong (still zero) later
on, so in those cases the units do need to be parsed)
Modified:
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h
llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h?rev=343884&r1=343883&r2=343884&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h Fri Oct 5 13:55:20 2018
@@ -231,7 +231,17 @@ public:
/// Get a DIE given an exact offset.
DWARFDie getDIEForOffset(uint32_t Offset);
- unsigned getMaxVersion() const { return MaxVersion; }
+ unsigned getMaxVersion() {
+ // Ensure info units have been parsed to discover MaxVersion
+ info_section_units();
+ return MaxVersion;
+ }
+
+ unsigned getMaxDWOVersion() {
+ // Ensure DWO info units have been parsed to discover MaxVersion
+ dwo_info_section_units();
+ return MaxVersion;
+ }
void setMaxVersionIfGreater(unsigned Version) {
if (Version > MaxVersion)
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=343884&r1=343883&r2=343884&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Fri Oct 5 13:55:20 2018
@@ -328,21 +328,20 @@ void DWARFContext::dump(
DObj->getAbbrevDWOSection()))
getDebugAbbrevDWO()->dump(OS);
- auto dumpDebugInfo = [&](bool IsExplicit, const char *Name,
- DWARFSection Section, unit_iterator_range Units) {
- if (shouldDump(IsExplicit, Name, DIDT_ID_DebugInfo, Section.Data)) {
- if (DumpOffset)
- getDIEForOffset(DumpOffset.getValue())
- .dump(OS, 0, DumpOpts.noImplicitRecursion());
- else
- for (const auto &U : Units)
- U->dump(OS, DumpOpts);
- }
+ auto dumpDebugInfo = [&](unit_iterator_range Units) {
+ if (DumpOffset)
+ getDIEForOffset(DumpOffset.getValue())
+ .dump(OS, 0, DumpOpts.noImplicitRecursion());
+ else
+ for (const auto &U : Units)
+ U->dump(OS, DumpOpts);
};
- dumpDebugInfo(Explicit, ".debug_info", DObj->getInfoSection(),
- info_section_units());
- dumpDebugInfo(ExplicitDWO, ".debug_info.dwo", DObj->getInfoDWOSection(),
- dwo_info_section_units());
+ if (shouldDump(Explicit, ".debug_info", DIDT_ID_DebugInfo,
+ DObj->getInfoSection().Data))
+ dumpDebugInfo(info_section_units());
+ if (shouldDump(ExplicitDWO, ".debug_info.dwo", DIDT_ID_DebugInfo,
+ DObj->getInfoDWOSection().Data))
+ dumpDebugInfo(dwo_info_section_units());
auto dumpDebugType = [&](const char *Name, unit_iterator_range Units) {
OS << '\n' << Name << " contents:\n";
@@ -543,7 +542,7 @@ void DWARFContext::dump(
dumpStringOffsetsSection(OS, "debug_str_offsets.dwo", *DObj,
DObj->getStringOffsetDWOSection(),
DObj->getStringDWOSection(), dwo_units(),
- isLittleEndian(), getMaxVersion());
+ isLittleEndian(), getMaxDWOVersion());
if (shouldDump(Explicit, ".gnu_index", DIDT_ID_GdbIndex,
DObj->getGdbIndexSection())) {
More information about the llvm-commits
mailing list