blob: 5395e4349b28dff004a9e344e51ef5bd61600a2c [file] [log] [blame]
Zachary Turneraaad5742016-05-23 23:41:13 +00001//===-- 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"
Zachary Turner1dfcf8d2017-05-19 05:57:45 +000014#include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
Zachary Turner93839cb2016-06-02 05:07:49 +000015#include "llvm/DebugInfo/CodeView/EnumTables.h"
Zachary Turner2d5c2cd2017-05-03 17:11:11 +000016#include "llvm/DebugInfo/CodeView/StringTable.h"
Zachary Turner0d840742016-10-07 21:34:46 +000017#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
Zachary Turneraaad5742016-05-23 23:41:13 +000018#include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h"
19#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
Zachary Turner0d840742016-10-07 21:34:46 +000020#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h"
21#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h"
Zachary Turneraaad5742016-05-23 23:41:13 +000022#include "llvm/DebugInfo/CodeView/TypeIndex.h"
Zachary Turner0d840742016-10-07 21:34:46 +000023#include "llvm/Support/Error.h"
Zachary Turneraaad5742016-05-23 23:41:13 +000024#include "llvm/Support/ScopedPrinter.h"
25
26#include <system_error>
27
28using namespace llvm;
29using namespace llvm::codeview;
30
Zachary Turneraaad5742016-05-23 23:41:13 +000031namespace {
Zachary Turneraaad5742016-05-23 23:41:13 +000032/// Use this private dumper implementation to keep implementation details about
33/// the visitor out of SymbolDumper.h.
Zachary Turner0d840742016-10-07 21:34:46 +000034class CVSymbolDumperImpl : public SymbolVisitorCallbacks {
Zachary Turneraaad5742016-05-23 23:41:13 +000035public:
Zachary Turner1dfcf8d2017-05-19 05:57:45 +000036 CVSymbolDumperImpl(TypeDatabase &TypeDB, SymbolDumpDelegate *ObjDelegate,
Zachary Turner3e78e2d2016-05-24 00:06:04 +000037 ScopedPrinter &W, bool PrintRecordBytes)
Zachary Turner1dfcf8d2017-05-19 05:57:45 +000038 : TypeDB(TypeDB), ObjDelegate(ObjDelegate), W(W),
Zachary Turner0d840742016-10-07 21:34:46 +000039 PrintRecordBytes(PrintRecordBytes), InFunctionScope(false) {}
Zachary Turneraaad5742016-05-23 23:41:13 +000040
41/// CVSymbolVisitor overrides.
42#define SYMBOL_RECORD(EnumName, EnumVal, Name) \
Zachary Turner0d840742016-10-07 21:34:46 +000043 Error visitKnownRecord(CVSymbol &CVR, Name &Record) override;
Zachary Turneraaad5742016-05-23 23:41:13 +000044#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
45#include "llvm/DebugInfo/CodeView/CVSymbolTypes.def"
46
Zachary Turner0d840742016-10-07 21:34:46 +000047 Error visitSymbolBegin(CVSymbol &Record) override;
48 Error visitSymbolEnd(CVSymbol &Record) override;
49 Error visitUnknownSymbol(CVSymbol &Record) override;
Zachary Turneraaad5742016-05-23 23:41:13 +000050
51private:
52 void printLocalVariableAddrRange(const LocalVariableAddrRange &Range,
53 uint32_t RelocationOffset);
54 void printLocalVariableAddrGap(ArrayRef<LocalVariableAddrGap> Gaps);
Zachary Turner629cb7d2017-01-11 23:24:22 +000055 void printTypeIndex(StringRef FieldName, TypeIndex TI);
Zachary Turneraaad5742016-05-23 23:41:13 +000056
Zachary Turner1dfcf8d2017-05-19 05:57:45 +000057 TypeDatabase &TypeDB;
Zachary Turneraaad5742016-05-23 23:41:13 +000058 SymbolDumpDelegate *ObjDelegate;
59 ScopedPrinter &W;
60
61 bool PrintRecordBytes;
62 bool InFunctionScope;
63};
64}
65
66void CVSymbolDumperImpl::printLocalVariableAddrRange(
67 const LocalVariableAddrRange &Range, uint32_t RelocationOffset) {
68 DictScope S(W, "LocalVariableAddrRange");
69 if (ObjDelegate)
70 ObjDelegate->printRelocatedField("OffsetStart", RelocationOffset,
71 Range.OffsetStart);
72 W.printHex("ISectStart", Range.ISectStart);
73 W.printHex("Range", Range.Range);
74}
75
76void CVSymbolDumperImpl::printLocalVariableAddrGap(
77 ArrayRef<LocalVariableAddrGap> Gaps) {
78 for (auto &Gap : Gaps) {
79 ListScope S(W, "LocalVariableAddrGap");
80 W.printHex("GapStartOffset", Gap.GapStartOffset);
81 W.printHex("Range", Gap.Range);
82 }
83}
84
Zachary Turner629cb7d2017-01-11 23:24:22 +000085void CVSymbolDumperImpl::printTypeIndex(StringRef FieldName, TypeIndex TI) {
Zachary Turner1dfcf8d2017-05-19 05:57:45 +000086 CVTypeDumper::printTypeIndex(W, FieldName, TI, TypeDB);
Zachary Turner629cb7d2017-01-11 23:24:22 +000087}
88
Zachary Turner0d840742016-10-07 21:34:46 +000089Error CVSymbolDumperImpl::visitSymbolBegin(CVSymbol &CVR) {
90 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +000091}
92
Zachary Turner0d840742016-10-07 21:34:46 +000093Error CVSymbolDumperImpl::visitSymbolEnd(CVSymbol &CVR) {
94 if (PrintRecordBytes && ObjDelegate)
95 ObjDelegate->printBinaryBlockWithRelocs("SymData", CVR.content());
96 return Error::success();
97}
98
99Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, BlockSym &Block) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000100 DictScope S(W, "BlockStart");
101
102 StringRef LinkageName;
Zachary Turner46225b12016-12-16 22:48:14 +0000103 W.printHex("PtrParent", Block.Parent);
104 W.printHex("PtrEnd", Block.End);
105 W.printHex("CodeSize", Block.CodeSize);
Zachary Turneraaad5742016-05-23 23:41:13 +0000106 if (ObjDelegate) {
107 ObjDelegate->printRelocatedField("CodeOffset", Block.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000108 Block.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000109 }
Zachary Turner46225b12016-12-16 22:48:14 +0000110 W.printHex("Segment", Block.Segment);
Zachary Turneraaad5742016-05-23 23:41:13 +0000111 W.printString("BlockName", Block.Name);
112 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000113 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000114}
115
Zachary Turner0d840742016-10-07 21:34:46 +0000116Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, Thunk32Sym &Thunk) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000117 DictScope S(W, "Thunk32");
Zachary Turner46225b12016-12-16 22:48:14 +0000118 W.printNumber("Parent", Thunk.Parent);
119 W.printNumber("End", Thunk.End);
120 W.printNumber("Next", Thunk.Next);
121 W.printNumber("Off", Thunk.Offset);
122 W.printNumber("Seg", Thunk.Segment);
123 W.printNumber("Len", Thunk.Length);
124 W.printEnum("Ordinal", uint8_t(Thunk.Thunk), getThunkOrdinalNames());
Zachary Turner0d840742016-10-07 21:34:46 +0000125 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000126}
127
Zachary Turner0d840742016-10-07 21:34:46 +0000128Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
129 TrampolineSym &Tramp) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000130 DictScope S(W, "Trampoline");
Zachary Turner46225b12016-12-16 22:48:14 +0000131 W.printEnum("Type", uint16_t(Tramp.Type), getTrampolineNames());
132 W.printNumber("Size", Tramp.Size);
133 W.printNumber("ThunkOff", Tramp.ThunkOffset);
134 W.printNumber("TargetOff", Tramp.TargetOffset);
135 W.printNumber("ThunkSection", Tramp.ThunkSection);
136 W.printNumber("TargetSection", Tramp.TargetSection);
Zachary Turner0d840742016-10-07 21:34:46 +0000137 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000138}
139
Zachary Turner0d840742016-10-07 21:34:46 +0000140Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, SectionSym &Section) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000141 DictScope S(W, "Section");
Zachary Turner46225b12016-12-16 22:48:14 +0000142 W.printNumber("SectionNumber", Section.SectionNumber);
143 W.printNumber("Alignment", Section.Alignment);
144 W.printNumber("Rva", Section.Rva);
145 W.printNumber("Length", Section.Length);
146 W.printFlags("Characteristics", Section.Characteristics,
Zachary Turner93839cb2016-06-02 05:07:49 +0000147 getImageSectionCharacteristicNames(),
148 COFF::SectionCharacteristics(0x00F00000));
149
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000150 W.printString("Name", Section.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000151 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000152}
153
Zachary Turner0d840742016-10-07 21:34:46 +0000154Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000155 CoffGroupSym &CoffGroup) {
156 DictScope S(W, "COFF Group");
Zachary Turner46225b12016-12-16 22:48:14 +0000157 W.printNumber("Size", CoffGroup.Size);
158 W.printFlags("Characteristics", CoffGroup.Characteristics,
Zachary Turner93839cb2016-06-02 05:07:49 +0000159 getImageSectionCharacteristicNames(),
160 COFF::SectionCharacteristics(0x00F00000));
Zachary Turner46225b12016-12-16 22:48:14 +0000161 W.printNumber("Offset", CoffGroup.Offset);
162 W.printNumber("Segment", CoffGroup.Segment);
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000163 W.printString("Name", CoffGroup.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000164 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000165}
166
Zachary Turner0d840742016-10-07 21:34:46 +0000167Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
168 BPRelativeSym &BPRel) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000169 DictScope S(W, "BPRelativeSym");
170
Zachary Turner46225b12016-12-16 22:48:14 +0000171 W.printNumber("Offset", BPRel.Offset);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000172 printTypeIndex("Type", BPRel.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000173 W.printString("VarName", BPRel.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000174 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000175}
176
Zachary Turner0d840742016-10-07 21:34:46 +0000177Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
Zachary Turneraaad5742016-05-23 23:41:13 +0000178 BuildInfoSym &BuildInfo) {
179 DictScope S(W, "BuildInfo");
180
Zachary Turner46225b12016-12-16 22:48:14 +0000181 W.printNumber("BuildId", BuildInfo.BuildId);
Zachary Turner0d840742016-10-07 21:34:46 +0000182 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000183}
184
Zachary Turner0d840742016-10-07 21:34:46 +0000185Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
186 CallSiteInfoSym &CallSiteInfo) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000187 DictScope S(W, "CallSiteInfo");
188
189 StringRef LinkageName;
190 if (ObjDelegate) {
Zachary Turner46225b12016-12-16 22:48:14 +0000191 ObjDelegate->printRelocatedField("CodeOffset",
192 CallSiteInfo.getRelocationOffset(),
193 CallSiteInfo.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000194 }
Zachary Turner46225b12016-12-16 22:48:14 +0000195 W.printHex("Segment", CallSiteInfo.Segment);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000196 printTypeIndex("Type", CallSiteInfo.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000197 if (!LinkageName.empty())
198 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000199 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000200}
201
Zachary Turner0d840742016-10-07 21:34:46 +0000202Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
203 EnvBlockSym &EnvBlock) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000204 DictScope S(W, "EnvBlock");
205
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000206 ListScope L(W, "Entries");
207 for (auto Entry : EnvBlock.Fields) {
208 W.printString(Entry);
209 }
Zachary Turner0d840742016-10-07 21:34:46 +0000210 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000211}
212
Zachary Turner0d840742016-10-07 21:34:46 +0000213Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
214 FileStaticSym &FileStatic) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000215 DictScope S(W, "FileStatic");
Zachary Turner46225b12016-12-16 22:48:14 +0000216 W.printNumber("Index", FileStatic.Index);
217 W.printNumber("ModFilenameOffset", FileStatic.ModFilenameOffset);
218 W.printFlags("Flags", uint16_t(FileStatic.Flags), getLocalFlagNames());
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000219 W.printString("Name", FileStatic.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000220 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000221}
222
Zachary Turner0d840742016-10-07 21:34:46 +0000223Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ExportSym &Export) {
Zachary Turner9f054d42016-05-25 00:12:40 +0000224 DictScope S(W, "Export");
Zachary Turner46225b12016-12-16 22:48:14 +0000225 W.printNumber("Ordinal", Export.Ordinal);
226 W.printFlags("Flags", uint16_t(Export.Flags), getExportSymFlagNames());
Zachary Turner9f054d42016-05-25 00:12:40 +0000227 W.printString("Name", Export.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000228 return Error::success();
Zachary Turner9f054d42016-05-25 00:12:40 +0000229}
230
Zachary Turner0d840742016-10-07 21:34:46 +0000231Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
232 Compile2Sym &Compile2) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000233 DictScope S(W, "CompilerFlags2");
234
Zachary Turner46225b12016-12-16 22:48:14 +0000235 W.printEnum("Language", Compile2.getLanguage(), getSourceLanguageNames());
236 W.printFlags("Flags", Compile2.getFlags(), getCompileSym2FlagNames());
237 W.printEnum("Machine", unsigned(Compile2.Machine), getCPUTypeNames());
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000238 std::string FrontendVersion;
239 {
240 raw_string_ostream Out(FrontendVersion);
Zachary Turner46225b12016-12-16 22:48:14 +0000241 Out << Compile2.VersionFrontendMajor << '.' << Compile2.VersionFrontendMinor
242 << '.' << Compile2.VersionFrontendBuild;
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000243 }
244 std::string BackendVersion;
245 {
246 raw_string_ostream Out(BackendVersion);
Zachary Turner46225b12016-12-16 22:48:14 +0000247 Out << Compile2.VersionBackendMajor << '.' << Compile2.VersionBackendMinor
248 << '.' << Compile2.VersionBackendBuild;
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000249 }
250 W.printString("FrontendVersion", FrontendVersion);
251 W.printString("BackendVersion", BackendVersion);
252 W.printString("VersionName", Compile2.Version);
Zachary Turner0d840742016-10-07 21:34:46 +0000253 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000254}
255
Zachary Turner0d840742016-10-07 21:34:46 +0000256Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
257 Compile3Sym &Compile3) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000258 DictScope S(W, "CompilerFlags3");
Zachary Turneraaad5742016-05-23 23:41:13 +0000259
Zachary Turner46225b12016-12-16 22:48:14 +0000260 W.printEnum("Language", Compile3.getLanguage(), getSourceLanguageNames());
261 W.printFlags("Flags", Compile3.getFlags(), getCompileSym3FlagNames());
262 W.printEnum("Machine", unsigned(Compile3.Machine), getCPUTypeNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000263 std::string FrontendVersion;
264 {
265 raw_string_ostream Out(FrontendVersion);
Zachary Turner46225b12016-12-16 22:48:14 +0000266 Out << Compile3.VersionFrontendMajor << '.' << Compile3.VersionFrontendMinor
267 << '.' << Compile3.VersionFrontendBuild << '.'
268 << Compile3.VersionFrontendQFE;
Zachary Turneraaad5742016-05-23 23:41:13 +0000269 }
270 std::string BackendVersion;
271 {
272 raw_string_ostream Out(BackendVersion);
Zachary Turner46225b12016-12-16 22:48:14 +0000273 Out << Compile3.VersionBackendMajor << '.' << Compile3.VersionBackendMinor
274 << '.' << Compile3.VersionBackendBuild << '.'
275 << Compile3.VersionBackendQFE;
Zachary Turneraaad5742016-05-23 23:41:13 +0000276 }
277 W.printString("FrontendVersion", FrontendVersion);
278 W.printString("BackendVersion", BackendVersion);
279 W.printString("VersionName", Compile3.Version);
Zachary Turner0d840742016-10-07 21:34:46 +0000280 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000281}
282
Zachary Turner0d840742016-10-07 21:34:46 +0000283Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
284 ConstantSym &Constant) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000285 DictScope S(W, "Constant");
286
Zachary Turner629cb7d2017-01-11 23:24:22 +0000287 printTypeIndex("Type", Constant.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000288 W.printNumber("Value", Constant.Value);
289 W.printString("Name", Constant.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000290 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000291}
292
Zachary Turner0d840742016-10-07 21:34:46 +0000293Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, DataSym &Data) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000294 DictScope S(W, "DataSym");
295
Zachary Turner0d840742016-10-07 21:34:46 +0000296 W.printEnum("Kind", uint16_t(CVR.kind()), getSymbolTypeNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000297 StringRef LinkageName;
298 if (ObjDelegate) {
299 ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000300 Data.DataOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000301 }
Zachary Turner629cb7d2017-01-11 23:24:22 +0000302 printTypeIndex("Type", Data.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000303 W.printString("DisplayName", Data.Name);
304 if (!LinkageName.empty())
305 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000306 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000307}
308
Zachary Turner0d840742016-10-07 21:34:46 +0000309Error CVSymbolDumperImpl::visitKnownRecord(
310 CVSymbol &CVR,
Zachary Turneraaad5742016-05-23 23:41:13 +0000311 DefRangeFramePointerRelFullScopeSym &DefRangeFramePointerRelFullScope) {
312 DictScope S(W, "DefRangeFramePointerRelFullScope");
Zachary Turner46225b12016-12-16 22:48:14 +0000313 W.printNumber("Offset", DefRangeFramePointerRelFullScope.Offset);
Zachary Turner0d840742016-10-07 21:34:46 +0000314 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000315}
316
Zachary Turner0d840742016-10-07 21:34:46 +0000317Error CVSymbolDumperImpl::visitKnownRecord(
318 CVSymbol &CVR, DefRangeFramePointerRelSym &DefRangeFramePointerRel) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000319 DictScope S(W, "DefRangeFramePointerRel");
320
Zachary Turner46225b12016-12-16 22:48:14 +0000321 W.printNumber("Offset", DefRangeFramePointerRel.Offset);
322 printLocalVariableAddrRange(DefRangeFramePointerRel.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000323 DefRangeFramePointerRel.getRelocationOffset());
324 printLocalVariableAddrGap(DefRangeFramePointerRel.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000325 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000326}
327
Zachary Turner0d840742016-10-07 21:34:46 +0000328Error CVSymbolDumperImpl::visitKnownRecord(
329 CVSymbol &CVR, DefRangeRegisterRelSym &DefRangeRegisterRel) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000330 DictScope S(W, "DefRangeRegisterRel");
331
Zachary Turner46225b12016-12-16 22:48:14 +0000332 W.printNumber("BaseRegister", DefRangeRegisterRel.Hdr.Register);
Zachary Turneraaad5742016-05-23 23:41:13 +0000333 W.printBoolean("HasSpilledUDTMember",
334 DefRangeRegisterRel.hasSpilledUDTMember());
335 W.printNumber("OffsetInParent", DefRangeRegisterRel.offsetInParent());
Zachary Turner46225b12016-12-16 22:48:14 +0000336 W.printNumber("BasePointerOffset", DefRangeRegisterRel.Hdr.BasePointerOffset);
337 printLocalVariableAddrRange(DefRangeRegisterRel.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000338 DefRangeRegisterRel.getRelocationOffset());
339 printLocalVariableAddrGap(DefRangeRegisterRel.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000340 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000341}
342
Zachary Turner0d840742016-10-07 21:34:46 +0000343Error CVSymbolDumperImpl::visitKnownRecord(
344 CVSymbol &CVR, DefRangeRegisterSym &DefRangeRegister) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000345 DictScope S(W, "DefRangeRegister");
346
Zachary Turner46225b12016-12-16 22:48:14 +0000347 W.printNumber("Register", DefRangeRegister.Hdr.Register);
348 W.printNumber("MayHaveNoName", DefRangeRegister.Hdr.MayHaveNoName);
349 printLocalVariableAddrRange(DefRangeRegister.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000350 DefRangeRegister.getRelocationOffset());
351 printLocalVariableAddrGap(DefRangeRegister.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000352 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000353}
354
Zachary Turner0d840742016-10-07 21:34:46 +0000355Error CVSymbolDumperImpl::visitKnownRecord(
356 CVSymbol &CVR, DefRangeSubfieldRegisterSym &DefRangeSubfieldRegister) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000357 DictScope S(W, "DefRangeSubfieldRegister");
358
Zachary Turner46225b12016-12-16 22:48:14 +0000359 W.printNumber("Register", DefRangeSubfieldRegister.Hdr.Register);
360 W.printNumber("MayHaveNoName", DefRangeSubfieldRegister.Hdr.MayHaveNoName);
361 W.printNumber("OffsetInParent", DefRangeSubfieldRegister.Hdr.OffsetInParent);
362 printLocalVariableAddrRange(DefRangeSubfieldRegister.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000363 DefRangeSubfieldRegister.getRelocationOffset());
364 printLocalVariableAddrGap(DefRangeSubfieldRegister.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000365 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000366}
367
Zachary Turner0d840742016-10-07 21:34:46 +0000368Error CVSymbolDumperImpl::visitKnownRecord(
369 CVSymbol &CVR, DefRangeSubfieldSym &DefRangeSubfield) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000370 DictScope S(W, "DefRangeSubfield");
371
372 if (ObjDelegate) {
Zachary Turner2d5c2cd2017-05-03 17:11:11 +0000373 StringTableRef Strings = ObjDelegate->getStringTable();
374 auto ExpectedProgram = Strings.getString(DefRangeSubfield.Program);
375 if (!ExpectedProgram) {
376 consumeError(ExpectedProgram.takeError());
Zachary Turner0d840742016-10-07 21:34:46 +0000377 return llvm::make_error<CodeViewError>(
378 "String table offset outside of bounds of String Table!");
Zachary Turner2d5c2cd2017-05-03 17:11:11 +0000379 }
380 W.printString("Program", *ExpectedProgram);
Zachary Turneraaad5742016-05-23 23:41:13 +0000381 }
Zachary Turner46225b12016-12-16 22:48:14 +0000382 W.printNumber("OffsetInParent", DefRangeSubfield.OffsetInParent);
383 printLocalVariableAddrRange(DefRangeSubfield.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000384 DefRangeSubfield.getRelocationOffset());
385 printLocalVariableAddrGap(DefRangeSubfield.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000386 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000387}
388
Zachary Turner0d840742016-10-07 21:34:46 +0000389Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
390 DefRangeSym &DefRange) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000391 DictScope S(W, "DefRange");
392
393 if (ObjDelegate) {
Zachary Turner2d5c2cd2017-05-03 17:11:11 +0000394 StringTableRef Strings = ObjDelegate->getStringTable();
395 auto ExpectedProgram = Strings.getString(DefRange.Program);
396 if (!ExpectedProgram) {
397 consumeError(ExpectedProgram.takeError());
Zachary Turner0d840742016-10-07 21:34:46 +0000398 return llvm::make_error<CodeViewError>(
399 "String table offset outside of bounds of String Table!");
Zachary Turner2d5c2cd2017-05-03 17:11:11 +0000400 }
401 W.printString("Program", *ExpectedProgram);
Zachary Turneraaad5742016-05-23 23:41:13 +0000402 }
Zachary Turner46225b12016-12-16 22:48:14 +0000403 printLocalVariableAddrRange(DefRange.Range, DefRange.getRelocationOffset());
Zachary Turneraaad5742016-05-23 23:41:13 +0000404 printLocalVariableAddrGap(DefRange.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000405 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000406}
407
Zachary Turner0d840742016-10-07 21:34:46 +0000408Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
409 FrameCookieSym &FrameCookie) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000410 DictScope S(W, "FrameCookie");
411
412 StringRef LinkageName;
413 if (ObjDelegate) {
Zachary Turner46225b12016-12-16 22:48:14 +0000414 ObjDelegate->printRelocatedField("CodeOffset",
415 FrameCookie.getRelocationOffset(),
416 FrameCookie.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000417 }
Zachary Turner46225b12016-12-16 22:48:14 +0000418 W.printHex("Register", FrameCookie.Register);
419 W.printEnum("CookieKind", uint16_t(FrameCookie.CookieKind),
Zachary Turner93839cb2016-06-02 05:07:49 +0000420 getFrameCookieKindNames());
Zachary Turner46225b12016-12-16 22:48:14 +0000421 W.printHex("Flags", FrameCookie.Flags);
Zachary Turner0d840742016-10-07 21:34:46 +0000422 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000423}
424
Zachary Turner0d840742016-10-07 21:34:46 +0000425Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
Zachary Turneraaad5742016-05-23 23:41:13 +0000426 FrameProcSym &FrameProc) {
427 DictScope S(W, "FrameProc");
428
Zachary Turner46225b12016-12-16 22:48:14 +0000429 W.printHex("TotalFrameBytes", FrameProc.TotalFrameBytes);
430 W.printHex("PaddingFrameBytes", FrameProc.PaddingFrameBytes);
431 W.printHex("OffsetToPadding", FrameProc.OffsetToPadding);
Zachary Turneraaad5742016-05-23 23:41:13 +0000432 W.printHex("BytesOfCalleeSavedRegisters",
Zachary Turner46225b12016-12-16 22:48:14 +0000433 FrameProc.BytesOfCalleeSavedRegisters);
434 W.printHex("OffsetOfExceptionHandler", FrameProc.OffsetOfExceptionHandler);
Zachary Turneraaad5742016-05-23 23:41:13 +0000435 W.printHex("SectionIdOfExceptionHandler",
Zachary Turner46225b12016-12-16 22:48:14 +0000436 FrameProc.SectionIdOfExceptionHandler);
437 W.printFlags("Flags", static_cast<uint32_t>(FrameProc.Flags),
438 getFrameProcSymFlagNames());
Zachary Turner0d840742016-10-07 21:34:46 +0000439 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000440}
441
Zachary Turner0d840742016-10-07 21:34:46 +0000442Error CVSymbolDumperImpl::visitKnownRecord(
443 CVSymbol &CVR, HeapAllocationSiteSym &HeapAllocSite) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000444 DictScope S(W, "HeapAllocationSite");
445
446 StringRef LinkageName;
447 if (ObjDelegate) {
Zachary Turner46225b12016-12-16 22:48:14 +0000448 ObjDelegate->printRelocatedField("CodeOffset",
449 HeapAllocSite.getRelocationOffset(),
450 HeapAllocSite.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000451 }
Zachary Turner46225b12016-12-16 22:48:14 +0000452 W.printHex("Segment", HeapAllocSite.Segment);
453 W.printHex("CallInstructionSize", HeapAllocSite.CallInstructionSize);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000454 printTypeIndex("Type", HeapAllocSite.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000455 if (!LinkageName.empty())
456 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000457 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000458}
459
Zachary Turner0d840742016-10-07 21:34:46 +0000460Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
461 InlineSiteSym &InlineSite) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000462 DictScope S(W, "InlineSite");
463
Zachary Turner46225b12016-12-16 22:48:14 +0000464 W.printHex("PtrParent", InlineSite.Parent);
465 W.printHex("PtrEnd", InlineSite.End);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000466 printTypeIndex("Inlinee", InlineSite.Inlinee);
Zachary Turneraaad5742016-05-23 23:41:13 +0000467
468 ListScope BinaryAnnotations(W, "BinaryAnnotations");
469 for (auto &Annotation : InlineSite.annotations()) {
470 switch (Annotation.OpCode) {
471 case BinaryAnnotationsOpCode::Invalid:
Zachary Turner42cb87f2017-03-17 00:15:27 +0000472 W.printString("(Annotation Padding)");
473 break;
Zachary Turneraaad5742016-05-23 23:41:13 +0000474 case BinaryAnnotationsOpCode::CodeOffset:
475 case BinaryAnnotationsOpCode::ChangeCodeOffset:
476 case BinaryAnnotationsOpCode::ChangeCodeLength:
477 W.printHex(Annotation.Name, Annotation.U1);
478 break;
479 case BinaryAnnotationsOpCode::ChangeCodeOffsetBase:
480 case BinaryAnnotationsOpCode::ChangeLineEndDelta:
481 case BinaryAnnotationsOpCode::ChangeRangeKind:
482 case BinaryAnnotationsOpCode::ChangeColumnStart:
483 case BinaryAnnotationsOpCode::ChangeColumnEnd:
484 W.printNumber(Annotation.Name, Annotation.U1);
485 break;
486 case BinaryAnnotationsOpCode::ChangeLineOffset:
487 case BinaryAnnotationsOpCode::ChangeColumnEndDelta:
488 W.printNumber(Annotation.Name, Annotation.S1);
489 break;
490 case BinaryAnnotationsOpCode::ChangeFile:
491 if (ObjDelegate) {
492 W.printHex("ChangeFile",
493 ObjDelegate->getFileNameForFileOffset(Annotation.U1),
494 Annotation.U1);
495 } else {
496 W.printHex("ChangeFile", Annotation.U1);
497 }
498
499 break;
500 case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset: {
501 W.startLine() << "ChangeCodeOffsetAndLineOffset: {CodeOffset: "
502 << W.hex(Annotation.U1) << ", LineOffset: " << Annotation.S1
503 << "}\n";
504 break;
505 }
506 case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset: {
507 W.startLine() << "ChangeCodeLengthAndCodeOffset: {CodeOffset: "
508 << W.hex(Annotation.U2)
509 << ", Length: " << W.hex(Annotation.U1) << "}\n";
510 break;
511 }
512 }
513 }
Zachary Turner0d840742016-10-07 21:34:46 +0000514 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000515}
516
Zachary Turner0d840742016-10-07 21:34:46 +0000517Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
518 RegisterSym &Register) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000519 DictScope S(W, "RegisterSym");
Zachary Turner46225b12016-12-16 22:48:14 +0000520 W.printNumber("Type", Register.Index);
521 W.printEnum("Seg", uint16_t(Register.Register), getRegisterNames());
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000522 W.printString("Name", Register.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000523 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000524}
525
Zachary Turner0d840742016-10-07 21:34:46 +0000526Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, PublicSym32 &Public) {
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000527 DictScope S(W, "PublicSym");
Zachary Turner46225b12016-12-16 22:48:14 +0000528 W.printNumber("Type", Public.Index);
529 W.printNumber("Seg", Public.Segment);
530 W.printNumber("Off", Public.Offset);
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000531 W.printString("Name", Public.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000532 return Error::success();
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000533}
534
Zachary Turner0d840742016-10-07 21:34:46 +0000535Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ProcRefSym &ProcRef) {
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000536 DictScope S(W, "ProcRef");
Zachary Turner46225b12016-12-16 22:48:14 +0000537 W.printNumber("SumName", ProcRef.SumName);
538 W.printNumber("SymOffset", ProcRef.SymOffset);
539 W.printNumber("Mod", ProcRef.Module);
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000540 W.printString("Name", ProcRef.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000541 return Error::success();
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000542}
543
Zachary Turner0d840742016-10-07 21:34:46 +0000544Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LabelSym &Label) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000545 DictScope S(W, "Label");
546
547 StringRef LinkageName;
548 if (ObjDelegate) {
549 ObjDelegate->printRelocatedField("CodeOffset", Label.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000550 Label.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000551 }
Zachary Turner46225b12016-12-16 22:48:14 +0000552 W.printHex("Segment", Label.Segment);
553 W.printHex("Flags", uint8_t(Label.Flags));
554 W.printFlags("Flags", uint8_t(Label.Flags), getProcSymFlagNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000555 W.printString("DisplayName", Label.Name);
556 if (!LinkageName.empty())
557 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000558 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000559}
560
Zachary Turner0d840742016-10-07 21:34:46 +0000561Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LocalSym &Local) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000562 DictScope S(W, "Local");
563
Zachary Turner629cb7d2017-01-11 23:24:22 +0000564 printTypeIndex("Type", Local.Type);
Zachary Turner46225b12016-12-16 22:48:14 +0000565 W.printFlags("Flags", uint16_t(Local.Flags), getLocalFlagNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000566 W.printString("VarName", Local.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000567 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000568}
569
Zachary Turner0d840742016-10-07 21:34:46 +0000570Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ObjNameSym &ObjName) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000571 DictScope S(W, "ObjectName");
572
Zachary Turner46225b12016-12-16 22:48:14 +0000573 W.printHex("Signature", ObjName.Signature);
Zachary Turneraaad5742016-05-23 23:41:13 +0000574 W.printString("ObjectName", ObjName.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000575 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000576}
577
Zachary Turner0d840742016-10-07 21:34:46 +0000578Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ProcSym &Proc) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000579 DictScope S(W, "ProcStart");
580
581 if (InFunctionScope)
Zachary Turner0d840742016-10-07 21:34:46 +0000582 return llvm::make_error<CodeViewError>(
583 "Visiting a ProcSym while inside function scope!");
Zachary Turneraaad5742016-05-23 23:41:13 +0000584
585 InFunctionScope = true;
586
587 StringRef LinkageName;
Zachary Turner0d840742016-10-07 21:34:46 +0000588 W.printEnum("Kind", uint16_t(CVR.kind()), getSymbolTypeNames());
Zachary Turner46225b12016-12-16 22:48:14 +0000589 W.printHex("PtrParent", Proc.Parent);
590 W.printHex("PtrEnd", Proc.End);
591 W.printHex("PtrNext", Proc.Next);
592 W.printHex("CodeSize", Proc.CodeSize);
593 W.printHex("DbgStart", Proc.DbgStart);
594 W.printHex("DbgEnd", Proc.DbgEnd);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000595 printTypeIndex("FunctionType", Proc.FunctionType);
Zachary Turneraaad5742016-05-23 23:41:13 +0000596 if (ObjDelegate) {
597 ObjDelegate->printRelocatedField("CodeOffset", Proc.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000598 Proc.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000599 }
Zachary Turner46225b12016-12-16 22:48:14 +0000600 W.printHex("Segment", Proc.Segment);
601 W.printFlags("Flags", static_cast<uint8_t>(Proc.Flags),
Zachary Turner93839cb2016-06-02 05:07:49 +0000602 getProcSymFlagNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000603 W.printString("DisplayName", Proc.Name);
604 if (!LinkageName.empty())
605 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000606 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000607}
608
Zachary Turner0d840742016-10-07 21:34:46 +0000609Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
610 ScopeEndSym &ScopeEnd) {
611 if (CVR.kind() == SymbolKind::S_END)
Zachary Turnercac29ae2016-05-24 17:30:25 +0000612 DictScope S(W, "BlockEnd");
Zachary Turner0d840742016-10-07 21:34:46 +0000613 else if (CVR.kind() == SymbolKind::S_PROC_ID_END)
Zachary Turnercac29ae2016-05-24 17:30:25 +0000614 DictScope S(W, "ProcEnd");
Zachary Turner0d840742016-10-07 21:34:46 +0000615 else if (CVR.kind() == SymbolKind::S_INLINESITE_END)
Zachary Turneraaad5742016-05-23 23:41:13 +0000616 DictScope S(W, "InlineSiteEnd");
617
618 InFunctionScope = false;
Zachary Turner0d840742016-10-07 21:34:46 +0000619 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000620}
621
Zachary Turner0d840742016-10-07 21:34:46 +0000622Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, CallerSym &Caller) {
623 ListScope S(W, CVR.kind() == S_CALLEES ? "Callees" : "Callers");
Zachary Turneraaad5742016-05-23 23:41:13 +0000624 for (auto FuncID : Caller.Indices)
Zachary Turner629cb7d2017-01-11 23:24:22 +0000625 printTypeIndex("FuncID", FuncID);
Zachary Turner0d840742016-10-07 21:34:46 +0000626 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000627}
628
Zachary Turner0d840742016-10-07 21:34:46 +0000629Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
630 RegRelativeSym &RegRel) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000631 DictScope S(W, "RegRelativeSym");
632
Zachary Turner46225b12016-12-16 22:48:14 +0000633 W.printHex("Offset", RegRel.Offset);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000634 printTypeIndex("Type", RegRel.Type);
Zachary Turner46225b12016-12-16 22:48:14 +0000635 W.printHex("Register", RegRel.Register);
Zachary Turneraaad5742016-05-23 23:41:13 +0000636 W.printString("VarName", RegRel.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000637 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000638}
639
Zachary Turner0d840742016-10-07 21:34:46 +0000640Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
641 ThreadLocalDataSym &Data) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000642 DictScope S(W, "ThreadLocalDataSym");
643
644 StringRef LinkageName;
645 if (ObjDelegate) {
646 ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000647 Data.DataOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000648 }
Zachary Turner629cb7d2017-01-11 23:24:22 +0000649 printTypeIndex("Type", Data.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000650 W.printString("DisplayName", Data.Name);
651 if (!LinkageName.empty())
652 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000653 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000654}
655
Zachary Turner0d840742016-10-07 21:34:46 +0000656Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, UDTSym &UDT) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000657 DictScope S(W, "UDT");
Zachary Turner629cb7d2017-01-11 23:24:22 +0000658 printTypeIndex("Type", UDT.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000659 W.printString("UDTName", UDT.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000660 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000661}
662
Zachary Turner0d840742016-10-07 21:34:46 +0000663Error CVSymbolDumperImpl::visitUnknownSymbol(CVSymbol &CVR) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000664 DictScope S(W, "UnknownSym");
Zachary Turner0d840742016-10-07 21:34:46 +0000665 W.printEnum("Kind", uint16_t(CVR.kind()), getSymbolTypeNames());
666 W.printNumber("Length", CVR.length());
667 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000668}
669
Zachary Turner0d840742016-10-07 21:34:46 +0000670Error CVSymbolDumper::dump(CVRecord<SymbolKind> &Record) {
671 SymbolVisitorCallbackPipeline Pipeline;
672 SymbolDeserializer Deserializer(ObjDelegate.get());
Zachary Turner1dfcf8d2017-05-19 05:57:45 +0000673 CVSymbolDumperImpl Dumper(TypeDB, ObjDelegate.get(), W, PrintRecordBytes);
Zachary Turner0d840742016-10-07 21:34:46 +0000674
675 Pipeline.addCallbackToPipeline(Deserializer);
676 Pipeline.addCallbackToPipeline(Dumper);
677 CVSymbolVisitor Visitor(Pipeline);
678 return Visitor.visitSymbolRecord(Record);
Zachary Turneraaad5742016-05-23 23:41:13 +0000679}
680
Zachary Turner0d840742016-10-07 21:34:46 +0000681Error CVSymbolDumper::dump(const CVSymbolArray &Symbols) {
682 SymbolVisitorCallbackPipeline Pipeline;
683 SymbolDeserializer Deserializer(ObjDelegate.get());
Zachary Turner1dfcf8d2017-05-19 05:57:45 +0000684 CVSymbolDumperImpl Dumper(TypeDB, ObjDelegate.get(), W, PrintRecordBytes);
Zachary Turner0d840742016-10-07 21:34:46 +0000685
686 Pipeline.addCallbackToPipeline(Deserializer);
687 Pipeline.addCallbackToPipeline(Dumper);
688 CVSymbolVisitor Visitor(Pipeline);
689 return Visitor.visitSymbolStream(Symbols);
Zachary Turneraaad5742016-05-23 23:41:13 +0000690}