9 #ifndef LLVM_DEBUGINFO_DWARFLISTTABLE_H 10 #define LLVM_DEBUGINFO_DWARFLISTTABLE_H 39 using EntryType = ListEntryType;
40 using ListEntries = std::vector<EntryType>;
46 const ListEntries &
getEntries()
const {
return Entries; }
47 bool empty()
const {
return Entries.empty(); }
48 void clear() { Entries.clear(); }
83 uint64_t HeaderOffset;
92 : SectionName(SectionName), ListTypeString(ListTypeString) {}
100 uint64_t
getLength()
const {
return HeaderData.Length; }
120 if (Index < Offsets.size())
121 return Offsets[Index];
131 uint64_t length()
const;
143 std::map<uint64_t, DWARFListType> ListMap;
151 : Header(SectionName, ListTypeString), HeaderString(HeaderString) {}
160 return Header.
extract(Data, OffsetPtr);
191 template <
typename DWARFListType>
193 uint64_t *OffsetPtr) {
195 if (
Error E = extractHeaderAndOffsets(Data, OffsetPtr))
199 uint64_t End = getHeaderOffset() + Header.length();
200 while (*OffsetPtr < End) {
202 uint64_t Off = *OffsetPtr;
203 if (
Error E = CurrentList.
extract(Data, getHeaderOffset(), End, OffsetPtr,
204 Header.getSectionName(),
205 Header.getListTypeString()))
207 ListMap[Off] = CurrentList;
210 assert(*OffsetPtr == End &&
211 "mismatch between expected length of table and length " 212 "of extracted data");
216 template <
typename ListEntryType>
218 uint64_t HeaderOffset, uint64_t End,
222 if (*OffsetPtr < HeaderOffset || *OffsetPtr >= End)
224 "invalid %s list offset 0x%" PRIx64,
225 ListTypeString.
data(), *OffsetPtr);
227 while (*OffsetPtr < End) {
229 if (
Error E = Entry.extract(Data, End, OffsetPtr))
231 Entries.push_back(Entry);
232 if (Entry.isSentinel())
236 "no end of list marker detected at end of %s table " 237 "starting at offset 0x%" PRIx64,
238 SectionName.
data(), HeaderOffset);
241 template <
typename DWARFListType>
247 Header.dump(OS, DumpOpts);
248 OS << HeaderString <<
"\n";
252 size_t MaxEncodingStringLength = 0;
254 for (
const auto &
List : ListMap)
255 for (
const auto &
Entry :
List.second.getEntries())
256 MaxEncodingStringLength =
261 uint64_t CurrentBase = 0;
262 for (
const auto &
List : ListMap)
263 for (
const auto &
Entry :
List.second.getEntries())
264 Entry.dump(OS, getAddrSize(), MaxEncodingStringLength, CurrentBase,
265 DumpOpts, LookupPooledAddress);
268 template <
typename DWARFListType>
272 auto Entry = ListMap.find(Offset);
273 if (
Entry != ListMap.end())
274 return Entry->second;
278 uint64_t End = getHeaderOffset() + Header.length();
279 uint64_t StartingOffset =
Offset;
281 List.extract(Data, getHeaderOffset(), End, &Offset,
282 Header.getSectionName(), Header.getListTypeString()))
284 ListMap[StartingOffset] =
List;
290 #endif // LLVM_DEBUGINFO_DWARFLISTTABLE_H
dwarf::DwarfFormat getFormat() const
This class represents lattice values for constants.
const ListEntries & getEntries() const
An efficient, type-erasing, non-owning reference to a callable.
Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr)
Extract an entire table, including all list entries.
uint64_t Offset
The offset at which the entry is located in the section.
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
A base class for DWARF list entries, such as range or location list entries.
uint8_t EntryKind
The DWARF encoding (DW_RLE_* or DW_LLE_*).
Tagged union holding either a T or a Error.
LLVM_NODISCARD size_t size() const
size - Get the string size.
uint64_t SectionIndex
The index of the section this entry belongs to.
Container for dump options that control which debug information will be dumped.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Error extractHeaderAndOffsets(DWARFDataExtractor Data, uint64_t *OffsetPtr)
Extract the table header and the array of offsets.
StringRef RangeListEncodingString(unsigned Encoding)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
DWARFListTableBase(StringRef SectionName, StringRef HeaderString, StringRef ListTypeString)
static ErrorSuccess success()
Create a success value.
Align max(MaybeAlign Lhs, Align Rhs)
Expected< DWARFListType > findList(DWARFDataExtractor Data, uint64_t Offset)
Look up a list based on a given offset.
This file contains constants used for implementing Dwarf debug support.
uint8_t getHeaderSize() const
Return the size of the table header including the length but not including the offsets.
void dump(raw_ostream &OS, llvm::function_ref< Optional< object::SectionedAddress >(uint32_t)> LookupPooledAddress, DIDumpOptions DumpOpts={}) const
static void clear(coro::Shape &Shape)
uint64_t getHeaderOffset() const
Optional< uint64_t > getOffsetEntry(uint32_t Index) const
Return the contents of the offset entry designated by a given index.
Error extract(DWARFDataExtractor Data, uint64_t HeaderOffset, uint64_t End, uint64_t *OffsetPtr, StringRef SectionName, StringRef ListStringName)
LLVM_NODISCARD const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
uint8_t getAddrSize() const
Lightweight error class with error context and mandatory checking.
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
A base class for lists of entries that are extracted from a particular section, such as range lists o...
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
A class representing a table of lists as specified in the DWARF v5 standard for location lists and ra...