30 if (!AccelSection.
isValidOffset(offsetof(Header, HeaderDataLength)+4))
33 Hdr.Magic = AccelSection.
getU32(&Offset);
34 Hdr.Version = AccelSection.
getU16(&Offset);
35 Hdr.HashFunction = AccelSection.
getU16(&Offset);
36 Hdr.NumBuckets = AccelSection.
getU32(&Offset);
37 Hdr.NumHashes = AccelSection.
getU32(&Offset);
38 Hdr.HeaderDataLength = AccelSection.
getU32(&Offset);
42 if (!AccelSection.
isValidOffset(
sizeof(Hdr) + Hdr.HeaderDataLength +
43 Hdr.NumBuckets*4 + Hdr.NumHashes*8))
46 HdrData.DIEOffsetBase = AccelSection.
getU32(&Offset);
49 for (
unsigned i = 0; i < NumAtoms; ++i) {
50 uint16_t AtomType = AccelSection.
getU16(&Offset);
52 HdrData.Atoms.push_back(std::make_pair(AtomType, AtomForm));
62 return Hdr.HeaderDataLength;
65 ArrayRef<std::pair<DWARFAcceleratorTable::HeaderData::AtomType,
78 FormValue.
getForm() == dwarf::DW_FORM_sdata)
92 FormValue.
extractValue(AccelSection, &HashDataOffset, NULL);
106 OS <<
"Magic = " <<
format(
"0x%08x", Hdr.Magic) <<
'\n'
107 <<
"Version = " <<
format(
"0x%04x", Hdr.Version) <<
'\n'
108 <<
"Hash function = " <<
format(
"0x%08x", Hdr.HashFunction) <<
'\n'
109 <<
"Bucket count = " << Hdr.NumBuckets <<
'\n'
110 <<
"Hashes count = " << Hdr.NumHashes <<
'\n'
111 <<
"HeaderData length = " << Hdr.HeaderDataLength <<
'\n'
112 <<
"DIE offset base = " << HdrData.DIEOffsetBase <<
'\n'
113 <<
"Number of atoms = " << HdrData.Atoms.size() <<
'\n';
117 for (
const auto &Atom: HdrData.Atoms) {
118 OS <<
format(
"Atom[%d] Type: ", i++);
120 if (!TypeString.empty())
123 OS <<
format(
"DW_ATOM_Unknown_0x%x", Atom.first);
126 if (!FormString.empty())
129 OS <<
format(
"DW_FORM_Unknown_0x%x", Atom.second);
136 unsigned HashesBase = Offset + Hdr.NumBuckets * 4;
137 unsigned OffsetsBase = HashesBase + Hdr.NumHashes * 4;
139 for (
unsigned Bucket = 0; Bucket < Hdr.NumBuckets; ++Bucket) {
140 unsigned Index = AccelSection.
getU32(&Offset);
142 OS <<
format(
"Bucket[%d]\n", Bucket);
143 if (Index == UINT32_MAX) {
148 for (
unsigned HashIdx = Index; HashIdx < Hdr.NumHashes; ++HashIdx) {
149 unsigned HashOffset = HashesBase + HashIdx*4;
150 unsigned OffsetsOffset = OffsetsBase + HashIdx*4;
153 if (Hash % Hdr.NumBuckets != Bucket)
156 unsigned DataOffset = AccelSection.
getU32(&OffsetsOffset);
157 OS <<
format(
" Hash = 0x%08x Offset = 0x%08x\n", Hash, DataOffset);
159 OS <<
" Invalid section offset\n";
166 OS <<
format(
" Name: %08x \"%s\"\n", StringOffset,
167 StringSection.
getCStr(&StringOffset));
168 unsigned NumData = AccelSection.
getU32(&DataOffset);
172 for (
auto &Atom : AtomForms) {
173 OS <<
format(
"{Atom[%d]: ", i++);
174 if (Atom.extractValue(AccelSection, &DataOffset,
nullptr))
177 OS <<
"Error extracting the value";
void push_back(const T &Elt)
StringRef AtomTypeString(unsigned Atom)
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
StringRef FormEncodingString(unsigned Encoding)
uint32_t readAtoms(uint32_t &HashDataOffset)
Return information related to the DWARF DIE we're looking for when performing a lookup by name...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
uint32_t getHeaderDataLength()
format_object< Ts...> format(const char *Fmt, const Ts &...Vals)
These are helper functions used to produce formatted output.
const uint32_t DW_INVALID_OFFSET
for(unsigned i=0, e=MI->getNumOperands();i!=e;++i)
ArrayRef< std::pair< HeaderData::AtomType, HeaderData::Form > > getAtomsDesc()
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
void dump(raw_ostream &OS) const
This class implements an extremely fast bulk output stream that can only output to a stream...
std::string Hash(const Unit &U)