blob: 326e1f5add6514d9731b023e5f6d8d8350ba055a [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 Turner93839cb2016-06-02 05:07:49 +000014#include "llvm/DebugInfo/CodeView/EnumTables.h"
Zachary Turner0d840742016-10-07 21:34:46 +000015#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
Zachary Turneraaad5742016-05-23 23:41:13 +000016#include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h"
17#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
Zachary Turner0d840742016-10-07 21:34:46 +000018#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h"
19#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h"
Zachary Turneraaad5742016-05-23 23:41:13 +000020#include "llvm/DebugInfo/CodeView/TypeDumper.h"
21#include "llvm/DebugInfo/CodeView/TypeIndex.h"
Zachary Turner0d840742016-10-07 21:34:46 +000022#include "llvm/Support/Error.h"
Zachary Turneraaad5742016-05-23 23:41:13 +000023#include "llvm/Support/ScopedPrinter.h"
24
25#include <system_error>
26
27using namespace llvm;
28using namespace llvm::codeview;
29
Zachary Turneraaad5742016-05-23 23:41:13 +000030namespace {
Zachary Turneraaad5742016-05-23 23:41:13 +000031/// Use this private dumper implementation to keep implementation details about
32/// the visitor out of SymbolDumper.h.
Zachary Turner0d840742016-10-07 21:34:46 +000033class CVSymbolDumperImpl : public SymbolVisitorCallbacks {
Zachary Turneraaad5742016-05-23 23:41:13 +000034public:
Zachary Turner3e78e2d2016-05-24 00:06:04 +000035 CVSymbolDumperImpl(CVTypeDumper &CVTD, SymbolDumpDelegate *ObjDelegate,
36 ScopedPrinter &W, bool PrintRecordBytes)
Zachary Turner0d840742016-10-07 21:34:46 +000037 : CVTD(CVTD), ObjDelegate(ObjDelegate), W(W),
38 PrintRecordBytes(PrintRecordBytes), InFunctionScope(false) {}
Zachary Turneraaad5742016-05-23 23:41:13 +000039
40/// CVSymbolVisitor overrides.
41#define SYMBOL_RECORD(EnumName, EnumVal, Name) \
Zachary Turner0d840742016-10-07 21:34:46 +000042 Error visitKnownRecord(CVSymbol &CVR, Name &Record) override;
Zachary Turneraaad5742016-05-23 23:41:13 +000043#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
44#include "llvm/DebugInfo/CodeView/CVSymbolTypes.def"
45
Zachary Turner0d840742016-10-07 21:34:46 +000046 Error visitSymbolBegin(CVSymbol &Record) override;
47 Error visitSymbolEnd(CVSymbol &Record) override;
48 Error visitUnknownSymbol(CVSymbol &Record) override;
Zachary Turneraaad5742016-05-23 23:41:13 +000049
50private:
51 void printLocalVariableAddrRange(const LocalVariableAddrRange &Range,
52 uint32_t RelocationOffset);
53 void printLocalVariableAddrGap(ArrayRef<LocalVariableAddrGap> Gaps);
54
Zachary Turneraaad5742016-05-23 23:41:13 +000055 CVTypeDumper &CVTD;
56 SymbolDumpDelegate *ObjDelegate;
57 ScopedPrinter &W;
58
59 bool PrintRecordBytes;
60 bool InFunctionScope;
61};
62}
63
64void CVSymbolDumperImpl::printLocalVariableAddrRange(
65 const LocalVariableAddrRange &Range, uint32_t RelocationOffset) {
66 DictScope S(W, "LocalVariableAddrRange");
67 if (ObjDelegate)
68 ObjDelegate->printRelocatedField("OffsetStart", RelocationOffset,
69 Range.OffsetStart);
70 W.printHex("ISectStart", Range.ISectStart);
71 W.printHex("Range", Range.Range);
72}
73
74void CVSymbolDumperImpl::printLocalVariableAddrGap(
75 ArrayRef<LocalVariableAddrGap> Gaps) {
76 for (auto &Gap : Gaps) {
77 ListScope S(W, "LocalVariableAddrGap");
78 W.printHex("GapStartOffset", Gap.GapStartOffset);
79 W.printHex("Range", Gap.Range);
80 }
81}
82
Zachary Turner0d840742016-10-07 21:34:46 +000083Error CVSymbolDumperImpl::visitSymbolBegin(CVSymbol &CVR) {
84 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +000085}
86
Zachary Turner0d840742016-10-07 21:34:46 +000087Error CVSymbolDumperImpl::visitSymbolEnd(CVSymbol &CVR) {
88 if (PrintRecordBytes && ObjDelegate)
89 ObjDelegate->printBinaryBlockWithRelocs("SymData", CVR.content());
90 return Error::success();
91}
92
93Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, BlockSym &Block) {
Zachary Turneraaad5742016-05-23 23:41:13 +000094 DictScope S(W, "BlockStart");
95
96 StringRef LinkageName;
Zachary Turner46225b12016-12-16 22:48:14 +000097 W.printHex("PtrParent", Block.Parent);
98 W.printHex("PtrEnd", Block.End);
99 W.printHex("CodeSize", Block.CodeSize);
Zachary Turneraaad5742016-05-23 23:41:13 +0000100 if (ObjDelegate) {
101 ObjDelegate->printRelocatedField("CodeOffset", Block.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000102 Block.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000103 }
Zachary Turner46225b12016-12-16 22:48:14 +0000104 W.printHex("Segment", Block.Segment);
Zachary Turneraaad5742016-05-23 23:41:13 +0000105 W.printString("BlockName", Block.Name);
106 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000107 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000108}
109
Zachary Turner0d840742016-10-07 21:34:46 +0000110Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, Thunk32Sym &Thunk) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000111 DictScope S(W, "Thunk32");
Zachary Turner46225b12016-12-16 22:48:14 +0000112 W.printNumber("Parent", Thunk.Parent);
113 W.printNumber("End", Thunk.End);
114 W.printNumber("Next", Thunk.Next);
115 W.printNumber("Off", Thunk.Offset);
116 W.printNumber("Seg", Thunk.Segment);
117 W.printNumber("Len", Thunk.Length);
118 W.printEnum("Ordinal", uint8_t(Thunk.Thunk), getThunkOrdinalNames());
Zachary Turner0d840742016-10-07 21:34:46 +0000119 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000120}
121
Zachary Turner0d840742016-10-07 21:34:46 +0000122Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
123 TrampolineSym &Tramp) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000124 DictScope S(W, "Trampoline");
Zachary Turner46225b12016-12-16 22:48:14 +0000125 W.printEnum("Type", uint16_t(Tramp.Type), getTrampolineNames());
126 W.printNumber("Size", Tramp.Size);
127 W.printNumber("ThunkOff", Tramp.ThunkOffset);
128 W.printNumber("TargetOff", Tramp.TargetOffset);
129 W.printNumber("ThunkSection", Tramp.ThunkSection);
130 W.printNumber("TargetSection", Tramp.TargetSection);
Zachary Turner0d840742016-10-07 21:34:46 +0000131 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000132}
133
Zachary Turner0d840742016-10-07 21:34:46 +0000134Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, SectionSym &Section) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000135 DictScope S(W, "Section");
Zachary Turner46225b12016-12-16 22:48:14 +0000136 W.printNumber("SectionNumber", Section.SectionNumber);
137 W.printNumber("Alignment", Section.Alignment);
138 W.printNumber("Rva", Section.Rva);
139 W.printNumber("Length", Section.Length);
140 W.printFlags("Characteristics", Section.Characteristics,
Zachary Turner93839cb2016-06-02 05:07:49 +0000141 getImageSectionCharacteristicNames(),
142 COFF::SectionCharacteristics(0x00F00000));
143
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000144 W.printString("Name", Section.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000145 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000146}
147
Zachary Turner0d840742016-10-07 21:34:46 +0000148Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000149 CoffGroupSym &CoffGroup) {
150 DictScope S(W, "COFF Group");
Zachary Turner46225b12016-12-16 22:48:14 +0000151 W.printNumber("Size", CoffGroup.Size);
152 W.printFlags("Characteristics", CoffGroup.Characteristics,
Zachary Turner93839cb2016-06-02 05:07:49 +0000153 getImageSectionCharacteristicNames(),
154 COFF::SectionCharacteristics(0x00F00000));
Zachary Turner46225b12016-12-16 22:48:14 +0000155 W.printNumber("Offset", CoffGroup.Offset);
156 W.printNumber("Segment", CoffGroup.Segment);
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000157 W.printString("Name", CoffGroup.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000158 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000159}
160
Zachary Turner0d840742016-10-07 21:34:46 +0000161Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
162 BPRelativeSym &BPRel) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000163 DictScope S(W, "BPRelativeSym");
164
Zachary Turner46225b12016-12-16 22:48:14 +0000165 W.printNumber("Offset", BPRel.Offset);
166 CVTD.printTypeIndex("Type", BPRel.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000167 W.printString("VarName", BPRel.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000168 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000169}
170
Zachary Turner0d840742016-10-07 21:34:46 +0000171Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
Zachary Turneraaad5742016-05-23 23:41:13 +0000172 BuildInfoSym &BuildInfo) {
173 DictScope S(W, "BuildInfo");
174
Zachary Turner46225b12016-12-16 22:48:14 +0000175 W.printNumber("BuildId", BuildInfo.BuildId);
Zachary Turner0d840742016-10-07 21:34:46 +0000176 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000177}
178
Zachary Turner0d840742016-10-07 21:34:46 +0000179Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
180 CallSiteInfoSym &CallSiteInfo) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000181 DictScope S(W, "CallSiteInfo");
182
183 StringRef LinkageName;
184 if (ObjDelegate) {
Zachary Turner46225b12016-12-16 22:48:14 +0000185 ObjDelegate->printRelocatedField("CodeOffset",
186 CallSiteInfo.getRelocationOffset(),
187 CallSiteInfo.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000188 }
Zachary Turner46225b12016-12-16 22:48:14 +0000189 W.printHex("Segment", CallSiteInfo.Segment);
190 CVTD.printTypeIndex("Type", CallSiteInfo.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000191 if (!LinkageName.empty())
192 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000193 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000194}
195
Zachary Turner0d840742016-10-07 21:34:46 +0000196Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
197 EnvBlockSym &EnvBlock) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000198 DictScope S(W, "EnvBlock");
199
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000200 ListScope L(W, "Entries");
201 for (auto Entry : EnvBlock.Fields) {
202 W.printString(Entry);
203 }
Zachary Turner0d840742016-10-07 21:34:46 +0000204 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000205}
206
Zachary Turner0d840742016-10-07 21:34:46 +0000207Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
208 FileStaticSym &FileStatic) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000209 DictScope S(W, "FileStatic");
Zachary Turner46225b12016-12-16 22:48:14 +0000210 W.printNumber("Index", FileStatic.Index);
211 W.printNumber("ModFilenameOffset", FileStatic.ModFilenameOffset);
212 W.printFlags("Flags", uint16_t(FileStatic.Flags), getLocalFlagNames());
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000213 W.printString("Name", FileStatic.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000214 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000215}
216
Zachary Turner0d840742016-10-07 21:34:46 +0000217Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ExportSym &Export) {
Zachary Turner9f054d42016-05-25 00:12:40 +0000218 DictScope S(W, "Export");
Zachary Turner46225b12016-12-16 22:48:14 +0000219 W.printNumber("Ordinal", Export.Ordinal);
220 W.printFlags("Flags", uint16_t(Export.Flags), getExportSymFlagNames());
Zachary Turner9f054d42016-05-25 00:12:40 +0000221 W.printString("Name", Export.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000222 return Error::success();
Zachary Turner9f054d42016-05-25 00:12:40 +0000223}
224
Zachary Turner0d840742016-10-07 21:34:46 +0000225Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
226 Compile2Sym &Compile2) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000227 DictScope S(W, "CompilerFlags2");
228
Zachary Turner46225b12016-12-16 22:48:14 +0000229 W.printEnum("Language", Compile2.getLanguage(), getSourceLanguageNames());
230 W.printFlags("Flags", Compile2.getFlags(), getCompileSym2FlagNames());
231 W.printEnum("Machine", unsigned(Compile2.Machine), getCPUTypeNames());
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000232 std::string FrontendVersion;
233 {
234 raw_string_ostream Out(FrontendVersion);
Zachary Turner46225b12016-12-16 22:48:14 +0000235 Out << Compile2.VersionFrontendMajor << '.' << Compile2.VersionFrontendMinor
236 << '.' << Compile2.VersionFrontendBuild;
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000237 }
238 std::string BackendVersion;
239 {
240 raw_string_ostream Out(BackendVersion);
Zachary Turner46225b12016-12-16 22:48:14 +0000241 Out << Compile2.VersionBackendMajor << '.' << Compile2.VersionBackendMinor
242 << '.' << Compile2.VersionBackendBuild;
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000243 }
244 W.printString("FrontendVersion", FrontendVersion);
245 W.printString("BackendVersion", BackendVersion);
246 W.printString("VersionName", Compile2.Version);
Zachary Turner0d840742016-10-07 21:34:46 +0000247 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000248}
249
Zachary Turner0d840742016-10-07 21:34:46 +0000250Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
251 Compile3Sym &Compile3) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000252 DictScope S(W, "CompilerFlags3");
Zachary Turneraaad5742016-05-23 23:41:13 +0000253
Zachary Turner46225b12016-12-16 22:48:14 +0000254 W.printEnum("Language", Compile3.getLanguage(), getSourceLanguageNames());
255 W.printFlags("Flags", Compile3.getFlags(), getCompileSym3FlagNames());
256 W.printEnum("Machine", unsigned(Compile3.Machine), getCPUTypeNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000257 std::string FrontendVersion;
258 {
259 raw_string_ostream Out(FrontendVersion);
Zachary Turner46225b12016-12-16 22:48:14 +0000260 Out << Compile3.VersionFrontendMajor << '.' << Compile3.VersionFrontendMinor
261 << '.' << Compile3.VersionFrontendBuild << '.'
262 << Compile3.VersionFrontendQFE;
Zachary Turneraaad5742016-05-23 23:41:13 +0000263 }
264 std::string BackendVersion;
265 {
266 raw_string_ostream Out(BackendVersion);
Zachary Turner46225b12016-12-16 22:48:14 +0000267 Out << Compile3.VersionBackendMajor << '.' << Compile3.VersionBackendMinor
268 << '.' << Compile3.VersionBackendBuild << '.'
269 << Compile3.VersionBackendQFE;
Zachary Turneraaad5742016-05-23 23:41:13 +0000270 }
271 W.printString("FrontendVersion", FrontendVersion);
272 W.printString("BackendVersion", BackendVersion);
273 W.printString("VersionName", Compile3.Version);
Zachary Turner0d840742016-10-07 21:34:46 +0000274 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000275}
276
Zachary Turner0d840742016-10-07 21:34:46 +0000277Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
278 ConstantSym &Constant) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000279 DictScope S(W, "Constant");
280
Zachary Turner46225b12016-12-16 22:48:14 +0000281 CVTD.printTypeIndex("Type", Constant.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000282 W.printNumber("Value", Constant.Value);
283 W.printString("Name", Constant.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000284 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000285}
286
Zachary Turner0d840742016-10-07 21:34:46 +0000287Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, DataSym &Data) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000288 DictScope S(W, "DataSym");
289
Zachary Turner0d840742016-10-07 21:34:46 +0000290 W.printEnum("Kind", uint16_t(CVR.kind()), getSymbolTypeNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000291 StringRef LinkageName;
292 if (ObjDelegate) {
293 ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000294 Data.DataOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000295 }
Zachary Turner46225b12016-12-16 22:48:14 +0000296 CVTD.printTypeIndex("Type", Data.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000297 W.printString("DisplayName", Data.Name);
298 if (!LinkageName.empty())
299 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000300 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000301}
302
Zachary Turner0d840742016-10-07 21:34:46 +0000303Error CVSymbolDumperImpl::visitKnownRecord(
304 CVSymbol &CVR,
Zachary Turneraaad5742016-05-23 23:41:13 +0000305 DefRangeFramePointerRelFullScopeSym &DefRangeFramePointerRelFullScope) {
306 DictScope S(W, "DefRangeFramePointerRelFullScope");
Zachary Turner46225b12016-12-16 22:48:14 +0000307 W.printNumber("Offset", DefRangeFramePointerRelFullScope.Offset);
Zachary Turner0d840742016-10-07 21:34:46 +0000308 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000309}
310
Zachary Turner0d840742016-10-07 21:34:46 +0000311Error CVSymbolDumperImpl::visitKnownRecord(
312 CVSymbol &CVR, DefRangeFramePointerRelSym &DefRangeFramePointerRel) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000313 DictScope S(W, "DefRangeFramePointerRel");
314
Zachary Turner46225b12016-12-16 22:48:14 +0000315 W.printNumber("Offset", DefRangeFramePointerRel.Offset);
316 printLocalVariableAddrRange(DefRangeFramePointerRel.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000317 DefRangeFramePointerRel.getRelocationOffset());
318 printLocalVariableAddrGap(DefRangeFramePointerRel.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000319 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000320}
321
Zachary Turner0d840742016-10-07 21:34:46 +0000322Error CVSymbolDumperImpl::visitKnownRecord(
323 CVSymbol &CVR, DefRangeRegisterRelSym &DefRangeRegisterRel) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000324 DictScope S(W, "DefRangeRegisterRel");
325
Zachary Turner46225b12016-12-16 22:48:14 +0000326 W.printNumber("BaseRegister", DefRangeRegisterRel.Hdr.Register);
Zachary Turneraaad5742016-05-23 23:41:13 +0000327 W.printBoolean("HasSpilledUDTMember",
328 DefRangeRegisterRel.hasSpilledUDTMember());
329 W.printNumber("OffsetInParent", DefRangeRegisterRel.offsetInParent());
Zachary Turner46225b12016-12-16 22:48:14 +0000330 W.printNumber("BasePointerOffset", DefRangeRegisterRel.Hdr.BasePointerOffset);
331 printLocalVariableAddrRange(DefRangeRegisterRel.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000332 DefRangeRegisterRel.getRelocationOffset());
333 printLocalVariableAddrGap(DefRangeRegisterRel.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000334 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000335}
336
Zachary Turner0d840742016-10-07 21:34:46 +0000337Error CVSymbolDumperImpl::visitKnownRecord(
338 CVSymbol &CVR, DefRangeRegisterSym &DefRangeRegister) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000339 DictScope S(W, "DefRangeRegister");
340
Zachary Turner46225b12016-12-16 22:48:14 +0000341 W.printNumber("Register", DefRangeRegister.Hdr.Register);
342 W.printNumber("MayHaveNoName", DefRangeRegister.Hdr.MayHaveNoName);
343 printLocalVariableAddrRange(DefRangeRegister.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000344 DefRangeRegister.getRelocationOffset());
345 printLocalVariableAddrGap(DefRangeRegister.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000346 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000347}
348
Zachary Turner0d840742016-10-07 21:34:46 +0000349Error CVSymbolDumperImpl::visitKnownRecord(
350 CVSymbol &CVR, DefRangeSubfieldRegisterSym &DefRangeSubfieldRegister) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000351 DictScope S(W, "DefRangeSubfieldRegister");
352
Zachary Turner46225b12016-12-16 22:48:14 +0000353 W.printNumber("Register", DefRangeSubfieldRegister.Hdr.Register);
354 W.printNumber("MayHaveNoName", DefRangeSubfieldRegister.Hdr.MayHaveNoName);
355 W.printNumber("OffsetInParent", DefRangeSubfieldRegister.Hdr.OffsetInParent);
356 printLocalVariableAddrRange(DefRangeSubfieldRegister.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000357 DefRangeSubfieldRegister.getRelocationOffset());
358 printLocalVariableAddrGap(DefRangeSubfieldRegister.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000359 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000360}
361
Zachary Turner0d840742016-10-07 21:34:46 +0000362Error CVSymbolDumperImpl::visitKnownRecord(
363 CVSymbol &CVR, DefRangeSubfieldSym &DefRangeSubfield) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000364 DictScope S(W, "DefRangeSubfield");
365
366 if (ObjDelegate) {
367 StringRef StringTable = ObjDelegate->getStringTable();
Zachary Turner46225b12016-12-16 22:48:14 +0000368 auto ProgramStringTableOffset = DefRangeSubfield.Program;
David Majnemerc6cb2ec2016-05-28 20:04:46 +0000369 if (ProgramStringTableOffset >= StringTable.size())
Zachary Turner0d840742016-10-07 21:34:46 +0000370 return llvm::make_error<CodeViewError>(
371 "String table offset outside of bounds of String Table!");
David Majnemerc6cb2ec2016-05-28 20:04:46 +0000372 StringRef Program =
373 StringTable.drop_front(ProgramStringTableOffset).split('\0').first;
374 W.printString("Program", Program);
Zachary Turneraaad5742016-05-23 23:41:13 +0000375 }
Zachary Turner46225b12016-12-16 22:48:14 +0000376 W.printNumber("OffsetInParent", DefRangeSubfield.OffsetInParent);
377 printLocalVariableAddrRange(DefRangeSubfield.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000378 DefRangeSubfield.getRelocationOffset());
379 printLocalVariableAddrGap(DefRangeSubfield.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000380 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000381}
382
Zachary Turner0d840742016-10-07 21:34:46 +0000383Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
384 DefRangeSym &DefRange) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000385 DictScope S(W, "DefRange");
386
387 if (ObjDelegate) {
388 StringRef StringTable = ObjDelegate->getStringTable();
Zachary Turner46225b12016-12-16 22:48:14 +0000389 auto ProgramStringTableOffset = DefRange.Program;
David Majnemerb3433102016-05-28 19:45:56 +0000390 if (ProgramStringTableOffset >= StringTable.size())
Zachary Turner0d840742016-10-07 21:34:46 +0000391 return llvm::make_error<CodeViewError>(
392 "String table offset outside of bounds of String Table!");
David Majnemerb3433102016-05-28 19:45:56 +0000393 StringRef Program =
394 StringTable.drop_front(ProgramStringTableOffset).split('\0').first;
395 W.printString("Program", Program);
Zachary Turneraaad5742016-05-23 23:41:13 +0000396 }
Zachary Turner46225b12016-12-16 22:48:14 +0000397 printLocalVariableAddrRange(DefRange.Range, DefRange.getRelocationOffset());
Zachary Turneraaad5742016-05-23 23:41:13 +0000398 printLocalVariableAddrGap(DefRange.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000399 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000400}
401
Zachary Turner0d840742016-10-07 21:34:46 +0000402Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
403 FrameCookieSym &FrameCookie) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000404 DictScope S(W, "FrameCookie");
405
406 StringRef LinkageName;
407 if (ObjDelegate) {
Zachary Turner46225b12016-12-16 22:48:14 +0000408 ObjDelegate->printRelocatedField("CodeOffset",
409 FrameCookie.getRelocationOffset(),
410 FrameCookie.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000411 }
Zachary Turner46225b12016-12-16 22:48:14 +0000412 W.printHex("Register", FrameCookie.Register);
413 W.printEnum("CookieKind", uint16_t(FrameCookie.CookieKind),
Zachary Turner93839cb2016-06-02 05:07:49 +0000414 getFrameCookieKindNames());
Zachary Turner46225b12016-12-16 22:48:14 +0000415 W.printHex("Flags", FrameCookie.Flags);
Zachary Turner0d840742016-10-07 21:34:46 +0000416 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000417}
418
Zachary Turner0d840742016-10-07 21:34:46 +0000419Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
Zachary Turneraaad5742016-05-23 23:41:13 +0000420 FrameProcSym &FrameProc) {
421 DictScope S(W, "FrameProc");
422
Zachary Turner46225b12016-12-16 22:48:14 +0000423 W.printHex("TotalFrameBytes", FrameProc.TotalFrameBytes);
424 W.printHex("PaddingFrameBytes", FrameProc.PaddingFrameBytes);
425 W.printHex("OffsetToPadding", FrameProc.OffsetToPadding);
Zachary Turneraaad5742016-05-23 23:41:13 +0000426 W.printHex("BytesOfCalleeSavedRegisters",
Zachary Turner46225b12016-12-16 22:48:14 +0000427 FrameProc.BytesOfCalleeSavedRegisters);
428 W.printHex("OffsetOfExceptionHandler", FrameProc.OffsetOfExceptionHandler);
Zachary Turneraaad5742016-05-23 23:41:13 +0000429 W.printHex("SectionIdOfExceptionHandler",
Zachary Turner46225b12016-12-16 22:48:14 +0000430 FrameProc.SectionIdOfExceptionHandler);
431 W.printFlags("Flags", static_cast<uint32_t>(FrameProc.Flags),
432 getFrameProcSymFlagNames());
Zachary Turner0d840742016-10-07 21:34:46 +0000433 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000434}
435
Zachary Turner0d840742016-10-07 21:34:46 +0000436Error CVSymbolDumperImpl::visitKnownRecord(
437 CVSymbol &CVR, HeapAllocationSiteSym &HeapAllocSite) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000438 DictScope S(W, "HeapAllocationSite");
439
440 StringRef LinkageName;
441 if (ObjDelegate) {
Zachary Turner46225b12016-12-16 22:48:14 +0000442 ObjDelegate->printRelocatedField("CodeOffset",
443 HeapAllocSite.getRelocationOffset(),
444 HeapAllocSite.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000445 }
Zachary Turner46225b12016-12-16 22:48:14 +0000446 W.printHex("Segment", HeapAllocSite.Segment);
447 W.printHex("CallInstructionSize", HeapAllocSite.CallInstructionSize);
448 CVTD.printTypeIndex("Type", HeapAllocSite.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000449 if (!LinkageName.empty())
450 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000451 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000452}
453
Zachary Turner0d840742016-10-07 21:34:46 +0000454Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
455 InlineSiteSym &InlineSite) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000456 DictScope S(W, "InlineSite");
457
Zachary Turner46225b12016-12-16 22:48:14 +0000458 W.printHex("PtrParent", InlineSite.Parent);
459 W.printHex("PtrEnd", InlineSite.End);
460 CVTD.printTypeIndex("Inlinee", InlineSite.Inlinee);
Zachary Turneraaad5742016-05-23 23:41:13 +0000461
462 ListScope BinaryAnnotations(W, "BinaryAnnotations");
463 for (auto &Annotation : InlineSite.annotations()) {
464 switch (Annotation.OpCode) {
465 case BinaryAnnotationsOpCode::Invalid:
Zachary Turner0d840742016-10-07 21:34:46 +0000466 return llvm::make_error<CodeViewError>(
467 "Invalid binary annotation opcode!");
Zachary Turneraaad5742016-05-23 23:41:13 +0000468 case BinaryAnnotationsOpCode::CodeOffset:
469 case BinaryAnnotationsOpCode::ChangeCodeOffset:
470 case BinaryAnnotationsOpCode::ChangeCodeLength:
471 W.printHex(Annotation.Name, Annotation.U1);
472 break;
473 case BinaryAnnotationsOpCode::ChangeCodeOffsetBase:
474 case BinaryAnnotationsOpCode::ChangeLineEndDelta:
475 case BinaryAnnotationsOpCode::ChangeRangeKind:
476 case BinaryAnnotationsOpCode::ChangeColumnStart:
477 case BinaryAnnotationsOpCode::ChangeColumnEnd:
478 W.printNumber(Annotation.Name, Annotation.U1);
479 break;
480 case BinaryAnnotationsOpCode::ChangeLineOffset:
481 case BinaryAnnotationsOpCode::ChangeColumnEndDelta:
482 W.printNumber(Annotation.Name, Annotation.S1);
483 break;
484 case BinaryAnnotationsOpCode::ChangeFile:
485 if (ObjDelegate) {
486 W.printHex("ChangeFile",
487 ObjDelegate->getFileNameForFileOffset(Annotation.U1),
488 Annotation.U1);
489 } else {
490 W.printHex("ChangeFile", Annotation.U1);
491 }
492
493 break;
494 case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset: {
495 W.startLine() << "ChangeCodeOffsetAndLineOffset: {CodeOffset: "
496 << W.hex(Annotation.U1) << ", LineOffset: " << Annotation.S1
497 << "}\n";
498 break;
499 }
500 case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset: {
501 W.startLine() << "ChangeCodeLengthAndCodeOffset: {CodeOffset: "
502 << W.hex(Annotation.U2)
503 << ", Length: " << W.hex(Annotation.U1) << "}\n";
504 break;
505 }
506 }
507 }
Zachary Turner0d840742016-10-07 21:34:46 +0000508 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000509}
510
Zachary Turner0d840742016-10-07 21:34:46 +0000511Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
512 RegisterSym &Register) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000513 DictScope S(W, "RegisterSym");
Zachary Turner46225b12016-12-16 22:48:14 +0000514 W.printNumber("Type", Register.Index);
515 W.printEnum("Seg", uint16_t(Register.Register), getRegisterNames());
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000516 W.printString("Name", Register.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000517 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000518}
519
Zachary Turner0d840742016-10-07 21:34:46 +0000520Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, PublicSym32 &Public) {
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000521 DictScope S(W, "PublicSym");
Zachary Turner46225b12016-12-16 22:48:14 +0000522 W.printNumber("Type", Public.Index);
523 W.printNumber("Seg", Public.Segment);
524 W.printNumber("Off", Public.Offset);
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000525 W.printString("Name", Public.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000526 return Error::success();
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000527}
528
Zachary Turner0d840742016-10-07 21:34:46 +0000529Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ProcRefSym &ProcRef) {
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000530 DictScope S(W, "ProcRef");
Zachary Turner46225b12016-12-16 22:48:14 +0000531 W.printNumber("SumName", ProcRef.SumName);
532 W.printNumber("SymOffset", ProcRef.SymOffset);
533 W.printNumber("Mod", ProcRef.Module);
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000534 W.printString("Name", ProcRef.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000535 return Error::success();
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000536}
537
Zachary Turner0d840742016-10-07 21:34:46 +0000538Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LabelSym &Label) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000539 DictScope S(W, "Label");
540
541 StringRef LinkageName;
542 if (ObjDelegate) {
543 ObjDelegate->printRelocatedField("CodeOffset", Label.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000544 Label.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000545 }
Zachary Turner46225b12016-12-16 22:48:14 +0000546 W.printHex("Segment", Label.Segment);
547 W.printHex("Flags", uint8_t(Label.Flags));
548 W.printFlags("Flags", uint8_t(Label.Flags), getProcSymFlagNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000549 W.printString("DisplayName", Label.Name);
550 if (!LinkageName.empty())
551 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000552 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000553}
554
Zachary Turner0d840742016-10-07 21:34:46 +0000555Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LocalSym &Local) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000556 DictScope S(W, "Local");
557
Zachary Turner46225b12016-12-16 22:48:14 +0000558 CVTD.printTypeIndex("Type", Local.Type);
559 W.printFlags("Flags", uint16_t(Local.Flags), getLocalFlagNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000560 W.printString("VarName", Local.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000561 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000562}
563
Zachary Turner0d840742016-10-07 21:34:46 +0000564Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ObjNameSym &ObjName) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000565 DictScope S(W, "ObjectName");
566
Zachary Turner46225b12016-12-16 22:48:14 +0000567 W.printHex("Signature", ObjName.Signature);
Zachary Turneraaad5742016-05-23 23:41:13 +0000568 W.printString("ObjectName", ObjName.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000569 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000570}
571
Zachary Turner0d840742016-10-07 21:34:46 +0000572Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ProcSym &Proc) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000573 DictScope S(W, "ProcStart");
574
575 if (InFunctionScope)
Zachary Turner0d840742016-10-07 21:34:46 +0000576 return llvm::make_error<CodeViewError>(
577 "Visiting a ProcSym while inside function scope!");
Zachary Turneraaad5742016-05-23 23:41:13 +0000578
579 InFunctionScope = true;
580
581 StringRef LinkageName;
Zachary Turner0d840742016-10-07 21:34:46 +0000582 W.printEnum("Kind", uint16_t(CVR.kind()), getSymbolTypeNames());
Zachary Turner46225b12016-12-16 22:48:14 +0000583 W.printHex("PtrParent", Proc.Parent);
584 W.printHex("PtrEnd", Proc.End);
585 W.printHex("PtrNext", Proc.Next);
586 W.printHex("CodeSize", Proc.CodeSize);
587 W.printHex("DbgStart", Proc.DbgStart);
588 W.printHex("DbgEnd", Proc.DbgEnd);
589 CVTD.printTypeIndex("FunctionType", Proc.FunctionType);
Zachary Turneraaad5742016-05-23 23:41:13 +0000590 if (ObjDelegate) {
591 ObjDelegate->printRelocatedField("CodeOffset", Proc.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000592 Proc.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000593 }
Zachary Turner46225b12016-12-16 22:48:14 +0000594 W.printHex("Segment", Proc.Segment);
595 W.printFlags("Flags", static_cast<uint8_t>(Proc.Flags),
Zachary Turner93839cb2016-06-02 05:07:49 +0000596 getProcSymFlagNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000597 W.printString("DisplayName", Proc.Name);
598 if (!LinkageName.empty())
599 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000600 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000601}
602
Zachary Turner0d840742016-10-07 21:34:46 +0000603Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
604 ScopeEndSym &ScopeEnd) {
605 if (CVR.kind() == SymbolKind::S_END)
Zachary Turnercac29ae2016-05-24 17:30:25 +0000606 DictScope S(W, "BlockEnd");
Zachary Turner0d840742016-10-07 21:34:46 +0000607 else if (CVR.kind() == SymbolKind::S_PROC_ID_END)
Zachary Turnercac29ae2016-05-24 17:30:25 +0000608 DictScope S(W, "ProcEnd");
Zachary Turner0d840742016-10-07 21:34:46 +0000609 else if (CVR.kind() == SymbolKind::S_INLINESITE_END)
Zachary Turneraaad5742016-05-23 23:41:13 +0000610 DictScope S(W, "InlineSiteEnd");
611
612 InFunctionScope = false;
Zachary Turner0d840742016-10-07 21:34:46 +0000613 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000614}
615
Zachary Turner0d840742016-10-07 21:34:46 +0000616Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, CallerSym &Caller) {
617 ListScope S(W, CVR.kind() == S_CALLEES ? "Callees" : "Callers");
Zachary Turneraaad5742016-05-23 23:41:13 +0000618 for (auto FuncID : Caller.Indices)
619 CVTD.printTypeIndex("FuncID", FuncID);
Zachary Turner0d840742016-10-07 21:34:46 +0000620 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000621}
622
Zachary Turner0d840742016-10-07 21:34:46 +0000623Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
624 RegRelativeSym &RegRel) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000625 DictScope S(W, "RegRelativeSym");
626
Zachary Turner46225b12016-12-16 22:48:14 +0000627 W.printHex("Offset", RegRel.Offset);
628 CVTD.printTypeIndex("Type", RegRel.Type);
629 W.printHex("Register", RegRel.Register);
Zachary Turneraaad5742016-05-23 23:41:13 +0000630 W.printString("VarName", RegRel.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000631 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000632}
633
Zachary Turner0d840742016-10-07 21:34:46 +0000634Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
635 ThreadLocalDataSym &Data) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000636 DictScope S(W, "ThreadLocalDataSym");
637
638 StringRef LinkageName;
639 if (ObjDelegate) {
640 ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000641 Data.DataOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000642 }
Zachary Turner46225b12016-12-16 22:48:14 +0000643 CVTD.printTypeIndex("Type", Data.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000644 W.printString("DisplayName", Data.Name);
645 if (!LinkageName.empty())
646 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000647 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000648}
649
Zachary Turner0d840742016-10-07 21:34:46 +0000650Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, UDTSym &UDT) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000651 DictScope S(W, "UDT");
Zachary Turner46225b12016-12-16 22:48:14 +0000652 CVTD.printTypeIndex("Type", UDT.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000653 W.printString("UDTName", UDT.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000654 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000655}
656
Zachary Turner0d840742016-10-07 21:34:46 +0000657Error CVSymbolDumperImpl::visitUnknownSymbol(CVSymbol &CVR) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000658 DictScope S(W, "UnknownSym");
Zachary Turner0d840742016-10-07 21:34:46 +0000659 W.printEnum("Kind", uint16_t(CVR.kind()), getSymbolTypeNames());
660 W.printNumber("Length", CVR.length());
661 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000662}
663
Zachary Turner0d840742016-10-07 21:34:46 +0000664Error CVSymbolDumper::dump(CVRecord<SymbolKind> &Record) {
665 SymbolVisitorCallbackPipeline Pipeline;
666 SymbolDeserializer Deserializer(ObjDelegate.get());
Zachary Turner3e78e2d2016-05-24 00:06:04 +0000667 CVSymbolDumperImpl Dumper(CVTD, ObjDelegate.get(), W, PrintRecordBytes);
Zachary Turner0d840742016-10-07 21:34:46 +0000668
669 Pipeline.addCallbackToPipeline(Deserializer);
670 Pipeline.addCallbackToPipeline(Dumper);
671 CVSymbolVisitor Visitor(Pipeline);
672 return Visitor.visitSymbolRecord(Record);
Zachary Turneraaad5742016-05-23 23:41:13 +0000673}
674
Zachary Turner0d840742016-10-07 21:34:46 +0000675Error CVSymbolDumper::dump(const CVSymbolArray &Symbols) {
676 SymbolVisitorCallbackPipeline Pipeline;
677 SymbolDeserializer Deserializer(ObjDelegate.get());
Zachary Turner3e78e2d2016-05-24 00:06:04 +0000678 CVSymbolDumperImpl Dumper(CVTD, ObjDelegate.get(), W, PrintRecordBytes);
Zachary Turner0d840742016-10-07 21:34:46 +0000679
680 Pipeline.addCallbackToPipeline(Deserializer);
681 Pipeline.addCallbackToPipeline(Dumper);
682 CVSymbolVisitor Visitor(Pipeline);
683 return Visitor.visitSymbolStream(Symbols);
Zachary Turneraaad5742016-05-23 23:41:13 +0000684}