diff options
author | Paul Robinson <paul.robinson@sony.com> | 2018-08-01 20:54:11 +0000 |
---|---|---|
committer | Paul Robinson <paul.robinson@sony.com> | 2018-08-01 20:54:11 +0000 |
commit | 2c25f345d7af47eff5e113e18e29e0ec84162eb4 (patch) | |
tree | 9ada25a48f29ff597aaf29ae0ac0d2cfc24b499b /llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | |
parent | 11307fab931d369dfd60d73f58a0408f1d1aa3bd (diff) | |
download | bcm5719-llvm-2c25f345d7af47eff5e113e18e29e0ec84162eb4.tar.gz bcm5719-llvm-2c25f345d7af47eff5e113e18e29e0ec84162eb4.zip |
[DebugInfo/DWARF] [4/4] Unify handling of compile and type units. NFC
This is patch 4 of 4 NFC refactorings to handle type units and compile
units more consistently and with less concern about the object-file
section that they came from.
Patch 4 combines separate DWARFUnitVectors for compile and type units
into a single DWARFUnitVector that contains both. For now the
implementation distinguishes compile units from type units by putting
all compile units at the front of the vector, reflecting the DWARF v4
distinction between .debug_info and .debug_types sections. A future
patch will change this to allow the free mixing of unit kinds, as is
specified by DWARF v5.
Differential Revision: https://reviews.llvm.org/D49744
llvm-svn: 338633
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFContext.cpp')
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index 79e463da824..683da066422 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -351,9 +351,9 @@ void DWARFContext::dump( } }; dumpDebugInfo(Explicit, ".debug_info", DObj->getInfoSection(), - compile_units()); + info_section_units()); dumpDebugInfo(ExplicitDWO, ".debug_info.dwo", DObj->getInfoDWOSection(), - dwo_compile_units()); + dwo_info_section_units()); auto dumpDebugType = [&](const char *Name, tu_iterator_range TUs) { OS << '\n' << Name << " contents:\n"; @@ -367,9 +367,9 @@ void DWARFContext::dump( }; if ((DumpType & DIDT_DebugTypes)) { if (Explicit || getNumTypeUnits()) - dumpDebugType(".debug_types", type_units()); + dumpDebugType(".debug_types", types_section_units()); if (ExplicitDWO || getNumDWOTypeUnits()) - dumpDebugType(".debug_types.dwo", dwo_type_units()); + dumpDebugType(".debug_types.dwo", dwo_types_section_units()); } if (shouldDump(Explicit, ".debug_loc", DIDT_ID_DebugLoc, @@ -581,13 +581,12 @@ void DWARFContext::dump( } DWARFCompileUnit *DWARFContext::getDWOCompileUnitForHash(uint64_t Hash) { - if (DWOCUs.empty()) - DWOCUs.addUnitsForDWOSection(*this, DObj->getInfoDWOSection(), DW_SECT_INFO, - true); + parseDWOUnits(LazyParse); if (const auto &CUI = getCUIndex()) { if (const auto *R = CUI.getFromHash(Hash)) - return dyn_cast_or_null<DWARFCompileUnit>(DWOCUs.getUnitForIndexEntry(*R)); + return dyn_cast_or_null<DWARFCompileUnit>( + DWOUnits.getUnitForIndexEntry(*R)); return nullptr; } @@ -612,8 +611,8 @@ DWARFCompileUnit *DWARFContext::getDWOCompileUnitForHash(uint64_t Hash) { } DWARFDie DWARFContext::getDIEForOffset(uint32_t Offset) { - parseCompileUnits(); - if (auto *CU = CUs.getUnitForOffset(Offset)) + parseNormalUnits(); + if (auto *CU = NormalUnits.getUnitForOffset(Offset)) return CU->getDIEForOffset(Offset); return DWARFDie(); } @@ -842,37 +841,31 @@ Expected<const DWARFDebugLine::LineTable *> DWARFContext::getLineTableForUnit( RecoverableErrorCallback); } -void DWARFContext::parseCompileUnits() { - if (!CUs.empty()) - return; - CUs.addUnitsForSection(*this, DObj->getInfoSection(), DW_SECT_INFO); -} - -void DWARFContext::parseTypeUnits() { - if (!TUs.empty()) +void DWARFContext::parseNormalUnits() { + if (!NormalUnits.empty()) return; + NormalUnits.addUnitsForSection(*this, DObj->getInfoSection(), DW_SECT_INFO); + NormalUnits.finishedInfoUnits(); DObj->forEachTypesSections([&](const DWARFSection &S) { - TUs.addUnitsForSection(*this, S, DW_SECT_TYPES); + NormalUnits.addUnitsForSection(*this, S, DW_SECT_TYPES); }); } -void DWARFContext::parseDWOCompileUnits() { - if (!DWOCUs.empty()) - return; - DWOCUs.addUnitsForDWOSection(*this, DObj->getInfoDWOSection(), DW_SECT_INFO); -} - -void DWARFContext::parseDWOTypeUnits() { - if (!DWOTUs.empty()) +void DWARFContext::parseDWOUnits(bool Lazy) { + if (!DWOUnits.empty()) return; + DWOUnits.addUnitsForDWOSection(*this, DObj->getInfoDWOSection(), DW_SECT_INFO, + Lazy); + DWOUnits.finishedInfoUnits(); DObj->forEachTypesDWOSections([&](const DWARFSection &S) { - DWOTUs.addUnitsForDWOSection(*this, S, DW_SECT_TYPES); + DWOUnits.addUnitsForDWOSection(*this, S, DW_SECT_TYPES, Lazy); }); } DWARFCompileUnit *DWARFContext::getCompileUnitForOffset(uint32_t Offset) { - parseCompileUnits(); - return dyn_cast_or_null<DWARFCompileUnit>(CUs.getUnitForOffset(Offset)); + parseNormalUnits(); + return dyn_cast_or_null<DWARFCompileUnit>( + NormalUnits.getUnitForOffset(Offset)); } DWARFCompileUnit *DWARFContext::getCompileUnitForAddress(uint64_t Address) { |