9#ifndef LLVM_DEBUGINFO_DWARF_DWARFLISTTABLE_H
10#define LLVM_DEBUGINFO_DWARF_DWARFLISTTABLE_H
38 using EntryType = ListEntryType;
39 using ListEntries = std::vector<EntryType>;
117 if (
Index >= HeaderData.OffsetEntryCount)
129 auto R =
Data.getUnsigned(&
Offset, OffsetByteSize);
151 std::map<uint64_t, DWARFListType> ListMap;
159 : Header(
SectionName, ListTypeString), HeaderString(HeaderString) {}
168 return Header.extract(
Data, OffsetPtr);
191 return Header.getOffsetEntry(
Data,
Index);
203template <
typename DWARFListType>
207 if (
Error E = extractHeaderAndOffsets(
Data, OffsetPtr))
210 Data.setAddressSize(Header.getAddrSize());
212 while (
Data.isValidOffset(*OffsetPtr)) {
216 Header.getSectionName(),
217 Header.getListTypeString()))
219 ListMap[Off] = CurrentList;
223 "mismatch between expected length of table and length "
224 "of extracted data");
228template <
typename ListEntryType>
234 if (*OffsetPtr < HeaderOffset || *OffsetPtr >=
Data.size())
236 "invalid %s list offset 0x%" PRIx64,
237 ListTypeString.
data(), *OffsetPtr);
239 while (
Data.isValidOffset(*OffsetPtr)) {
243 Entries.push_back(Entry);
244 if (Entry.isSentinel())
248 "no end of list marker detected at end of %s table "
249 "starting at offset 0x%" PRIx64,
253template <
typename DWARFListType>
259 Header.dump(
Data,
OS, DumpOpts);
260 OS << HeaderString <<
"\n";
264 size_t MaxEncodingStringLength = 0;
266 for (
const auto &
List : ListMap)
267 for (
const auto &Entry :
List.second.getEntries())
268 MaxEncodingStringLength =
269 std::max(MaxEncodingStringLength,
274 for (
const auto &
List : ListMap)
275 for (
const auto &Entry :
List.second.getEntries())
276 Entry.dump(
OS, getAddrSize(), MaxEncodingStringLength, CurrentBase,
277 DumpOpts, LookupPooledAddress);
280template <
typename DWARFListType>
289 List.extract(
Data, Header.length() ? getHeaderOffset() : 0, &
Offset,
290 Header.getSectionName(), Header.getListTypeString()))
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static void clear(coro::Shape &Shape)
This file contains constants used for implementing Dwarf debug support.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A class representing a table of lists as specified in the DWARF v5 standard for location lists and ra...
uint8_t getHeaderSize() const
Return the size of the table header including the length but not including the offsets.
std::optional< uint64_t > getOffsetEntry(DataExtractor Data, uint32_t Index) const
Return the contents of the offset entry designated by a given index.
uint32_t getOffsetEntryCount() const
uint64_t getHeaderOffset() const
uint8_t getAddrSize() const
Expected< DWARFListType > findList(DWARFDataExtractor Data, uint64_t Offset) const
Look up a list based on a given offset.
dwarf::DwarfFormat getFormat() const
Error extractHeaderAndOffsets(DWARFDataExtractor Data, uint64_t *OffsetPtr)
Extract the table header and the array of offsets.
Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr)
Extract an entire table, including all list entries.
void dump(DWARFDataExtractor Data, raw_ostream &OS, llvm::function_ref< std::optional< object::SectionedAddress >(uint32_t)> LookupPooledAddress, DIDumpOptions DumpOpts={}) const
DWARFListTableBase(StringRef SectionName, StringRef HeaderString, StringRef ListTypeString)
A base class for lists of entries that are extracted from a particular section, such as range lists o...
const ListEntries & getEntries() const
Error extract(DWARFDataExtractor Data, uint64_t HeaderOffset, uint64_t *OffsetPtr, StringRef SectionName, StringRef ListStringName)
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
StringRef - Represent a constant reference to a string, i.e.
constexpr size_t size() const
size - Get the string size.
constexpr const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
StringRef RangeListEncodingString(unsigned Encoding)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
DwarfFormat
Constants that define the DWARF format as 32 or 64 bit.
This is an optimization pass for GlobalISel generic memory operations.
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.
Container for dump options that control which debug information will be dumped.
A base class for DWARF list entries, such as range or location list entries.
uint64_t SectionIndex
The index of the section this entry belongs to.
uint8_t EntryKind
The DWARF encoding (DW_RLE_* or DW_LLE_*).
uint64_t Offset
The offset at which the entry is located in the section.