10b57cec5SDimitry Andric //===-- SymbolDumper.cpp - CodeView symbol info dumper ----------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/SymbolDumper.h" 100b57cec5SDimitry Andric #include "llvm/ADT/SmallString.h" 110b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/CVSymbolVisitor.h" 120b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h" 130b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/EnumTables.h" 140b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/SymbolDeserializer.h" 150b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h" 160b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/SymbolRecord.h" 170b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h" 180b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h" 190b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/TypeIndex.h" 200b57cec5SDimitry Andric #include "llvm/Support/Error.h" 210b57cec5SDimitry Andric #include "llvm/Support/ScopedPrinter.h" 220b57cec5SDimitry Andric 230b57cec5SDimitry Andric #include <system_error> 240b57cec5SDimitry Andric 250b57cec5SDimitry Andric using namespace llvm; 260b57cec5SDimitry Andric using namespace llvm::codeview; 270b57cec5SDimitry Andric 280b57cec5SDimitry Andric namespace { 290b57cec5SDimitry Andric /// Use this private dumper implementation to keep implementation details about 300b57cec5SDimitry Andric /// the visitor out of SymbolDumper.h. 310b57cec5SDimitry Andric class CVSymbolDumperImpl : public SymbolVisitorCallbacks { 320b57cec5SDimitry Andric public: 330b57cec5SDimitry Andric CVSymbolDumperImpl(TypeCollection &Types, SymbolDumpDelegate *ObjDelegate, 340b57cec5SDimitry Andric ScopedPrinter &W, CPUType CPU, bool PrintRecordBytes) 350b57cec5SDimitry Andric : Types(Types), ObjDelegate(ObjDelegate), W(W), CompilationCPUType(CPU), 360b57cec5SDimitry Andric PrintRecordBytes(PrintRecordBytes), InFunctionScope(false) {} 370b57cec5SDimitry Andric 380b57cec5SDimitry Andric /// CVSymbolVisitor overrides. 390b57cec5SDimitry Andric #define SYMBOL_RECORD(EnumName, EnumVal, Name) \ 400b57cec5SDimitry Andric Error visitKnownRecord(CVSymbol &CVR, Name &Record) override; 410b57cec5SDimitry Andric #define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) 420b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def" 430b57cec5SDimitry Andric 440b57cec5SDimitry Andric Error visitSymbolBegin(CVSymbol &Record) override; 450b57cec5SDimitry Andric Error visitSymbolEnd(CVSymbol &Record) override; 460b57cec5SDimitry Andric Error visitUnknownSymbol(CVSymbol &Record) override; 470b57cec5SDimitry Andric 480b57cec5SDimitry Andric CPUType getCompilationCPUType() const { return CompilationCPUType; } 490b57cec5SDimitry Andric 500b57cec5SDimitry Andric private: 510b57cec5SDimitry Andric void printLocalVariableAddrRange(const LocalVariableAddrRange &Range, 520b57cec5SDimitry Andric uint32_t RelocationOffset); 530b57cec5SDimitry Andric void printLocalVariableAddrGap(ArrayRef<LocalVariableAddrGap> Gaps); 540b57cec5SDimitry Andric void printTypeIndex(StringRef FieldName, TypeIndex TI); 550b57cec5SDimitry Andric 560b57cec5SDimitry Andric TypeCollection &Types; 570b57cec5SDimitry Andric SymbolDumpDelegate *ObjDelegate; 580b57cec5SDimitry Andric ScopedPrinter &W; 590b57cec5SDimitry Andric 600b57cec5SDimitry Andric /// Save the machine or CPU type when dumping a compile symbols. 610b57cec5SDimitry Andric CPUType CompilationCPUType = CPUType::X64; 620b57cec5SDimitry Andric 630b57cec5SDimitry Andric bool PrintRecordBytes; 640b57cec5SDimitry Andric bool InFunctionScope; 650b57cec5SDimitry Andric }; 660b57cec5SDimitry Andric } 670b57cec5SDimitry Andric 680b57cec5SDimitry Andric static StringRef getSymbolKindName(SymbolKind Kind) { 690b57cec5SDimitry Andric switch (Kind) { 700b57cec5SDimitry Andric #define SYMBOL_RECORD(EnumName, EnumVal, Name) \ 710b57cec5SDimitry Andric case EnumName: \ 720b57cec5SDimitry Andric return #Name; 730b57cec5SDimitry Andric #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def" 740b57cec5SDimitry Andric default: 750b57cec5SDimitry Andric break; 760b57cec5SDimitry Andric } 770b57cec5SDimitry Andric return "UnknownSym"; 780b57cec5SDimitry Andric } 790b57cec5SDimitry Andric 800b57cec5SDimitry Andric void CVSymbolDumperImpl::printLocalVariableAddrRange( 810b57cec5SDimitry Andric const LocalVariableAddrRange &Range, uint32_t RelocationOffset) { 820b57cec5SDimitry Andric DictScope S(W, "LocalVariableAddrRange"); 830b57cec5SDimitry Andric if (ObjDelegate) 840b57cec5SDimitry Andric ObjDelegate->printRelocatedField("OffsetStart", RelocationOffset, 850b57cec5SDimitry Andric Range.OffsetStart); 860b57cec5SDimitry Andric W.printHex("ISectStart", Range.ISectStart); 870b57cec5SDimitry Andric W.printHex("Range", Range.Range); 880b57cec5SDimitry Andric } 890b57cec5SDimitry Andric 900b57cec5SDimitry Andric void CVSymbolDumperImpl::printLocalVariableAddrGap( 910b57cec5SDimitry Andric ArrayRef<LocalVariableAddrGap> Gaps) { 920b57cec5SDimitry Andric for (auto &Gap : Gaps) { 930b57cec5SDimitry Andric ListScope S(W, "LocalVariableAddrGap"); 940b57cec5SDimitry Andric W.printHex("GapStartOffset", Gap.GapStartOffset); 950b57cec5SDimitry Andric W.printHex("Range", Gap.Range); 960b57cec5SDimitry Andric } 970b57cec5SDimitry Andric } 980b57cec5SDimitry Andric 990b57cec5SDimitry Andric void CVSymbolDumperImpl::printTypeIndex(StringRef FieldName, TypeIndex TI) { 1000b57cec5SDimitry Andric codeview::printTypeIndex(W, FieldName, TI, Types); 1010b57cec5SDimitry Andric } 1020b57cec5SDimitry Andric 1030b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitSymbolBegin(CVSymbol &CVR) { 1040b57cec5SDimitry Andric W.startLine() << getSymbolKindName(CVR.kind()); 1050b57cec5SDimitry Andric W.getOStream() << " {\n"; 1060b57cec5SDimitry Andric W.indent(); 1070b57cec5SDimitry Andric W.printEnum("Kind", unsigned(CVR.kind()), getSymbolTypeNames()); 1080b57cec5SDimitry Andric return Error::success(); 1090b57cec5SDimitry Andric } 1100b57cec5SDimitry Andric 1110b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitSymbolEnd(CVSymbol &CVR) { 1120b57cec5SDimitry Andric if (PrintRecordBytes && ObjDelegate) 1130b57cec5SDimitry Andric ObjDelegate->printBinaryBlockWithRelocs("SymData", CVR.content()); 1140b57cec5SDimitry Andric 1150b57cec5SDimitry Andric W.unindent(); 1160b57cec5SDimitry Andric W.startLine() << "}\n"; 1170b57cec5SDimitry Andric return Error::success(); 1180b57cec5SDimitry Andric } 1190b57cec5SDimitry Andric 1200b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, BlockSym &Block) { 1210b57cec5SDimitry Andric StringRef LinkageName; 1220b57cec5SDimitry Andric W.printHex("PtrParent", Block.Parent); 1230b57cec5SDimitry Andric W.printHex("PtrEnd", Block.End); 1240b57cec5SDimitry Andric W.printHex("CodeSize", Block.CodeSize); 1250b57cec5SDimitry Andric if (ObjDelegate) { 1260b57cec5SDimitry Andric ObjDelegate->printRelocatedField("CodeOffset", Block.getRelocationOffset(), 1270b57cec5SDimitry Andric Block.CodeOffset, &LinkageName); 1280b57cec5SDimitry Andric } 1290b57cec5SDimitry Andric W.printHex("Segment", Block.Segment); 1300b57cec5SDimitry Andric W.printString("BlockName", Block.Name); 1310b57cec5SDimitry Andric W.printString("LinkageName", LinkageName); 1320b57cec5SDimitry Andric return Error::success(); 1330b57cec5SDimitry Andric } 1340b57cec5SDimitry Andric 1350b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, Thunk32Sym &Thunk) { 1360b57cec5SDimitry Andric W.printString("Name", Thunk.Name); 1370b57cec5SDimitry Andric W.printNumber("Parent", Thunk.Parent); 1380b57cec5SDimitry Andric W.printNumber("End", Thunk.End); 1390b57cec5SDimitry Andric W.printNumber("Next", Thunk.Next); 1400b57cec5SDimitry Andric W.printNumber("Off", Thunk.Offset); 1410b57cec5SDimitry Andric W.printNumber("Seg", Thunk.Segment); 1420b57cec5SDimitry Andric W.printNumber("Len", Thunk.Length); 1430b57cec5SDimitry Andric W.printEnum("Ordinal", uint8_t(Thunk.Thunk), getThunkOrdinalNames()); 1440b57cec5SDimitry Andric return Error::success(); 1450b57cec5SDimitry Andric } 1460b57cec5SDimitry Andric 1470b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 1480b57cec5SDimitry Andric TrampolineSym &Tramp) { 1490b57cec5SDimitry Andric W.printEnum("Type", uint16_t(Tramp.Type), getTrampolineNames()); 1500b57cec5SDimitry Andric W.printNumber("Size", Tramp.Size); 1510b57cec5SDimitry Andric W.printNumber("ThunkOff", Tramp.ThunkOffset); 1520b57cec5SDimitry Andric W.printNumber("TargetOff", Tramp.TargetOffset); 1530b57cec5SDimitry Andric W.printNumber("ThunkSection", Tramp.ThunkSection); 1540b57cec5SDimitry Andric W.printNumber("TargetSection", Tramp.TargetSection); 1550b57cec5SDimitry Andric return Error::success(); 1560b57cec5SDimitry Andric } 1570b57cec5SDimitry Andric 1580b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, SectionSym &Section) { 1590b57cec5SDimitry Andric W.printNumber("SectionNumber", Section.SectionNumber); 1600b57cec5SDimitry Andric W.printNumber("Alignment", Section.Alignment); 1610b57cec5SDimitry Andric W.printNumber("Rva", Section.Rva); 1620b57cec5SDimitry Andric W.printNumber("Length", Section.Length); 1630b57cec5SDimitry Andric W.printFlags("Characteristics", Section.Characteristics, 1640b57cec5SDimitry Andric getImageSectionCharacteristicNames(), 1650b57cec5SDimitry Andric COFF::SectionCharacteristics(0x00F00000)); 1660b57cec5SDimitry Andric 1670b57cec5SDimitry Andric W.printString("Name", Section.Name); 1680b57cec5SDimitry Andric return Error::success(); 1690b57cec5SDimitry Andric } 1700b57cec5SDimitry Andric 1710b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 1720b57cec5SDimitry Andric CoffGroupSym &CoffGroup) { 1730b57cec5SDimitry Andric W.printNumber("Size", CoffGroup.Size); 1740b57cec5SDimitry Andric W.printFlags("Characteristics", CoffGroup.Characteristics, 1750b57cec5SDimitry Andric getImageSectionCharacteristicNames(), 1760b57cec5SDimitry Andric COFF::SectionCharacteristics(0x00F00000)); 1770b57cec5SDimitry Andric W.printNumber("Offset", CoffGroup.Offset); 1780b57cec5SDimitry Andric W.printNumber("Segment", CoffGroup.Segment); 1790b57cec5SDimitry Andric W.printString("Name", CoffGroup.Name); 1800b57cec5SDimitry Andric return Error::success(); 1810b57cec5SDimitry Andric } 1820b57cec5SDimitry Andric 1830b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 1840b57cec5SDimitry Andric BPRelativeSym &BPRel) { 1850b57cec5SDimitry Andric W.printNumber("Offset", BPRel.Offset); 1860b57cec5SDimitry Andric printTypeIndex("Type", BPRel.Type); 1870b57cec5SDimitry Andric W.printString("VarName", BPRel.Name); 1880b57cec5SDimitry Andric return Error::success(); 1890b57cec5SDimitry Andric } 1900b57cec5SDimitry Andric 1910b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 1920b57cec5SDimitry Andric BuildInfoSym &BuildInfo) { 1930b57cec5SDimitry Andric printTypeIndex("BuildId", BuildInfo.BuildId); 1940b57cec5SDimitry Andric return Error::success(); 1950b57cec5SDimitry Andric } 1960b57cec5SDimitry Andric 1970b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 1980b57cec5SDimitry Andric CallSiteInfoSym &CallSiteInfo) { 1990b57cec5SDimitry Andric StringRef LinkageName; 2000b57cec5SDimitry Andric if (ObjDelegate) { 2010b57cec5SDimitry Andric ObjDelegate->printRelocatedField("CodeOffset", 2020b57cec5SDimitry Andric CallSiteInfo.getRelocationOffset(), 2030b57cec5SDimitry Andric CallSiteInfo.CodeOffset, &LinkageName); 2040b57cec5SDimitry Andric } 2050b57cec5SDimitry Andric W.printHex("Segment", CallSiteInfo.Segment); 2060b57cec5SDimitry Andric printTypeIndex("Type", CallSiteInfo.Type); 2070b57cec5SDimitry Andric if (!LinkageName.empty()) 2080b57cec5SDimitry Andric W.printString("LinkageName", LinkageName); 2090b57cec5SDimitry Andric return Error::success(); 2100b57cec5SDimitry Andric } 2110b57cec5SDimitry Andric 2120b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 2130b57cec5SDimitry Andric EnvBlockSym &EnvBlock) { 2140b57cec5SDimitry Andric ListScope L(W, "Entries"); 2150b57cec5SDimitry Andric for (auto Entry : EnvBlock.Fields) { 2160b57cec5SDimitry Andric W.printString(Entry); 2170b57cec5SDimitry Andric } 2180b57cec5SDimitry Andric return Error::success(); 2190b57cec5SDimitry Andric } 2200b57cec5SDimitry Andric 2210b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 2220b57cec5SDimitry Andric FileStaticSym &FileStatic) { 2230b57cec5SDimitry Andric printTypeIndex("Index", FileStatic.Index); 2240b57cec5SDimitry Andric W.printNumber("ModFilenameOffset", FileStatic.ModFilenameOffset); 2250b57cec5SDimitry Andric W.printFlags("Flags", uint16_t(FileStatic.Flags), getLocalFlagNames()); 2260b57cec5SDimitry Andric W.printString("Name", FileStatic.Name); 2270b57cec5SDimitry Andric return Error::success(); 2280b57cec5SDimitry Andric } 2290b57cec5SDimitry Andric 2300b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ExportSym &Export) { 2310b57cec5SDimitry Andric W.printNumber("Ordinal", Export.Ordinal); 2320b57cec5SDimitry Andric W.printFlags("Flags", uint16_t(Export.Flags), getExportSymFlagNames()); 2330b57cec5SDimitry Andric W.printString("Name", Export.Name); 2340b57cec5SDimitry Andric return Error::success(); 2350b57cec5SDimitry Andric } 2360b57cec5SDimitry Andric 2370b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 2380b57cec5SDimitry Andric Compile2Sym &Compile2) { 2390b57cec5SDimitry Andric W.printEnum("Language", Compile2.getLanguage(), getSourceLanguageNames()); 2400b57cec5SDimitry Andric W.printFlags("Flags", Compile2.getFlags(), getCompileSym2FlagNames()); 2410b57cec5SDimitry Andric W.printEnum("Machine", unsigned(Compile2.Machine), getCPUTypeNames()); 2420b57cec5SDimitry Andric CompilationCPUType = Compile2.Machine; 2430b57cec5SDimitry Andric std::string FrontendVersion; 2440b57cec5SDimitry Andric { 2450b57cec5SDimitry Andric raw_string_ostream Out(FrontendVersion); 2460b57cec5SDimitry Andric Out << Compile2.VersionFrontendMajor << '.' << Compile2.VersionFrontendMinor 2470b57cec5SDimitry Andric << '.' << Compile2.VersionFrontendBuild; 2480b57cec5SDimitry Andric } 2490b57cec5SDimitry Andric std::string BackendVersion; 2500b57cec5SDimitry Andric { 2510b57cec5SDimitry Andric raw_string_ostream Out(BackendVersion); 2520b57cec5SDimitry Andric Out << Compile2.VersionBackendMajor << '.' << Compile2.VersionBackendMinor 2530b57cec5SDimitry Andric << '.' << Compile2.VersionBackendBuild; 2540b57cec5SDimitry Andric } 2550b57cec5SDimitry Andric W.printString("FrontendVersion", FrontendVersion); 2560b57cec5SDimitry Andric W.printString("BackendVersion", BackendVersion); 2570b57cec5SDimitry Andric W.printString("VersionName", Compile2.Version); 2580b57cec5SDimitry Andric return Error::success(); 2590b57cec5SDimitry Andric } 2600b57cec5SDimitry Andric 2610b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 2620b57cec5SDimitry Andric Compile3Sym &Compile3) { 2630b57cec5SDimitry Andric W.printEnum("Language", uint8_t(Compile3.getLanguage()), getSourceLanguageNames()); 2640b57cec5SDimitry Andric W.printFlags("Flags", uint32_t(Compile3.getFlags()), 2650b57cec5SDimitry Andric getCompileSym3FlagNames()); 2660b57cec5SDimitry Andric W.printEnum("Machine", unsigned(Compile3.Machine), getCPUTypeNames()); 2670b57cec5SDimitry Andric CompilationCPUType = Compile3.Machine; 2680b57cec5SDimitry Andric std::string FrontendVersion; 2690b57cec5SDimitry Andric { 2700b57cec5SDimitry Andric raw_string_ostream Out(FrontendVersion); 2710b57cec5SDimitry Andric Out << Compile3.VersionFrontendMajor << '.' << Compile3.VersionFrontendMinor 2720b57cec5SDimitry Andric << '.' << Compile3.VersionFrontendBuild << '.' 2730b57cec5SDimitry Andric << Compile3.VersionFrontendQFE; 2740b57cec5SDimitry Andric } 2750b57cec5SDimitry Andric std::string BackendVersion; 2760b57cec5SDimitry Andric { 2770b57cec5SDimitry Andric raw_string_ostream Out(BackendVersion); 2780b57cec5SDimitry Andric Out << Compile3.VersionBackendMajor << '.' << Compile3.VersionBackendMinor 2790b57cec5SDimitry Andric << '.' << Compile3.VersionBackendBuild << '.' 2800b57cec5SDimitry Andric << Compile3.VersionBackendQFE; 2810b57cec5SDimitry Andric } 2820b57cec5SDimitry Andric W.printString("FrontendVersion", FrontendVersion); 2830b57cec5SDimitry Andric W.printString("BackendVersion", BackendVersion); 2840b57cec5SDimitry Andric W.printString("VersionName", Compile3.Version); 2850b57cec5SDimitry Andric return Error::success(); 2860b57cec5SDimitry Andric } 2870b57cec5SDimitry Andric 2880b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 2890b57cec5SDimitry Andric ConstantSym &Constant) { 2900b57cec5SDimitry Andric printTypeIndex("Type", Constant.Type); 2910b57cec5SDimitry Andric W.printNumber("Value", Constant.Value); 2920b57cec5SDimitry Andric W.printString("Name", Constant.Name); 2930b57cec5SDimitry Andric return Error::success(); 2940b57cec5SDimitry Andric } 2950b57cec5SDimitry Andric 2960b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, DataSym &Data) { 2970b57cec5SDimitry Andric StringRef LinkageName; 2980b57cec5SDimitry Andric if (ObjDelegate) { 2990b57cec5SDimitry Andric ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(), 3000b57cec5SDimitry Andric Data.DataOffset, &LinkageName); 3010b57cec5SDimitry Andric } 3020b57cec5SDimitry Andric printTypeIndex("Type", Data.Type); 3030b57cec5SDimitry Andric W.printString("DisplayName", Data.Name); 3040b57cec5SDimitry Andric if (!LinkageName.empty()) 3050b57cec5SDimitry Andric W.printString("LinkageName", LinkageName); 3060b57cec5SDimitry Andric return Error::success(); 3070b57cec5SDimitry Andric } 3080b57cec5SDimitry Andric 3090b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord( 3100b57cec5SDimitry Andric CVSymbol &CVR, 3110b57cec5SDimitry Andric DefRangeFramePointerRelFullScopeSym &DefRangeFramePointerRelFullScope) { 3120b57cec5SDimitry Andric W.printNumber("Offset", DefRangeFramePointerRelFullScope.Offset); 3130b57cec5SDimitry Andric return Error::success(); 3140b57cec5SDimitry Andric } 3150b57cec5SDimitry Andric 3160b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord( 3170b57cec5SDimitry Andric CVSymbol &CVR, DefRangeFramePointerRelSym &DefRangeFramePointerRel) { 318*8bcb0991SDimitry Andric W.printNumber("Offset", DefRangeFramePointerRel.Hdr.Offset); 3190b57cec5SDimitry Andric printLocalVariableAddrRange(DefRangeFramePointerRel.Range, 3200b57cec5SDimitry Andric DefRangeFramePointerRel.getRelocationOffset()); 3210b57cec5SDimitry Andric printLocalVariableAddrGap(DefRangeFramePointerRel.Gaps); 3220b57cec5SDimitry Andric return Error::success(); 3230b57cec5SDimitry Andric } 3240b57cec5SDimitry Andric 3250b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord( 3260b57cec5SDimitry Andric CVSymbol &CVR, DefRangeRegisterRelSym &DefRangeRegisterRel) { 3270b57cec5SDimitry Andric W.printEnum("BaseRegister", uint16_t(DefRangeRegisterRel.Hdr.Register), 3280b57cec5SDimitry Andric getRegisterNames(CompilationCPUType)); 3290b57cec5SDimitry Andric W.printBoolean("HasSpilledUDTMember", 3300b57cec5SDimitry Andric DefRangeRegisterRel.hasSpilledUDTMember()); 3310b57cec5SDimitry Andric W.printNumber("OffsetInParent", DefRangeRegisterRel.offsetInParent()); 3320b57cec5SDimitry Andric W.printNumber("BasePointerOffset", DefRangeRegisterRel.Hdr.BasePointerOffset); 3330b57cec5SDimitry Andric printLocalVariableAddrRange(DefRangeRegisterRel.Range, 3340b57cec5SDimitry Andric DefRangeRegisterRel.getRelocationOffset()); 3350b57cec5SDimitry Andric printLocalVariableAddrGap(DefRangeRegisterRel.Gaps); 3360b57cec5SDimitry Andric return Error::success(); 3370b57cec5SDimitry Andric } 3380b57cec5SDimitry Andric 3390b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord( 3400b57cec5SDimitry Andric CVSymbol &CVR, DefRangeRegisterSym &DefRangeRegister) { 3410b57cec5SDimitry Andric W.printEnum("Register", uint16_t(DefRangeRegister.Hdr.Register), 3420b57cec5SDimitry Andric getRegisterNames(CompilationCPUType)); 3430b57cec5SDimitry Andric W.printNumber("MayHaveNoName", DefRangeRegister.Hdr.MayHaveNoName); 3440b57cec5SDimitry Andric printLocalVariableAddrRange(DefRangeRegister.Range, 3450b57cec5SDimitry Andric DefRangeRegister.getRelocationOffset()); 3460b57cec5SDimitry Andric printLocalVariableAddrGap(DefRangeRegister.Gaps); 3470b57cec5SDimitry Andric return Error::success(); 3480b57cec5SDimitry Andric } 3490b57cec5SDimitry Andric 3500b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord( 3510b57cec5SDimitry Andric CVSymbol &CVR, DefRangeSubfieldRegisterSym &DefRangeSubfieldRegister) { 3520b57cec5SDimitry Andric W.printEnum("Register", uint16_t(DefRangeSubfieldRegister.Hdr.Register), 3530b57cec5SDimitry Andric getRegisterNames(CompilationCPUType)); 3540b57cec5SDimitry Andric W.printNumber("MayHaveNoName", DefRangeSubfieldRegister.Hdr.MayHaveNoName); 3550b57cec5SDimitry Andric W.printNumber("OffsetInParent", DefRangeSubfieldRegister.Hdr.OffsetInParent); 3560b57cec5SDimitry Andric printLocalVariableAddrRange(DefRangeSubfieldRegister.Range, 3570b57cec5SDimitry Andric DefRangeSubfieldRegister.getRelocationOffset()); 3580b57cec5SDimitry Andric printLocalVariableAddrGap(DefRangeSubfieldRegister.Gaps); 3590b57cec5SDimitry Andric return Error::success(); 3600b57cec5SDimitry Andric } 3610b57cec5SDimitry Andric 3620b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord( 3630b57cec5SDimitry Andric CVSymbol &CVR, DefRangeSubfieldSym &DefRangeSubfield) { 3640b57cec5SDimitry Andric if (ObjDelegate) { 3650b57cec5SDimitry Andric DebugStringTableSubsectionRef Strings = ObjDelegate->getStringTable(); 3660b57cec5SDimitry Andric auto ExpectedProgram = Strings.getString(DefRangeSubfield.Program); 3670b57cec5SDimitry Andric if (!ExpectedProgram) { 3680b57cec5SDimitry Andric consumeError(ExpectedProgram.takeError()); 3690b57cec5SDimitry Andric return llvm::make_error<CodeViewError>( 3700b57cec5SDimitry Andric "String table offset outside of bounds of String Table!"); 3710b57cec5SDimitry Andric } 3720b57cec5SDimitry Andric W.printString("Program", *ExpectedProgram); 3730b57cec5SDimitry Andric } 3740b57cec5SDimitry Andric W.printNumber("OffsetInParent", DefRangeSubfield.OffsetInParent); 3750b57cec5SDimitry Andric printLocalVariableAddrRange(DefRangeSubfield.Range, 3760b57cec5SDimitry Andric DefRangeSubfield.getRelocationOffset()); 3770b57cec5SDimitry Andric printLocalVariableAddrGap(DefRangeSubfield.Gaps); 3780b57cec5SDimitry Andric return Error::success(); 3790b57cec5SDimitry Andric } 3800b57cec5SDimitry Andric 3810b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 3820b57cec5SDimitry Andric DefRangeSym &DefRange) { 3830b57cec5SDimitry Andric if (ObjDelegate) { 3840b57cec5SDimitry Andric DebugStringTableSubsectionRef Strings = ObjDelegate->getStringTable(); 3850b57cec5SDimitry Andric auto ExpectedProgram = Strings.getString(DefRange.Program); 3860b57cec5SDimitry Andric if (!ExpectedProgram) { 3870b57cec5SDimitry Andric consumeError(ExpectedProgram.takeError()); 3880b57cec5SDimitry Andric return llvm::make_error<CodeViewError>( 3890b57cec5SDimitry Andric "String table offset outside of bounds of String Table!"); 3900b57cec5SDimitry Andric } 3910b57cec5SDimitry Andric W.printString("Program", *ExpectedProgram); 3920b57cec5SDimitry Andric } 3930b57cec5SDimitry Andric printLocalVariableAddrRange(DefRange.Range, DefRange.getRelocationOffset()); 3940b57cec5SDimitry Andric printLocalVariableAddrGap(DefRange.Gaps); 3950b57cec5SDimitry Andric return Error::success(); 3960b57cec5SDimitry Andric } 3970b57cec5SDimitry Andric 3980b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 3990b57cec5SDimitry Andric FrameCookieSym &FrameCookie) { 4000b57cec5SDimitry Andric StringRef LinkageName; 4010b57cec5SDimitry Andric if (ObjDelegate) { 4020b57cec5SDimitry Andric ObjDelegate->printRelocatedField("CodeOffset", 4030b57cec5SDimitry Andric FrameCookie.getRelocationOffset(), 4040b57cec5SDimitry Andric FrameCookie.CodeOffset, &LinkageName); 4050b57cec5SDimitry Andric } 4060b57cec5SDimitry Andric W.printEnum("Register", uint16_t(FrameCookie.Register), 4070b57cec5SDimitry Andric getRegisterNames(CompilationCPUType)); 4080b57cec5SDimitry Andric W.printEnum("CookieKind", uint16_t(FrameCookie.CookieKind), 4090b57cec5SDimitry Andric getFrameCookieKindNames()); 4100b57cec5SDimitry Andric W.printHex("Flags", FrameCookie.Flags); 4110b57cec5SDimitry Andric return Error::success(); 4120b57cec5SDimitry Andric } 4130b57cec5SDimitry Andric 4140b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 4150b57cec5SDimitry Andric FrameProcSym &FrameProc) { 4160b57cec5SDimitry Andric W.printHex("TotalFrameBytes", FrameProc.TotalFrameBytes); 4170b57cec5SDimitry Andric W.printHex("PaddingFrameBytes", FrameProc.PaddingFrameBytes); 4180b57cec5SDimitry Andric W.printHex("OffsetToPadding", FrameProc.OffsetToPadding); 4190b57cec5SDimitry Andric W.printHex("BytesOfCalleeSavedRegisters", 4200b57cec5SDimitry Andric FrameProc.BytesOfCalleeSavedRegisters); 4210b57cec5SDimitry Andric W.printHex("OffsetOfExceptionHandler", FrameProc.OffsetOfExceptionHandler); 4220b57cec5SDimitry Andric W.printHex("SectionIdOfExceptionHandler", 4230b57cec5SDimitry Andric FrameProc.SectionIdOfExceptionHandler); 4240b57cec5SDimitry Andric W.printFlags("Flags", static_cast<uint32_t>(FrameProc.Flags), 4250b57cec5SDimitry Andric getFrameProcSymFlagNames()); 4260b57cec5SDimitry Andric W.printEnum("LocalFramePtrReg", 4270b57cec5SDimitry Andric uint16_t(FrameProc.getLocalFramePtrReg(CompilationCPUType)), 4280b57cec5SDimitry Andric getRegisterNames(CompilationCPUType)); 4290b57cec5SDimitry Andric W.printEnum("ParamFramePtrReg", 4300b57cec5SDimitry Andric uint16_t(FrameProc.getParamFramePtrReg(CompilationCPUType)), 4310b57cec5SDimitry Andric getRegisterNames(CompilationCPUType)); 4320b57cec5SDimitry Andric return Error::success(); 4330b57cec5SDimitry Andric } 4340b57cec5SDimitry Andric 4350b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord( 4360b57cec5SDimitry Andric CVSymbol &CVR, HeapAllocationSiteSym &HeapAllocSite) { 4370b57cec5SDimitry Andric StringRef LinkageName; 4380b57cec5SDimitry Andric if (ObjDelegate) { 4390b57cec5SDimitry Andric ObjDelegate->printRelocatedField("CodeOffset", 4400b57cec5SDimitry Andric HeapAllocSite.getRelocationOffset(), 4410b57cec5SDimitry Andric HeapAllocSite.CodeOffset, &LinkageName); 4420b57cec5SDimitry Andric } 4430b57cec5SDimitry Andric W.printHex("Segment", HeapAllocSite.Segment); 4440b57cec5SDimitry Andric W.printHex("CallInstructionSize", HeapAllocSite.CallInstructionSize); 4450b57cec5SDimitry Andric printTypeIndex("Type", HeapAllocSite.Type); 4460b57cec5SDimitry Andric if (!LinkageName.empty()) 4470b57cec5SDimitry Andric W.printString("LinkageName", LinkageName); 4480b57cec5SDimitry Andric return Error::success(); 4490b57cec5SDimitry Andric } 4500b57cec5SDimitry Andric 4510b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 4520b57cec5SDimitry Andric InlineSiteSym &InlineSite) { 4530b57cec5SDimitry Andric W.printHex("PtrParent", InlineSite.Parent); 4540b57cec5SDimitry Andric W.printHex("PtrEnd", InlineSite.End); 4550b57cec5SDimitry Andric printTypeIndex("Inlinee", InlineSite.Inlinee); 4560b57cec5SDimitry Andric 4570b57cec5SDimitry Andric ListScope BinaryAnnotations(W, "BinaryAnnotations"); 4580b57cec5SDimitry Andric for (auto &Annotation : InlineSite.annotations()) { 4590b57cec5SDimitry Andric switch (Annotation.OpCode) { 4600b57cec5SDimitry Andric case BinaryAnnotationsOpCode::Invalid: 4610b57cec5SDimitry Andric W.printString("(Annotation Padding)"); 4620b57cec5SDimitry Andric break; 4630b57cec5SDimitry Andric case BinaryAnnotationsOpCode::CodeOffset: 4640b57cec5SDimitry Andric case BinaryAnnotationsOpCode::ChangeCodeOffset: 4650b57cec5SDimitry Andric case BinaryAnnotationsOpCode::ChangeCodeLength: 4660b57cec5SDimitry Andric W.printHex(Annotation.Name, Annotation.U1); 4670b57cec5SDimitry Andric break; 4680b57cec5SDimitry Andric case BinaryAnnotationsOpCode::ChangeCodeOffsetBase: 4690b57cec5SDimitry Andric case BinaryAnnotationsOpCode::ChangeLineEndDelta: 4700b57cec5SDimitry Andric case BinaryAnnotationsOpCode::ChangeRangeKind: 4710b57cec5SDimitry Andric case BinaryAnnotationsOpCode::ChangeColumnStart: 4720b57cec5SDimitry Andric case BinaryAnnotationsOpCode::ChangeColumnEnd: 4730b57cec5SDimitry Andric W.printNumber(Annotation.Name, Annotation.U1); 4740b57cec5SDimitry Andric break; 4750b57cec5SDimitry Andric case BinaryAnnotationsOpCode::ChangeLineOffset: 4760b57cec5SDimitry Andric case BinaryAnnotationsOpCode::ChangeColumnEndDelta: 4770b57cec5SDimitry Andric W.printNumber(Annotation.Name, Annotation.S1); 4780b57cec5SDimitry Andric break; 4790b57cec5SDimitry Andric case BinaryAnnotationsOpCode::ChangeFile: 4800b57cec5SDimitry Andric if (ObjDelegate) { 4810b57cec5SDimitry Andric W.printHex("ChangeFile", 4820b57cec5SDimitry Andric ObjDelegate->getFileNameForFileOffset(Annotation.U1), 4830b57cec5SDimitry Andric Annotation.U1); 4840b57cec5SDimitry Andric } else { 4850b57cec5SDimitry Andric W.printHex("ChangeFile", Annotation.U1); 4860b57cec5SDimitry Andric } 4870b57cec5SDimitry Andric 4880b57cec5SDimitry Andric break; 4890b57cec5SDimitry Andric case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset: { 4900b57cec5SDimitry Andric W.startLine() << "ChangeCodeOffsetAndLineOffset: {CodeOffset: " 4910b57cec5SDimitry Andric << W.hex(Annotation.U1) << ", LineOffset: " << Annotation.S1 4920b57cec5SDimitry Andric << "}\n"; 4930b57cec5SDimitry Andric break; 4940b57cec5SDimitry Andric } 4950b57cec5SDimitry Andric case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset: { 4960b57cec5SDimitry Andric W.startLine() << "ChangeCodeLengthAndCodeOffset: {CodeOffset: " 4970b57cec5SDimitry Andric << W.hex(Annotation.U2) 4980b57cec5SDimitry Andric << ", Length: " << W.hex(Annotation.U1) << "}\n"; 4990b57cec5SDimitry Andric break; 5000b57cec5SDimitry Andric } 5010b57cec5SDimitry Andric } 5020b57cec5SDimitry Andric } 5030b57cec5SDimitry Andric return Error::success(); 5040b57cec5SDimitry Andric } 5050b57cec5SDimitry Andric 5060b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 5070b57cec5SDimitry Andric RegisterSym &Register) { 5080b57cec5SDimitry Andric printTypeIndex("Type", Register.Index); 5090b57cec5SDimitry Andric W.printEnum("Seg", uint16_t(Register.Register), 5100b57cec5SDimitry Andric getRegisterNames(CompilationCPUType)); 5110b57cec5SDimitry Andric W.printString("Name", Register.Name); 5120b57cec5SDimitry Andric return Error::success(); 5130b57cec5SDimitry Andric } 5140b57cec5SDimitry Andric 5150b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, PublicSym32 &Public) { 5160b57cec5SDimitry Andric W.printFlags("Flags", uint32_t(Public.Flags), getPublicSymFlagNames()); 5170b57cec5SDimitry Andric W.printNumber("Seg", Public.Segment); 5180b57cec5SDimitry Andric W.printNumber("Off", Public.Offset); 5190b57cec5SDimitry Andric W.printString("Name", Public.Name); 5200b57cec5SDimitry Andric return Error::success(); 5210b57cec5SDimitry Andric } 5220b57cec5SDimitry Andric 5230b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ProcRefSym &ProcRef) { 5240b57cec5SDimitry Andric W.printNumber("SumName", ProcRef.SumName); 5250b57cec5SDimitry Andric W.printNumber("SymOffset", ProcRef.SymOffset); 5260b57cec5SDimitry Andric W.printNumber("Mod", ProcRef.Module); 5270b57cec5SDimitry Andric W.printString("Name", ProcRef.Name); 5280b57cec5SDimitry Andric return Error::success(); 5290b57cec5SDimitry Andric } 5300b57cec5SDimitry Andric 5310b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LabelSym &Label) { 5320b57cec5SDimitry Andric StringRef LinkageName; 5330b57cec5SDimitry Andric if (ObjDelegate) { 5340b57cec5SDimitry Andric ObjDelegate->printRelocatedField("CodeOffset", Label.getRelocationOffset(), 5350b57cec5SDimitry Andric Label.CodeOffset, &LinkageName); 5360b57cec5SDimitry Andric } 5370b57cec5SDimitry Andric W.printHex("Segment", Label.Segment); 5380b57cec5SDimitry Andric W.printHex("Flags", uint8_t(Label.Flags)); 5390b57cec5SDimitry Andric W.printFlags("Flags", uint8_t(Label.Flags), getProcSymFlagNames()); 5400b57cec5SDimitry Andric W.printString("DisplayName", Label.Name); 5410b57cec5SDimitry Andric if (!LinkageName.empty()) 5420b57cec5SDimitry Andric W.printString("LinkageName", LinkageName); 5430b57cec5SDimitry Andric return Error::success(); 5440b57cec5SDimitry Andric } 5450b57cec5SDimitry Andric 5460b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LocalSym &Local) { 5470b57cec5SDimitry Andric printTypeIndex("Type", Local.Type); 5480b57cec5SDimitry Andric W.printFlags("Flags", uint16_t(Local.Flags), getLocalFlagNames()); 5490b57cec5SDimitry Andric W.printString("VarName", Local.Name); 5500b57cec5SDimitry Andric return Error::success(); 5510b57cec5SDimitry Andric } 5520b57cec5SDimitry Andric 5530b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ObjNameSym &ObjName) { 5540b57cec5SDimitry Andric W.printHex("Signature", ObjName.Signature); 5550b57cec5SDimitry Andric W.printString("ObjectName", ObjName.Name); 5560b57cec5SDimitry Andric return Error::success(); 5570b57cec5SDimitry Andric } 5580b57cec5SDimitry Andric 5590b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ProcSym &Proc) { 5600b57cec5SDimitry Andric if (InFunctionScope) 5610b57cec5SDimitry Andric return llvm::make_error<CodeViewError>( 5620b57cec5SDimitry Andric "Visiting a ProcSym while inside function scope!"); 5630b57cec5SDimitry Andric 5640b57cec5SDimitry Andric InFunctionScope = true; 5650b57cec5SDimitry Andric 5660b57cec5SDimitry Andric StringRef LinkageName; 5670b57cec5SDimitry Andric W.printHex("PtrParent", Proc.Parent); 5680b57cec5SDimitry Andric W.printHex("PtrEnd", Proc.End); 5690b57cec5SDimitry Andric W.printHex("PtrNext", Proc.Next); 5700b57cec5SDimitry Andric W.printHex("CodeSize", Proc.CodeSize); 5710b57cec5SDimitry Andric W.printHex("DbgStart", Proc.DbgStart); 5720b57cec5SDimitry Andric W.printHex("DbgEnd", Proc.DbgEnd); 5730b57cec5SDimitry Andric printTypeIndex("FunctionType", Proc.FunctionType); 5740b57cec5SDimitry Andric if (ObjDelegate) { 5750b57cec5SDimitry Andric ObjDelegate->printRelocatedField("CodeOffset", Proc.getRelocationOffset(), 5760b57cec5SDimitry Andric Proc.CodeOffset, &LinkageName); 5770b57cec5SDimitry Andric } 5780b57cec5SDimitry Andric W.printHex("Segment", Proc.Segment); 5790b57cec5SDimitry Andric W.printFlags("Flags", static_cast<uint8_t>(Proc.Flags), 5800b57cec5SDimitry Andric getProcSymFlagNames()); 5810b57cec5SDimitry Andric W.printString("DisplayName", Proc.Name); 5820b57cec5SDimitry Andric if (!LinkageName.empty()) 5830b57cec5SDimitry Andric W.printString("LinkageName", LinkageName); 5840b57cec5SDimitry Andric return Error::success(); 5850b57cec5SDimitry Andric } 5860b57cec5SDimitry Andric 5870b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 5880b57cec5SDimitry Andric ScopeEndSym &ScopeEnd) { 5890b57cec5SDimitry Andric InFunctionScope = false; 5900b57cec5SDimitry Andric return Error::success(); 5910b57cec5SDimitry Andric } 5920b57cec5SDimitry Andric 5930b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, CallerSym &Caller) { 5940b57cec5SDimitry Andric ListScope S(W, CVR.kind() == S_CALLEES ? "Callees" : "Callers"); 5950b57cec5SDimitry Andric for (auto FuncID : Caller.Indices) 5960b57cec5SDimitry Andric printTypeIndex("FuncID", FuncID); 5970b57cec5SDimitry Andric return Error::success(); 5980b57cec5SDimitry Andric } 5990b57cec5SDimitry Andric 6000b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 6010b57cec5SDimitry Andric RegRelativeSym &RegRel) { 6020b57cec5SDimitry Andric W.printHex("Offset", RegRel.Offset); 6030b57cec5SDimitry Andric printTypeIndex("Type", RegRel.Type); 6040b57cec5SDimitry Andric W.printEnum("Register", uint16_t(RegRel.Register), 6050b57cec5SDimitry Andric getRegisterNames(CompilationCPUType)); 6060b57cec5SDimitry Andric W.printString("VarName", RegRel.Name); 6070b57cec5SDimitry Andric return Error::success(); 6080b57cec5SDimitry Andric } 6090b57cec5SDimitry Andric 6100b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 6110b57cec5SDimitry Andric ThreadLocalDataSym &Data) { 6120b57cec5SDimitry Andric StringRef LinkageName; 6130b57cec5SDimitry Andric if (ObjDelegate) { 6140b57cec5SDimitry Andric ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(), 6150b57cec5SDimitry Andric Data.DataOffset, &LinkageName); 6160b57cec5SDimitry Andric } 6170b57cec5SDimitry Andric printTypeIndex("Type", Data.Type); 6180b57cec5SDimitry Andric W.printString("DisplayName", Data.Name); 6190b57cec5SDimitry Andric if (!LinkageName.empty()) 6200b57cec5SDimitry Andric W.printString("LinkageName", LinkageName); 6210b57cec5SDimitry Andric return Error::success(); 6220b57cec5SDimitry Andric } 6230b57cec5SDimitry Andric 6240b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, UDTSym &UDT) { 6250b57cec5SDimitry Andric printTypeIndex("Type", UDT.Type); 6260b57cec5SDimitry Andric W.printString("UDTName", UDT.Name); 6270b57cec5SDimitry Andric return Error::success(); 6280b57cec5SDimitry Andric } 6290b57cec5SDimitry Andric 6300b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 6310b57cec5SDimitry Andric UsingNamespaceSym &UN) { 6320b57cec5SDimitry Andric W.printString("Namespace", UN.Name); 6330b57cec5SDimitry Andric return Error::success(); 6340b57cec5SDimitry Andric } 6350b57cec5SDimitry Andric 6360b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, 6370b57cec5SDimitry Andric AnnotationSym &Annot) { 6380b57cec5SDimitry Andric W.printHex("Offset", Annot.CodeOffset); 6390b57cec5SDimitry Andric W.printHex("Segment", Annot.Segment); 6400b57cec5SDimitry Andric 6410b57cec5SDimitry Andric ListScope S(W, "Strings"); 6420b57cec5SDimitry Andric for (StringRef Str : Annot.Strings) 6430b57cec5SDimitry Andric W.printString(Str); 6440b57cec5SDimitry Andric 6450b57cec5SDimitry Andric return Error::success(); 6460b57cec5SDimitry Andric } 6470b57cec5SDimitry Andric 6480b57cec5SDimitry Andric Error CVSymbolDumperImpl::visitUnknownSymbol(CVSymbol &CVR) { 6490b57cec5SDimitry Andric W.printNumber("Length", CVR.length()); 6500b57cec5SDimitry Andric return Error::success(); 6510b57cec5SDimitry Andric } 6520b57cec5SDimitry Andric 6530b57cec5SDimitry Andric Error CVSymbolDumper::dump(CVRecord<SymbolKind> &Record) { 6540b57cec5SDimitry Andric SymbolVisitorCallbackPipeline Pipeline; 6550b57cec5SDimitry Andric SymbolDeserializer Deserializer(ObjDelegate.get(), Container); 6560b57cec5SDimitry Andric CVSymbolDumperImpl Dumper(Types, ObjDelegate.get(), W, CompilationCPUType, 6570b57cec5SDimitry Andric PrintRecordBytes); 6580b57cec5SDimitry Andric 6590b57cec5SDimitry Andric Pipeline.addCallbackToPipeline(Deserializer); 6600b57cec5SDimitry Andric Pipeline.addCallbackToPipeline(Dumper); 6610b57cec5SDimitry Andric CVSymbolVisitor Visitor(Pipeline); 6620b57cec5SDimitry Andric auto Err = Visitor.visitSymbolRecord(Record); 6630b57cec5SDimitry Andric CompilationCPUType = Dumper.getCompilationCPUType(); 6640b57cec5SDimitry Andric return Err; 6650b57cec5SDimitry Andric } 6660b57cec5SDimitry Andric 6670b57cec5SDimitry Andric Error CVSymbolDumper::dump(const CVSymbolArray &Symbols) { 6680b57cec5SDimitry Andric SymbolVisitorCallbackPipeline Pipeline; 6690b57cec5SDimitry Andric SymbolDeserializer Deserializer(ObjDelegate.get(), Container); 6700b57cec5SDimitry Andric CVSymbolDumperImpl Dumper(Types, ObjDelegate.get(), W, CompilationCPUType, 6710b57cec5SDimitry Andric PrintRecordBytes); 6720b57cec5SDimitry Andric 6730b57cec5SDimitry Andric Pipeline.addCallbackToPipeline(Deserializer); 6740b57cec5SDimitry Andric Pipeline.addCallbackToPipeline(Dumper); 6750b57cec5SDimitry Andric CVSymbolVisitor Visitor(Pipeline); 6760b57cec5SDimitry Andric auto Err = Visitor.visitSymbolStream(Symbols); 6770b57cec5SDimitry Andric CompilationCPUType = Dumper.getCompilationCPUType(); 6780b57cec5SDimitry Andric return Err; 6790b57cec5SDimitry Andric } 680