forked from OSchip/llvm-project
Rename DwarfAcceleratorTable to AppleAcceleratorTable. NFC
This frees up the first name to be used as an base class for the apple table and the dwarf5 .debug_names accel table. The rename was split off from D42297 (adding of debug_names support), which is still under review. llvm-svn: 323113
This commit is contained in:
parent
62dbdf1790
commit
9b36fd2541
|
@ -24,7 +24,7 @@ class raw_ostream;
|
||||||
/// This implements the Apple accelerator table format, a precursor of the
|
/// This implements the Apple accelerator table format, a precursor of the
|
||||||
/// DWARF 5 accelerator table format.
|
/// DWARF 5 accelerator table format.
|
||||||
/// TODO: Factor out a common base class for both formats.
|
/// TODO: Factor out a common base class for both formats.
|
||||||
class DWARFAcceleratorTable {
|
class AppleAcceleratorTable {
|
||||||
struct Header {
|
struct Header {
|
||||||
uint32_t Magic;
|
uint32_t Magic;
|
||||||
uint16_t Version;
|
uint16_t Version;
|
||||||
|
@ -53,7 +53,7 @@ public:
|
||||||
/// multiple DWARFFormValues.
|
/// multiple DWARFFormValues.
|
||||||
class ValueIterator : public std::iterator<std::input_iterator_tag,
|
class ValueIterator : public std::iterator<std::input_iterator_tag,
|
||||||
ArrayRef<DWARFFormValue>> {
|
ArrayRef<DWARFFormValue>> {
|
||||||
const DWARFAcceleratorTable *AccelTable = nullptr;
|
const AppleAcceleratorTable *AccelTable = nullptr;
|
||||||
SmallVector<DWARFFormValue, 3> AtomForms; ///< The decoded data entry.
|
SmallVector<DWARFFormValue, 3> AtomForms; ///< The decoded data entry.
|
||||||
|
|
||||||
unsigned DataOffset = 0; ///< Offset into the section.
|
unsigned DataOffset = 0; ///< Offset into the section.
|
||||||
|
@ -64,7 +64,7 @@ public:
|
||||||
void Next();
|
void Next();
|
||||||
public:
|
public:
|
||||||
/// Construct a new iterator for the entries at \p DataOffset.
|
/// Construct a new iterator for the entries at \p DataOffset.
|
||||||
ValueIterator(const DWARFAcceleratorTable &AccelTable, unsigned DataOffset);
|
ValueIterator(const AppleAcceleratorTable &AccelTable, unsigned DataOffset);
|
||||||
/// End marker.
|
/// End marker.
|
||||||
ValueIterator() = default;
|
ValueIterator() = default;
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
DWARFAcceleratorTable(const DWARFDataExtractor &AccelSection,
|
AppleAcceleratorTable(const DWARFDataExtractor &AccelSection,
|
||||||
DataExtractor StringSection)
|
DataExtractor StringSection)
|
||||||
: AccelSection(AccelSection), StringSection(StringSection) {}
|
: AccelSection(AccelSection), StringSection(StringSection) {}
|
||||||
|
|
||||||
|
|
|
@ -69,10 +69,10 @@ class DWARFContext : public DIContext {
|
||||||
std::unique_ptr<DWARFDebugFrame> DebugFrame;
|
std::unique_ptr<DWARFDebugFrame> DebugFrame;
|
||||||
std::unique_ptr<DWARFDebugFrame> EHFrame;
|
std::unique_ptr<DWARFDebugFrame> EHFrame;
|
||||||
std::unique_ptr<DWARFDebugMacro> Macro;
|
std::unique_ptr<DWARFDebugMacro> Macro;
|
||||||
std::unique_ptr<DWARFAcceleratorTable> AppleNames;
|
std::unique_ptr<AppleAcceleratorTable> AppleNames;
|
||||||
std::unique_ptr<DWARFAcceleratorTable> AppleTypes;
|
std::unique_ptr<AppleAcceleratorTable> AppleTypes;
|
||||||
std::unique_ptr<DWARFAcceleratorTable> AppleNamespaces;
|
std::unique_ptr<AppleAcceleratorTable> AppleNamespaces;
|
||||||
std::unique_ptr<DWARFAcceleratorTable> AppleObjC;
|
std::unique_ptr<AppleAcceleratorTable> AppleObjC;
|
||||||
|
|
||||||
DWARFUnitSection<DWARFCompileUnit> DWOCUs;
|
DWARFUnitSection<DWARFCompileUnit> DWOCUs;
|
||||||
std::deque<DWARFUnitSection<DWARFTypeUnit>> DWOTUs;
|
std::deque<DWARFUnitSection<DWARFTypeUnit>> DWOTUs;
|
||||||
|
@ -243,16 +243,16 @@ public:
|
||||||
const DWARFDebugMacro *getDebugMacro();
|
const DWARFDebugMacro *getDebugMacro();
|
||||||
|
|
||||||
/// Get a reference to the parsed accelerator table object.
|
/// Get a reference to the parsed accelerator table object.
|
||||||
const DWARFAcceleratorTable &getAppleNames();
|
const AppleAcceleratorTable &getAppleNames();
|
||||||
|
|
||||||
/// Get a reference to the parsed accelerator table object.
|
/// Get a reference to the parsed accelerator table object.
|
||||||
const DWARFAcceleratorTable &getAppleTypes();
|
const AppleAcceleratorTable &getAppleTypes();
|
||||||
|
|
||||||
/// Get a reference to the parsed accelerator table object.
|
/// Get a reference to the parsed accelerator table object.
|
||||||
const DWARFAcceleratorTable &getAppleNamespaces();
|
const AppleAcceleratorTable &getAppleNamespaces();
|
||||||
|
|
||||||
/// Get a reference to the parsed accelerator table object.
|
/// Get a reference to the parsed accelerator table object.
|
||||||
const DWARFAcceleratorTable &getAppleObjC();
|
const AppleAcceleratorTable &getAppleObjC();
|
||||||
|
|
||||||
/// Get a pointer to a parsed line table corresponding to a compile unit.
|
/// Get a pointer to a parsed line table corresponding to a compile unit.
|
||||||
const DWARFDebugLine::LineTable *getLineTableForUnit(DWARFUnit *cu);
|
const DWARFDebugLine::LineTable *getLineTableForUnit(DWARFUnit *cu);
|
||||||
|
|
|
@ -24,7 +24,6 @@ struct DWARFAttribute;
|
||||||
class DWARFContext;
|
class DWARFContext;
|
||||||
class DWARFDie;
|
class DWARFDie;
|
||||||
class DWARFUnit;
|
class DWARFUnit;
|
||||||
class DWARFAcceleratorTable;
|
|
||||||
class DWARFDataExtractor;
|
class DWARFDataExtractor;
|
||||||
class DWARFDebugAbbrev;
|
class DWARFDebugAbbrev;
|
||||||
class DataExtractor;
|
class DataExtractor;
|
||||||
|
@ -229,8 +228,9 @@ private:
|
||||||
/// \param SectionName the name of the table we're verifying
|
/// \param SectionName the name of the table we're verifying
|
||||||
///
|
///
|
||||||
/// \returns The number of errors occured during verification
|
/// \returns The number of errors occured during verification
|
||||||
unsigned verifyAccelTable(const DWARFSection *AccelSection,
|
unsigned verifyAppleAccelTable(const DWARFSection *AccelSection,
|
||||||
DataExtractor *StrData, const char *SectionName);
|
DataExtractor *StrData,
|
||||||
|
const char *SectionName);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DWARFVerifier(raw_ostream &S, DWARFContext &D,
|
DWARFVerifier(raw_ostream &S, DWARFContext &D,
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
llvm::Error DWARFAcceleratorTable::extract() {
|
llvm::Error AppleAcceleratorTable::extract() {
|
||||||
uint32_t Offset = 0;
|
uint32_t Offset = 0;
|
||||||
|
|
||||||
// Check that we can at least read the header.
|
// Check that we can at least read the header.
|
||||||
|
@ -59,20 +59,20 @@ llvm::Error DWARFAcceleratorTable::extract() {
|
||||||
return Error::success();
|
return Error::success();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t DWARFAcceleratorTable::getNumBuckets() { return Hdr.NumBuckets; }
|
uint32_t AppleAcceleratorTable::getNumBuckets() { return Hdr.NumBuckets; }
|
||||||
uint32_t DWARFAcceleratorTable::getNumHashes() { return Hdr.NumHashes; }
|
uint32_t AppleAcceleratorTable::getNumHashes() { return Hdr.NumHashes; }
|
||||||
uint32_t DWARFAcceleratorTable::getSizeHdr() { return sizeof(Hdr); }
|
uint32_t AppleAcceleratorTable::getSizeHdr() { return sizeof(Hdr); }
|
||||||
uint32_t DWARFAcceleratorTable::getHeaderDataLength() {
|
uint32_t AppleAcceleratorTable::getHeaderDataLength() {
|
||||||
return Hdr.HeaderDataLength;
|
return Hdr.HeaderDataLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayRef<std::pair<DWARFAcceleratorTable::HeaderData::AtomType,
|
ArrayRef<std::pair<AppleAcceleratorTable::HeaderData::AtomType,
|
||||||
DWARFAcceleratorTable::HeaderData::Form>>
|
AppleAcceleratorTable::HeaderData::Form>>
|
||||||
DWARFAcceleratorTable::getAtomsDesc() {
|
AppleAcceleratorTable::getAtomsDesc() {
|
||||||
return HdrData.Atoms;
|
return HdrData.Atoms;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DWARFAcceleratorTable::validateForms() {
|
bool AppleAcceleratorTable::validateForms() {
|
||||||
for (auto Atom : getAtomsDesc()) {
|
for (auto Atom : getAtomsDesc()) {
|
||||||
DWARFFormValue FormValue(Atom.second);
|
DWARFFormValue FormValue(Atom.second);
|
||||||
switch (Atom.first) {
|
switch (Atom.first) {
|
||||||
|
@ -92,7 +92,7 @@ bool DWARFAcceleratorTable::validateForms() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<uint32_t, dwarf::Tag>
|
std::pair<uint32_t, dwarf::Tag>
|
||||||
DWARFAcceleratorTable::readAtoms(uint32_t &HashDataOffset) {
|
AppleAcceleratorTable::readAtoms(uint32_t &HashDataOffset) {
|
||||||
uint32_t DieOffset = dwarf::DW_INVALID_OFFSET;
|
uint32_t DieOffset = dwarf::DW_INVALID_OFFSET;
|
||||||
dwarf::Tag DieTag = dwarf::DW_TAG_null;
|
dwarf::Tag DieTag = dwarf::DW_TAG_null;
|
||||||
DWARFFormParams FormParams = {Hdr.Version, 0, dwarf::DwarfFormat::DWARF32};
|
DWARFFormParams FormParams = {Hdr.Version, 0, dwarf::DwarfFormat::DWARF32};
|
||||||
|
@ -114,7 +114,7 @@ DWARFAcceleratorTable::readAtoms(uint32_t &HashDataOffset) {
|
||||||
return {DieOffset, DieTag};
|
return {DieOffset, DieTag};
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVM_DUMP_METHOD void DWARFAcceleratorTable::dump(raw_ostream &OS) const {
|
LLVM_DUMP_METHOD void AppleAcceleratorTable::dump(raw_ostream &OS) const {
|
||||||
if (!IsValid)
|
if (!IsValid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -201,8 +201,8 @@ LLVM_DUMP_METHOD void DWARFAcceleratorTable::dump(raw_ostream &OS) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DWARFAcceleratorTable::ValueIterator::ValueIterator(
|
AppleAcceleratorTable::ValueIterator::ValueIterator(
|
||||||
const DWARFAcceleratorTable &AccelTable, unsigned Offset)
|
const AppleAcceleratorTable &AccelTable, unsigned Offset)
|
||||||
: AccelTable(&AccelTable), DataOffset(Offset) {
|
: AccelTable(&AccelTable), DataOffset(Offset) {
|
||||||
if (!AccelTable.AccelSection.isValidOffsetForDataOfSize(DataOffset, 4))
|
if (!AccelTable.AccelSection.isValidOffsetForDataOfSize(DataOffset, 4))
|
||||||
return;
|
return;
|
||||||
|
@ -215,7 +215,7 @@ DWARFAcceleratorTable::ValueIterator::ValueIterator(
|
||||||
Next();
|
Next();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWARFAcceleratorTable::ValueIterator::Next() {
|
void AppleAcceleratorTable::ValueIterator::Next() {
|
||||||
assert(NumData > 0 && "attempted to increment iterator past the end");
|
assert(NumData > 0 && "attempted to increment iterator past the end");
|
||||||
auto &AccelSection = AccelTable->AccelSection;
|
auto &AccelSection = AccelTable->AccelSection;
|
||||||
if (Data >= NumData ||
|
if (Data >= NumData ||
|
||||||
|
@ -230,8 +230,8 @@ void DWARFAcceleratorTable::ValueIterator::Next() {
|
||||||
++Data;
|
++Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator_range<DWARFAcceleratorTable::ValueIterator>
|
iterator_range<AppleAcceleratorTable::ValueIterator>
|
||||||
DWARFAcceleratorTable::equal_range(StringRef Key) const {
|
AppleAcceleratorTable::equal_range(StringRef Key) const {
|
||||||
if (!IsValid)
|
if (!IsValid)
|
||||||
return make_range(ValueIterator(), ValueIterator());
|
return make_range(ValueIterator(), ValueIterator());
|
||||||
|
|
||||||
|
|
|
@ -703,37 +703,37 @@ const DWARFDebugMacro *DWARFContext::getDebugMacro() {
|
||||||
return Macro.get();
|
return Macro.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
static DWARFAcceleratorTable &
|
static AppleAcceleratorTable &
|
||||||
getAccelTable(std::unique_ptr<DWARFAcceleratorTable> &Cache,
|
getAccelTable(std::unique_ptr<AppleAcceleratorTable> &Cache,
|
||||||
const DWARFObject &Obj, const DWARFSection &Section,
|
const DWARFObject &Obj, const DWARFSection &Section,
|
||||||
StringRef StringSection, bool IsLittleEndian) {
|
StringRef StringSection, bool IsLittleEndian) {
|
||||||
if (Cache)
|
if (Cache)
|
||||||
return *Cache;
|
return *Cache;
|
||||||
DWARFDataExtractor AccelSection(Obj, Section, IsLittleEndian, 0);
|
DWARFDataExtractor AccelSection(Obj, Section, IsLittleEndian, 0);
|
||||||
DataExtractor StrData(StringSection, IsLittleEndian, 0);
|
DataExtractor StrData(StringSection, IsLittleEndian, 0);
|
||||||
Cache.reset(new DWARFAcceleratorTable(AccelSection, StrData));
|
Cache.reset(new AppleAcceleratorTable(AccelSection, StrData));
|
||||||
if (Error E = Cache->extract())
|
if (Error E = Cache->extract())
|
||||||
llvm::consumeError(std::move(E));
|
llvm::consumeError(std::move(E));
|
||||||
return *Cache;
|
return *Cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DWARFAcceleratorTable &DWARFContext::getAppleNames() {
|
const AppleAcceleratorTable &DWARFContext::getAppleNames() {
|
||||||
return getAccelTable(AppleNames, *DObj, DObj->getAppleNamesSection(),
|
return getAccelTable(AppleNames, *DObj, DObj->getAppleNamesSection(),
|
||||||
DObj->getStringSection(), isLittleEndian());
|
DObj->getStringSection(), isLittleEndian());
|
||||||
}
|
}
|
||||||
|
|
||||||
const DWARFAcceleratorTable &DWARFContext::getAppleTypes() {
|
const AppleAcceleratorTable &DWARFContext::getAppleTypes() {
|
||||||
return getAccelTable(AppleTypes, *DObj, DObj->getAppleTypesSection(),
|
return getAccelTable(AppleTypes, *DObj, DObj->getAppleTypesSection(),
|
||||||
DObj->getStringSection(), isLittleEndian());
|
DObj->getStringSection(), isLittleEndian());
|
||||||
}
|
}
|
||||||
|
|
||||||
const DWARFAcceleratorTable &DWARFContext::getAppleNamespaces() {
|
const AppleAcceleratorTable &DWARFContext::getAppleNamespaces() {
|
||||||
return getAccelTable(AppleNamespaces, *DObj,
|
return getAccelTable(AppleNamespaces, *DObj,
|
||||||
DObj->getAppleNamespacesSection(),
|
DObj->getAppleNamespacesSection(),
|
||||||
DObj->getStringSection(), isLittleEndian());
|
DObj->getStringSection(), isLittleEndian());
|
||||||
}
|
}
|
||||||
|
|
||||||
const DWARFAcceleratorTable &DWARFContext::getAppleObjC() {
|
const AppleAcceleratorTable &DWARFContext::getAppleObjC() {
|
||||||
return getAccelTable(AppleObjC, *DObj, DObj->getAppleObjCSection(),
|
return getAccelTable(AppleObjC, *DObj, DObj->getAppleObjCSection(),
|
||||||
DObj->getStringSection(), isLittleEndian());
|
DObj->getStringSection(), isLittleEndian());
|
||||||
}
|
}
|
||||||
|
|
|
@ -669,13 +669,13 @@ bool DWARFVerifier::handleDebugLine() {
|
||||||
return NumDebugLineErrors == 0;
|
return NumDebugLineErrors == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned DWARFVerifier::verifyAccelTable(const DWARFSection *AccelSection,
|
unsigned DWARFVerifier::verifyAppleAccelTable(const DWARFSection *AccelSection,
|
||||||
DataExtractor *StrData,
|
DataExtractor *StrData,
|
||||||
const char *SectionName) {
|
const char *SectionName) {
|
||||||
unsigned NumErrors = 0;
|
unsigned NumErrors = 0;
|
||||||
DWARFDataExtractor AccelSectionData(DCtx.getDWARFObj(), *AccelSection,
|
DWARFDataExtractor AccelSectionData(DCtx.getDWARFObj(), *AccelSection,
|
||||||
DCtx.isLittleEndian(), 0);
|
DCtx.isLittleEndian(), 0);
|
||||||
DWARFAcceleratorTable AccelTable(AccelSectionData, *StrData);
|
AppleAcceleratorTable AccelTable(AccelSectionData, *StrData);
|
||||||
|
|
||||||
OS << "Verifying " << SectionName << "...\n";
|
OS << "Verifying " << SectionName << "...\n";
|
||||||
|
|
||||||
|
@ -779,16 +779,16 @@ bool DWARFVerifier::handleAccelTables() {
|
||||||
unsigned NumErrors = 0;
|
unsigned NumErrors = 0;
|
||||||
if (!D.getAppleNamesSection().Data.empty())
|
if (!D.getAppleNamesSection().Data.empty())
|
||||||
NumErrors +=
|
NumErrors +=
|
||||||
verifyAccelTable(&D.getAppleNamesSection(), &StrData, ".apple_names");
|
verifyAppleAccelTable(&D.getAppleNamesSection(), &StrData, ".apple_names");
|
||||||
if (!D.getAppleTypesSection().Data.empty())
|
if (!D.getAppleTypesSection().Data.empty())
|
||||||
NumErrors +=
|
NumErrors +=
|
||||||
verifyAccelTable(&D.getAppleTypesSection(), &StrData, ".apple_types");
|
verifyAppleAccelTable(&D.getAppleTypesSection(), &StrData, ".apple_types");
|
||||||
if (!D.getAppleNamespacesSection().Data.empty())
|
if (!D.getAppleNamespacesSection().Data.empty())
|
||||||
NumErrors += verifyAccelTable(&D.getAppleNamespacesSection(), &StrData,
|
NumErrors += verifyAppleAccelTable(&D.getAppleNamespacesSection(), &StrData,
|
||||||
".apple_namespaces");
|
".apple_namespaces");
|
||||||
if (!D.getAppleObjCSection().Data.empty())
|
if (!D.getAppleObjCSection().Data.empty())
|
||||||
NumErrors +=
|
NumErrors +=
|
||||||
verifyAccelTable(&D.getAppleObjCSection(), &StrData, ".apple_objc");
|
verifyAppleAccelTable(&D.getAppleObjCSection(), &StrData, ".apple_objc");
|
||||||
return NumErrors == 0;
|
return NumErrors == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -363,7 +363,7 @@ static bool dumpObjectFile(ObjectFile &Obj, DWARFContext &DICtx, Twine Filename,
|
||||||
if (!Find.empty()) {
|
if (!Find.empty()) {
|
||||||
DumpOffsets[DIDT_ID_DebugInfo] = [&]() -> llvm::Optional<uint64_t> {
|
DumpOffsets[DIDT_ID_DebugInfo] = [&]() -> llvm::Optional<uint64_t> {
|
||||||
for (auto Name : Find) {
|
for (auto Name : Find) {
|
||||||
auto find = [&](const DWARFAcceleratorTable &Accel)
|
auto find = [&](const AppleAcceleratorTable &Accel)
|
||||||
-> llvm::Optional<uint64_t> {
|
-> llvm::Optional<uint64_t> {
|
||||||
for (auto Entry : Accel.equal_range(Name))
|
for (auto Entry : Accel.equal_range(Name))
|
||||||
for (auto Atom : Entry)
|
for (auto Atom : Entry)
|
||||||
|
|
Loading…
Reference in New Issue