summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
diff options
context:
space:
mode:
authorPaul Robinson <paul.robinson@sony.com>2018-08-01 20:46:46 +0000
committerPaul Robinson <paul.robinson@sony.com>2018-08-01 20:46:46 +0000
commit7f33094486418f5b25275f2fd5076da4209149bc (patch)
treeb047b902e241ee827286d3fac54d3ff49ec70f84 /llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
parent143eaeab539b1f8cff3e4ea139aaf219ee117da6 (diff)
downloadbcm5719-llvm-7f33094486418f5b25275f2fd5076da4209149bc.tar.gz
bcm5719-llvm-7f33094486418f5b25275f2fd5076da4209149bc.zip
[DebugInfo/DWARF] [2/4] Type units no longer in a std::deque. NFC
This is patch 2 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 2 takes the existing std::deque<DWARFUnitSection> for type units and makes it a simple DWARFUnitSection, simplifying the handling of type units and making it more consistent with compile units. Differential Revision: https://reviews.llvm.org/D49742 llvm-svn: 338629
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFContext.cpp')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFContext.cpp83
1 files changed, 42 insertions, 41 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index a26ebba0a21..79e463da824 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -100,14 +100,12 @@ using ContributionCollection =
// sort them by their starting offsets and remove duplicates.
static ContributionCollection
collectContributionData(DWARFContext::cu_iterator_range CUs,
- DWARFContext::tu_section_iterator_range TUSs) {
+ DWARFContext::tu_iterator_range TUs) {
ContributionCollection Contributions;
for (const auto &CU : CUs)
Contributions.push_back(CU->getStringOffsetsTableContribution());
- for (const auto &TUS : TUSs)
- for (const auto &TU : TUS)
- Contributions.push_back(TU->getStringOffsetsTableContribution());
-
+ for (const auto &TU : TUs)
+ Contributions.push_back(TU->getStringOffsetsTableContribution());
// Sort the contributions so that any invalid ones are placed at
// the start of the contributions vector. This way they are reported
// first.
@@ -136,9 +134,9 @@ collectContributionData(DWARFContext::cu_iterator_range CUs,
static void dumpDWARFv5StringOffsetsSection(
raw_ostream &OS, StringRef SectionName, const DWARFObject &Obj,
const DWARFSection &StringOffsetsSection, StringRef StringSection,
- DWARFContext::cu_iterator_range CUs,
- DWARFContext::tu_section_iterator_range TUSs, bool LittleEndian) {
- auto Contributions = collectContributionData(CUs, TUSs);
+ DWARFContext::cu_iterator_range CUs, DWARFContext::tu_iterator_range TUs,
+ bool LittleEndian) {
+ auto Contributions = collectContributionData(CUs, TUs);
DWARFDataExtractor StrOffsetExt(Obj, StringOffsetsSection, LittleEndian, 0);
DataExtractor StrData(StringSection, LittleEndian, 0);
uint64_t SectionSize = StringOffsetsSection.Data.size();
@@ -215,18 +213,19 @@ static void dumpDWARFv5StringOffsetsSection(
// a header containing size and version number. Alternatively, it may be a
// monolithic series of string offsets, as generated by the pre-DWARF v5
// implementation of split DWARF.
-static void dumpStringOffsetsSection(
- raw_ostream &OS, StringRef SectionName, const DWARFObject &Obj,
- const DWARFSection &StringOffsetsSection, StringRef StringSection,
- DWARFContext::cu_iterator_range CUs,
- DWARFContext::tu_section_iterator_range TUSs, bool LittleEndian,
- unsigned MaxVersion) {
+static void dumpStringOffsetsSection(raw_ostream &OS, StringRef SectionName,
+ const DWARFObject &Obj,
+ const DWARFSection &StringOffsetsSection,
+ StringRef StringSection,
+ DWARFContext::cu_iterator_range CUs,
+ DWARFContext::tu_iterator_range TUs,
+ bool LittleEndian, unsigned MaxVersion) {
// If we have at least one (compile or type) unit with DWARF v5 or greater,
// we assume that the section is formatted like a DWARF v5 string offsets
// section.
if (MaxVersion >= 5)
dumpDWARFv5StringOffsetsSection(OS, SectionName, Obj, StringOffsetsSection,
- StringSection, CUs, TUSs, LittleEndian);
+ StringSection, CUs, TUs, LittleEndian);
else {
DataExtractor strOffsetExt(StringOffsetsSection.Data, LittleEndian, 0);
uint32_t offset = 0;
@@ -356,23 +355,21 @@ void DWARFContext::dump(
dumpDebugInfo(ExplicitDWO, ".debug_info.dwo", DObj->getInfoDWOSection(),
dwo_compile_units());
- auto dumpDebugType = [&](const char *Name,
- tu_section_iterator_range TUSections) {
+ auto dumpDebugType = [&](const char *Name, tu_iterator_range TUs) {
OS << '\n' << Name << " contents:\n";
DumpOffset = DumpOffsets[DIDT_ID_DebugTypes];
- for (const auto &TUS : TUSections)
- for (const auto &TU : TUS)
- if (DumpOffset)
- TU->getDIEForOffset(*DumpOffset)
- .dump(OS, 0, DumpOpts.noImplicitRecursion());
- else
- TU->dump(OS, DumpOpts);
+ for (const auto &TU : TUs)
+ if (DumpOffset)
+ TU->getDIEForOffset(*DumpOffset)
+ .dump(OS, 0, DumpOpts.noImplicitRecursion());
+ else
+ TU->dump(OS, DumpOpts);
};
if ((DumpType & DIDT_DebugTypes)) {
if (Explicit || getNumTypeUnits())
- dumpDebugType(".debug_types", type_unit_sections());
+ dumpDebugType(".debug_types", type_units());
if (ExplicitDWO || getNumDWOTypeUnits())
- dumpDebugType(".debug_types.dwo", dwo_type_unit_sections());
+ dumpDebugType(".debug_types.dwo", dwo_type_units());
}
if (shouldDump(Explicit, ".debug_loc", DIDT_ID_DebugLoc,
@@ -430,7 +427,7 @@ void DWARFContext::dump(
DWARFDataExtractor LineData(*DObj, DObj->getLineSection(), isLittleEndian(),
0);
DWARFDebugLine::SectionParser Parser(LineData, *this, compile_units(),
- type_unit_sections());
+ type_units());
DumpLineSection(Parser, DumpOpts);
}
@@ -439,7 +436,7 @@ void DWARFContext::dump(
DWARFDataExtractor LineData(*DObj, DObj->getLineDWOSection(),
isLittleEndian(), 0);
DWARFDebugLine::SectionParser Parser(LineData, *this, dwo_compile_units(),
- dwo_type_unit_sections());
+ dwo_type_units());
DumpLineSection(Parser, DumpOpts);
}
@@ -547,16 +544,16 @@ void DWARFContext::dump(
if (shouldDump(Explicit, ".debug_str_offsets", DIDT_ID_DebugStrOffsets,
DObj->getStringOffsetSection().Data))
- dumpStringOffsetsSection(
- OS, "debug_str_offsets", *DObj, DObj->getStringOffsetSection(),
- DObj->getStringSection(), compile_units(), type_unit_sections(),
- isLittleEndian(), getMaxVersion());
+ dumpStringOffsetsSection(OS, "debug_str_offsets", *DObj,
+ DObj->getStringOffsetSection(),
+ DObj->getStringSection(), compile_units(),
+ type_units(), isLittleEndian(), getMaxVersion());
if (shouldDump(ExplicitDWO, ".debug_str_offsets.dwo", DIDT_ID_DebugStrOffsets,
DObj->getStringOffsetDWOSection().Data))
dumpStringOffsetsSection(
OS, "debug_str_offsets.dwo", *DObj, DObj->getStringOffsetDWOSection(),
- DObj->getStringDWOSection(), dwo_compile_units(),
- dwo_type_unit_sections(), isLittleEndian(), getMaxVersion());
+ DObj->getStringDWOSection(), dwo_compile_units(), dwo_type_units(),
+ isLittleEndian(), getMaxVersion());
if (shouldDump(Explicit, ".gnu_index", DIDT_ID_GdbIndex,
DObj->getGdbIndexSection())) {
@@ -584,7 +581,9 @@ void DWARFContext::dump(
}
DWARFCompileUnit *DWARFContext::getDWOCompileUnitForHash(uint64_t Hash) {
- DWOCUs.parseDWO(*this, DObj->getInfoDWOSection(), DW_SECT_INFO, true);
+ if (DWOCUs.empty())
+ DWOCUs.addUnitsForDWOSection(*this, DObj->getInfoDWOSection(), DW_SECT_INFO,
+ true);
if (const auto &CUI = getCUIndex()) {
if (const auto *R = CUI.getFromHash(Hash))
@@ -844,28 +843,30 @@ Expected<const DWARFDebugLine::LineTable *> DWARFContext::getLineTableForUnit(
}
void DWARFContext::parseCompileUnits() {
- CUs.parse(*this, DObj->getInfoSection(), DW_SECT_INFO);
+ if (!CUs.empty())
+ return;
+ CUs.addUnitsForSection(*this, DObj->getInfoSection(), DW_SECT_INFO);
}
void DWARFContext::parseTypeUnits() {
if (!TUs.empty())
return;
DObj->forEachTypesSections([&](const DWARFSection &S) {
- TUs.emplace_back();
- TUs.back().parse(*this, S, DW_SECT_TYPES);
+ TUs.addUnitsForSection(*this, S, DW_SECT_TYPES);
});
}
void DWARFContext::parseDWOCompileUnits() {
- DWOCUs.parseDWO(*this, DObj->getInfoDWOSection(), DW_SECT_INFO);
+ if (!DWOCUs.empty())
+ return;
+ DWOCUs.addUnitsForDWOSection(*this, DObj->getInfoDWOSection(), DW_SECT_INFO);
}
void DWARFContext::parseDWOTypeUnits() {
if (!DWOTUs.empty())
return;
DObj->forEachTypesDWOSections([&](const DWARFSection &S) {
- DWOTUs.emplace_back();
- DWOTUs.back().parseDWO(*this, S, DW_SECT_TYPES);
+ DWOTUs.addUnitsForDWOSection(*this, S, DW_SECT_TYPES);
});
}
OpenPOWER on IntegriCloud