14#ifndef LLVM_DEBUGINFO_LOGICALVIEW_READERS_CODEVIEWVISITOR_H
15#define LLVM_DEBUGINFO_LOGICALVIEW_READERS_CODEVIEWVISITOR_H
31namespace logicalview {
35class LVCodeViewReader;
36class LVLogicalVisitor;
64 Types(
Types), Ids(Ids), StreamIdx(StreamIdx), Shared(Shared) {
65 HasIds = &
Types != &Ids;
95 : Reader(Reader), SectionContents(SectionContents) {
141 bool InFunctionScope =
false;
142 bool IsCompileUnit =
false;
145 RegisterId LocalFrameRegister = RegisterId::NONE;
146 RegisterId ParamFrameRegister = RegisterId::NONE;
156 case SymbolKind::S_COMPILE2:
157 case SymbolKind::S_COMPILE3:
166 if (
Register == LocalFrameRegister) {
167 Symbol->setIsVariable();
170 if (
Register == ParamFrameRegister) {
171 Symbol->setIsParameter();
175 Symbol->setIsVariable();
184 : Reader(Reader), W(W), LogicalVisitor(LogicalVisitor),
Types(
Types),
185 Ids(Ids), ObjDelegate(ObjDelegate), Shared(Shared) {
186 HasIds = &
Types != &Ids;
203 &DefRangeFramePointerRelFullScope)
override;
239 std::shared_ptr<llvm::pdb::InputFile> TypeServer =
nullptr;
240 std::shared_ptr<LazyRandomTypeCollection> PrecompHeader =
nullptr;
242 std::shared_ptr<LVShared> Shared;
247 return TypeServer ? TypeServer->types()
248 : (PrecompHeader ? *PrecompHeader : Input.
types());
251 return TypeServer ? TypeServer->ids()
252 : (PrecompHeader ? *PrecompHeader : Input.
ids());
255 using LVScopeStack = std::stack<LVScope *>;
256 LVScopeStack ScopeStack;
257 LVScope *ReaderParent =
nullptr;
258 LVScope *ReaderScope =
nullptr;
259 bool InCompileUnitScope =
false;
262 bool ProcessArgumentList =
false;
264 std::string CompileUnitName;
267 using LVInlineeEntry = std::pair<uint32_t, StringRef>;
268 using LVInlineeInfo = std::map<TypeIndex, LVInlineeEntry>;
269 LVInlineeInfo InlineeInfo;
295 void setInput(std::shared_ptr<llvm::pdb::InputFile> TypeServer) {
296 this->TypeServer = TypeServer;
298 void setInput(std::shared_ptr<LazyRandomTypeCollection> PrecompHeader) {
299 this->PrecompHeader = PrecompHeader;
303 InlineeInfo.emplace(std::piecewise_construct, std::forward_as_tuple(TI),
304 std::forward_as_tuple(LineNumber,
Filename));
322 ScopeStack.push(ReaderParent);
323 ReaderParent = ReaderScope;
327 ReaderScope = ReaderParent;
328 ReaderParent = ScopeStack.top();
332 if (InCompileUnitScope) {
333 InCompileUnitScope =
false;
345 CompileUnitName = std::move(
Name);
444 template <
typename T>
450 if (
Error Err = Callbacks.visitKnownMember(
Record, KnownRecord))
457 template <
typename T>
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Provides read only access to a subclass of BinaryStream.
Error readLongestContiguousChunk(ArrayRef< uint8_t > &Buffer)
Read as much as possible from the underlying string at the current offset without invoking a copy,...
This is an important base class in LLVM.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Wrapper class representing virtual and physical registers.
StringRef - Represent a constant reference to a string, i.e.
const unsigned char * bytes_begin() const
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)
Error visitKnownRecord(CVType &Record, ArgListRecord &Args, TypeIndex TI, LVElement *Element)
void printRecords(raw_ostream &OS) const
void stopProcessArgumentList()
void printTypeEnd(CVType &Record)
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)
LVElement * CurrentElement
void printMemberAttributes(MemberAttributes Attrs)
Error inlineSiteAnnotation(LVScope *AbstractFunction, LVScope *InlinedFunction, InlineSiteSym &InlineSite)
void printTypeIndex(StringRef FieldName, TypeIndex TI, uint32_t StreamIdx)
Error visitUnknownMember(CVMemberRecord &Record, TypeIndex TI)
void setRoot(LVScope *Root)
void setInput(std::shared_ptr< LazyRandomTypeCollection > PrecompHeader)
Error visitKnownMember(CVMemberRecord &Record, TypeVisitorCallbacks &Callbacks, TypeIndex TI, LVElement *Element)
void pushScope(LVScope *Scope)
Error visitUnknownType(CVType &Record, TypeIndex TI)
void startProcessArgumentList()
std::string getCompileUnitName()
void setInput(std::shared_ptr< llvm::pdb::InputFile > TypeServer)
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
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)
LVElement * createElement(TypeLeafKind Kind)
LVSymbolVisitorDelegate(LVCodeViewReader *Reader, const llvm::object::SectionRef &Section, const llvm::object::COFFObjectFile *Obj, StringRef SectionContents)
void getLinkageName(uint32_t RelocOffset, uint32_t Offset, StringRef *RelocSym=nullptr)
uint32_t getRecordOffset(BinaryStreamReader Reader) override
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)
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)
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.
const coff_section * getCOFFSection(const SectionRef &Section) const
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)
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.
void consumeError(Error Err)
Consume a Error without doing anything.
Equvalent to CV_fldattr_t in cvinfo.h.