LCOV - code coverage report
Current view: top level - lib/DebugInfo/CodeView - SymbolDumper.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 231 369 62.6 %
Date: 2018-06-17 00:07:59 Functions: 28 48 58.3 %
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/SmallString.h"
      12             : #include "llvm/DebugInfo/CodeView/CVSymbolVisitor.h"
      13             : #include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
      14             : #include "llvm/DebugInfo/CodeView/EnumTables.h"
      15             : #include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
      16             : #include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h"
      17             : #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
      18             : #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h"
      19             : #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h"
      20             : #include "llvm/DebugInfo/CodeView/TypeIndex.h"
      21             : #include "llvm/Support/Error.h"
      22             : #include "llvm/Support/ScopedPrinter.h"
      23             : 
      24             : #include <system_error>
      25             : 
      26             : using namespace llvm;
      27             : using namespace llvm::codeview;
      28             : 
      29             : namespace {
      30             : /// Use this private dumper implementation to keep implementation details about
      31             : /// the visitor out of SymbolDumper.h.
      32         350 : class CVSymbolDumperImpl : public SymbolVisitorCallbacks {
      33             : public:
      34             :   CVSymbolDumperImpl(TypeCollection &Types, SymbolDumpDelegate *ObjDelegate,
      35             :                      ScopedPrinter &W, bool PrintRecordBytes)
      36         350 :       : Types(Types), ObjDelegate(ObjDelegate), W(W),
      37         350 :         PrintRecordBytes(PrintRecordBytes), InFunctionScope(false) {}
      38             : 
      39             : /// CVSymbolVisitor overrides.
      40             : #define SYMBOL_RECORD(EnumName, EnumVal, Name)                                 \
      41             :   Error visitKnownRecord(CVSymbol &CVR, Name &Record) override;
      42             : #define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
      43             : #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
      44             : 
      45             :   Error visitSymbolBegin(CVSymbol &Record) override;
      46             :   Error visitSymbolEnd(CVSymbol &Record) override;
      47             :   Error visitUnknownSymbol(CVSymbol &Record) override;
      48             : 
      49             : private:
      50             :   void printLocalVariableAddrRange(const LocalVariableAddrRange &Range,
      51             :                                    uint32_t RelocationOffset);
      52             :   void printLocalVariableAddrGap(ArrayRef<LocalVariableAddrGap> Gaps);
      53             :   void printTypeIndex(StringRef FieldName, TypeIndex TI);
      54             : 
      55             :   TypeCollection &Types;
      56             :   SymbolDumpDelegate *ObjDelegate;
      57             :   ScopedPrinter &W;
      58             : 
      59             :   bool PrintRecordBytes;
      60             :   bool InFunctionScope;
      61             : };
      62             : }
      63             : 
      64        1341 : static StringRef getSymbolKindName(SymbolKind Kind) {
      65        1341 :   switch (Kind) {
      66             : #define SYMBOL_RECORD(EnumName, EnumVal, Name)                                 \
      67             :   case EnumName:                                                               \
      68             :     return #Name;
      69             : #include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
      70             :   default:
      71             :     break;
      72             :   }
      73           0 :   return "UnknownSym";
      74             : }
      75             : 
      76         176 : void CVSymbolDumperImpl::printLocalVariableAddrRange(
      77             :     const LocalVariableAddrRange &Range, uint32_t RelocationOffset) {
      78         352 :   DictScope S(W, "LocalVariableAddrRange");
      79         176 :   if (ObjDelegate)
      80         176 :     ObjDelegate->printRelocatedField("OffsetStart", RelocationOffset,
      81         176 :                                      Range.OffsetStart);
      82         352 :   W.printHex("ISectStart", Range.ISectStart);
      83         352 :   W.printHex("Range", Range.Range);
      84         176 : }
      85             : 
      86         176 : void CVSymbolDumperImpl::printLocalVariableAddrGap(
      87             :     ArrayRef<LocalVariableAddrGap> Gaps) {
      88         186 :   for (auto &Gap : Gaps) {
      89          10 :     ListScope S(W, "LocalVariableAddrGap");
      90          10 :     W.printHex("GapStartOffset", Gap.GapStartOffset);
      91          10 :     W.printHex("Range", Gap.Range);
      92             :   }
      93         176 : }
      94             : 
      95             : void CVSymbolDumperImpl::printTypeIndex(StringRef FieldName, TypeIndex TI) {
      96         792 :   codeview::printTypeIndex(W, FieldName, TI, Types);
      97             : }
      98             : 
      99        1341 : Error CVSymbolDumperImpl::visitSymbolBegin(CVSymbol &CVR) {
     100        2682 :   W.startLine() << getSymbolKindName(CVR.Type);
     101        1341 :   W.getOStream() << " {\n";
     102        1341 :   W.indent();
     103        2682 :   W.printEnum("Kind", unsigned(CVR.Type), getSymbolTypeNames());
     104        1341 :   return Error::success();
     105             : }
     106             : 
     107        1341 : Error CVSymbolDumperImpl::visitSymbolEnd(CVSymbol &CVR) {
     108        1341 :   if (PrintRecordBytes && ObjDelegate)
     109          28 :     ObjDelegate->printBinaryBlockWithRelocs("SymData", CVR.content());
     110             : 
     111        1341 :   W.unindent();
     112        1341 :   W.startLine() << "}\n";
     113        1341 :   return Error::success();
     114             : }
     115             : 
     116          10 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, BlockSym &Block) {
     117          10 :   StringRef LinkageName;
     118          20 :   W.printHex("PtrParent", Block.Parent);
     119          20 :   W.printHex("PtrEnd", Block.End);
     120          20 :   W.printHex("CodeSize", Block.CodeSize);
     121          10 :   if (ObjDelegate) {
     122          20 :     ObjDelegate->printRelocatedField("CodeOffset", Block.getRelocationOffset(),
     123          10 :                                      Block.CodeOffset, &LinkageName);
     124             :   }
     125          20 :   W.printHex("Segment", Block.Segment);
     126          20 :   W.printString("BlockName", Block.Name);
     127          20 :   W.printString("LinkageName", LinkageName);
     128          10 :   return Error::success();
     129             : }
     130             : 
     131           2 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, Thunk32Sym &Thunk) {
     132           4 :   W.printString("Name", Thunk.Name);
     133           4 :   W.printNumber("Parent", Thunk.Parent);
     134           4 :   W.printNumber("End", Thunk.End);
     135           4 :   W.printNumber("Next", Thunk.Next);
     136           4 :   W.printNumber("Off", Thunk.Offset);
     137           4 :   W.printNumber("Seg", Thunk.Segment);
     138           4 :   W.printNumber("Len", Thunk.Length);
     139           4 :   W.printEnum("Ordinal", uint8_t(Thunk.Thunk), getThunkOrdinalNames());
     140           2 :   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           9 :   return Error::success();
     185             : }
     186             : 
     187          19 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     188             :                                            BuildInfoSym &BuildInfo) {
     189          19 :   printTypeIndex("BuildId", BuildInfo.BuildId);
     190          19 :   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          14 :   for (auto Entry : EnvBlock.Fields) {
     212          12 :     W.printString(Entry);
     213             :   }
     214           2 :   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             :   std::string FrontendVersion;
     239             :   {
     240           0 :     raw_string_ostream Out(FrontendVersion);
     241           0 :     Out << Compile2.VersionFrontendMajor << '.' << Compile2.VersionFrontendMinor
     242           0 :         << '.' << Compile2.VersionFrontendBuild;
     243             :   }
     244             :   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          92 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     257             :                                            Compile3Sym &Compile3) {
     258         184 :   W.printEnum("Language", Compile3.getLanguage(), getSourceLanguageNames());
     259         184 :   W.printFlags("Flags", Compile3.getFlags(), getCompileSym3FlagNames());
     260         184 :   W.printEnum("Machine", unsigned(Compile3.Machine), getCPUTypeNames());
     261             :   std::string FrontendVersion;
     262             :   {
     263          92 :     raw_string_ostream Out(FrontendVersion);
     264         184 :     Out << Compile3.VersionFrontendMajor << '.' << Compile3.VersionFrontendMinor
     265          92 :         << '.' << Compile3.VersionFrontendBuild << '.'
     266          92 :         << Compile3.VersionFrontendQFE;
     267             :   }
     268             :   std::string BackendVersion;
     269             :   {
     270          92 :     raw_string_ostream Out(BackendVersion);
     271         184 :     Out << Compile3.VersionBackendMajor << '.' << Compile3.VersionBackendMinor
     272          92 :         << '.' << Compile3.VersionBackendBuild << '.'
     273          92 :         << Compile3.VersionBackendQFE;
     274             :   }
     275          92 :   W.printString("FrontendVersion", FrontendVersion);
     276          92 :   W.printString("BackendVersion", BackendVersion);
     277         184 :   W.printString("VersionName", Compile3.Version);
     278          92 :   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          57 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, DataSym &Data) {
     290          57 :   StringRef LinkageName;
     291          57 :   if (ObjDelegate) {
     292         114 :     ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(),
     293          57 :                                      Data.DataOffset, &LinkageName);
     294             :   }
     295          57 :   printTypeIndex("Type", Data.Type);
     296         114 :   W.printString("DisplayName", Data.Name);
     297          57 :   if (!LinkageName.empty())
     298         114 :     W.printString("LinkageName", LinkageName);
     299          57 :   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           1 :   printLocalVariableAddrGap(DefRangeFramePointerRel.Gaps);
     315           1 :   return Error::success();
     316             : }
     317             : 
     318         133 : Error CVSymbolDumperImpl::visitKnownRecord(
     319             :     CVSymbol &CVR, DefRangeRegisterRelSym &DefRangeRegisterRel) {
     320         399 :   W.printEnum("BaseRegister", uint16_t(DefRangeRegisterRel.Hdr.Register),
     321             :               getRegisterNames());
     322         399 :   W.printBoolean("HasSpilledUDTMember",
     323             :                  DefRangeRegisterRel.hasSpilledUDTMember());
     324         266 :   W.printNumber("OffsetInParent", DefRangeRegisterRel.offsetInParent());
     325         266 :   W.printNumber("BasePointerOffset", DefRangeRegisterRel.Hdr.BasePointerOffset);
     326         266 :   printLocalVariableAddrRange(DefRangeRegisterRel.Range,
     327             :                               DefRangeRegisterRel.getRelocationOffset());
     328         133 :   printLocalVariableAddrGap(DefRangeRegisterRel.Gaps);
     329         133 :   return Error::success();
     330             : }
     331             : 
     332          35 : Error CVSymbolDumperImpl::visitKnownRecord(
     333             :     CVSymbol &CVR, DefRangeRegisterSym &DefRangeRegister) {
     334         105 :   W.printEnum("Register", uint16_t(DefRangeRegister.Hdr.Register),
     335             :               getRegisterNames());
     336         105 :   W.printNumber("MayHaveNoName", DefRangeRegister.Hdr.MayHaveNoName);
     337          70 :   printLocalVariableAddrRange(DefRangeRegister.Range,
     338             :                               DefRangeRegister.getRelocationOffset());
     339          35 :   printLocalVariableAddrGap(DefRangeRegister.Gaps);
     340          35 :   return Error::success();
     341             : }
     342             : 
     343           7 : Error CVSymbolDumperImpl::visitKnownRecord(
     344             :     CVSymbol &CVR, DefRangeSubfieldRegisterSym &DefRangeSubfieldRegister) {
     345          21 :   W.printEnum("Register", uint16_t(DefRangeSubfieldRegister.Hdr.Register),
     346             :               getRegisterNames());
     347          21 :   W.printNumber("MayHaveNoName", DefRangeSubfieldRegister.Hdr.MayHaveNoName);
     348          14 :   W.printNumber("OffsetInParent", DefRangeSubfieldRegister.Hdr.OffsetInParent);
     349          14 :   printLocalVariableAddrRange(DefRangeSubfieldRegister.Range,
     350             :                               DefRangeSubfieldRegister.getRelocationOffset());
     351           7 :   printLocalVariableAddrGap(DefRangeSubfieldRegister.Gaps);
     352           7 :   return Error::success();
     353             : }
     354             : 
     355           0 : Error CVSymbolDumperImpl::visitKnownRecord(
     356             :     CVSymbol &CVR, DefRangeSubfieldSym &DefRangeSubfield) {
     357           0 :   if (ObjDelegate) {
     358           0 :     DebugStringTableSubsectionRef Strings = ObjDelegate->getStringTable();
     359           0 :     auto ExpectedProgram = Strings.getString(DefRangeSubfield.Program);
     360           0 :     if (!ExpectedProgram) {
     361           0 :       consumeError(ExpectedProgram.takeError());
     362             :       return llvm::make_error<CodeViewError>(
     363             :           "String table offset outside of bounds of String Table!");
     364             :     }
     365           0 :     W.printString("Program", *ExpectedProgram);
     366             :   }
     367           0 :   W.printNumber("OffsetInParent", DefRangeSubfield.OffsetInParent);
     368           0 :   printLocalVariableAddrRange(DefRangeSubfield.Range,
     369             :                               DefRangeSubfield.getRelocationOffset());
     370           0 :   printLocalVariableAddrGap(DefRangeSubfield.Gaps);
     371             :   return Error::success();
     372             : }
     373             : 
     374           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     375             :                                            DefRangeSym &DefRange) {
     376           0 :   if (ObjDelegate) {
     377           0 :     DebugStringTableSubsectionRef Strings = ObjDelegate->getStringTable();
     378           0 :     auto ExpectedProgram = Strings.getString(DefRange.Program);
     379           0 :     if (!ExpectedProgram) {
     380           0 :       consumeError(ExpectedProgram.takeError());
     381             :       return llvm::make_error<CodeViewError>(
     382             :           "String table offset outside of bounds of String Table!");
     383             :     }
     384           0 :     W.printString("Program", *ExpectedProgram);
     385             :   }
     386           0 :   printLocalVariableAddrRange(DefRange.Range, DefRange.getRelocationOffset());
     387           0 :   printLocalVariableAddrGap(DefRange.Gaps);
     388             :   return Error::success();
     389             : }
     390             : 
     391           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     392             :                                            FrameCookieSym &FrameCookie) {
     393           0 :   StringRef LinkageName;
     394           0 :   if (ObjDelegate) {
     395           0 :     ObjDelegate->printRelocatedField("CodeOffset",
     396             :                                      FrameCookie.getRelocationOffset(),
     397           0 :                                      FrameCookie.CodeOffset, &LinkageName);
     398             :   }
     399           0 :   W.printEnum("Register", uint16_t(FrameCookie.Register), getRegisterNames());
     400           0 :   W.printEnum("CookieKind", uint16_t(FrameCookie.CookieKind),
     401             :               getFrameCookieKindNames());
     402           0 :   W.printHex("Flags", FrameCookie.Flags);
     403           0 :   return Error::success();
     404             : }
     405             : 
     406          40 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     407             :                                            FrameProcSym &FrameProc) {
     408          80 :   W.printHex("TotalFrameBytes", FrameProc.TotalFrameBytes);
     409          80 :   W.printHex("PaddingFrameBytes", FrameProc.PaddingFrameBytes);
     410          80 :   W.printHex("OffsetToPadding", FrameProc.OffsetToPadding);
     411          80 :   W.printHex("BytesOfCalleeSavedRegisters",
     412             :              FrameProc.BytesOfCalleeSavedRegisters);
     413          80 :   W.printHex("OffsetOfExceptionHandler", FrameProc.OffsetOfExceptionHandler);
     414         120 :   W.printHex("SectionIdOfExceptionHandler",
     415          40 :              FrameProc.SectionIdOfExceptionHandler);
     416          80 :   W.printFlags("Flags", static_cast<uint32_t>(FrameProc.Flags),
     417             :                getFrameProcSymFlagNames());
     418          40 :   return Error::success();
     419             : }
     420             : 
     421           0 : Error CVSymbolDumperImpl::visitKnownRecord(
     422             :     CVSymbol &CVR, HeapAllocationSiteSym &HeapAllocSite) {
     423           0 :   StringRef LinkageName;
     424           0 :   if (ObjDelegate) {
     425           0 :     ObjDelegate->printRelocatedField("CodeOffset",
     426             :                                      HeapAllocSite.getRelocationOffset(),
     427           0 :                                      HeapAllocSite.CodeOffset, &LinkageName);
     428             :   }
     429           0 :   W.printHex("Segment", HeapAllocSite.Segment);
     430           0 :   W.printHex("CallInstructionSize", HeapAllocSite.CallInstructionSize);
     431           0 :   printTypeIndex("Type", HeapAllocSite.Type);
     432           0 :   if (!LinkageName.empty())
     433           0 :     W.printString("LinkageName", LinkageName);
     434           0 :   return Error::success();
     435             : }
     436             : 
     437          29 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     438             :                                            InlineSiteSym &InlineSite) {
     439          58 :   W.printHex("PtrParent", InlineSite.Parent);
     440          58 :   W.printHex("PtrEnd", InlineSite.End);
     441          29 :   printTypeIndex("Inlinee", InlineSite.Inlinee);
     442             : 
     443          58 :   ListScope BinaryAnnotations(W, "BinaryAnnotations");
     444         207 :   for (auto &Annotation : InlineSite.annotations()) {
     445          89 :     switch (Annotation.OpCode) {
     446           0 :     case BinaryAnnotationsOpCode::Invalid:
     447           0 :       W.printString("(Annotation Padding)");
     448           0 :       break;
     449          34 :     case BinaryAnnotationsOpCode::CodeOffset:
     450             :     case BinaryAnnotationsOpCode::ChangeCodeOffset:
     451             :     case BinaryAnnotationsOpCode::ChangeCodeLength:
     452          34 :       W.printHex(Annotation.Name, Annotation.U1);
     453          34 :       break;
     454           0 :     case BinaryAnnotationsOpCode::ChangeCodeOffsetBase:
     455             :     case BinaryAnnotationsOpCode::ChangeLineEndDelta:
     456             :     case BinaryAnnotationsOpCode::ChangeRangeKind:
     457             :     case BinaryAnnotationsOpCode::ChangeColumnStart:
     458             :     case BinaryAnnotationsOpCode::ChangeColumnEnd:
     459           0 :       W.printNumber(Annotation.Name, Annotation.U1);
     460           0 :       break;
     461          13 :     case BinaryAnnotationsOpCode::ChangeLineOffset:
     462             :     case BinaryAnnotationsOpCode::ChangeColumnEndDelta:
     463          13 :       W.printNumber(Annotation.Name, Annotation.S1);
     464          13 :       break;
     465           4 :     case BinaryAnnotationsOpCode::ChangeFile:
     466           4 :       if (ObjDelegate) {
     467          16 :         W.printHex("ChangeFile",
     468           4 :                    ObjDelegate->getFileNameForFileOffset(Annotation.U1),
     469           4 :                    Annotation.U1);
     470             :       } else {
     471           0 :         W.printHex("ChangeFile", Annotation.U1);
     472             :       }
     473             : 
     474             :       break;
     475          33 :     case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset: {
     476          33 :       W.startLine() << "ChangeCodeOffsetAndLineOffset: {CodeOffset: "
     477          99 :                     << W.hex(Annotation.U1) << ", LineOffset: " << Annotation.S1
     478          33 :                     << "}\n";
     479          33 :       break;
     480             :     }
     481           5 :     case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset: {
     482           5 :       W.startLine() << "ChangeCodeLengthAndCodeOffset: {CodeOffset: "
     483          15 :                     << W.hex(Annotation.U2)
     484          10 :                     << ", Length: " << W.hex(Annotation.U1) << "}\n";
     485           5 :       break;
     486             :     }
     487             :     }
     488             :   }
     489          29 :   return Error::success();
     490             : }
     491             : 
     492           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     493             :                                            RegisterSym &Register) {
     494           0 :   printTypeIndex("Type", Register.Index);
     495           0 :   W.printEnum("Seg", uint16_t(Register.Register), getRegisterNames());
     496           0 :   W.printString("Name", Register.Name);
     497           0 :   return Error::success();
     498             : }
     499             : 
     500           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, PublicSym32 &Public) {
     501           0 :   W.printFlags("Flags", uint32_t(Public.Flags), getPublicSymFlagNames());
     502           0 :   W.printNumber("Seg", Public.Segment);
     503           0 :   W.printNumber("Off", Public.Offset);
     504           0 :   W.printString("Name", Public.Name);
     505           0 :   return Error::success();
     506             : }
     507             : 
     508           0 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ProcRefSym &ProcRef) {
     509           0 :   W.printNumber("SumName", ProcRef.SumName);
     510           0 :   W.printNumber("SymOffset", ProcRef.SymOffset);
     511           0 :   W.printNumber("Mod", ProcRef.Module);
     512           0 :   W.printString("Name", ProcRef.Name);
     513           0 :   return Error::success();
     514             : }
     515             : 
     516           1 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LabelSym &Label) {
     517           1 :   StringRef LinkageName;
     518           1 :   if (ObjDelegate) {
     519           2 :     ObjDelegate->printRelocatedField("CodeOffset", Label.getRelocationOffset(),
     520           1 :                                      Label.CodeOffset, &LinkageName);
     521             :   }
     522           2 :   W.printHex("Segment", Label.Segment);
     523           2 :   W.printHex("Flags", uint8_t(Label.Flags));
     524           2 :   W.printFlags("Flags", uint8_t(Label.Flags), getProcSymFlagNames());
     525           2 :   W.printString("DisplayName", Label.Name);
     526           1 :   if (!LinkageName.empty())
     527           2 :     W.printString("LinkageName", LinkageName);
     528           1 :   return Error::success();
     529             : }
     530             : 
     531         163 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LocalSym &Local) {
     532         163 :   printTypeIndex("Type", Local.Type);
     533         326 :   W.printFlags("Flags", uint16_t(Local.Flags), getLocalFlagNames());
     534         326 :   W.printString("VarName", Local.Name);
     535         163 :   return Error::success();
     536             : }
     537             : 
     538          21 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ObjNameSym &ObjName) {
     539          42 :   W.printHex("Signature", ObjName.Signature);
     540          42 :   W.printString("ObjectName", ObjName.Name);
     541          21 :   return Error::success();
     542             : }
     543             : 
     544         165 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ProcSym &Proc) {
     545         165 :   if (InFunctionScope)
     546             :     return llvm::make_error<CodeViewError>(
     547             :         "Visiting a ProcSym while inside function scope!");
     548             : 
     549         165 :   InFunctionScope = true;
     550             : 
     551         165 :   StringRef LinkageName;
     552         330 :   W.printHex("PtrParent", Proc.Parent);
     553         330 :   W.printHex("PtrEnd", Proc.End);
     554         330 :   W.printHex("PtrNext", Proc.Next);
     555         330 :   W.printHex("CodeSize", Proc.CodeSize);
     556         330 :   W.printHex("DbgStart", Proc.DbgStart);
     557         330 :   W.printHex("DbgEnd", Proc.DbgEnd);
     558         165 :   printTypeIndex("FunctionType", Proc.FunctionType);
     559         165 :   if (ObjDelegate) {
     560         330 :     ObjDelegate->printRelocatedField("CodeOffset", Proc.getRelocationOffset(),
     561         165 :                                      Proc.CodeOffset, &LinkageName);
     562             :   }
     563         330 :   W.printHex("Segment", Proc.Segment);
     564         330 :   W.printFlags("Flags", static_cast<uint8_t>(Proc.Flags),
     565             :                getProcSymFlagNames());
     566         330 :   W.printString("DisplayName", Proc.Name);
     567         165 :   if (!LinkageName.empty())
     568         330 :     W.printString("LinkageName", LinkageName);
     569             :   return Error::success();
     570             : }
     571             : 
     572         206 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     573             :                                            ScopeEndSym &ScopeEnd) {
     574         206 :   InFunctionScope = false;
     575         206 :   return Error::success();
     576             : }
     577             : 
     578           4 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, CallerSym &Caller) {
     579          12 :   ListScope S(W, CVR.kind() == S_CALLEES ? "Callees" : "Callers");
     580           9 :   for (auto FuncID : Caller.Indices)
     581           5 :     printTypeIndex("FuncID", FuncID);
     582           4 :   return Error::success();
     583             : }
     584             : 
     585           5 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     586             :                                            RegRelativeSym &RegRel) {
     587          10 :   W.printHex("Offset", RegRel.Offset);
     588           5 :   printTypeIndex("Type", RegRel.Type);
     589          10 :   W.printEnum("Register", uint16_t(RegRel.Register), getRegisterNames());
     590          10 :   W.printString("VarName", RegRel.Name);
     591           5 :   return Error::success();
     592             : }
     593             : 
     594           1 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
     595             :                                            ThreadLocalDataSym &Data) {
     596           1 :   StringRef LinkageName;
     597           1 :   if (ObjDelegate) {
     598           2 :     ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(),
     599           1 :                                      Data.DataOffset, &LinkageName);
     600             :   }
     601           1 :   printTypeIndex("Type", Data.Type);
     602           2 :   W.printString("DisplayName", Data.Name);
     603           1 :   if (!LinkageName.empty())
     604           2 :     W.printString("LinkageName", LinkageName);
     605           1 :   return Error::success();
     606             : }
     607             : 
     608         339 : Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, UDTSym &UDT) {
     609         339 :   printTypeIndex("Type", UDT.Type);
     610         678 :   W.printString("UDTName", UDT.Name);
     611         339 :   return Error::success();
     612             : }
     613             : 
     614           0 : Error CVSymbolDumperImpl::visitUnknownSymbol(CVSymbol &CVR) {
     615           0 :   W.printNumber("Length", CVR.length());
     616           0 :   return Error::success();
     617             : }
     618             : 
     619           0 : Error CVSymbolDumper::dump(CVRecord<SymbolKind> &Record) {
     620             :   SymbolVisitorCallbackPipeline Pipeline;
     621           0 :   SymbolDeserializer Deserializer(ObjDelegate.get(), Container);
     622           0 :   CVSymbolDumperImpl Dumper(Types, ObjDelegate.get(), W, PrintRecordBytes);
     623             : 
     624             :   Pipeline.addCallbackToPipeline(Deserializer);
     625             :   Pipeline.addCallbackToPipeline(Dumper);
     626           0 :   CVSymbolVisitor Visitor(Pipeline);
     627           0 :   return Visitor.visitSymbolRecord(Record);
     628             : }
     629             : 
     630         350 : Error CVSymbolDumper::dump(const CVSymbolArray &Symbols) {
     631             :   SymbolVisitorCallbackPipeline Pipeline;
     632         350 :   SymbolDeserializer Deserializer(ObjDelegate.get(), Container);
     633         350 :   CVSymbolDumperImpl Dumper(Types, ObjDelegate.get(), W, PrintRecordBytes);
     634             : 
     635             :   Pipeline.addCallbackToPipeline(Deserializer);
     636             :   Pipeline.addCallbackToPipeline(Dumper);
     637         350 :   CVSymbolVisitor Visitor(Pipeline);
     638         700 :   return Visitor.visitSymbolStream(Symbols);
     639             : }

Generated by: LCOV version 1.13