summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp74
1 files changed, 31 insertions, 43 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index 9d75dc94604..d475c44c393 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -175,7 +175,7 @@ DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section,
: Context(DC), InfoSection(Section), Header(Header), Abbrev(DA),
RangeSection(RS), LocSection(LocSection), LineSection(LS),
StringSection(SS), StringOffsetSection(SOS), AddrOffsetSection(AOS),
- isLittleEndian(LE), isDWO(IsDWO), UnitVector(UnitVector) {
+ isLittleEndian(LE), IsDWO(IsDWO), UnitVector(UnitVector) {
clear();
// For split DWARF we only need to keep track of the location list section's
// data (no relocations), and if we are reading a package file, we need to
@@ -197,7 +197,7 @@ DWARFDataExtractor DWARFUnit::getDebugInfoExtractor() const {
Optional<SectionedAddress>
DWARFUnit::getAddrOffsetSectionItem(uint32_t Index) const {
- if (isDWO) {
+ if (IsDWO) {
auto R = Context.info_section_units();
auto I = R.begin();
// Surprising if a DWO file has more than one skeleton unit in it - this
@@ -409,7 +409,7 @@ size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) {
DWARFDie UnitDie = getUnitDIE();
if (Optional<uint64_t> DWOId = toUnsigned(UnitDie.find(DW_AT_GNU_dwo_id)))
Header.setDWOId(*DWOId);
- if (!isDWO) {
+ if (!IsDWO) {
assert(AddrOffsetSectionBase == 0);
assert(RangeSectionBase == 0);
AddrOffsetSectionBase = toSectionOffset(UnitDie.find(DW_AT_addr_base), 0);
@@ -426,27 +426,19 @@ size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) {
// 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.
- uint64_t StringOffsetsContributionBase =
- isDWO ? 0 : toSectionOffset(UnitDie.find(DW_AT_str_offsets_base), 0);
- auto IndexEntry = Header.getIndexEntry();
- if (IndexEntry)
- if (const auto *C = IndexEntry->getOffset(DW_SECT_STR_OFFSETS))
- StringOffsetsContributionBase += C->Offset;
-
DWARFDataExtractor DA(Context.getDWARFObj(), StringOffsetSection,
isLittleEndian, 0);
- if (isDWO)
+ if (IsDWO)
StringOffsetsTableContribution =
- determineStringOffsetsTableContributionDWO(
- DA, StringOffsetsContributionBase);
+ determineStringOffsetsTableContributionDWO(DA);
else if (getVersion() >= 5)
- StringOffsetsTableContribution = determineStringOffsetsTableContribution(
- DA, StringOffsetsContributionBase);
+ StringOffsetsTableContribution =
+ determineStringOffsetsTableContribution(DA);
// DWARF v5 uses the .debug_rnglists and .debug_rnglists.dwo sections to
// describe address ranges.
if (getVersion() >= 5) {
- if (isDWO)
+ if (IsDWO)
setRangesSection(&Context.getDWARFObj().getRnglistsDWOSection(), 0);
else
setRangesSection(&Context.getDWARFObj().getRnglistsSection(),
@@ -466,20 +458,20 @@ size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) {
// In a split dwarf unit, there is no DW_AT_rnglists_base attribute.
// Adjust RangeSectionBase to point past the table header.
- if (isDWO && RngListTable)
+ 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();
}
bool DWARFUnit::parseDWO() {
- if (isDWO)
+ if (IsDWO)
return false;
if (DWO.get())
return false;
@@ -794,7 +786,7 @@ StrOffsetsContributionDescriptor::validateContributionSize(
if (ValidationSize >= Size)
if (DA.isValidOffsetForDataOfSize((uint32_t)Base, ValidationSize))
return *this;
- return Optional<StrOffsetsContributionDescriptor>();
+ return None;
}
// Look for a DWARF64-formatted contribution to the string offsets table
@@ -802,18 +794,17 @@ StrOffsetsContributionDescriptor::validateContributionSize(
static Optional<StrOffsetsContributionDescriptor>
parseDWARF64StringOffsetsTableHeader(DWARFDataExtractor &DA, uint32_t Offset) {
if (!DA.isValidOffsetForDataOfSize(Offset, 16))
- return Optional<StrOffsetsContributionDescriptor>();
+ return None;
if (DA.getU32(&Offset) != 0xffffffff)
- return Optional<StrOffsetsContributionDescriptor>();
+ return None;
uint64_t Size = DA.getU64(&Offset);
uint8_t Version = DA.getU16(&Offset);
(void)DA.getU16(&Offset); // padding
// The encoded length includes the 2-byte version field and the 2-byte
// padding, so we need to subtract them out when we populate the descriptor.
- return StrOffsetsContributionDescriptor(Offset, Size - 4, Version, DWARF64);
- //return Optional<StrOffsetsContributionDescriptor>(Descriptor);
+ return {{Offset, Size - 4, Version, DWARF64}};
}
// Look for a DWARF32-formatted contribution to the string offsets table
@@ -821,22 +812,20 @@ parseDWARF64StringOffsetsTableHeader(DWARFDataExtractor &DA, uint32_t Offset) {
static Optional<StrOffsetsContributionDescriptor>
parseDWARF32StringOffsetsTableHeader(DWARFDataExtractor &DA, uint32_t Offset) {
if (!DA.isValidOffsetForDataOfSize(Offset, 8))
- return Optional<StrOffsetsContributionDescriptor>();
+ return None;
uint32_t ContributionSize = DA.getU32(&Offset);
if (ContributionSize >= 0xfffffff0)
- return Optional<StrOffsetsContributionDescriptor>();
+ return None;
uint8_t Version = DA.getU16(&Offset);
(void)DA.getU16(&Offset); // padding
// The encoded length includes the 2-byte version field and the 2-byte
// padding, so we need to subtract them out when we populate the descriptor.
- return StrOffsetsContributionDescriptor(Offset, ContributionSize - 4, Version,
- DWARF32);
- //return Optional<StrOffsetsContributionDescriptor>(Descriptor);
+ return {{Offset, ContributionSize - 4, Version, DWARF32}};
}
Optional<StrOffsetsContributionDescriptor>
-DWARFUnit::determineStringOffsetsTableContribution(DWARFDataExtractor &DA,
- uint64_t Offset) {
+DWARFUnit::determineStringOffsetsTableContribution(DWARFDataExtractor &DA) {
+ auto Offset = toSectionOffset(getUnitDIE().find(DW_AT_str_offsets_base), 0);
Optional<StrOffsetsContributionDescriptor> Descriptor;
// Attempt to find a DWARF64 contribution 16 bytes before the base.
if (Offset >= 16)
@@ -849,8 +838,13 @@ DWARFUnit::determineStringOffsetsTableContribution(DWARFDataExtractor &DA,
}
Optional<StrOffsetsContributionDescriptor>
-DWARFUnit::determineStringOffsetsTableContributionDWO(DWARFDataExtractor &DA,
- uint64_t Offset) {
+DWARFUnit::determineStringOffsetsTableContributionDWO(DWARFDataExtractor & DA) {
+ uint64_t Offset = 0;
+ auto IndexEntry = Header.getIndexEntry();
+ const auto *C =
+ IndexEntry ? IndexEntry->getOffset(DW_SECT_STR_OFFSETS) : nullptr;
+ if (C)
+ Offset = C->Offset;
if (getVersion() >= 5) {
// Look for a valid contribution at the given offset.
auto Descriptor =
@@ -862,15 +856,9 @@ DWARFUnit::determineStringOffsetsTableContributionDWO(DWARFDataExtractor &DA,
// Prior to DWARF v5, we derive the contribution size from the
// index table (in a package file). In a .dwo file it is simply
// the length of the string offsets section.
- uint64_t Size = 0;
- auto IndexEntry = Header.getIndexEntry();
if (!IndexEntry)
- Size = StringOffsetSection.Data.size();
- else if (const auto *C = IndexEntry->getOffset(DW_SECT_STR_OFFSETS))
- Size = C->Length;
- // Return a descriptor with the given offset as base, version 4 and
- // DWARF32 format.
- //return Optional<StrOffsetsContributionDescriptor>(
- //StrOffsetsContributionDescriptor(Offset, Size, 4, DWARF32));
- return StrOffsetsContributionDescriptor(Offset, Size, 4, DWARF32);
+ return {{0, StringOffsetSection.Data.size(), 4, DWARF32}};
+ if (C)
+ return {{C->Offset, C->Length, 4, DWARF32}};
+ return None;
}
OpenPOWER on IntegriCloud