Index: llvm/trunk/lib/DebugInfo/DWARFContext.h =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFContext.h +++ llvm/trunk/lib/DebugInfo/DWARFContext.h @@ -30,7 +30,7 @@ class DWARFContext : public DIContext { DWARFUnitSection CUs; - DWARFUnitSection TUs; + SmallVector,1> TUs; std::unique_ptr Abbrev; std::unique_ptr Loc; std::unique_ptr Aranges; @@ -38,7 +38,7 @@ std::unique_ptr DebugFrame; DWARFUnitSection DWOCUs; - DWARFUnitSection DWOTUs; + SmallVector,1> DWOTUs; std::unique_ptr AbbrevDWO; std::unique_ptr LocDWO; @@ -77,6 +77,7 @@ typedef DWARFUnitSection::iterator_range cu_iterator_range; typedef DWARFUnitSection::iterator_range tu_iterator_range; + typedef iterator_range>::iterator> tu_section_iterator_range; /// Get compile units in this context. cu_iterator_range compile_units() { @@ -85,9 +86,9 @@ } /// Get type units in this context. - tu_iterator_range type_units() { + tu_section_iterator_range type_unit_sections() { parseTypeUnits(); - return tu_iterator_range(TUs.begin(), TUs.end()); + return tu_section_iterator_range(TUs.begin(), TUs.end()); } /// Get compile units in the DWO context. @@ -97,9 +98,9 @@ } /// Get type units in the DWO context. - tu_iterator_range dwo_type_units() { + tu_section_iterator_range dwo_type_unit_sections() { parseDWOTypeUnits(); - return tu_iterator_range(DWOTUs.begin(), DWOTUs.end()); + return tu_section_iterator_range(DWOTUs.begin(), DWOTUs.end()); } /// Get the number of compile units in this context. Index: llvm/trunk/lib/DebugInfo/DWARFContext.cpp =================================================================== --- llvm/trunk/lib/DebugInfo/DWARFContext.cpp +++ llvm/trunk/lib/DebugInfo/DWARFContext.cpp @@ -86,15 +86,17 @@ if ((DumpType == DIDT_All || DumpType == DIDT_Types) && getNumTypeUnits()) { OS << "\n.debug_types contents:\n"; - for (const auto &TU : type_units()) - TU->dump(OS); + for (const auto &TUS : type_unit_sections()) + for (const auto &TU : TUS) + TU->dump(OS); } if ((DumpType == DIDT_All || DumpType == DIDT_TypesDwo) && getNumDWOTypeUnits()) { OS << "\n.debug_types.dwo contents:\n"; - for (const auto &DWOTU : dwo_type_units()) - DWOTU->dump(OS); + for (const auto &DWOTUS : dwo_type_unit_sections()) + for (const auto &DWOTU : DWOTUS) + DWOTU->dump(OS); } if (DumpType == DIDT_All || DumpType == DIDT_Loc) { @@ -337,15 +339,17 @@ uint32_t offset = 0; const DataExtractor &DIData = DataExtractor(I.second.Data, isLittleEndian(), 0); + TUs.push_back(DWARFUnitSection()); + auto &TUS = TUs.back(); while (DIData.isValidOffset(offset)) { std::unique_ptr TU(new DWARFTypeUnit(*this, getDebugAbbrev(), I.second.Data, getRangeSection(), getStringSection(), StringRef(), getAddrSection(), - &I.second.Relocs, isLittleEndian(), TUs)); + &I.second.Relocs, isLittleEndian(), TUS)); if (!TU->extract(DIData, &offset)) break; - TUs.push_back(std::move(TU)); - offset = TUs.back()->getNextUnitOffset(); + TUS.push_back(std::move(TU)); + offset = TUS.back()->getNextUnitOffset(); } } } @@ -376,15 +380,17 @@ uint32_t offset = 0; const DataExtractor &DIData = DataExtractor(I.second.Data, isLittleEndian(), 0); + DWOTUs.push_back(DWARFUnitSection()); + auto &TUS = DWOTUs.back(); while (DIData.isValidOffset(offset)) { std::unique_ptr TU(new DWARFTypeUnit(*this, getDebugAbbrevDWO(), I.second.Data, getRangeDWOSection(), getStringDWOSection(), getStringOffsetDWOSection(), getAddrSection(), - &I.second.Relocs, isLittleEndian(), DWOTUs)); + &I.second.Relocs, isLittleEndian(), TUS)); if (!TU->extract(DIData, &offset)) break; - DWOTUs.push_back(std::move(TU)); - offset = DWOTUs.back()->getNextUnitOffset(); + TUS.push_back(std::move(TU)); + offset = TUS.back()->getNextUnitOffset(); } } }