LLVM: include/llvm/DebugInfo/LogicalView/Readers/LVCodeViewVisitor.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14#ifndef LLVM_DEBUGINFO_LOGICALVIEW_READERS_CODEVIEWVISITOR_H

15#define LLVM_DEBUGINFO_LOGICALVIEW_READERS_CODEVIEWVISITOR_H

16

27#include

28#include

29

30namespace llvm {

32

33using namespace llvm::codeview;

34

38

46

47

48

49

50

51 bool HasIds = false;

52

53

55

58

59public:

64 Types(Types), Ids(Ids), StreamIdx(StreamIdx), Shared(Shared) {

65 HasIds = &Types != &Ids;

66 }

67

73

83};

84

89

90public:

95 : Reader(Reader), SectionContents(SectionContents) {

96 CoffSection = Obj->getCOFFSection(Section);

97 }

98

101 if (Error Err = Reader.readLongestContiguousChunk(Data)) {

103 return 0;

104 }

105 return Data.data() - SectionContents.bytes_begin();

106 }

107

110

113

116};

117

118class LVElement;

119class LVScope;

120class LVSymbol;

121class LVType;

122

123

132

133

135

137

138 LVSymbol *LocalSymbol = nullptr;

139

140 bool HasIds;

141 bool InFunctionScope = false;

142 bool IsCompileUnit = false;

143

144

145 RegisterId LocalFrameRegister = RegisterId::NONE;

146 RegisterId ParamFrameRegister = RegisterId::NONE;

147

152

153

155 switch (Kind) {

156 case SymbolKind::S_COMPILE2:

157 case SymbolKind::S_COMPILE3:

158 return true;

159 default:

160 return false;

161 }

162 }

163

164

166 if (Register == LocalFrameRegister) {

167 Symbol->setIsVariable();

168 return;

169 }

170 if (Register == ParamFrameRegister) {

171 Symbol->setIsParameter();

172 return;

173 }

174

175 Symbol->setIsVariable();

176 }

177

178public:

184 : Reader(Reader), W(W), LogicalVisitor(LogicalVisitor), Types(Types),

185 Ids(Ids), ObjDelegate(ObjDelegate), Shared(Shared) {

186 HasIds = &Types != &Ids;

187 }

188

193

203 &DefRangeFramePointerRelFullScope) override;

229};

230

231

235

236

237

239 std::shared_ptrllvm::pdb::InputFile TypeServer = nullptr;

240 std::shared_ptr PrecompHeader = nullptr;

241

242 std::shared_ptr Shared;

243

244

245

247 return TypeServer ? TypeServer->types()

248 : (PrecompHeader ? *PrecompHeader : Input.types());

249 }

251 return TypeServer ? TypeServer->ids()

252 : (PrecompHeader ? *PrecompHeader : Input.ids());

253 }

254

255 using LVScopeStack = std::stack<LVScope *>;

256 LVScopeStack ScopeStack;

257 LVScope *ReaderParent = nullptr;

258 LVScope *ReaderScope = nullptr;

259 bool InCompileUnitScope = false;

260

261

262 bool ProcessArgumentList = false;

264 std::string CompileUnitName;

265

266

267 using LVInlineeEntry = std::pair<uint32_t, StringRef>;

268 using LVInlineeInfo = std::map<TypeIndex, LVInlineeEntry>;

269 LVInlineeInfo InlineeInfo;

270

273

282

283public:

286

287

288

293

294

295 void setInput(std::shared_ptrllvm::pdb::InputFile TypeServer) {

296 this->TypeServer = TypeServer;

297 }

298 void setInput(std::shared_ptr PrecompHeader) {

299 this->PrecompHeader = PrecompHeader;

300 }

301

303 InlineeInfo.emplace(std::piecewise_construct, std::forward_as_tuple(TI),

304 std::forward_as_tuple(LineNumber, Filename));

305 }

306

311

315

316

318 LVScope *InlinedFunction,

320

322 ScopeStack.push(ReaderParent);

323 ReaderParent = ReaderScope;

324 ReaderScope = Scope;

325 }

327 ReaderScope = ReaderParent;

