forked from OSchip/llvm-project
DebugInfo/DWARF: Remove unused return type from DWARFUnit::extractDIEsIfNeeded
llvm-svn: 368212
This commit is contained in:
parent
0091621e0c
commit
1b1f1d6677
|
@ -502,8 +502,8 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// extractDIEsIfNeeded - Parses a compile unit and indexes its DIEs if it
|
/// extractDIEsIfNeeded - Parses a compile unit and indexes its DIEs if it
|
||||||
/// hasn't already been done. Returns the number of DIEs parsed at this call.
|
/// hasn't already been done
|
||||||
size_t extractDIEsIfNeeded(bool CUDieOnly);
|
void extractDIEsIfNeeded(bool CUDieOnly);
|
||||||
|
|
||||||
/// extractDIEsToVector - Appends all parsed DIEs to a vector.
|
/// extractDIEsToVector - Appends all parsed DIEs to a vector.
|
||||||
void extractDIEsToVector(bool AppendCUDie, bool AppendNonCUDIEs,
|
void extractDIEsToVector(bool AppendCUDie, bool AppendNonCUDIEs,
|
||||||
|
|
|
@ -401,86 +401,85 @@ void DWARFUnit::extractDIEsToVector(
|
||||||
getOffset(), DIEOffset);
|
getOffset(), DIEOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) {
|
void DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) {
|
||||||
if ((CUDieOnly && !DieArray.empty()) ||
|
if ((CUDieOnly && !DieArray.empty()) ||
|
||||||
DieArray.size() > 1)
|
DieArray.size() > 1)
|
||||||
return 0; // Already parsed.
|
return; // Already parsed.
|
||||||
|
|
||||||
bool HasCUDie = !DieArray.empty();
|
bool HasCUDie = !DieArray.empty();
|
||||||
extractDIEsToVector(!HasCUDie, !CUDieOnly, DieArray);
|
extractDIEsToVector(!HasCUDie, !CUDieOnly, DieArray);
|
||||||
|
|
||||||
if (DieArray.empty())
|
if (DieArray.empty())
|
||||||
return 0;
|
return;
|
||||||
|
|
||||||
// If CU DIE was just parsed, copy several attribute values from it.
|
// If CU DIE was just parsed, copy several attribute values from it.
|
||||||
if (!HasCUDie) {
|
if (HasCUDie)
|
||||||
DWARFDie UnitDie = getUnitDIE();
|
return;
|
||||||
if (Optional<uint64_t> DWOId = toUnsigned(UnitDie.find(DW_AT_GNU_dwo_id)))
|
|
||||||
Header.setDWOId(*DWOId);
|
|
||||||
if (!IsDWO) {
|
|
||||||
assert(AddrOffsetSectionBase == 0);
|
|
||||||
assert(RangeSectionBase == 0);
|
|
||||||
AddrOffsetSectionBase = toSectionOffset(UnitDie.find(DW_AT_addr_base), 0);
|
|
||||||
if (!AddrOffsetSectionBase)
|
|
||||||
AddrOffsetSectionBase =
|
|
||||||
toSectionOffset(UnitDie.find(DW_AT_GNU_addr_base), 0);
|
|
||||||
RangeSectionBase = toSectionOffset(UnitDie.find(DW_AT_rnglists_base), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// In general, in DWARF v5 and beyond we derive the start of the unit's
|
DWARFDie UnitDie = getUnitDIE();
|
||||||
// contribution to the string offsets table from the unit DIE's
|
if (Optional<uint64_t> DWOId = toUnsigned(UnitDie.find(DW_AT_GNU_dwo_id)))
|
||||||
// DW_AT_str_offsets_base attribute. Split DWARF units do not use this
|
Header.setDWOId(*DWOId);
|
||||||
// attribute, so we assume that there is a contribution to the string
|
if (!IsDWO) {
|
||||||
// offsets table starting at offset 0 of the debug_str_offsets.dwo section.
|
assert(AddrOffsetSectionBase == 0);
|
||||||
// In both cases we need to determine the format of the contribution,
|
assert(RangeSectionBase == 0);
|
||||||
// which may differ from the unit's format.
|
AddrOffsetSectionBase = toSectionOffset(UnitDie.find(DW_AT_addr_base), 0);
|
||||||
DWARFDataExtractor DA(Context.getDWARFObj(), StringOffsetSection,
|
if (!AddrOffsetSectionBase)
|
||||||
isLittleEndian, 0);
|
AddrOffsetSectionBase =
|
||||||
if (IsDWO || getVersion() >= 5) {
|
toSectionOffset(UnitDie.find(DW_AT_GNU_addr_base), 0);
|
||||||
auto StringOffsetOrError =
|
RangeSectionBase = toSectionOffset(UnitDie.find(DW_AT_rnglists_base), 0);
|
||||||
IsDWO ? determineStringOffsetsTableContributionDWO(DA)
|
|
||||||
: determineStringOffsetsTableContribution(DA);
|
|
||||||
if (!StringOffsetOrError) {
|
|
||||||
WithColor::error() << "invalid contribution to string offsets table in section .debug_str_offsets[.dwo]: "
|
|
||||||
<< toString(StringOffsetOrError.takeError()) << '\n';
|
|
||||||
} else {
|
|
||||||
StringOffsetsTableContribution = *StringOffsetOrError;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DWARF v5 uses the .debug_rnglists and .debug_rnglists.dwo sections to
|
|
||||||
// describe address ranges.
|
|
||||||
if (getVersion() >= 5) {
|
|
||||||
if (IsDWO)
|
|
||||||
setRangesSection(&Context.getDWARFObj().getRnglistsDWOSection(), 0);
|
|
||||||
else
|
|
||||||
setRangesSection(&Context.getDWARFObj().getRnglistsSection(),
|
|
||||||
toSectionOffset(UnitDie.find(DW_AT_rnglists_base), 0));
|
|
||||||
if (RangeSection->Data.size()) {
|
|
||||||
// Parse the range list table header. Individual range lists are
|
|
||||||
// extracted lazily.
|
|
||||||
DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection,
|
|
||||||
isLittleEndian, 0);
|
|
||||||
if (auto TableOrError =
|
|
||||||
parseRngListTableHeader(RangesDA, RangeSectionBase))
|
|
||||||
RngListTable = TableOrError.get();
|
|
||||||
else
|
|
||||||
WithColor::error() << "parsing a range list table: "
|
|
||||||
<< toString(TableOrError.takeError())
|
|
||||||
<< '\n';
|
|
||||||
|
|
||||||
// In a split dwarf unit, there is no DW_AT_rnglists_base attribute.
|
|
||||||
// Adjust RangeSectionBase to point past the table header.
|
|
||||||
if (IsDWO && RngListTable)
|
|
||||||
RangeSectionBase = RngListTable->getHeaderSize();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't fall back to DW_AT_GNU_ranges_base: it should be ignored for
|
|
||||||
// skeleton CU DIE, so that DWARF users not aware of it are not broken.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return DieArray.size();
|
// In general, in DWARF v5 and beyond we derive the start of the unit's
|
||||||
|
// contribution to the string offsets table from the unit DIE's
|
||||||
|
// DW_AT_str_offsets_base attribute. Split DWARF units do not use this
|
||||||
|
// attribute, so we assume that there is a contribution to the string
|
||||||
|
// offsets table starting at offset 0 of the debug_str_offsets.dwo section.
|
||||||
|
// In both cases we need to determine the format of the contribution,
|
||||||
|
// which may differ from the unit's format.
|
||||||
|
DWARFDataExtractor DA(Context.getDWARFObj(), StringOffsetSection,
|
||||||
|
isLittleEndian, 0);
|
||||||
|
if (IsDWO || getVersion() >= 5) {
|
||||||
|
auto StringOffsetOrError =
|
||||||
|
IsDWO ? determineStringOffsetsTableContributionDWO(DA)
|
||||||
|
: determineStringOffsetsTableContribution(DA);
|
||||||
|
if (!StringOffsetOrError) {
|
||||||
|
WithColor::error() << "invalid contribution to string offsets table in "
|
||||||
|
"section .debug_str_offsets[.dwo]: "
|
||||||
|
<< toString(StringOffsetOrError.takeError()) << '\n';
|
||||||
|
} else {
|
||||||
|
StringOffsetsTableContribution = *StringOffsetOrError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DWARF v5 uses the .debug_rnglists and .debug_rnglists.dwo sections to
|
||||||
|
// describe address ranges.
|
||||||
|
if (getVersion() >= 5) {
|
||||||
|
if (IsDWO)
|
||||||
|
setRangesSection(&Context.getDWARFObj().getRnglistsDWOSection(), 0);
|
||||||
|
else
|
||||||
|
setRangesSection(&Context.getDWARFObj().getRnglistsSection(),
|
||||||
|
toSectionOffset(UnitDie.find(DW_AT_rnglists_base), 0));
|
||||||
|
if (RangeSection->Data.size()) {
|
||||||
|
// Parse the range list table header. Individual range lists are
|
||||||
|
// extracted lazily.
|
||||||
|
DWARFDataExtractor RangesDA(Context.getDWARFObj(), *RangeSection,
|
||||||
|
isLittleEndian, 0);
|
||||||
|
if (auto TableOrError =
|
||||||
|
parseRngListTableHeader(RangesDA, RangeSectionBase))
|
||||||
|
RngListTable = TableOrError.get();
|
||||||
|
else
|
||||||
|
WithColor::error() << "parsing a range list table: "
|
||||||
|
<< toString(TableOrError.takeError()) << '\n';
|
||||||
|
|
||||||
|
// In a split dwarf unit, there is no DW_AT_rnglists_base attribute.
|
||||||
|
// Adjust RangeSectionBase to point past the table header.
|
||||||
|
if (IsDWO && RngListTable)
|
||||||
|
RangeSectionBase = RngListTable->getHeaderSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't fall back to DW_AT_GNU_ranges_base: it should be ignored for
|
||||||
|
// skeleton CU DIE, so that DWARF users not aware of it are not broken.
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DWARFUnit::parseDWO() {
|
bool DWARFUnit::parseDWO() {
|
||||||
|
|
Loading…
Reference in New Issue