LCOV - code coverage report
Current view: top level - lib/DebugInfo/CodeView - SymbolDumper.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 211 384 54.9 %
Date: 2017-09-14 15:23:50 Functions: 25 48 52.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- SymbolDumper.cpp - CodeView symbol info dumper ----------*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : 
      10             : #include "llvm/DebugInfo/CodeView/SymbolDumper.h"
      11             : #include "llvm/ADT/DenseMap.h"
      12             : #include "llvm/ADT/SmallString.h"
      13             : #include "llvm/DebugInfo/CodeView/CVSymbolVisitor.h"
      14             : #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
      15             : #include "llvm/DebugInfo/CodeView/EnumTables.h"
      16             : #include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
      17             : #include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h"
      18             : #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
      19             : #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h"
      20             : #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h"
      21             : #include "llvm/DebugInfo/CodeView/TypeIndex.h"
      22             : #include "llvm/Support/Error.h"
      23             : #include "llvm/Support/ScopedPrinter.h"
      24             : 
      25             : #include <system_error>
      26             : 
      27             : using namespace llvm;
      28             : using namespace llvm::codeview;
      29             : 
      30             : namespace {
      31             : /// Use this private dumper implementation to keep implementation details about
      32             : /// the visitor out of SymbolDumper.h.
      33         273 : class CVSymbolDumperImpl : public SymbolVisitorCallbacks {
      34             : public:
      35             :   CVSymbolDumperImpl(TypeCollection &Types, SymbolDumpDelegate *ObjDelegate,
      36             :                      ScopedPrinter &W, bool PrintRecordBytes)
      37         273 :       : Types(Types), ObjDelegate(ObjDelegate), W(W),
      38         273 :         PrintRecordBytes(PrintRecordBytes), InFunctionScope(false) {}
      39             : 
      40             : /// CVSymbolVisitor overrides.
      41             : #define SYMBOL_RECORD(EnumName, EnumVal, Name)                                 \
      42             :   Error visitKnownRecord(CVSymbol &CVR, Name &Record) override;
      43             : #define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
      44             : #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
      45             : 
      46             :   Error visitSymbolBegin(CVSymbol &Record) override;
      47             :   Error visitSymbolEnd(CVSymbol &Record) override;
      48             :   Error visitUnknownSymbol(CVSymbol &Record) override;
      49             : 
      50             : private:
      51             :   void printLocalVariableAddrRange(const LocalVariableAddrRange &Range,
      52             :                                    uint32_t RelocationOffset);
      53             :   void printLocalVariableAddrGap(ArrayRef<LocalVariableAddrGap> Gaps);
      54             :   void printTypeIndex(StringRef FieldName, TypeIndex TI);
      55             : 
      56             :   TypeCollection &Types;
      57             :   SymbolDumpDelegate *ObjDelegate;
      58             :   ScopedPrinter &W;
      59             : 
      60             :   bool PrintRecordBytes;
      61             :   bool InFunctionScope;
      62             : };
      63             : }
      64             : 
      65         889 : static StringRef getSymbolKindName(SymbolKind Kind) {
      66         889 :   switch (Kind) {
      67             : #define SYMBOL_RECORD(EnumName, EnumVal, Name)                                 \
      68             :   case EnumName:                                                               \
      69             :     return #Name;
      70             : #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
      71             :   default:
      72             :     break;
      73             :   }
      74           0 :   return "UnknownSym";
      75             : }
      76             : 
      77         108 : void CVSymbolDumperImpl::printLocalVariableAddrRange(
      78             :     const LocalVariableAddrRange &Range, uint32_t RelocationOffset) {
      79         216 :   DictScope S(W, "LocalVariableAddrRange");
      80         108 :   if (ObjDelegate)
      81         108 :     ObjDelegate->printRelocatedField("OffsetStart", RelocationOffset,
      82         108 :                                      Range.OffsetStart);
      83         216 :   W.printHex("ISectStart", Range.ISectStart);
      84         216 :   W.printHex("Range", Range.Range);
      85         108 : }
      86             : 
      87         108 : void CVSymbolDumperImpl::printLocalVariableAddrGap(
      88             :     ArrayRef<LocalVariableAddrGap> Gaps) {
      89         219 :   for (auto &Gap : Gaps) {
      90           6 :     ListScope S(W, "LocalVariableAddrGap");
      91           6 :     W.printHex("GapStartOffset", Gap.GapStartOffset);
      92           6 :     W.printHex("Range", Gap.Range);
      93             :   }
      94         108 : }
      95             : 
      96             : void CVSymbolDumperImpl::printTypeIndex(StringRef FieldName, TypeIndex TI) {
      97         496 :   codeview::printTypeIndex(W, FieldName, TI, Types);
      98             : }
      99             : 
     100         889 : Error CVSymbolDumperImpl::visitSymbolBegin(CVSymbol &CVR) {
     101        1778 :   W.startLine() << getSymbolKindName(CVR.Type);
     102         889 :   W.getOStream() << " {\n";
     103        1778 :   W.indent();
     104        1778 :   W.printEnum("Kind", unsigned(CVR.Type), getSymbolTypeNames());
     105        2667 :   return Error::success();
     106             : }
     107             : 
     108         889 : Error CVSymbolDumperImpl::visitSymbolEnd(CVSymbol &CVR) {
     109         889 :   if (PrintRecordBytes && ObjDelegate)
     110          42 :     ObjDelegate->printBinaryBlockWithRelocs("SymData", CVR.content());
     111             : 
     112        1778 :   W.unindent();
     113        1778 :   W.startLine() << "}\n";
     114        2667 :   return Error::success();
     115             : }
     116             : 
     117           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, BlockSym &Block) {
     118           0 :   StringRef LinkageName;
     119           0 :   W.printHex("PtrParent", Block.Parent);
     120           0 :   W.printHex("PtrEnd", Block.End);
     121           0 :   W.printHex("CodeSize", Block.CodeSize);
     122           0 :   if (ObjDelegate) {
     123           0 :     ObjDelegate->printRelocatedField("CodeOffset", Block.getRelocationOffset(),
     124           0 :                                      Block.CodeOffset, &LinkageName);
     125             :   }
     126           0 :   W.printHex("Segment", Block.Segment);
     127           0 :   W.printString("BlockName", Block.Name);
     128           0 :   W.printString("LinkageName", LinkageName);
     129           0 :   return Error::success();
     130             : }
     131             : 
     132           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, Thunk32Sym &Thunk) {
     133           0 :   W.printNumber("Parent", Thunk.Parent);
     134           0 :   W.printNumber("End", Thunk.End);
     135           0 :   W.printNumber("Next", Thunk.Next);
     136           0 :   W.printNumber("Off", Thunk.Offset);
     137           0 :   W.printNumber("Seg", Thunk.Segment);
     138           0 :   W.printNumber("Len", Thunk.Length);
     139           0 :   W.printEnum("Ordinal", uint8_t(Thunk.Thunk), getThunkOrdinalNames());
     140           0 :   return Error::success();
     141             : }
     142             : 
     143           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     144             :                                            TrampolineSym &Tramp) {
     145           0 :   W.printEnum("Type", uint16_t(Tramp.Type), getTrampolineNames());
     146           0 :   W.printNumber("Size", Tramp.Size);
     147           0 :   W.printNumber("ThunkOff", Tramp.ThunkOffset);
     148           0 :   W.printNumber("TargetOff", Tramp.TargetOffset);
     149           0 :   W.printNumber("ThunkSection", Tramp.ThunkSection);
     150           0 :   W.printNumber("TargetSection", Tramp.TargetSection);
     151           0 :   return Error::success();
     152             : }
     153             : 
     154           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, SectionSym &Section) {
     155           0 :   W.printNumber("SectionNumber", Section.SectionNumber);
     156           0 :   W.printNumber("Alignment", Section.Alignment);
     157           0 :   W.printNumber("Rva", Section.Rva);
     158           0 :   W.printNumber("Length", Section.Length);
     159           0 :   W.printFlags("Characteristics", Section.Characteristics,
     160             :                getImageSectionCharacteristicNames(),
     161             :                COFF::SectionCharacteristics(0x00F00000));
     162             : 
     163           0 :   W.printString("Name", Section.Name);
     164           0 :   return Error::success();
     165             : }
     166             : 
     167           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     168             :                                            CoffGroupSym &CoffGroup) {
     169           0 :   W.printNumber("Size", CoffGroup.Size);
     170           0 :   W.printFlags("Characteristics", CoffGroup.Characteristics,
     171             :                getImageSectionCharacteristicNames(),
     172             :                COFF::SectionCharacteristics(0x00F00000));
     173           0 :   W.printNumber("Offset", CoffGroup.Offset);
     174           0 :   W.printNumber("Segment", CoffGroup.Segment);
     175           0 :   W.printString("Name", CoffGroup.Name);
     176           0 :   return Error::success();
     177             : }
     178             : 
     179           9 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     180             :                                            BPRelativeSym &BPRel) {
     181          18 :   W.printNumber("Offset", BPRel.Offset);
     182           9 :   printTypeIndex("Type", BPRel.Type);
     183          18 :   W.printString("VarName", BPRel.Name);
     184          27 :   return Error::success();
     185             : }
     186             : 
     187          16 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     188             :                                            BuildInfoSym &BuildInfo) {
     189          16 :   printTypeIndex("BuildId", BuildInfo.BuildId);
     190          48 :   return Error::success();
     191             : }
     192             : 
     193           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     194             :                                            CallSiteInfoSym &CallSiteInfo) {
     195           0 :   StringRef LinkageName;
     196           0 :   if (ObjDelegate) {
     197           0 :     ObjDelegate->printRelocatedField("CodeOffset",
     198             :                                      CallSiteInfo.getRelocationOffset(),
     199           0 :                                      CallSiteInfo.CodeOffset, &LinkageName);
     200             :   }
     201           0 :   W.printHex("Segment", CallSiteInfo.Segment);
     202           0 :   printTypeIndex("Type", CallSiteInfo.Type);
     203           0 :   if (!LinkageName.empty())
     204           0 :     W.printString("LinkageName", LinkageName);
     205           0 :   return Error::success();
     206             : }
     207             : 
     208           2 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     209             :                                            EnvBlockSym &EnvBlock) {
     210           4 :   ListScope L(W, "Entries");
     211          20 :   for (auto Entry : EnvBlock.Fields) {
     212          12 :     W.printString(Entry);
     213             :   }
     214           8 :   return Error::success();
     215             : }
     216             : 
     217           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     218             :                                            FileStaticSym &FileStatic) {
     219           0 :   printTypeIndex("Index", FileStatic.Index);
     220           0 :   W.printNumber("ModFilenameOffset", FileStatic.ModFilenameOffset);
     221           0 :   W.printFlags("Flags", uint16_t(FileStatic.Flags), getLocalFlagNames());
     222           0 :   W.printString("Name", FileStatic.Name);
     223           0 :   return Error::success();
     224             : }
     225             : 
     226           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ExportSym &Export) {
     227           0 :   W.printNumber("Ordinal", Export.Ordinal);
     228           0 :   W.printFlags("Flags", uint16_t(Export.Flags), getExportSymFlagNames());
     229           0 :   W.printString("Name", Export.Name);
     230           0 :   return Error::success();
     231             : }
     232             : 
     233           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     234             :                                            Compile2Sym &Compile2) {
     235           0 :   W.printEnum("Language", Compile2.getLanguage(), getSourceLanguageNames());
     236           0 :   W.printFlags("Flags", Compile2.getFlags(), getCompileSym2FlagNames());
     237           0 :   W.printEnum("Machine", unsigned(Compile2.Machine), getCPUTypeNames());
     238           0 :   std::string FrontendVersion;
     239             :   {
     240           0 :     raw_string_ostream Out(FrontendVersion);
     241           0 :     Out << Compile2.VersionFrontendMajor << '.' << Compile2.VersionFrontendMinor
     242           0 :         << '.' << Compile2.VersionFrontendBuild;
     243             :   }
     244           0 :   std::string BackendVersion;
     245             :   {
     246           0 :     raw_string_ostream Out(BackendVersion);
     247           0 :     Out << Compile2.VersionBackendMajor << '.' << Compile2.VersionBackendMinor
     248           0 :         << '.' << Compile2.VersionBackendBuild;
     249             :   }
     250           0 :   W.printString("FrontendVersion", FrontendVersion);
     251           0 :   W.printString("BackendVersion", BackendVersion);
     252           0 :   W.printString("VersionName", Compile2.Version);
     253           0 :   return Error::success();
     254             : }
     255             : 
     256          74 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     257             :                                            Compile3Sym &Compile3) {
     258         148 :   W.printEnum("Language", Compile3.getLanguage(), getSourceLanguageNames());
     259         222 :   W.printFlags("Flags", Compile3.getFlags(), getCompileSym3FlagNames());
     260         148 :   W.printEnum("Machine", unsigned(Compile3.Machine), getCPUTypeNames());
     261         148 :   std::string FrontendVersion;
     262             :   {
     263         148 :     raw_string_ostream Out(FrontendVersion);
     264         296 :     Out << Compile3.VersionFrontendMajor << '.' << Compile3.VersionFrontendMinor
     265         222 :         << '.' << Compile3.VersionFrontendBuild << '.'
     266         148 :         << Compile3.VersionFrontendQFE;
     267             :   }
     268         148 :   std::string BackendVersion;
     269             :   {
     270         148 :     raw_string_ostream Out(BackendVersion);
     271         296 :     Out << Compile3.VersionBackendMajor << '.' << Compile3.VersionBackendMinor
     272         222 :         << '.' << Compile3.VersionBackendBuild << '.'
     273         148 :         << Compile3.VersionBackendQFE;
     274             :   }
     275         148 :   W.printString("FrontendVersion", FrontendVersion);
     276         148 :   W.printString("BackendVersion", BackendVersion);
     277         148 :   W.printString("VersionName", Compile3.Version);
     278         296 :   return Error::success();
     279             : }
     280             : 
     281           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     282             :                                            ConstantSym &Constant) {
     283           0 :   printTypeIndex("Type", Constant.Type);
     284           0 :   W.printNumber("Value", Constant.Value);
     285           0 :   W.printString("Name", Constant.Name);
     286           0 :   return Error::success();
     287             : }
     288             : 
     289          48 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, DataSym &Data) {
     290          48 :   StringRef LinkageName;
     291          48 :   if (ObjDelegate) {
     292         144 :     ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(),
     293          48 :                                      Data.DataOffset, &LinkageName);
     294             :   }
     295          48 :   printTypeIndex("Type", Data.Type);
     296          96 :   W.printString("DisplayName", Data.Name);
     297          48 :   if (!LinkageName.empty())
     298          96 :     W.printString("LinkageName", LinkageName);
     299         144 :   return Error::success();
     300             : }
     301             : 
     302           0 : Error CVSymbolDumperImpl::visitKnownRecord(
     303             :     CVSymbol &CVR,
     304             :     DefRangeFramePointerRelFullScopeSym &DefRangeFramePointerRelFullScope) {
     305           0 :   W.printNumber("Offset", DefRangeFramePointerRelFullScope.Offset);
     306           0 :   return Error::success();
     307             : }
     308             : 
     309           1 : Error CVSymbolDumperImpl::visitKnownRecord(
     310             :     CVSymbol &CVR, DefRangeFramePointerRelSym &DefRangeFramePointerRel) {
     311           2 :   W.printNumber("Offset", DefRangeFramePointerRel.Offset);
     312           2 :   printLocalVariableAddrRange(DefRangeFramePointerRel.Range,
     313             :                               DefRangeFramePointerRel.getRelocationOffset());
     314           2 :   printLocalVariableAddrGap(DefRangeFramePointerRel.Gaps);
     315           3 :   return Error::success();
     316             : }
     317             : 
     318          87 : Error CVSymbolDumperImpl::visitKnownRecord(
     319             :     CVSymbol &CVR, DefRangeRegisterRelSym &DefRangeRegisterRel) {
     320         261 :   W.printNumber("BaseRegister", DefRangeRegisterRel.Hdr.Register);
     321         261 :   W.printBoolean("HasSpilledUDTMember",
     322          87 :                  DefRangeRegisterRel.hasSpilledUDTMember());
     323         261 :   W.printNumber("OffsetInParent", DefRangeRegisterRel.offsetInParent());
     324         261 :   W.printNumber("BasePointerOffset", DefRangeRegisterRel.Hdr.BasePointerOffset);
     325         174 :   printLocalVariableAddrRange(DefRangeRegisterRel.Range,
     326             :                               DefRangeRegisterRel.getRelocationOffset());
     327         174 :   printLocalVariableAddrGap(DefRangeRegisterRel.Gaps);
     328         261 :   return Error::success();
     329             : }
     330             : 
     331          15 : Error CVSymbolDumperImpl::visitKnownRecord(
     332             :     CVSymbol &CVR, DefRangeRegisterSym &DefRangeRegister) {
     333          45 :   W.printNumber("Register", DefRangeRegister.Hdr.Register);
     334          45 :   W.printNumber("MayHaveNoName", DefRangeRegister.Hdr.MayHaveNoName);
     335          30 :   printLocalVariableAddrRange(DefRangeRegister.Range,
     336             :                               DefRangeRegister.getRelocationOffset());
     337          30 :   printLocalVariableAddrGap(DefRangeRegister.Gaps);
     338          45 :   return Error::success();
     339             : }
     340             : 
     341           5 : Error CVSymbolDumperImpl::visitKnownRecord(
     342             :     CVSymbol &CVR, DefRangeSubfieldRegisterSym &DefRangeSubfieldRegister) {
     343          15 :   W.printNumber("Register", DefRangeSubfieldRegister.Hdr.Register);
     344          15 :   W.printNumber("MayHaveNoName", DefRangeSubfieldRegister.Hdr.MayHaveNoName);
     345          15 :   W.printNumber("OffsetInParent", DefRangeSubfieldRegister.Hdr.OffsetInParent);
     346          10 :   printLocalVariableAddrRange(DefRangeSubfieldRegister.Range,
     347             :                               DefRangeSubfieldRegister.getRelocationOffset());
     348          10 :   printLocalVariableAddrGap(DefRangeSubfieldRegister.Gaps);
     349          15 :   return Error::success();
     350             : }
     351             : 
     352           0 : Error CVSymbolDumperImpl::visitKnownRecord(
     353             :     CVSymbol &CVR, DefRangeSubfieldSym &DefRangeSubfield) {
     354           0 :   if (ObjDelegate) {
     355           0 :     DebugStringTableSubsectionRef Strings = ObjDelegate->getStringTable();
     356           0 :     auto ExpectedProgram = Strings.getString(DefRangeSubfield.Program);
     357           0 :     if (!ExpectedProgram) {
     358           0 :       consumeError(ExpectedProgram.takeError());
     359             :       return llvm::make_error<CodeViewError>(
     360           0 :           "String table offset outside of bounds of String Table!");
     361             :     }
     362           0 :     W.printString("Program", *ExpectedProgram);
     363             :   }
     364           0 :   W.printNumber("OffsetInParent", DefRangeSubfield.OffsetInParent);
     365           0 :   printLocalVariableAddrRange(DefRangeSubfield.Range,
     366             :                               DefRangeSubfield.getRelocationOffset());
     367           0 :   printLocalVariableAddrGap(DefRangeSubfield.Gaps);
     368           0 :   return Error::success();
     369             : }
     370             : 
     371           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     372             :                                            DefRangeSym &DefRange) {
     373           0 :   if (ObjDelegate) {
     374           0 :     DebugStringTableSubsectionRef Strings = ObjDelegate->getStringTable();
     375           0 :     auto ExpectedProgram = Strings.getString(DefRange.Program);
     376           0 :     if (!ExpectedProgram) {
     377           0 :       consumeError(ExpectedProgram.takeError());
     378             :       return llvm::make_error<CodeViewError>(
     379           0 :           "String table offset outside of bounds of String Table!");
     380             :     }
     381           0 :     W.printString("Program", *ExpectedProgram);
     382             :   }
     383           0 :   printLocalVariableAddrRange(DefRange.Range, DefRange.getRelocationOffset());
     384           0 :   printLocalVariableAddrGap(DefRange.Gaps);
     385           0 :   return Error::success();
     386             : }
     387             : 
     388           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     389             :                                            FrameCookieSym &FrameCookie) {
     390           0 :   StringRef LinkageName;
     391           0 :   if (ObjDelegate) {
     392           0 :     ObjDelegate->printRelocatedField("CodeOffset",
     393             :                                      FrameCookie.getRelocationOffset(),
     394           0 :                                      FrameCookie.CodeOffset, &LinkageName);
     395             :   }
     396           0 :   W.printHex("Register", FrameCookie.Register);
     397           0 :   W.printEnum("CookieKind", uint16_t(FrameCookie.CookieKind),
     398             :               getFrameCookieKindNames());
     399           0 :   W.printHex("Flags", FrameCookie.Flags);
     400           0 :   return Error::success();
     401             : }
     402             : 
     403          36 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     404             :                                            FrameProcSym &FrameProc) {
     405          72 :   W.printHex("TotalFrameBytes", FrameProc.TotalFrameBytes);
     406          72 :   W.printHex("PaddingFrameBytes", FrameProc.PaddingFrameBytes);
     407          72 :   W.printHex("OffsetToPadding", FrameProc.OffsetToPadding);
     408          72 :   W.printHex("BytesOfCalleeSavedRegisters",
     409             :              FrameProc.BytesOfCalleeSavedRegisters);
     410          72 :   W.printHex("OffsetOfExceptionHandler", FrameProc.OffsetOfExceptionHandler);
     411         108 :   W.printHex("SectionIdOfExceptionHandler",
     412          36 :              FrameProc.SectionIdOfExceptionHandler);
     413          72 :   W.printFlags("Flags", static_cast<uint32_t>(FrameProc.Flags),
     414             :                getFrameProcSymFlagNames());
     415         108 :   return Error::success();
     416             : }
     417             : 
     418           0 : Error CVSymbolDumperImpl::visitKnownRecord(
     419             :     CVSymbol &CVR, HeapAllocationSiteSym &HeapAllocSite) {
     420           0 :   StringRef LinkageName;
     421           0 :   if (ObjDelegate) {
     422           0 :     ObjDelegate->printRelocatedField("CodeOffset",
     423             :                                      HeapAllocSite.getRelocationOffset(),
     424           0 :                                      HeapAllocSite.CodeOffset, &LinkageName);
     425             :   }
     426           0 :   W.printHex("Segment", HeapAllocSite.Segment);
     427           0 :   W.printHex("CallInstructionSize", HeapAllocSite.CallInstructionSize);
     428           0 :   printTypeIndex("Type", HeapAllocSite.Type);
     429           0 :   if (!LinkageName.empty())
     430           0 :     W.printString("LinkageName", LinkageName);
     431           0 :   return Error::success();
     432             : }
     433             : 
     434          26 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     435             :                                            InlineSiteSym &InlineSite) {
     436          52 :   W.printHex("PtrParent", InlineSite.Parent);
     437          52 :   W.printHex("PtrEnd", InlineSite.End);
     438          52 :   printTypeIndex("Inlinee", InlineSite.Inlinee);
     439             : 
     440          52 :   ListScope BinaryAnnotations(W, "BinaryAnnotations");
     441         405 :   for (auto &Annotation : InlineSite.annotations()) {
     442          83 :     switch (Annotation.OpCode) {
     443           0 :     case BinaryAnnotationsOpCode::Invalid:
     444           0 :       W.printString("(Annotation Padding)");
     445           0 :       break;
     446          32 :     case BinaryAnnotationsOpCode::CodeOffset:
     447             :     case BinaryAnnotationsOpCode::ChangeCodeOffset:
     448             :     case BinaryAnnotationsOpCode::ChangeCodeLength:
     449          32 :       W.printHex(Annotation.Name, Annotation.U1);
     450          32 :       break;
     451           0 :     case BinaryAnnotationsOpCode::ChangeCodeOffsetBase:
     452             :     case BinaryAnnotationsOpCode::ChangeLineEndDelta:
     453             :     case BinaryAnnotationsOpCode::ChangeRangeKind:
     454             :     case BinaryAnnotationsOpCode::ChangeColumnStart:
     455             :     case BinaryAnnotationsOpCode::ChangeColumnEnd:
     456           0 :       W.printNumber(Annotation.Name, Annotation.U1);
     457           0 :       break;
     458          12 :     case BinaryAnnotationsOpCode::ChangeLineOffset:
     459             :     case BinaryAnnotationsOpCode::ChangeColumnEndDelta:
     460          12 :       W.printNumber(Annotation.Name, Annotation.S1);
     461          12 :       break;
     462           4 :     case BinaryAnnotationsOpCode::ChangeFile:
     463           4 :       if (ObjDelegate) {
     464          16 :         W.printHex("ChangeFile",
     465           4 :                    ObjDelegate->getFileNameForFileOffset(Annotation.U1),
     466           4 :                    Annotation.U1);
     467             :       } else {
     468           0 :         W.printHex("ChangeFile", Annotation.U1);
     469             :       }
     470             : 
     471             :       break;
     472          32 :     case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset: {
     473          64 :       W.startLine() << "ChangeCodeOffsetAndLineOffset: {CodeOffset: "
     474         128 :                     << W.hex(Annotation.U1) << ", LineOffset: " << Annotation.S1
     475          32 :                     << "}\n";
     476          32 :       break;
     477             :     }
     478           3 :     case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset: {
     479           6 :       W.startLine() << "ChangeCodeLengthAndCodeOffset: {CodeOffset: "
     480           9 :                     << W.hex(Annotation.U2)
     481           6 :                     << ", Length: " << W.hex(Annotation.U1) << "}\n";
     482           3 :       break;
     483             :     }
     484             :     }
     485             :   }
     486         104 :   return Error::success();
     487             : }
     488             : 
     489           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     490             :                                            RegisterSym &Register) {
     491           0 :   printTypeIndex("Type", Register.Index);
     492           0 :   W.printEnum("Seg", uint16_t(Register.Register), getRegisterNames());
     493           0 :   W.printString("Name", Register.Name);
     494           0 :   return Error::success();
     495             : }
     496             : 
     497           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, PublicSym32 &Public) {
     498           0 :   W.printFlags("Flags", uint32_t(Public.Flags), getPublicSymFlagNames());
     499           0 :   W.printNumber("Seg", Public.Segment);
     500           0 :   W.printNumber("Off", Public.Offset);
     501           0 :   W.printString("Name", Public.Name);
     502           0 :   return Error::success();
     503             : }
     504             : 
     505           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ProcRefSym &ProcRef) {
     506           0 :   W.printNumber("SumName", ProcRef.SumName);
     507           0 :   W.printNumber("SymOffset", ProcRef.SymOffset);
     508           0 :   W.printNumber("Mod", ProcRef.Module);
     509           0 :   W.printString("Name", ProcRef.Name);
     510           0 :   return Error::success();
     511             : }
     512             : 
     513           1 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LabelSym &Label) {
     514           1 :   StringRef LinkageName;
     515           1 :   if (ObjDelegate) {
     516           3 :     ObjDelegate->printRelocatedField("CodeOffset", Label.getRelocationOffset(),
     517           1 :                                      Label.CodeOffset, &LinkageName);
     518             :   }
     519           2 :   W.printHex("Segment", Label.Segment);
     520           2 :   W.printHex("Flags", uint8_t(Label.Flags));
     521           2 :   W.printFlags("Flags", uint8_t(Label.Flags), getProcSymFlagNames());
     522           2 :   W.printString("DisplayName", Label.Name);
     523           1 :   if (!LinkageName.empty())
     524           2 :     W.printString("LinkageName", LinkageName);
     525           3 :   return Error::success();
     526             : }
     527             : 
     528         100 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LocalSym &Local) {
     529         100 :   printTypeIndex("Type", Local.Type);
     530         200 :   W.printFlags("Flags", uint16_t(Local.Flags), getLocalFlagNames());
     531         200 :   W.printString("VarName", Local.Name);
     532         300 :   return Error::success();
     533             : }
     534             : 
     535          18 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ObjNameSym &ObjName) {
     536          36 :   W.printHex("Signature", ObjName.Signature);
     537          36 :   W.printString("ObjectName", ObjName.Name);
     538          54 :   return Error::success();
     539             : }
     540             : 
     541         128 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ProcSym &Proc) {
     542         128 :   if (InFunctionScope)
     543             :     return llvm::make_error<CodeViewError>(
     544             :         "Visiting a ProcSym while inside function scope!");
     545             : 
     546         128 :   InFunctionScope = true;
     547             : 
     548         128 :   StringRef LinkageName;
     549         256 :   W.printHex("PtrParent", Proc.Parent);
     550         256 :   W.printHex("PtrEnd", Proc.End);
     551         256 :   W.printHex("PtrNext", Proc.Next);
     552         256 :   W.printHex("CodeSize", Proc.CodeSize);
     553         256 :   W.printHex("DbgStart", Proc.DbgStart);
     554         256 :   W.printHex("DbgEnd", Proc.DbgEnd);
     555         128 :   printTypeIndex("FunctionType", Proc.FunctionType);
     556         128 :   if (ObjDelegate) {
     557         384 :     ObjDelegate->printRelocatedField("CodeOffset", Proc.getRelocationOffset(),
     558         128 :                                      Proc.CodeOffset, &LinkageName);
     559             :   }
     560         256 :   W.printHex("Segment", Proc.Segment);
     561         256 :   W.printFlags("Flags", static_cast<uint8_t>(Proc.Flags),
     562             :                getProcSymFlagNames());
     563         256 :   W.printString("DisplayName", Proc.Name);
     564         128 :   if (!LinkageName.empty())
     565         256 :     W.printString("LinkageName", LinkageName);
     566         384 :   return Error::success();
     567             : }
     568             : 
     569         154 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     570             :                                            ScopeEndSym &ScopeEnd) {
     571         154 :   InFunctionScope = false;
     572         462 :   return Error::success();
     573             : }
     574             : 
     575           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, CallerSym &Caller) {
     576           0 :   ListScope S(W, CVR.kind() == S_CALLEES ? "Callees" : "Callers");
     577           0 :   for (auto FuncID : Caller.Indices)
     578           0 :     printTypeIndex("FuncID", FuncID);
     579           0 :   return Error::success();
     580             : }
     581             : 
     582           5 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     583             :                                            RegRelativeSym &RegRel) {
     584          10 :   W.printHex("Offset", RegRel.Offset);
     585           5 :   printTypeIndex("Type", RegRel.Type);
     586          10 :   W.printEnum("Register", uint16_t(RegRel.Register), getRegisterNames());
     587          10 :   W.printString("VarName", RegRel.Name);
     588          15 :   return Error::success();
     589             : }
     590             : 
     591           1 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     592             :                                            ThreadLocalDataSym &Data) {
     593           1 :   StringRef LinkageName;
     594           1 :   if (ObjDelegate) {
     595           3 :     ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(),
     596           1 :                                      Data.DataOffset, &LinkageName);
     597             :   }
     598           1 :   printTypeIndex("Type", Data.Type);
     599           2 :   W.printString("DisplayName", Data.Name);
     600           1 :   if (!LinkageName.empty())
     601           2 :     W.printString("LinkageName", LinkageName);
     602           3 :   return Error::success();
     603             : }
     604             : 
     605         163 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, UDTSym &UDT) {
     606         163 :   printTypeIndex("Type", UDT.Type);
     607         326 :   W.printString("UDTName", UDT.Name);
     608         489 :   return Error::success();
     609             : }
     610             : 
     611           0 : Error CVSymbolDumperImpl::visitUnknownSymbol(CVSymbol &CVR) {
     612           0 :   W.printNumber("Length", CVR.length());
     613           0 :   return Error::success();
     614             : }
     615             : 
     616           0 : Error CVSymbolDumper::dump(CVRecord<SymbolKind> &Record) {
     617           0 :   SymbolVisitorCallbackPipeline Pipeline;
     618           0 :   SymbolDeserializer Deserializer(ObjDelegate.get(), Container);
     619           0 :   CVSymbolDumperImpl Dumper(Types, ObjDelegate.get(), W, PrintRecordBytes);
     620             : 
     621           0 :   Pipeline.addCallbackToPipeline(Deserializer);
     622           0 :   Pipeline.addCallbackToPipeline(Dumper);
     623           0 :   CVSymbolVisitor Visitor(Pipeline);
     624           0 :   return Visitor.visitSymbolRecord(Record);
     625             : }
     626             : 
     627         273 : Error CVSymbolDumper::dump(const CVSymbolArray &Symbols) {
     628         546 :   SymbolVisitorCallbackPipeline Pipeline;
     629        1092 :   SymbolDeserializer Deserializer(ObjDelegate.get(), Container);
     630        1092 :   CVSymbolDumperImpl Dumper(Types, ObjDelegate.get(), W, PrintRecordBytes);
     631             : 
     632         273 :   Pipeline.addCallbackToPipeline(Deserializer);
     633         273 :   Pipeline.addCallbackToPipeline(Dumper);
     634         273 :   CVSymbolVisitor Visitor(Pipeline);
     635         546 :   return Visitor.visitSymbolStream(Symbols);
     636             : }

Generated by: LCOV version 1.13