328 ReaderParent = ScopeStack.top();

329 ScopeStack.pop();

330 }

332 if (InCompileUnitScope) {

333 InCompileUnitScope = false;

335 }

336 }

338

342

345 CompileUnitName = std::move(Name);

346 }

347

349 LVScope *Parent = nullptr);

351

353

360

363

367

369

421

443

444 template

449 T KnownRecord(RK);

450 if (Error Err = Callbacks.visitKnownMember(Record, KnownRecord))

451 return Err;

453 return Err;

455 }

456

457 template

460 T KnownRecord(RK);

463 return Err;

465 return Err;

467 }

468

473};

474

475}

476}

477

478#endif

OptimizedStructLayoutField Field

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

Provides read only access to a subclass of BinaryStream.

This is an important base class in LLVM.

Lightweight error class with error context and mandatory checking.

static ErrorSuccess success()

Create a success value.

StringRef - Represent a constant reference to a string, i.e.

The instances of the Type class are immutable: once they are created, they are never changed.

Represents a read-only view of a CodeView string table.

Provides amortized O(1) random access to a CodeView type stream.

LF_INDEX - Used to chain two large LF_FIELDLIST or LF_METHODLIST records together.

For method overload sets. LF_METHOD.

static Error deserializeAs(CVType &CVT, T &Record)

void addInlineeInfo(TypeIndex TI, uint32_t LineNumber, StringRef Filename)

Definition LVCodeViewVisitor.h:302

Error visitKnownRecord(CVType &Record, ArgListRecord &Args, TypeIndex TI, LVElement *Element)

LVScope * CurrentScope

Definition LVCodeViewVisitor.h:290

void printRecords(raw_ostream &OS) const

void stopProcessArgumentList()

Definition LVCodeViewVisitor.h:362

void printTypeEnd(CVType &Record)

void closeScope()

Definition LVCodeViewVisitor.h:331

Error visitMemberRecord(CVMemberRecord &Record, TypeVisitorCallbacks &Callbacks, TypeIndex TI, LVElement *Element)

Error visitKnownMember(CVMemberRecord &Record, BaseClassRecord &Base, TypeIndex TI, LVElement *Element)

void printMemberAttributes(MemberAccess Access, MethodKind Kind, MethodOptions Options)

void printMemberEnd(CVMemberRecord &Record)

void setCompileUnitName(std::string Name)

Definition LVCodeViewVisitor.h:344

void popScope()

Definition LVCodeViewVisitor.h:326

LVSymbol * CurrentSymbol

Definition LVCodeViewVisitor.h:291

LVElement * CurrentElement

Definition LVCodeViewVisitor.h:289

void printMemberAttributes(MemberAttributes Attrs)

LVType * CurrentType

Definition LVCodeViewVisitor.h:292

Error inlineSiteAnnotation(LVScope *AbstractFunction, LVScope *InlinedFunction, InlineSiteSym &InlineSite)

LVLogicalVisitor(LVCodeViewReader *Reader, ScopedPrinter &W, llvm::pdb::InputFile &Input)

void printTypeIndex(StringRef FieldName, TypeIndex TI, uint32_t StreamIdx)

Error visitUnknownMember(CVMemberRecord &Record, TypeIndex TI)

void setRoot(LVScope *Root)

Definition LVCodeViewVisitor.h:337

void setInput(std::shared_ptr< LazyRandomTypeCollection > PrecompHeader)

Definition LVCodeViewVisitor.h:298

Error visitKnownMember(CVMemberRecord &Record, TypeVisitorCallbacks &Callbacks, TypeIndex TI, LVElement *Element)

Definition LVCodeViewVisitor.h:445

void pushScope(LVScope *Scope)

Definition LVCodeViewVisitor.h:321

Error visitUnknownType(CVType &Record, TypeIndex TI)

void startProcessArgumentList()

Definition LVCodeViewVisitor.h:361

LVShared * getShared()

Definition LVCodeViewVisitor.h:350

std::string getCompileUnitName()

Definition LVCodeViewVisitor.h:343

void setInput(std::shared_ptr< llvm::pdb::InputFile > TypeServer)

