[DebugInfo/DWARF] [3/4] Rename DWARFUnitSection to DWARFUnitVector. NFC

This is patch 3 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 3 simply renames DWARFUnitSection to DWARFUnitVector, as the
object-file section of a unit is nearly irrelevant now.

Differential Revision: https://reviews.llvm.org/D49743

llvm-svn: 338632
This commit is contained in:
Paul Robinson 2018-08-01 20:49:44 +00:00
parent a7dfd48310
commit 11307fab93
8 changed files with 33 additions and 33 deletions

View File

@ -22,9 +22,9 @@ public:
const DWARFDebugAbbrev *DA, const DWARFSection *RS,
StringRef SS, const DWARFSection &SOS,
const DWARFSection *AOS, const DWARFSection &LS, bool LE,
bool IsDWO, const DWARFUnitSection &UnitSection)
bool IsDWO, const DWARFUnitVector &UnitVector)
: DWARFUnit(Context, Section, Header, DA, RS, SS, SOS, AOS, LS, LE, IsDWO,
UnitSection) {}
UnitVector) {}
/// VTable anchor.
~DWARFCompileUnit() override;

View File

@ -57,8 +57,8 @@ enum class ErrorPolicy { Halt, Continue };
/// This data structure is the top level entity that deals with dwarf debug
/// information parsing. The actual data is supplied through DWARFObj.
class DWARFContext : public DIContext {
DWARFUnitSection CUs;
DWARFUnitSection TUs;
DWARFUnitVector CUs;
DWARFUnitVector TUs;
std::unique_ptr<DWARFUnitIndex> CUIndex;
std::unique_ptr<DWARFGdbIndex> GdbIndex;
std::unique_ptr<DWARFUnitIndex> TUIndex;
@ -75,8 +75,8 @@ class DWARFContext : public DIContext {
std::unique_ptr<AppleAcceleratorTable> AppleNamespaces;
std::unique_ptr<AppleAcceleratorTable> AppleObjC;
DWARFUnitSection DWOCUs;
DWARFUnitSection DWOTUs;
DWARFUnitVector DWOCUs;
DWARFUnitVector DWOTUs;
std::unique_ptr<DWARFDebugAbbrev> AbbrevDWO;
std::unique_ptr<DWARFDebugLocDWO> LocDWO;
@ -139,8 +139,8 @@ public:
bool verify(raw_ostream &OS, DIDumpOptions DumpOpts = {}) override;
using cu_iterator_range = DWARFUnitSection::iterator_range;
using tu_iterator_range = DWARFUnitSection::iterator_range;
using cu_iterator_range = DWARFUnitVector::iterator_range;
using tu_iterator_range = DWARFUnitVector::iterator_range;
/// Get compile units in this context.
cu_iterator_range compile_units() {

View File

@ -278,8 +278,8 @@ public:
/// Helper to allow for parsing of an entire .debug_line section in sequence.
class SectionParser {
public:
using cu_range = DWARFUnitSection::iterator_range;
using tu_range = DWARFUnitSection::iterator_range;
using cu_range = DWARFUnitVector::iterator_range;
using tu_range = DWARFUnitVector::iterator_range;
using LineToUnitMap = std::map<uint64_t, DWARFUnit *>;
SectionParser(DWARFDataExtractor &Data, const DWARFContext &C, cu_range CUs,

View File

@ -30,9 +30,9 @@ public:
const DWARFDebugAbbrev *DA, const DWARFSection *RS,
StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS,
const DWARFSection &LS, bool LE, bool IsDWO,
const DWARFUnitSection &UnitSection)
const DWARFUnitVector &UnitVector)
: DWARFUnit(Context, Section, Header, DA, RS, SS, SOS, AOS, LS, LE, IsDWO,
UnitSection) {}
UnitVector) {}
uint64_t getTypeHash() const { return getHeader().getTypeHash(); }
uint32_t getTypeOffset() const { return getHeader().getTypeOffset(); }

View File

@ -105,7 +105,7 @@ const DWARFUnitIndex &getDWARFUnitIndex(DWARFContext &Context,
DWARFSectionKind Kind);
/// Describes one section's Units.
class DWARFUnitSection final : public SmallVector<std::unique_ptr<DWARFUnit>, 1> {
class DWARFUnitVector final : public SmallVector<std::unique_ptr<DWARFUnit>, 1> {
std::function<std::unique_ptr<DWARFUnit>(uint32_t, const DWARFSection *)>
Parser;
@ -176,7 +176,7 @@ class DWARFUnit {
uint32_t AddrOffsetSectionBase = 0;
bool isLittleEndian;
bool isDWO;
const DWARFUnitSection &UnitSection;
const DWARFUnitVector &UnitVector;
/// Start, length, and DWARF format of the unit's contribution to the string
/// offsets table (DWARF v5).
@ -233,7 +233,7 @@ public:
const DWARFDebugAbbrev *DA, const DWARFSection *RS, StringRef SS,
const DWARFSection &SOS, const DWARFSection *AOS,
const DWARFSection &LS, bool LE, bool IsDWO,
const DWARFUnitSection &UnitSection);
const DWARFUnitVector &UnitVector);
virtual ~DWARFUnit();
@ -389,8 +389,8 @@ public:
void getInlinedChainForAddress(uint64_t Address,
SmallVectorImpl<DWARFDie> &InlinedChain);
/// getUnitSection - Return the DWARFUnitSection containing this unit.
const DWARFUnitSection &getUnitSection() const { return UnitSection; }
/// Return the DWARFUnitVector containing this unit.
const DWARFUnitVector &getUnitVector() const { return UnitVector; }
/// Returns the number of DIEs in the unit. Parses the unit
/// if necessary.

View File

@ -350,7 +350,7 @@ DWARFDie::findRecursively(ArrayRef<dwarf::Attribute> Attrs) const {
DWARFDie
DWARFDie::getAttributeValueAsReferencedDie(dwarf::Attribute Attr) const {
if (auto SpecRef = toReference(find(Attr))) {
if (auto SpecUnit = U->getUnitSection().getUnitForOffset(*SpecRef))
if (auto SpecUnit = U->getUnitVector().getUnitForOffset(*SpecRef))
return SpecUnit->getDIEForOffset(*SpecRef);
}
return DWARFDie();

View File

@ -33,9 +33,9 @@
using namespace llvm;
using namespace dwarf;
void DWARFUnitSection::addUnitsForSection(DWARFContext &C,
const DWARFSection &Section,
DWARFSectionKind SectionKind) {
void DWARFUnitVector::addUnitsForSection(DWARFContext &C,
const DWARFSection &Section,
DWARFSectionKind SectionKind) {
const DWARFObject &D = C.getDWARFObj();
addUnitsImpl(C, D, Section, C.getDebugAbbrev(), &D.getRangeSection(),
D.getStringSection(), D.getStringOffsetSection(),
@ -43,10 +43,10 @@ void DWARFUnitSection::addUnitsForSection(DWARFContext &C,
false, false, SectionKind);
}
void DWARFUnitSection::addUnitsForDWOSection(DWARFContext &C,
const DWARFSection &DWOSection,
DWARFSectionKind SectionKind,
bool Lazy) {
void DWARFUnitVector::addUnitsForDWOSection(DWARFContext &C,
const DWARFSection &DWOSection,
DWARFSectionKind SectionKind,
bool Lazy) {
const DWARFObject &D = C.getDWARFObj();
addUnitsImpl(C, D, DWOSection, C.getDebugAbbrevDWO(), &D.getRangeDWOSection(),
D.getStringDWOSection(), D.getStringOffsetDWOSection(),
@ -54,7 +54,7 @@ void DWARFUnitSection::addUnitsForDWOSection(DWARFContext &C,
true, Lazy, SectionKind);
}
void DWARFUnitSection::addUnitsImpl(
void DWARFUnitVector::addUnitsImpl(
DWARFContext &Context, const DWARFObject &Obj, const DWARFSection &Section,
const DWARFDebugAbbrev *DA, const DWARFSection *RS, StringRef SS,
const DWARFSection &SOS, const DWARFSection *AOS, const DWARFSection &LS,
@ -104,7 +104,7 @@ void DWARFUnitSection::addUnitsImpl(
}
}
DWARFUnit *DWARFUnitSection::getUnitForOffset(uint32_t Offset) const {
DWARFUnit *DWARFUnitVector::getUnitForOffset(uint32_t Offset) const {
auto *CU = std::upper_bound(
this->begin(), this->end(), Offset,
[](uint32_t LHS, const std::unique_ptr<DWARFUnit> &RHS) {
@ -116,7 +116,7 @@ DWARFUnit *DWARFUnitSection::getUnitForOffset(uint32_t Offset) const {
}
DWARFUnit *
DWARFUnitSection::getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) {
DWARFUnitVector::getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) {
const auto *CUOff = E.getOffset(DW_SECT_INFO);
if (!CUOff)
return nullptr;
@ -148,11 +148,11 @@ DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section,
const DWARFDebugAbbrev *DA, const DWARFSection *RS,
StringRef SS, const DWARFSection &SOS,
const DWARFSection *AOS, const DWARFSection &LS, bool LE,
bool IsDWO, const DWARFUnitSection &UnitSection)
bool IsDWO, const DWARFUnitVector &UnitVector)
: Context(DC), InfoSection(Section), Header(Header), Abbrev(DA),
RangeSection(RS), LineSection(LS), StringSection(SS),
StringOffsetSection(SOS), AddrOffsetSection(AOS), isLittleEndian(LE),
isDWO(IsDWO), UnitSection(UnitSection) {
isDWO(IsDWO), UnitVector(UnitVector) {
clear();
}

View File

@ -264,7 +264,7 @@ bool DWARFVerifier::handleDebugInfo() {
bool isUnitDWARF64 = false;
bool isHeaderChainValid = true;
bool hasDIE = DebugInfoData.isValidOffset(Offset);
DWARFUnitSection UnitSection{};
DWARFUnitVector UnitVector{};
while (hasDIE) {
OffsetStart = Offset;
if (!verifyUnitHeader(DebugInfoData, &Offset, UnitIdx, UnitType,
@ -283,7 +283,7 @@ bool DWARFVerifier::handleDebugInfo() {
DCtx, DObj.getInfoSection(), Header, DCtx.getDebugAbbrev(),
&DObj.getRangeSection(), DObj.getStringSection(),
DObj.getStringOffsetSection(), &DObj.getAppleObjCSection(),
DObj.getLineSection(), DCtx.isLittleEndian(), false, UnitSection));
DObj.getLineSection(), DCtx.isLittleEndian(), false, UnitVector));
break;
}
case dwarf::DW_UT_skeleton:
@ -297,7 +297,7 @@ bool DWARFVerifier::handleDebugInfo() {
DCtx, DObj.getInfoSection(), Header, DCtx.getDebugAbbrev(),
&DObj.getRangeSection(), DObj.getStringSection(),
DObj.getStringOffsetSection(), &DObj.getAppleObjCSection(),
DObj.getLineSection(), DCtx.isLittleEndian(), false, UnitSection));
DObj.getLineSection(), DCtx.isLittleEndian(), false, UnitVector));
break;
}
default: { llvm_unreachable("Invalid UnitType."); }