10 #ifndef LLVM_DEBUGINFO_DWARFLISTTABLE_H 11 #define LLVM_DEBUGINFO_DWARFLISTTABLE_H 39 using EntryType = ListEntryType;
40 using ListEntries = std::vector<EntryType>;
50 const ListEntries &
getEntries()
const {
return Entries; }
51 bool empty()
const {
return Entries.empty(); }
52 void clear() { Entries.clear(); }
96 : SectionName(SectionName), ListTypeString(ListTypeString) {}
111 if (Index < Offsets.size())
112 return Offsets[Index];
134 std::map<uint32_t, DWARFListType> ListMap;
142 : Header(SectionName, ListTypeString), HeaderString(HeaderString) {}
151 return Header.
extract(Data, OffsetPtr);
184 template <
typename DWARFListType>
188 if (
Error E = extractHeaderAndOffsets(Data, OffsetPtr))
192 uint32_t End = getHeaderOffset() + Header.length();
193 while (*OffsetPtr < End) {
196 if (
Error E = CurrentList.
extract(Data, getHeaderOffset(), End, OffsetPtr,
197 Header.getSectionName(),
198 Header.getListTypeString()))
200 ListMap[Off] = CurrentList;
203 assert(*OffsetPtr == End &&
204 "mismatch between expected length of table and length " 205 "of extracted data");
209 template <
typename ListEntryType>
215 if (*OffsetPtr < HeaderOffset || *OffsetPtr >= End)
216 return createError(
"invalid %s list offset 0x%" PRIx32,
217 ListTypeString.
data(), *OffsetPtr);
219 while (*OffsetPtr < End) {
221 if (
Error E = Entry.extract(Data, End, OffsetPtr))
223 Entries.push_back(Entry);
224 if (Entry.isSentinel())
227 return createError(
"no end of list marker detected at end of %s table " 228 "starting at offset 0x%" PRIx32,
229 SectionName.
data(), HeaderOffset);
232 template <
typename DWARFListType>
235 Header.dump(OS, DumpOpts);
236 OS << HeaderString <<
"\n";
240 size_t MaxEncodingStringLength = 0;
242 for (
const auto &
List : ListMap)
243 for (
const auto &Entry :
List.second.getEntries())
244 MaxEncodingStringLength =
249 uint64_t CurrentBase = 0;
250 for (
const auto &
List : ListMap)
251 for (
const auto &Entry :
List.second.getEntries())
252 Entry.
dump(OS, getAddrSize(), MaxEncodingStringLength, CurrentBase,
256 template <
typename DWARFListType>
260 auto Entry = ListMap.find(Offset);
261 if (Entry != ListMap.end())
262 return Entry->second;
266 uint32_t End = getHeaderOffset() + Header.length();
269 List.extract(Data, getHeaderOffset(), End, &Offset,
270 Header.getSectionName(), Header.getListTypeString()))
272 ListMap[StartingOffset] =
List;
278 #endif // LLVM_DEBUGINFO_DWARFLISTTABLE_H
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
Compute iterated dominance frontiers using a linear time algorithm.
const ListEntries & getEntries() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Expected< DWARFListType > findList(DWARFDataExtractor Data, uint32_t Offset)
Look up a list based on a given offset.
static Error createError(StringRef Err)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
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.
uint64_t SectionIndex
The index of the section this entry belongs to.
Container for dump options that control which debug information will be dumped.
uint32_t getHeaderOffset() const
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
void dump(raw_ostream &OS, DIDumpOptions DumpOpts={}) const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Optional< uint32_t > getOffsetEntry(uint32_t Index) const
Return the contents of the offset entry designated by a given index.
Error extract(DWARFDataExtractor Data, uint32_t HeaderOffset, uint32_t End, uint32_t *OffsetPtr, StringRef SectionName, StringRef ListStringName)
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.
uint32_t Offset
The offset at which the entry is located in the section.
Error extractHeaderAndOffsets(DWARFDataExtractor Data, uint32_t *OffsetPtr)
Extract the table header and the array of offsets.
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.
static void clear(coro::Shape &Shape)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Error extract(DWARFDataExtractor Data, uint32_t *OffsetPtr)
Extract an entire table, including all list entries.
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...
A class representing a table of lists as specified in the DWARF v5 standard for location lists and ra...