Definition LVCodeViewVisitor.h:295

void addElement(LVScope *Scope, bool IsCompileUnit)

void printTypeBegin(CVType &Record, TypeIndex TI, LVElement *Element, uint32_t StreamIdx)

LVElement * getElement(uint32_t StreamIdx, TypeIndex TI, LVScope *Parent=nullptr)

LVScope * getReaderScope() const

Definition LVCodeViewVisitor.h:352

void printMemberBegin(CVMemberRecord &Record, TypeIndex TI, LVElement *Element, uint32_t StreamIdx)

Error finishVisitation(CVType &Record, TypeIndex TI, LVElement *Element)

Error visitKnownRecord(CVType &Record, TypeIndex TI, LVElement *Element)

Definition LVCodeViewVisitor.h:458

LVElement * createElement(TypeLeafKind Kind)

Definition LVCodeViewVisitor.h:85

LVSymbolVisitorDelegate(LVCodeViewReader *Reader, const llvm::object::SectionRef &Section, const llvm::object::COFFObjectFile *Obj, StringRef SectionContents)

Definition LVCodeViewVisitor.h:91

void getLinkageName(uint32_t RelocOffset, uint32_t Offset, StringRef *RelocSym=nullptr)

uint32_t getRecordOffset(BinaryStreamReader Reader) override

Definition LVCodeViewVisitor.h:99

void printRelocatedField(StringRef Label, uint32_t RelocOffset, uint32_t Offset, StringRef *RelocSym=nullptr)

DebugStringTableSubsectionRef getStringTable() override

StringRef getFileNameForFileOffset(uint32_t FileOffset) override

Error visitSymbolEnd(CVSymbol &Record) override

LVSymbolVisitor(LVCodeViewReader *Reader, ScopedPrinter &W, LVLogicalVisitor *LogicalVisitor, LazyRandomTypeCollection &Types, LazyRandomTypeCollection &Ids, LVSymbolVisitorDelegate *ObjDelegate, LVShared *Shared)

Definition LVCodeViewVisitor.h:179

Error visitKnownRecord(CVSymbol &Record, BlockSym &Block) override

Error visitSymbolBegin(CVSymbol &Record) override

Error visitUnknownSymbol(CVSymbol &Record) override

Action to take on unknown symbols. By default, they are ignored.

Error visitMemberEnd(CVMemberRecord &Record) override

LVTypeVisitor(ScopedPrinter &W, LVLogicalVisitor *LogicalVisitor, LazyRandomTypeCollection &Types, LazyRandomTypeCollection &Ids, uint32_t StreamIdx, LVShared *Shared)

Definition LVCodeViewVisitor.h:60

Error visitUnknownMember(CVMemberRecord &Record) override

Error visitTypeBegin(CVType &Record) override

Paired begin/end actions for all types.

Error visitMemberBegin(CVMemberRecord &Record) override

Error visitKnownRecord(CVType &Record, BuildInfoRecord &Args) override

Error visitUnknownType(CVType &Record) override

Action to take on unknown types. By default, they are ignored.

This is a value type class that represents a single section in the list of sections in the object fil...

This class implements an extremely fast bulk output stream that can only output to a stream.

MethodKind

Part of member attribute flags. (CV_methodprop_e)

CVRecord< TypeLeafKind > CVType

CVRecord< SymbolKind > CVSymbol

MethodOptions

Equivalent to CV_fldattr_t bitfield.

MemberAccess

Source-level access specifier. (CV_access_e)

TypeLeafKind

Duplicate copy of the above enum, but using the official CV names.

TypeRecordKind

Distinguishes individual records in .debug$T or .debug$P section or PDB type stream.

SymbolKind

Duplicate copy of the above enum, but using the official CV names.

This is an optimization pass for GlobalISel generic memory operations.

std::tuple< uint64_t, uint32_t > InlineSite

@ Mod

The access may modify the value stored in memory.

FunctionAddr VTableAddr uintptr_t uintptr_t Data

void consumeError(Error Err)

Consume a Error without doing anything.

Equvalent to CV_fldattr_t in cvinfo.h.