LLVM: include/llvm/DebugInfo/DWARF/DWARFListTable.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_DEBUGINFO_DWARF_DWARFLISTTABLE_H

10#define LLVM_DEBUGINFO_DWARF_DWARFLISTTABLE_H

11

19#include

20#include

21#include

22

23namespace llvm {

24

25

26

35

36

37

39 using EntryType = ListEntryType;

40 using ListEntries = std::vector;

41

42protected:

44

45public:

52};

53

54

55

57 struct Header {

58

59

61

63

64

65

67

68

70

72 };

73

74 Header HeaderData;

75

77

78

80

82

83

85

86public:

88 : SectionName(SectionName), ListTypeString(ListTypeString) {}

89

101

102

103

105 switch (Format) {

107 return 12;

109 return 20;

110 }

111 llvm_unreachable("Invalid DWARF format (expected DWARF32 or DWARF64");

112 }

113

118 if (Index >= HeaderData.OffsetEntryCount)

119 return std::nullopt;

120

122 }

123

129 uint64_t Offset = OffsetTableOffset + OffsetByteSize * Index;

130 auto R = Data.getUnsigned(&Offset, OffsetByteSize);

131 return R;

132 }

133

134

136

137

138

139

141};

142

143

144

145

146

147

150

151

152 std::map<uint64_t, DWARFListType> ListMap;

153

154

156

157protected:

160 : Header(SectionName, ListTypeString), HeaderString(HeaderString) {}

161

162public:

164 Header.clear();

165 ListMap.clear();

166 }

167

169 return Header.extract(Data, OffsetPtr);

170 }

171

173

174

177

182

183 void

186 LookupPooledAddress,

188

189

192 return Header.getOffsetEntry(Data, Index);

193 }

194

195

196

200

202};

203

204template

209 return E;

210

211 Data.setAddressSize(Header.getAddrSize());

213 while (Data.isValidOffset(*OffsetPtr)) {

217 Header.getSectionName(),

218 Header.getListTypeString()))

219 return E;

220 ListMap[Off] = CurrentList;

221 }

222

224 "mismatch between expected length of table and length "

225 "of extracted data");

227}

228

229template

235 if (*OffsetPtr < HeaderOffset || *OffsetPtr >= Data.size())

237 "invalid %s list offset 0x%" PRIx64,

238 ListTypeString.data(), *OffsetPtr);

240 while (Data.isValidOffset(*OffsetPtr)) {

241 ListEntryType Entry;

242 if (Error E = Entry.extract(Data, OffsetPtr))

243 return E;

244 Entries.push_back(Entry);

245 if (Entry.isSentinel())

247 }

249 "no end of list marker detected at end of %s table "

250 "starting at offset 0x%" PRIx64,

252}

253

254template

258 LookupPooledAddress,

260 Header.dump(Data, OS, DumpOpts);

261 OS << HeaderString << "\n";

262

263

264

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,

272 }

273

275 for (const auto &List : ListMap)

276 for (const auto &Entry : List.second.getEntries())

277 Entry.dump(OS, getAddrSize(), MaxEncodingStringLength, CurrentBase,

278 DumpOpts, LookupPooledAddress);

279}

280

281template

285

287 if (Header.length())

291 Header.getSectionName(), Header.getListTypeString()))

292 return std::move(E);

294}

295

296}

297

298#endif

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.

uint8_t getHeaderSize() const

Return the size of the table header including the length but not including the offsets.

Definition DWARFListTable.h:197

std::optional< uint64_t > getOffsetEntry(DataExtractor Data, uint32_t Index) const

Return the contents of the offset entry designated by a given index.

Definition DWARFListTable.h:190

uint32_t getOffsetEntryCount() const

Definition DWARFListTable.h:180

uint64_t getHeaderOffset() const

Definition DWARFListTable.h:178

uint8_t getAddrSize() const

Definition DWARFListTable.h:179

uint64_t length()

Definition DWARFListTable.h:201

void clear()

Definition DWARFListTable.h:163

Expected< DWARFListType > findList(DWARFDataExtractor Data, uint64_t Offset) const

Look up a list based on a given offset.

Definition DWARFListTable.h:283

dwarf::DwarfFormat getFormat() const

Definition DWARFListTable.h:181

Error extractHeaderAndOffsets(DWARFDataExtractor Data, uint64_t *OffsetPtr)

Extract the table header and the array of offsets.

Definition DWARFListTable.h:168

Error extract(DWARFDataExtractor Data, uint64_t *OffsetPtr)

Extract an entire table, including all list entries.

Definition DWARFListTable.h:205

void dump(DWARFDataExtractor Data, raw_ostream &OS, llvm::function_ref< std::optional< object::SectionedAddress >(uint32_t)> LookupPooledAddress, DIDumpOptions DumpOpts={}) const

Definition DWARFListTable.h:255

DWARFListTableBase(StringRef SectionName, StringRef HeaderString, StringRef ListTypeString)

Definition DWARFListTable.h:158

A base class for lists of entries that are extracted from a particular section, such as range lists o...

Definition DWARFListTable.h:38

ListEntries Entries

Definition DWARFListTable.h:43

const ListEntries & getEntries() const

Definition DWARFListTable.h:46

Error extract(DWARFDataExtractor Data, uint64_t HeaderOffset, uint64_t *OffsetPtr, StringRef SectionName, StringRef ListStringName)

Definition DWARFListTable.h:230

void clear()

Definition DWARFListTable.h:48

bool empty() const

Definition DWARFListTable.h:47

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 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.

FunctionAddr VTableAddr uintptr_t uintptr_t Version

FunctionAddr VTableAddr uintptr_t uintptr_t Data

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.

Definition DWARFListTable.h:27

uint64_t SectionIndex

The index of the section this entry belongs to.

Definition DWARFListTable.h:33

uint8_t EntryKind

The DWARF encoding (DW_RLE_* or DW_LLE_*).

Definition DWARFListTable.h:31

uint64_t Offset

The offset at which the entry is located in the section.

Definition DWARFListTable.h:29