24 #include <system_error> 36 : Types(Types), ObjDelegate(ObjDelegate), W(W), CompilationCPUType(CPU),
37 PrintRecordBytes(PrintRecordBytes), InFunctionScope(
false) {}
40 #define SYMBOL_RECORD(EnumName, EnumVal, Name) \ 41 Error visitKnownRecord(CVSymbol &CVR, Name &Record) override; 42 #define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) 43 #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def" 49 CPUType getCompilationCPUType()
const {
return CompilationCPUType; }
64 bool PrintRecordBytes;
71 #define SYMBOL_RECORD(EnumName, EnumVal, Name) \ 74 #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def" 81 void CVSymbolDumperImpl::printLocalVariableAddrRange(
85 ObjDelegate->printRelocatedField(
"OffsetStart", RelocationOffset,
88 W.printHex(
"Range", Range.
Range);
91 void CVSymbolDumperImpl::printLocalVariableAddrGap(
93 for (
auto &Gap : Gaps) {
95 W.printHex(
"GapStartOffset", Gap.GapStartOffset);
96 W.printHex(
"Range", Gap.Range);
106 W.getOStream() <<
" {\n";
113 if (PrintRecordBytes && ObjDelegate)
114 ObjDelegate->printBinaryBlockWithRelocs(
"SymData", CVR.
content());
117 W.startLine() <<
"}\n";
123 W.printHex(
"PtrParent", Block.
Parent);
124 W.printHex(
"PtrEnd", Block.
End);
130 W.printHex(
"Segment", Block.
Segment);
131 W.printString(
"BlockName", Block.
Name);
132 W.printString(
"LinkageName", LinkageName);
137 W.printString(
"Name", Thunk.
Name);
138 W.printNumber(
"Parent", Thunk.
Parent);
139 W.printNumber(
"End", Thunk.
End);
140 W.printNumber(
"Next", Thunk.
Next);
141 W.printNumber(
"Off", Thunk.
Offset);
142 W.printNumber(
"Seg", Thunk.
Segment);
143 W.printNumber(
"Len", Thunk.
Length);
151 W.printNumber(
"Size", Tramp.
Size);
161 W.printNumber(
"Alignment", Section.
Alignment);
162 W.printNumber(
"Rva", Section.
Rva);
163 W.printNumber(
"Length", Section.
Length);
168 W.printString(
"Name", Section.
Name);
174 W.printNumber(
"Size", CoffGroup.
Size);
178 W.printNumber(
"Offset", CoffGroup.
Offset);
179 W.printNumber(
"Segment", CoffGroup.
Segment);
180 W.printString(
"Name", CoffGroup.
Name);
186 W.printNumber(
"Offset", BPRel.
Offset);
188 W.printString(
"VarName", BPRel.
Name);
202 ObjDelegate->printRelocatedField(
"CodeOffset",
206 W.printHex(
"Segment", CallSiteInfo.
Segment);
208 if (!LinkageName.
empty())
209 W.printString(
"LinkageName", LinkageName);
216 for (
auto Entry : EnvBlock.
Fields) {
217 W.printString(Entry);
227 W.printString(
"Name", FileStatic.
Name);
232 W.printNumber(
"Ordinal", Export.
Ordinal);
234 W.printString(
"Name", Export.
Name);
243 CompilationCPUType = Compile2.
Machine;
244 std::string FrontendVersion;
250 std::string BackendVersion;
256 W.printString(
"FrontendVersion", FrontendVersion);
257 W.printString(
"BackendVersion", BackendVersion);
258 W.printString(
"VersionName", Compile2.
Version);
268 CompilationCPUType = Compile3.
Machine;
269 std::string FrontendVersion;
276 std::string BackendVersion;
283 W.printString(
"FrontendVersion", FrontendVersion);
284 W.printString(
"BackendVersion", BackendVersion);
285 W.printString(
"VersionName", Compile3.
Version);
292 W.printNumber(
"Value", Constant.
Value);
293 W.printString(
"Name", Constant.
Name);
304 W.printString(
"DisplayName", Data.
Name);
305 if (!LinkageName.
empty())
306 W.printString(
"LinkageName", LinkageName);
313 W.printNumber(
"Offset", DefRangeFramePointerRelFullScope.
Offset);
319 W.printNumber(
"Offset", DefRangeFramePointerRel.
Offset);
320 printLocalVariableAddrRange(DefRangeFramePointerRel.
Range,
322 printLocalVariableAddrGap(DefRangeFramePointerRel.
Gaps);
328 W.printEnum(
"BaseRegister", uint16_t(DefRangeRegisterRel.
Hdr.
Register),
330 W.printBoolean(
"HasSpilledUDTMember",
334 printLocalVariableAddrRange(DefRangeRegisterRel.
Range,
336 printLocalVariableAddrGap(DefRangeRegisterRel.
Gaps);
342 W.printEnum(
"Register", uint16_t(DefRangeRegister.
Hdr.
Register),
345 printLocalVariableAddrRange(DefRangeRegister.
Range,
347 printLocalVariableAddrGap(DefRangeRegister.
Gaps);
353 W.printEnum(
"Register", uint16_t(DefRangeSubfieldRegister.
Hdr.
Register),
357 printLocalVariableAddrRange(DefRangeSubfieldRegister.
Range,
359 printLocalVariableAddrGap(DefRangeSubfieldRegister.
Gaps);
368 if (!ExpectedProgram) {
370 return llvm::make_error<CodeViewError>(
371 "String table offset outside of bounds of String Table!");
373 W.printString(
"Program", *ExpectedProgram);
376 printLocalVariableAddrRange(DefRangeSubfield.
Range,
378 printLocalVariableAddrGap(DefRangeSubfield.
Gaps);
387 if (!ExpectedProgram) {
389 return llvm::make_error<CodeViewError>(
390 "String table offset outside of bounds of String Table!");
392 W.printString(
"Program", *ExpectedProgram);
395 printLocalVariableAddrGap(DefRange.
Gaps);
403 ObjDelegate->printRelocatedField(
"CodeOffset",
408 W.printEnum(
"CookieKind", uint16_t(FrameCookie.
CookieKind),
410 W.printHex(
"Flags", FrameCookie.
Flags);
419 W.printHex(
"BytesOfCalleeSavedRegisters",
422 W.printHex(
"SectionIdOfExceptionHandler",
424 W.printFlags(
"Flags", static_cast<uint32_t>(FrameProc.
Flags),
426 W.printEnum(
"LocalFramePtrReg",
429 W.printEnum(
"ParamFramePtrReg",
439 ObjDelegate->printRelocatedField(
"CodeOffset",
443 W.printHex(
"Segment", HeapAllocSite.
Segment);
446 if (!LinkageName.
empty())
447 W.printString(
"LinkageName", LinkageName);
453 W.printHex(
"PtrParent", InlineSite.
Parent);
454 W.printHex(
"PtrEnd", InlineSite.
End);
457 ListScope BinaryAnnotations(
W,
"BinaryAnnotations");
458 for (
auto &Annotation : InlineSite.
annotations()) {
459 switch (Annotation.OpCode) {
461 W.printString(
"(Annotation Padding)");
466 W.printHex(Annotation.Name, Annotation.U1);
473 W.printNumber(Annotation.Name, Annotation.U1);
477 W.printNumber(Annotation.Name, Annotation.S1);
481 W.printHex(
"ChangeFile",
482 ObjDelegate->getFileNameForFileOffset(Annotation.U1),
485 W.printHex(
"ChangeFile", Annotation.U1);
490 W.startLine() <<
"ChangeCodeOffsetAndLineOffset: {CodeOffset: " 491 <<
W.hex(Annotation.U1) <<
", LineOffset: " << Annotation.S1
496 W.startLine() <<
"ChangeCodeLengthAndCodeOffset: {CodeOffset: " 497 <<
W.hex(Annotation.U2)
498 <<
", Length: " <<
W.hex(Annotation.U1) <<
"}\n";
510 W.printString(
"Name", Register.
Name);
516 W.printNumber(
"Seg", Public.
Segment);
517 W.printNumber(
"Off", Public.
Offset);
518 W.printString(
"Name", Public.
Name);
523 W.printNumber(
"SumName", ProcRef.
SumName);
524 W.printNumber(
"SymOffset", ProcRef.
SymOffset);
525 W.printNumber(
"Mod", ProcRef.
Module);
526 W.printString(
"Name", ProcRef.
Name);
536 W.printHex(
"Segment", Label.
Segment);
537 W.printHex(
"Flags", uint8_t(Label.
Flags));
539 W.printString(
"DisplayName", Label.
Name);
540 if (!LinkageName.
empty())
541 W.printString(
"LinkageName", LinkageName);
548 W.printString(
"VarName", Local.
Name);
554 W.printString(
"ObjectName", ObjName.
Name);
560 return llvm::make_error<CodeViewError>(
561 "Visiting a ProcSym while inside function scope!");
563 InFunctionScope =
true;
566 W.printHex(
"PtrParent", Proc.
Parent);
567 W.printHex(
"PtrEnd", Proc.
End);
568 W.printHex(
"PtrNext", Proc.
Next);
571 W.printHex(
"DbgEnd", Proc.
DbgEnd);
577 W.printHex(
"Segment", Proc.
Segment);
578 W.printFlags(
"Flags", static_cast<uint8_t>(Proc.
Flags),
580 W.printString(
"DisplayName", Proc.
Name);
581 if (!LinkageName.
empty())
582 W.printString(
"LinkageName", LinkageName);
588 InFunctionScope =
false;
594 for (
auto FuncID : Caller.
Indices)
601 W.printHex(
"Offset", RegRel.
Offset);
604 W.printString(
"VarName", RegRel.
Name);
616 W.printString(
"DisplayName", Data.
Name);
617 if (!LinkageName.
empty())
618 W.printString(
"LinkageName", LinkageName);
624 W.printString(
"UDTName", UDT.
Name);
630 W.printString(
"Namespace", UN.
Name);
634 Error CVSymbolDumperImpl::visitUnknownSymbol(
CVSymbol &CVR) {
635 W.printNumber(
"Length", CVR.
length());
642 CVSymbolDumperImpl Dumper(Types, ObjDelegate.get(),
W, CompilationCPUType,
649 CompilationCPUType = Dumper.getCompilationCPUType();
656 CVSymbolDumperImpl Dumper(Types, ObjDelegate.get(),
W, CompilationCPUType,
663 CompilationCPUType = Dumper.getCompilationCPUType();
uint32_t ModFilenameOffset
uint32_t getRelocationOffset() const
uint32_t OffsetOfExceptionHandler
This class represents lattice values for constants.
uint32_t getRelocationOffset() const
ArrayRef< EnumEntry< uint16_t > > getExportSymFlagNames()
ArrayRef< EnumEntry< uint32_t > > getCompileSym3FlagNames()
CompileSym3Flags getFlags() const
uint16_t SectionIdOfExceptionHandler
FrameProcedureOptions Flags
uint32_t BytesOfCalleeSavedRegisters
uint32_t getRelocationOffset() const
ArrayRef< EnumEntry< uint16_t > > getRegisterNames()
Error visitSymbolRecord(CVSymbol &Record)
uint16_t VersionBackendMinor
Expected< StringRef > getString(uint32_t Offset) const
uint16_t VersionFrontendMajor
ArrayRef< EnumEntry< uint32_t > > getPublicSymFlagNames()
std::vector< LocalVariableAddrGap > Gaps
uint16_t VersionBackendBuild
std::vector< LocalVariableAddrGap > Gaps
RegisterId getParamFramePtrReg(CPUType CPU) const
Extract the register this frame uses to refer to parameters.
uint16_t VersionFrontendMajor
ArrayRef< EnumEntry< uint8_t > > getThunkOrdinalNames()
uint16_t VersionFrontendQFE
ArrayRef< uint8_t > content() const
uint16_t VersionBackendMajor
uint8_t getLanguage() const
ArrayRef< EnumEntry< uint8_t > > getFrameCookieKindNames()
static Error visitKnownRecord(CVSymbol &Record, SymbolVisitorCallbacks &Callbacks)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
uint16_t CallInstructionSize
uint32_t getRelocationOffset() const
ArrayRef< EnumEntry< COFF::SectionCharacteristics > > getImageSectionCharacteristicNames()
uint32_t getRelocationOffset() const
uint32_t getRelocationOffset() const
static StringRef getSymbolKindName(SymbolKind Kind)
uint16_t VersionFrontendBuild
ArrayRef< EnumEntry< unsigned > > getCPUTypeNames()
void printTypeIndex(ScopedPrinter &Printer, StringRef FieldName, TypeIndex TI, TypeCollection &Types)
std::vector< LocalVariableAddrGap > Gaps
void addCallbackToPipeline(SymbolVisitorCallbacks &Callbacks)
This is an important base class in LLVM.
std::vector< StringRef > Fields
LocalVariableAddrRange Range
LocalVariableAddrRange Range
uint32_t getFlags() const
uint16_t VersionBackendMajor
std::vector< TypeIndex > Indices
LocalVariableAddrRange Range
std::vector< LocalVariableAddrGap > Gaps
void consumeError(Error Err)
Consume a Error without doing anything.
bool hasSpilledUDTMember() const
LocalVariableAddrRange Range
uint16_t VersionFrontendMinor
uint16_t VersionFrontendMinor
Error dump(CVRecord< SymbolKind > &Record)
Dumps one type record.
ArrayRef< EnumEntry< uint32_t > > getFrameProcSymFlagNames()
static ErrorSuccess success()
Create a success value.
uint32_t getRelocationOffset() const
ArrayRef< EnumEntry< SymbolKind > > getSymbolTypeNames()
LocalVariableAddrRange Range
uint16_t VersionBackendMinor
CPUType
These values correspond to the CV_CPU_TYPE_e enumeration, and are documented here: https://msdn...
Promote Memory to Register
ArrayRef< EnumEntry< uint8_t > > getProcSymFlagNames()
LocalVariableAddrRange Range
ArrayRef< EnumEntry< SourceLanguage > > getSourceLanguageNames()
uint32_t PaddingFrameBytes
ArrayRef< EnumEntry< uint32_t > > getCompileSym2FlagNames()
Represents a read-only view of a CodeView string table.
ArrayRef< EnumEntry< uint16_t > > getTrampolineNames()
Error visitSymbolStream(const CVSymbolArray &Symbols)
std::vector< LocalVariableAddrGap > Gaps
uint32_t getRelocationOffset() const
uint16_t VersionBackendBuild
SourceLanguage getLanguage() const
uint32_t getRelocationOffset() const
RegisterId getLocalFramePtrReg(CPUType CPU) const
Extract the register this frame uses to refer to local variables.
SymbolKind
Duplicate copy of the above enum, but using the official CV names.
uint32_t getRelocationOffset() const
iterator_range< BinaryAnnotationIterator > annotations() const
std::vector< LocalVariableAddrGap > Gaps
uint16_t VersionBackendQFE
A raw_ostream that writes to an std::string.
Lightweight error class with error context and mandatory checking.
ArrayRef< EnumEntry< uint16_t > > getLocalFlagNames()
uint32_t getRelocationOffset() const
StringRef - Represent a constant reference to a string, i.e.
uint32_t getRelocationOffset() const
FrameCookieKind CookieKind
uint16_t offsetInParent() const
uint32_t getRelocationOffset() const
uint32_t getRelocationOffset() const
uint16_t VersionFrontendBuild