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