9#ifndef LLVM_DEBUGINFO_DWARF_DWARFACCELERATORTABLE_H
10#define LLVM_DEBUGINFO_DWARF_DWARFACCELERATORTABLE_H
78 virtual std::optional<dwarf::Tag>
getTag()
const = 0;
119 std::optional<uint64_t>
120 extractOffset(std::optional<DWARFFormValue>
Value)
const;
127 bool IsValid =
false;
137 bool UseRelocation =
false)
const;
140 std::optional<StringRef>
141 readStringFromStrSection(
uint64_t StringSectionOffset)
const;
144 uint64_t getBucketBase()
const {
return sizeof(Hdr) + Hdr.HeaderDataLength; }
148 return getBucketBase() +
I * 4;
167 return getOffsetBase() +
I * 4;
178 return hashToBucketIdx(Hash) == BucketIdx;
183 std::optional<uint32_t> readIthBucket(
uint32_t I)
const {
185 return readU32FromAccel(
Offset);
189 std::optional<uint32_t> readIthHash(
uint32_t I)
const {
191 return readU32FromAccel(
Offset);
195 std::optional<uint32_t> readIthOffset(
uint32_t I)
const {
197 return readU32FromAccel(
Offset);
202 std::optional<uint32_t> readStringOffsetAt(
uint64_t &
Offset)
const {
203 return readU32FromAccel(
Offset,
true);
208 std::optional<uint32_t> idxOfHashInBucket(
uint32_t HashToFind,
220 std::optional<uint64_t>
getCUOffset()
const override;
228 std::optional<dwarf::Tag>
getTag()
const override;
252 Current.extract(&OffsetCopy);
261 return A.Offset ==
B.Offset;
281 constexpr static auto EndMarker = std::numeric_limits<uint64_t>::max();
287 void setToEnd() { Offset = EndMarker; }
288 bool isEnd()
const {
return Offset == EndMarker; }
295 void prepareNextEntryOrEnd();
301 void prepareNextStringOrEnd();
307 prepareNextEntryOrEnd();
312 assert(!isEnd() &&
"dereferencing end iterator");
445 std::optional<uint64_t>
getCUOffset()
const override;
448 std::optional<dwarf::Tag>
getTag()
const override {
return tag(); }
523 struct AbbrevMapInfo {
524 static Abbrev getEmptyKey();
525 static Abbrev getTombstoneKey();
526 static unsigned getHashValue(
uint32_t Code) {
529 static unsigned getHashValue(
const Abbrev &Abbr) {
530 return getHashValue(Abbr.Code);
536 return LHS.Code ==
RHS.Code;
553 : StrData(StrData), Index(Index), StringOffset(StringOffset),
554 EntryOffset(EntryOffset) {}
577 size_t TargetSize =
Target.size();
578 return Data.size() > TargetSize && !
Data[TargetSize] &&
579 strncmp(
Data.data(),
Target.data(), TargetSize) == 0;
615 std::optional<uint32_t> Hash)
const;
675 return getEntry(&OffsetFromSection);
713 std::optional<Entry> CurrentEntry;
716 std::optional<uint32_t> Hash;
718 bool getEntryAtCurrentOffset();
719 std::optional<uint64_t> findEntryOffsetInCurrentIndex();
720 bool findInCurrentIndex();
721 void searchFromStartOfCurrentIndex();
752 return A.CurrentIndex ==
B.CurrentIndex &&
A.DataOffset ==
B.DataOffset;
768 assert(CurrentName <= CurrentIndex->getNameCount());
782 : CurrentIndex(CurrentIndex), CurrentName(CurrentName) {}
798 return A.CurrentIndex ==
B.CurrentIndex &&
A.CurrentName ==
B.CurrentName;
832DWARFDebugNames::DWARFDebugNamesOffsets
834 const DWARFDebugNames::Header &Hdr);
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file defines the DenseSet and SmallDenseSet classes.
This file contains constants used for implementing Dwarf debug support.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
This file defines the SmallVector class.
This class holds an abstract representation of an Accelerator Table, consisting of a sequence of buck...
Apple-specific implementation of an Accelerator Entry.
std::optional< DWARFFormValue > lookup(HeaderData::AtomType Atom) const
Returns the value of the Atom in this Accelerator Entry, if the Entry contains such Atom.
std::optional< uint64_t > getDIESectionOffset() const
Returns the Section Offset of the Debug Info Entry associated with this Accelerator Entry or std::nul...
std::optional< dwarf::Tag > getTag() const override
Returns the Tag of the Debug Info Entry associated with this Accelerator Entry or std::nullopt if the...
std::optional< uint64_t > getCUOffset() const override
Returns the Offset of the Compilation Unit associated with this Accelerator Entry or std::nullopt if ...
friend class ValueIterator
An iterator for all entries in the table.
bool operator==(const Iterator &It) const
const EntryWithName & operator*() const
An iterator for Entries all having the same string as key.
const Entry & operator*()
SameNameIterator & operator++()
friend bool operator==(const SameNameIterator &A, const SameNameIterator &B)
This implements the Apple accelerator table format, a precursor of the DWARF 5 accelerator table form...
iterator_range< SameNameIterator > equal_range(StringRef Key) const
Look up all entries in the accelerator table matching Key.
AppleAcceleratorTable(const DWARFDataExtractor &AccelSection, DataExtractor StringSection)
uint32_t getNumBuckets() const
bool containsAtomType(HeaderData::AtomType AtomTy) const
Returns true iff AtomTy is one of the atoms available in Entries of this table.
uint32_t getSizeHdr() const
std::pair< uint64_t, dwarf::Tag > readAtoms(uint64_t *HashDataOffset)
Return information related to the DWARF DIE we're looking for when performing a lookup by name.
uint32_t getNumHashes() const
uint32_t getHashDataEntryLength() const
Returns the size of one HashData entry.
void dump(raw_ostream &OS) const override
ArrayRef< std::pair< HeaderData::AtomType, HeaderData::Form > > getAtomsDesc()
Return the Atom description, which can be used to interpret the raw values of the Accelerator Entries...
uint32_t getHeaderDataLength() const
auto entries() const
Lookup all entries in the accelerator table.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
An abstract class representing a single entry in the accelerator tables.
Entry & operator=(Entry &&)=default
ArrayRef< DWARFFormValue > getValues() const
Returns the raw values of fields in the Accelerator Entry.
SmallVector< DWARFFormValue, 3 > Values
Entry(const Entry &)=default
virtual std::optional< uint64_t > getForeignTUTypeSignature() const
Returns the type signature of the Type Unit associated with this Accelerator Entry or std::nullopt if...
virtual std::optional< uint64_t > getLocalTUOffset() const
Returns the Offset of the Type Unit associated with this Accelerator Entry or std::nullopt if the Typ...
Entry & operator=(const Entry &)=default
virtual std::optional< uint64_t > getCUOffset() const =0
Returns the Offset of the Compilation Unit associated with this Accelerator Entry or std::nullopt if ...
virtual std::optional< dwarf::Tag > getTag() const =0
Returns the Tag of the Debug Info Entry associated with this Accelerator Entry or std::nullopt if the...
The accelerator tables are designed to allow efficient random access (using a symbol name as a key) i...
DWARFAcceleratorTable(const DWARFDataExtractor &AccelSection, DataExtractor StringSection)
virtual Error extract()=0
virtual void dump(raw_ostream &OS) const =0
void operator=(const DWARFAcceleratorTable &)=delete
DataExtractor StringSection
virtual ~DWARFAcceleratorTable()
DWARFDataExtractor AccelSection
DWARFAcceleratorTable(const DWARFAcceleratorTable &)=delete
DWARF v5-specific implementation of an Accelerator Entry.
std::optional< uint64_t > getForeignTUTypeSignature() const override
Returns the type signature of the Type Unit associated with this Accelerator Entry or std::nullopt if...
std::optional< uint64_t > getRelatedCUIndex() const
Similar functionality to getCUIndex() but without the DW_IDX_type_unit restriction.
std::optional< uint64_t > getCUIndex() const
Returns the Index into the Compilation Unit list of the owning Name Index or std::nullopt if this Acc...
std::optional< uint64_t > getRelatedCUOffset() const
const Abbrev & getAbbrev() const
Return the Abbreviation that can be used to interpret the raw values of this Accelerator Entry.
const NameIndex * getNameIndex() const
std::optional< uint64_t > getCUOffset() const override
Returns the Offset of the Compilation Unit associated with this Accelerator Entry or std::nullopt if ...
std::optional< uint64_t > getDIEUnitOffset() const
Returns the Offset of the DIE within the containing CU or TU.
Expected< std::optional< DWARFDebugNames::Entry > > getParentDIEEntry() const
Returns the Entry corresponding to the parent of the DIE represented by this Entry.
dwarf::Tag tag() const
.debug_names-specific getter, which always succeeds (DWARF v5 index entries always have a tag).
bool hasParentInformation() const
Returns true if this Entry has information about its parent DIE (i.e.
std::optional< uint64_t > getTUIndex() const
Returns the index of the Type Unit of the owning Name Index or std::nullopt if this Accelerator Entry...
std::optional< DWARFFormValue > lookup(dwarf::Index Index) const
Returns the value of the Index Attribute in this Accelerator Entry, if the Entry contains such Attrib...
std::optional< uint64_t > getLocalTUOffset() const override
Returns the Offset of the Type Unit associated with this Accelerator Entry or std::nullopt if the Typ...
std::optional< dwarf::Tag > getTag() const override
Returns the Tag of the Debug Info Entry associated with this Accelerator Entry or std::nullopt if the...
void dumpParentIdx(ScopedPrinter &W, const DWARFFormValue &FormValue) const
void dump(ScopedPrinter &W) const
Represents a single accelerator table within the DWARF v5 .debug_names section.
uint32_t getHashArrayEntry(uint32_t Index) const
Reads an entry in the Hash Array for the given Index.
uint64_t getLocalTUOffset(uint32_t TU) const
Reads offset of local type unit TU, TU is 0-based.
uint32_t getBucketArrayEntry(uint32_t Bucket) const
Reads an entry in the Bucket Array for the given Bucket.
uint64_t getNextUnitOffset() const
NameIterator begin() const
uint64_t getUnitOffset() const
void dump(ScopedPrinter &W) const
uint32_t getCUCount() const
Header getHeader() const
Returns Hdr field.
iterator_range< ValueIterator > equal_range(StringRef Key) const
Look up all entries in this Name Index matching Key.
uint64_t getCUOffset(uint32_t CU) const
Reads offset of compilation unit CU. CU is 0-based.
Expected< Entry > getEntry(uint64_t *Offset) const
NameTableEntry getNameTableEntry(uint32_t Index) const
Reads an entry in the Name Table for the given Index.
NameIndex(const DWARFDebugNames &Section, uint64_t Base)
uint32_t getNameCount() const
const DenseSet< Abbrev, AbbrevMapInfo > & getAbbrevs() const
uint32_t getForeignTUCount() const
uint64_t getForeignTUSignature(uint32_t TU) const
Reads signature of foreign type unit TU. TU is 0-based.
uint32_t getBucketCount() const
DWARFDebugNamesOffsets getOffsets() const
Returns Offsets field.
uint32_t getLocalTUCount() const
Expected< Entry > getEntryAtRelativeOffset(uint64_t Offset) const
Returns the Entry at the relative Offset from the start of the Entry pool.
NameTableEntry operator*() const
friend bool operator==(const NameIterator &A, const NameIterator &B)
NameIterator operator++(int)
NameIterator & operator++()
NameIterator(const NameIndex *CurrentIndex, uint32_t CurrentName)
Creates an iterator whose initial position is name CurrentName in CurrentIndex.
std::input_iterator_tag iterator_category
friend bool operator!=(const NameIterator &A, const NameIterator &B)
A single entry in the Name Table (DWARF v5 sect.
uint64_t getStringOffset() const
Returns the offset of the name of the described entities.
uint64_t getEntryOffset() const
Returns the offset of the first Entry in the list.
bool sameNameAs(StringRef Target) const
Compares the name of this entry against Target, returning true if they are equal.
NameTableEntry(const DataExtractor &StrData, uint32_t Index, uint64_t StringOffset, uint64_t EntryOffset)
const char * getString() const
Return the string referenced by this name table entry or nullptr if the string offset is not valid.
uint32_t getIndex() const
Return the index of this name in the parent Name Index.
Error returned by NameIndex::getEntry to report it has reached the end of the entry list.
void log(raw_ostream &OS) const override
Print an error message to an output stream.
std::error_code convertToErrorCode() const override
Convert this error to a std::error_code.
friend bool operator==(const ValueIterator &A, const ValueIterator &B)
friend bool operator!=(const ValueIterator &A, const ValueIterator &B)
std::ptrdiff_t difference_type
ValueIterator operator++(int)
ValueIterator()=default
End marker.
const Entry & operator*() const
std::input_iterator_tag iterator_category
ValueIterator & operator++()
.debug_names section consists of one or more units.
const_iterator end() const
const_iterator begin() const
DWARFDebugNames(const DWARFDataExtractor &AccelSection, DataExtractor StringSection)
iterator_range< ValueIterator > equal_range(StringRef Key) const
Look up all entries in the accelerator table matching Key.
const NameIndex * getCUOrTUNameIndex(uint64_t UnitOffset)
Return the Name Index covering the compile unit or local type unit at UnitOffset, or nullptr if there...
void dump(raw_ostream &OS) const override
Implements a dense probed hash-table based set.
Base class for user error types.
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
constexpr StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
Target - Wrapper for Target specific information.
LLVM Value Representation.
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
uint8_t getUnitLengthFieldByteSize(DwarfFormat Format)
Get the byte size of the unit length field depending on the DWARF format.
DWARFDebugNames::DWARFDebugNamesOffsets findDebugNamesOffsets(uint64_t EndOfHeaderOffset, const DWARFDebugNames::Header &Hdr)
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
auto make_first_range(ContainerTy &&c)
Given a container of pairs, return a range over the first elements.
std::optional< StringRef > StripTemplateParameters(StringRef Name)
If Name is the name of a templated function that includes template parameters, returns a substring of...
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
std::optional< ObjCSelectorNames > getObjCNamesIfSelector(StringRef Name)
If Name is the AT_name of a DIE which refers to an Objective-C selector, returns an instance of ObjCS...
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Implement std::hash so that hash_code can be used in STL containers.
EntryWithName(const AppleAcceleratorTable &Table)
std::optional< StringRef > readName() const
Abbreviation describing the encoding of Name Index entries.
void dump(ScopedPrinter &W) const
uint32_t Code
< Abbreviation offset in the .debug_names section
Abbrev(uint32_t Code, dwarf::Tag Tag, uint64_t AbbrevOffset, std::vector< AttributeEncoding > Attributes)
std::vector< AttributeEncoding > Attributes
List of index attributes.
dwarf::Tag Tag
Dwarf Tag of the described entity.
Index attribute and its encoding.
friend bool operator==(const AttributeEncoding &LHS, const AttributeEncoding &RHS)
constexpr AttributeEncoding(dwarf::Index Index, dwarf::Form Form)
Offsets for the start of various important tables from the start of the section.
uint64_t EntryOffsetsBase
uint64_t StringOffsetsBase
An information struct used to provide DenseMap with the various necessary components for a given valu...
StringRef ClassName
For "-[A(Category) method:]", this would be "A(category)".
std::optional< std::string > MethodNameNoCategory
For "-[A(Category) method:]", this would be "A method:".
StringRef Selector
For "-[A(Category) method:]", this would be "method:".
std::optional< StringRef > ClassNameNoCategory
For "-[A(Category) method:]", this would be "A".