9#ifndef LLVM_DEBUGINFO_DWARF_DWARFLISTTABLE_H
10#define LLVM_DEBUGINFO_DWARF_DWARFLISTTABLE_H
39 using EntryType = ListEntryType;
40 using ListEntries = std::vector<EntryType>;
118 if (
Index >= HeaderData.OffsetEntryCount)
130 auto R =
Data.getUnsigned(&
Offset, OffsetByteSize);
152 std::map<uint64_t, DWARFListType> ListMap;
160 : Header(
SectionName, ListTypeString), HeaderString(HeaderString) {}
169 return Header.extract(
Data, OffsetPtr);
192 return Header.getOffsetEntry(
Data,
Index);
204template <
typename DWARFListType>
208 if (
Error E = extractHeaderAndOffsets(
Data, OffsetPtr))
211 Data.setAddressSize(Header.getAddrSize());
213 while (
Data.isValidOffset(*OffsetPtr)) {
217 Header.getSectionName(),
218 Header.getListTypeString()))
220 ListMap[Off] = CurrentList;
224 "mismatch between expected length of table and length "
225 "of extracted data");
229template <
typename ListEntryType>
235 if (*OffsetPtr < HeaderOffset || *OffsetPtr >=
Data.size())
237 "invalid %s list offset 0x%" PRIx64,
238 ListTypeString.
data(), *OffsetPtr);
240 while (
Data.isValidOffset(*OffsetPtr)) {
244 Entries.push_back(Entry);
245 if (Entry.isSentinel())
249 "no end of list marker detected at end of %s table "
250 "starting at offset 0x%" PRIx64,
254template <
typename DWARFListType>
260 Header.dump(
Data,
OS, DumpOpts);
261 OS << HeaderString <<
"\n";
265 size_t MaxEncodingStringLength = 0;
267 for (
const auto &
List : ListMap)
268 for (
const auto &Entry :
List.second.getEntries())
269 MaxEncodingStringLength =
270 std::max(MaxEncodingStringLength,
275 for (
const auto &
List : ListMap)
276 for (
const auto &Entry :
List.second.getEntries())
277 Entry.dump(
OS, getAddrSize(), MaxEncodingStringLength, CurrentBase,
278 DumpOpts, LookupPooledAddress);
281template <
typename DWARFListType>
290 List.extract(
Data, Header.length() ? getHeaderOffset() : 0, &
Offset,
291 Header.getSectionName(), Header.getListTypeString()))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains constants used for implementing Dwarf debug support.
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.
LLVM_ABI 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.