blob: fd54fba13c763627c518de5f4758a706f2ee2065 [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 Turnera9054dd2017-01-11 00:35:43 +000014#include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
Zachary Turner93839cb2016-06-02 05:07:49 +000015#include "llvm/DebugInfo/CodeView/EnumTables.h"
Zachary Turner0d840742016-10-07 21:34:46 +000016#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
Zachary Turneraaad5742016-05-23 23:41:13 +000017#include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h"
18#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
Zachary Turner0d840742016-10-07 21:34:46 +000019#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h"
20#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h"
Zachary Turneraaad5742016-05-23 23:41:13 +000021#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 Turner629cb7d2017-01-11 23:24:22 +000035 CVSymbolDumperImpl(TypeDatabase &TypeDB, SymbolDumpDelegate *ObjDelegate,
Zachary Turner3e78e2d2016-05-24 00:06:04 +000036 ScopedPrinter &W, bool PrintRecordBytes)
Zachary Turner629cb7d2017-01-11 23:24:22 +000037 : TypeDB(TypeDB), ObjDelegate(ObjDelegate), W(W),
Zachary Turner0d840742016-10-07 21:34:46 +000038 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);
Zachary Turner629cb7d2017-01-11 23:24:22 +000054 void printTypeIndex(StringRef FieldName, TypeIndex TI);
Zachary Turneraaad5742016-05-23 23:41:13 +000055
Zachary Turner629cb7d2017-01-11 23:24:22 +000056 TypeDatabase &TypeDB;
Zachary Turneraaad5742016-05-23 23:41:13 +000057 SymbolDumpDelegate *ObjDelegate;
58 ScopedPrinter &W;
59
60 bool PrintRecordBytes;
61 bool InFunctionScope;
62};
63}
64
65void CVSymbolDumperImpl::printLocalVariableAddrRange(
66 const LocalVariableAddrRange &Range, uint32_t RelocationOffset) {
67 DictScope S(W, "LocalVariableAddrRange");
68 if (ObjDelegate)
69 ObjDelegate->printRelocatedField("OffsetStart", RelocationOffset,
70 Range.OffsetStart);
71 W.printHex("ISectStart", Range.ISectStart);
72 W.printHex("Range", Range.Range);
73}
74
75void CVSymbolDumperImpl::printLocalVariableAddrGap(
76 ArrayRef<LocalVariableAddrGap> Gaps) {
77 for (auto &Gap : Gaps) {
78 ListScope S(W, "LocalVariableAddrGap");
79 W.printHex("GapStartOffset", Gap.GapStartOffset);
80 W.printHex("Range", Gap.Range);
81 }
82}
83
Zachary Turner629cb7d2017-01-11 23:24:22 +000084void CVSymbolDumperImpl::printTypeIndex(StringRef FieldName, TypeIndex TI) {
85 CVTypeDumper::printTypeIndex(W, FieldName, TI, TypeDB);
86}
87
Zachary Turner0d840742016-10-07 21:34:46 +000088Error CVSymbolDumperImpl::visitSymbolBegin(CVSymbol &CVR) {
89 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +000090}
91
Zachary Turner0d840742016-10-07 21:34:46 +000092Error CVSymbolDumperImpl::visitSymbolEnd(CVSymbol &CVR) {
93 if (PrintRecordBytes && ObjDelegate)
94 ObjDelegate->printBinaryBlockWithRelocs("SymData", CVR.content());
95 return Error::success();
96}
97
98Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, BlockSym &Block) {
Zachary Turneraaad5742016-05-23 23:41:13 +000099 DictScope S(W, "BlockStart");
100
101 StringRef LinkageName;
Zachary Turner46225b12016-12-16 22:48:14 +0000102 W.printHex("PtrParent", Block.Parent);
103 W.printHex("PtrEnd", Block.End);
104 W.printHex("CodeSize", Block.CodeSize);
Zachary Turneraaad5742016-05-23 23:41:13 +0000105 if (ObjDelegate) {
106 ObjDelegate->printRelocatedField("CodeOffset", Block.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000107 Block.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000108 }
Zachary Turner46225b12016-12-16 22:48:14 +0000109 W.printHex("Segment", Block.Segment);
Zachary Turneraaad5742016-05-23 23:41:13 +0000110 W.printString("BlockName", Block.Name);
111 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000112 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000113}
114
Zachary Turner0d840742016-10-07 21:34:46 +0000115Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, Thunk32Sym &Thunk) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000116 DictScope S(W, "Thunk32");
Zachary Turner46225b12016-12-16 22:48:14 +0000117 W.printNumber("Parent", Thunk.Parent);
118 W.printNumber("End", Thunk.End);
119 W.printNumber("Next", Thunk.Next);
120 W.printNumber("Off", Thunk.Offset);
121 W.printNumber("Seg", Thunk.Segment);
122 W.printNumber("Len", Thunk.Length);
123 W.printEnum("Ordinal", uint8_t(Thunk.Thunk), getThunkOrdinalNames());
Zachary Turner0d840742016-10-07 21:34:46 +0000124 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000125}
126
Zachary Turner0d840742016-10-07 21:34:46 +0000127Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
128 TrampolineSym &Tramp) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000129 DictScope S(W, "Trampoline");
Zachary Turner46225b12016-12-16 22:48:14 +0000130 W.printEnum("Type", uint16_t(Tramp.Type), getTrampolineNames());
131 W.printNumber("Size", Tramp.Size);
132 W.printNumber("ThunkOff", Tramp.ThunkOffset);
133 W.printNumber("TargetOff", Tramp.TargetOffset);
134 W.printNumber("ThunkSection", Tramp.ThunkSection);
135 W.printNumber("TargetSection", Tramp.TargetSection);
Zachary Turner0d840742016-10-07 21:34:46 +0000136 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000137}
138
Zachary Turner0d840742016-10-07 21:34:46 +0000139Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, SectionSym &Section) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000140 DictScope S(W, "Section");
Zachary Turner46225b12016-12-16 22:48:14 +0000141 W.printNumber("SectionNumber", Section.SectionNumber);
142 W.printNumber("Alignment", Section.Alignment);
143 W.printNumber("Rva", Section.Rva);
144 W.printNumber("Length", Section.Length);
145 W.printFlags("Characteristics", Section.Characteristics,
Zachary Turner93839cb2016-06-02 05:07:49 +0000146 getImageSectionCharacteristicNames(),
147 COFF::SectionCharacteristics(0x00F00000));
148
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000149 W.printString("Name", Section.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000150 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000151}
152
Zachary Turner0d840742016-10-07 21:34:46 +0000153Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000154 CoffGroupSym &CoffGroup) {
155 DictScope S(W, "COFF Group");
Zachary Turner46225b12016-12-16 22:48:14 +0000156 W.printNumber("Size", CoffGroup.Size);
157 W.printFlags("Characteristics", CoffGroup.Characteristics,
Zachary Turner93839cb2016-06-02 05:07:49 +0000158 getImageSectionCharacteristicNames(),
159 COFF::SectionCharacteristics(0x00F00000));
Zachary Turner46225b12016-12-16 22:48:14 +0000160 W.printNumber("Offset", CoffGroup.Offset);
161 W.printNumber("Segment", CoffGroup.Segment);
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000162 W.printString("Name", CoffGroup.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000163 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000164}
165
Zachary Turner0d840742016-10-07 21:34:46 +0000166Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
167 BPRelativeSym &BPRel) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000168 DictScope S(W, "BPRelativeSym");
169
Zachary Turner46225b12016-12-16 22:48:14 +0000170 W.printNumber("Offset", BPRel.Offset);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000171 printTypeIndex("Type", BPRel.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000172 W.printString("VarName", BPRel.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000173 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000174}
175
Zachary Turner0d840742016-10-07 21:34:46 +0000176Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
Zachary Turneraaad5742016-05-23 23:41:13 +0000177 BuildInfoSym &BuildInfo) {
178 DictScope S(W, "BuildInfo");
179
Zachary Turner46225b12016-12-16 22:48:14 +0000180 W.printNumber("BuildId", BuildInfo.BuildId);
Zachary Turner0d840742016-10-07 21:34:46 +0000181 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000182}
183
Zachary Turner0d840742016-10-07 21:34:46 +0000184Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
185 CallSiteInfoSym &CallSiteInfo) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000186 DictScope S(W, "CallSiteInfo");
187
188 StringRef LinkageName;
189 if (ObjDelegate) {
Zachary Turner46225b12016-12-16 22:48:14 +0000190 ObjDelegate->printRelocatedField("CodeOffset",
191 CallSiteInfo.getRelocationOffset(),
192 CallSiteInfo.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000193 }
Zachary Turner46225b12016-12-16 22:48:14 +0000194 W.printHex("Segment", CallSiteInfo.Segment);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000195 printTypeIndex("Type", CallSiteInfo.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000196 if (!LinkageName.empty())
197 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000198 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000199}
200
Zachary Turner0d840742016-10-07 21:34:46 +0000201Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
202 EnvBlockSym &EnvBlock) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000203 DictScope S(W, "EnvBlock");
204
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000205 ListScope L(W, "Entries");
206 for (auto Entry : EnvBlock.Fields) {
207 W.printString(Entry);
208 }
Zachary Turner0d840742016-10-07 21:34:46 +0000209 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000210}
211
Zachary Turner0d840742016-10-07 21:34:46 +0000212Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
213 FileStaticSym &FileStatic) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000214 DictScope S(W, "FileStatic");
Zachary Turner46225b12016-12-16 22:48:14 +0000215 W.printNumber("Index", FileStatic.Index);
216 W.printNumber("ModFilenameOffset", FileStatic.ModFilenameOffset);
217 W.printFlags("Flags", uint16_t(FileStatic.Flags), getLocalFlagNames());
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000218 W.printString("Name", FileStatic.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000219 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000220}
221
Zachary Turner0d840742016-10-07 21:34:46 +0000222Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ExportSym &Export) {
Zachary Turner9f054d42016-05-25 00:12:40 +0000223 DictScope S(W, "Export");
Zachary Turner46225b12016-12-16 22:48:14 +0000224 W.printNumber("Ordinal", Export.Ordinal);
225 W.printFlags("Flags", uint16_t(Export.Flags), getExportSymFlagNames());
Zachary Turner9f054d42016-05-25 00:12:40 +0000226 W.printString("Name", Export.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000227 return Error::success();
Zachary Turner9f054d42016-05-25 00:12:40 +0000228}
229
Zachary Turner0d840742016-10-07 21:34:46 +0000230Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
231 Compile2Sym &Compile2) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000232 DictScope S(W, "CompilerFlags2");
233
Zachary Turner46225b12016-12-16 22:48:14 +0000234 W.printEnum("Language", Compile2.getLanguage(), getSourceLanguageNames());
235 W.printFlags("Flags", Compile2.getFlags(), getCompileSym2FlagNames());
236 W.printEnum("Machine", unsigned(Compile2.Machine), getCPUTypeNames());
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000237 std::string FrontendVersion;
238 {
239 raw_string_ostream Out(FrontendVersion);
Zachary Turner46225b12016-12-16 22:48:14 +0000240 Out << Compile2.VersionFrontendMajor << '.' << Compile2.VersionFrontendMinor
241 << '.' << Compile2.VersionFrontendBuild;
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000242 }
243 std::string BackendVersion;
244 {
245 raw_string_ostream Out(BackendVersion);
Zachary Turner46225b12016-12-16 22:48:14 +0000246 Out << Compile2.VersionBackendMajor << '.' << Compile2.VersionBackendMinor
247 << '.' << Compile2.VersionBackendBuild;
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000248 }
249 W.printString("FrontendVersion", FrontendVersion);
250 W.printString("BackendVersion", BackendVersion);
251 W.printString("VersionName", Compile2.Version);
Zachary Turner0d840742016-10-07 21:34:46 +0000252 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000253}
254
Zachary Turner0d840742016-10-07 21:34:46 +0000255Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
256 Compile3Sym &Compile3) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000257 DictScope S(W, "CompilerFlags3");
Zachary Turneraaad5742016-05-23 23:41:13 +0000258
Zachary Turner46225b12016-12-16 22:48:14 +0000259 W.printEnum("Language", Compile3.getLanguage(), getSourceLanguageNames());
260 W.printFlags("Flags", Compile3.getFlags(), getCompileSym3FlagNames());
261 W.printEnum("Machine", unsigned(Compile3.Machine), getCPUTypeNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000262 std::string FrontendVersion;
263 {
264 raw_string_ostream Out(FrontendVersion);
Zachary Turner46225b12016-12-16 22:48:14 +0000265 Out << Compile3.VersionFrontendMajor << '.' << Compile3.VersionFrontendMinor
266 << '.' << Compile3.VersionFrontendBuild << '.'
267 << Compile3.VersionFrontendQFE;
Zachary Turneraaad5742016-05-23 23:41:13 +0000268 }
269 std::string BackendVersion;
270 {
271 raw_string_ostream Out(BackendVersion);
Zachary Turner46225b12016-12-16 22:48:14 +0000272 Out << Compile3.VersionBackendMajor << '.' << Compile3.VersionBackendMinor
273 << '.' << Compile3.VersionBackendBuild << '.'
274 << Compile3.VersionBackendQFE;
Zachary Turneraaad5742016-05-23 23:41:13 +0000275 }
276 W.printString("FrontendVersion", FrontendVersion);
277 W.printString("BackendVersion", BackendVersion);
278 W.printString("VersionName", Compile3.Version);
Zachary Turner0d840742016-10-07 21:34:46 +0000279 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000280}
281
Zachary Turner0d840742016-10-07 21:34:46 +0000282Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
283 ConstantSym &Constant) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000284 DictScope S(W, "Constant");
285
Zachary Turner629cb7d2017-01-11 23:24:22 +0000286 printTypeIndex("Type", Constant.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000287 W.printNumber("Value", Constant.Value);
288 W.printString("Name", Constant.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000289 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000290}
291
Zachary Turner0d840742016-10-07 21:34:46 +0000292Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, DataSym &Data) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000293 DictScope S(W, "DataSym");
294
Zachary Turner0d840742016-10-07 21:34:46 +0000295 W.printEnum("Kind", uint16_t(CVR.kind()), getSymbolTypeNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000296 StringRef LinkageName;
297 if (ObjDelegate) {
298 ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000299 Data.DataOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000300 }
Zachary Turner629cb7d2017-01-11 23:24:22 +0000301 printTypeIndex("Type", Data.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000302 W.printString("DisplayName", Data.Name);
303 if (!LinkageName.empty())
304 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000305 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000306}
307
Zachary Turner0d840742016-10-07 21:34:46 +0000308Error CVSymbolDumperImpl::visitKnownRecord(
309 CVSymbol &CVR,
Zachary Turneraaad5742016-05-23 23:41:13 +0000310 DefRangeFramePointerRelFullScopeSym &DefRangeFramePointerRelFullScope) {
311 DictScope S(W, "DefRangeFramePointerRelFullScope");
Zachary Turner46225b12016-12-16 22:48:14 +0000312 W.printNumber("Offset", DefRangeFramePointerRelFullScope.Offset);
Zachary Turner0d840742016-10-07 21:34:46 +0000313 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000314}
315
Zachary Turner0d840742016-10-07 21:34:46 +0000316Error CVSymbolDumperImpl::visitKnownRecord(
317 CVSymbol &CVR, DefRangeFramePointerRelSym &DefRangeFramePointerRel) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000318 DictScope S(W, "DefRangeFramePointerRel");
319
Zachary Turner46225b12016-12-16 22:48:14 +0000320 W.printNumber("Offset", DefRangeFramePointerRel.Offset);
321 printLocalVariableAddrRange(DefRangeFramePointerRel.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000322 DefRangeFramePointerRel.getRelocationOffset());
323 printLocalVariableAddrGap(DefRangeFramePointerRel.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000324 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000325}
326
Zachary Turner0d840742016-10-07 21:34:46 +0000327Error CVSymbolDumperImpl::visitKnownRecord(
328 CVSymbol &CVR, DefRangeRegisterRelSym &DefRangeRegisterRel) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000329 DictScope S(W, "DefRangeRegisterRel");
330
Zachary Turner46225b12016-12-16 22:48:14 +0000331 W.printNumber("BaseRegister", DefRangeRegisterRel.Hdr.Register);
Zachary Turneraaad5742016-05-23 23:41:13 +0000332 W.printBoolean("HasSpilledUDTMember",
333 DefRangeRegisterRel.hasSpilledUDTMember());
334 W.printNumber("OffsetInParent", DefRangeRegisterRel.offsetInParent());
Zachary Turner46225b12016-12-16 22:48:14 +0000335 W.printNumber("BasePointerOffset", DefRangeRegisterRel.Hdr.BasePointerOffset);
336 printLocalVariableAddrRange(DefRangeRegisterRel.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000337 DefRangeRegisterRel.getRelocationOffset());
338 printLocalVariableAddrGap(DefRangeRegisterRel.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000339 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000340}
341
Zachary Turner0d840742016-10-07 21:34:46 +0000342Error CVSymbolDumperImpl::visitKnownRecord(
343 CVSymbol &CVR, DefRangeRegisterSym &DefRangeRegister) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000344 DictScope S(W, "DefRangeRegister");
345
Zachary Turner46225b12016-12-16 22:48:14 +0000346 W.printNumber("Register", DefRangeRegister.Hdr.Register);
347 W.printNumber("MayHaveNoName", DefRangeRegister.Hdr.MayHaveNoName);
348 printLocalVariableAddrRange(DefRangeRegister.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000349 DefRangeRegister.getRelocationOffset());
350 printLocalVariableAddrGap(DefRangeRegister.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000351 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000352}
353
Zachary Turner0d840742016-10-07 21:34:46 +0000354Error CVSymbolDumperImpl::visitKnownRecord(
355 CVSymbol &CVR, DefRangeSubfieldRegisterSym &DefRangeSubfieldRegister) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000356 DictScope S(W, "DefRangeSubfieldRegister");
357
Zachary Turner46225b12016-12-16 22:48:14 +0000358 W.printNumber("Register", DefRangeSubfieldRegister.Hdr.Register);
359 W.printNumber("MayHaveNoName", DefRangeSubfieldRegister.Hdr.MayHaveNoName);
360 W.printNumber("OffsetInParent", DefRangeSubfieldRegister.Hdr.OffsetInParent);
361 printLocalVariableAddrRange(DefRangeSubfieldRegister.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000362 DefRangeSubfieldRegister.getRelocationOffset());
363 printLocalVariableAddrGap(DefRangeSubfieldRegister.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000364 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000365}
366
Zachary Turner0d840742016-10-07 21:34:46 +0000367Error CVSymbolDumperImpl::visitKnownRecord(
368 CVSymbol &CVR, DefRangeSubfieldSym &DefRangeSubfield) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000369 DictScope S(W, "DefRangeSubfield");
370
371 if (ObjDelegate) {
372 StringRef StringTable = ObjDelegate->getStringTable();
Zachary Turner46225b12016-12-16 22:48:14 +0000373 auto ProgramStringTableOffset = DefRangeSubfield.Program;
David Majnemerc6cb2ec2016-05-28 20:04:46 +0000374 if (ProgramStringTableOffset >= StringTable.size())
Zachary Turner0d840742016-10-07 21:34:46 +0000375 return llvm::make_error<CodeViewError>(
376 "String table offset outside of bounds of String Table!");
David Majnemerc6cb2ec2016-05-28 20:04:46 +0000377 StringRef Program =
378 StringTable.drop_front(ProgramStringTableOffset).split('\0').first;
379 W.printString("Program", Program);
Zachary Turneraaad5742016-05-23 23:41:13 +0000380 }
Zachary Turner46225b12016-12-16 22:48:14 +0000381 W.printNumber("OffsetInParent", DefRangeSubfield.OffsetInParent);
382 printLocalVariableAddrRange(DefRangeSubfield.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000383 DefRangeSubfield.getRelocationOffset());
384 printLocalVariableAddrGap(DefRangeSubfield.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000385 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000386}
387
Zachary Turner0d840742016-10-07 21:34:46 +0000388Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
389 DefRangeSym &DefRange) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000390 DictScope S(W, "DefRange");
391
392 if (ObjDelegate) {
393 StringRef StringTable = ObjDelegate->getStringTable();
Zachary Turner46225b12016-12-16 22:48:14 +0000394 auto ProgramStringTableOffset = DefRange.Program;
David Majnemerb3433102016-05-28 19:45:56 +0000395 if (ProgramStringTableOffset >= StringTable.size())
Zachary Turner0d840742016-10-07 21:34:46 +0000396 return llvm::make_error<CodeViewError>(
397 "String table offset outside of bounds of String Table!");
David Majnemerb3433102016-05-28 19:45:56 +0000398 StringRef Program =
399 StringTable.drop_front(ProgramStringTableOffset).split('\0').first;
400 W.printString("Program", Program);
Zachary Turneraaad5742016-05-23 23:41:13 +0000401 }
Zachary Turner46225b12016-12-16 22:48:14 +0000402 printLocalVariableAddrRange(DefRange.Range, DefRange.getRelocationOffset());
Zachary Turneraaad5742016-05-23 23:41:13 +0000403 printLocalVariableAddrGap(DefRange.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000404 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000405}
406
Zachary Turner0d840742016-10-07 21:34:46 +0000407Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
408 FrameCookieSym &FrameCookie) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000409 DictScope S(W, "FrameCookie");
410
411 StringRef LinkageName;
412 if (ObjDelegate) {
Zachary Turner46225b12016-12-16 22:48:14 +0000413 ObjDelegate->printRelocatedField("CodeOffset",
414 FrameCookie.getRelocationOffset(),
415 FrameCookie.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000416 }
Zachary Turner46225b12016-12-16 22:48:14 +0000417 W.printHex("Register", FrameCookie.Register);
418 W.printEnum("CookieKind", uint16_t(FrameCookie.CookieKind),
Zachary Turner93839cb2016-06-02 05:07:49 +0000419 getFrameCookieKindNames());
Zachary Turner46225b12016-12-16 22:48:14 +0000420 W.printHex("Flags", FrameCookie.Flags);
Zachary Turner0d840742016-10-07 21:34:46 +0000421 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000422}
423
Zachary Turner0d840742016-10-07 21:34:46 +0000424Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
Zachary Turneraaad5742016-05-23 23:41:13 +0000425 FrameProcSym &FrameProc) {
426 DictScope S(W, "FrameProc");
427
Zachary Turner46225b12016-12-16 22:48:14 +0000428 W.printHex("TotalFrameBytes", FrameProc.TotalFrameBytes);
429 W.printHex("PaddingFrameBytes", FrameProc.PaddingFrameBytes);
430 W.printHex("OffsetToPadding", FrameProc.OffsetToPadding);
Zachary Turneraaad5742016-05-23 23:41:13 +0000431 W.printHex("BytesOfCalleeSavedRegisters",
Zachary Turner46225b12016-12-16 22:48:14 +0000432 FrameProc.BytesOfCalleeSavedRegisters);
433 W.printHex("OffsetOfExceptionHandler", FrameProc.OffsetOfExceptionHandler);
Zachary Turneraaad5742016-05-23 23:41:13 +0000434 W.printHex("SectionIdOfExceptionHandler",
Zachary Turner46225b12016-12-16 22:48:14 +0000435 FrameProc.SectionIdOfExceptionHandler);
436 W.printFlags("Flags", static_cast<uint32_t>(FrameProc.Flags),
437 getFrameProcSymFlagNames());
Zachary Turner0d840742016-10-07 21:34:46 +0000438 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000439}
440
Zachary Turner0d840742016-10-07 21:34:46 +0000441Error CVSymbolDumperImpl::visitKnownRecord(
442 CVSymbol &CVR, HeapAllocationSiteSym &HeapAllocSite) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000443 DictScope S(W, "HeapAllocationSite");
444
445 StringRef LinkageName;
446 if (ObjDelegate) {
Zachary Turner46225b12016-12-16 22:48:14 +0000447 ObjDelegate->printRelocatedField("CodeOffset",
448 HeapAllocSite.getRelocationOffset(),
449 HeapAllocSite.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000450 }
Zachary Turner46225b12016-12-16 22:48:14 +0000451 W.printHex("Segment", HeapAllocSite.Segment);
452 W.printHex("CallInstructionSize", HeapAllocSite.CallInstructionSize);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000453 printTypeIndex("Type", HeapAllocSite.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000454 if (!LinkageName.empty())
455 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000456 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000457}
458
Zachary Turner0d840742016-10-07 21:34:46 +0000459Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
460 InlineSiteSym &InlineSite) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000461 DictScope S(W, "InlineSite");
462
Zachary Turner46225b12016-12-16 22:48:14 +0000463 W.printHex("PtrParent", InlineSite.Parent);
464 W.printHex("PtrEnd", InlineSite.End);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000465 printTypeIndex("Inlinee", InlineSite.Inlinee);
Zachary Turneraaad5742016-05-23 23:41:13 +0000466
467 ListScope BinaryAnnotations(W, "BinaryAnnotations");
468 for (auto &Annotation : InlineSite.annotations()) {
469 switch (Annotation.OpCode) {
470 case BinaryAnnotationsOpCode::Invalid:
Zachary Turner0d840742016-10-07 21:34:46 +0000471 return llvm::make_error<CodeViewError>(
472 "Invalid binary annotation opcode!");
Zachary Turneraaad5742016-05-23 23:41:13 +0000473 case BinaryAnnotationsOpCode::CodeOffset:
474 case BinaryAnnotationsOpCode::ChangeCodeOffset:
475 case BinaryAnnotationsOpCode::ChangeCodeLength:
476 W.printHex(Annotation.Name, Annotation.U1);
477 break;
478 case BinaryAnnotationsOpCode::ChangeCodeOffsetBase:
479 case BinaryAnnotationsOpCode::ChangeLineEndDelta:
480 case BinaryAnnotationsOpCode::ChangeRangeKind:
481 case BinaryAnnotationsOpCode::ChangeColumnStart:
482 case BinaryAnnotationsOpCode::ChangeColumnEnd:
483 W.printNumber(Annotation.Name, Annotation.U1);
484 break;
485 case BinaryAnnotationsOpCode::ChangeLineOffset:
486 case BinaryAnnotationsOpCode::ChangeColumnEndDelta:
487 W.printNumber(Annotation.Name, Annotation.S1);
488 break;
489 case BinaryAnnotationsOpCode::ChangeFile:
490 if (ObjDelegate) {
491 W.printHex("ChangeFile",
492 ObjDelegate->getFileNameForFileOffset(Annotation.U1),
493 Annotation.U1);
494 } else {
495 W.printHex("ChangeFile", Annotation.U1);
496 }
497
498 break;
499 case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset: {
500 W.startLine() << "ChangeCodeOffsetAndLineOffset: {CodeOffset: "
501 << W.hex(Annotation.U1) << ", LineOffset: " << Annotation.S1
502 << "}\n";
503 break;
504 }
505 case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset: {
506 W.startLine() << "ChangeCodeLengthAndCodeOffset: {CodeOffset: "
507 << W.hex(Annotation.U2)
508 << ", Length: " << W.hex(Annotation.U1) << "}\n";
509 break;
510 }
511 }
512 }
Zachary Turner0d840742016-10-07 21:34:46 +0000513 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000514}
515
Zachary Turner0d840742016-10-07 21:34:46 +0000516Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
517 RegisterSym &Register) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000518 DictScope S(W, "RegisterSym");
Zachary Turner46225b12016-12-16 22:48:14 +0000519 W.printNumber("Type", Register.Index);
520 W.printEnum("Seg", uint16_t(Register.Register), getRegisterNames());
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000521 W.printString("Name", Register.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000522 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000523}
524
Zachary Turner0d840742016-10-07 21:34:46 +0000525Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, PublicSym32 &Public) {
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000526 DictScope S(W, "PublicSym");
Zachary Turner46225b12016-12-16 22:48:14 +0000527 W.printNumber("Type", Public.Index);
528 W.printNumber("Seg", Public.Segment);
529 W.printNumber("Off", Public.Offset);
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000530 W.printString("Name", Public.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000531 return Error::success();
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000532}
533
Zachary Turner0d840742016-10-07 21:34:46 +0000534Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ProcRefSym &ProcRef) {
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000535 DictScope S(W, "ProcRef");
Zachary Turner46225b12016-12-16 22:48:14 +0000536 W.printNumber("SumName", ProcRef.SumName);
537 W.printNumber("SymOffset", ProcRef.SymOffset);
538 W.printNumber("Mod", ProcRef.Module);
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000539 W.printString("Name", ProcRef.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000540 return Error::success();
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000541}
542
Zachary Turner0d840742016-10-07 21:34:46 +0000543Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LabelSym &Label) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000544 DictScope S(W, "Label");
545
546 StringRef LinkageName;
547 if (ObjDelegate) {
548 ObjDelegate->printRelocatedField("CodeOffset", Label.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000549 Label.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000550 }
Zachary Turner46225b12016-12-16 22:48:14 +0000551 W.printHex("Segment", Label.Segment);
552 W.printHex("Flags", uint8_t(Label.Flags));
553 W.printFlags("Flags", uint8_t(Label.Flags), getProcSymFlagNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000554 W.printString("DisplayName", Label.Name);
555 if (!LinkageName.empty())
556 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000557 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000558}
559
Zachary Turner0d840742016-10-07 21:34:46 +0000560Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LocalSym &Local) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000561 DictScope S(W, "Local");
562
Zachary Turner629cb7d2017-01-11 23:24:22 +0000563 printTypeIndex("Type", Local.Type);
Zachary Turner46225b12016-12-16 22:48:14 +0000564 W.printFlags("Flags", uint16_t(Local.Flags), getLocalFlagNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000565 W.printString("VarName", Local.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000566 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000567}
568
Zachary Turner0d840742016-10-07 21:34:46 +0000569Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ObjNameSym &ObjName) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000570 DictScope S(W, "ObjectName");
571
Zachary Turner46225b12016-12-16 22:48:14 +0000572 W.printHex("Signature", ObjName.Signature);
Zachary Turneraaad5742016-05-23 23:41:13 +0000573 W.printString("ObjectName", ObjName.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000574 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000575}
576
Zachary Turner0d840742016-10-07 21:34:46 +0000577Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ProcSym &Proc) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000578 DictScope S(W, "ProcStart");
579
580 if (InFunctionScope)
Zachary Turner0d840742016-10-07 21:34:46 +0000581 return llvm::make_error<CodeViewError>(
582 "Visiting a ProcSym while inside function scope!");
Zachary Turneraaad5742016-05-23 23:41:13 +0000583
584 InFunctionScope = true;
585
586 StringRef LinkageName;
Zachary Turner0d840742016-10-07 21:34:46 +0000587 W.printEnum("Kind", uint16_t(CVR.kind()), getSymbolTypeNames());
Zachary Turner46225b12016-12-16 22:48:14 +0000588 W.printHex("PtrParent", Proc.Parent);
589 W.printHex("PtrEnd", Proc.End);
590 W.printHex("PtrNext", Proc.Next);
591 W.printHex("CodeSize", Proc.CodeSize);
592 W.printHex("DbgStart", Proc.DbgStart);
593 W.printHex("DbgEnd", Proc.DbgEnd);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000594 printTypeIndex("FunctionType", Proc.FunctionType);
Zachary Turneraaad5742016-05-23 23:41:13 +0000595 if (ObjDelegate) {
596 ObjDelegate->printRelocatedField("CodeOffset", Proc.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000597 Proc.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000598 }
Zachary Turner46225b12016-12-16 22:48:14 +0000599 W.printHex("Segment", Proc.Segment);
600 W.printFlags("Flags", static_cast<uint8_t>(Proc.Flags),
Zachary Turner93839cb2016-06-02 05:07:49 +0000601 getProcSymFlagNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000602 W.printString("DisplayName", Proc.Name);
603 if (!LinkageName.empty())
604 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000605 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000606}
607
Zachary Turner0d840742016-10-07 21:34:46 +0000608Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
609 ScopeEndSym &ScopeEnd) {
610 if (CVR.kind() == SymbolKind::S_END)
Zachary Turnercac29ae2016-05-24 17:30:25 +0000611 DictScope S(W, "BlockEnd");
Zachary Turner0d840742016-10-07 21:34:46 +0000612 else if (CVR.kind() == SymbolKind::S_PROC_ID_END)
Zachary Turnercac29ae2016-05-24 17:30:25 +0000613 DictScope S(W, "ProcEnd");
Zachary Turner0d840742016-10-07 21:34:46 +0000614 else if (CVR.kind() == SymbolKind::S_INLINESITE_END)
Zachary Turneraaad5742016-05-23 23:41:13 +0000615 DictScope S(W, "InlineSiteEnd");
616
617 InFunctionScope = false;
Zachary Turner0d840742016-10-07 21:34:46 +0000618 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000619}
620
Zachary Turner0d840742016-10-07 21:34:46 +0000621Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, CallerSym &Caller) {
622 ListScope S(W, CVR.kind() == S_CALLEES ? "Callees" : "Callers");
Zachary Turneraaad5742016-05-23 23:41:13 +0000623 for (auto FuncID : Caller.Indices)
Zachary Turner629cb7d2017-01-11 23:24:22 +0000624 printTypeIndex("FuncID", FuncID);
Zachary Turner0d840742016-10-07 21:34:46 +0000625 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000626}
627
Zachary Turner0d840742016-10-07 21:34:46 +0000628Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
629 RegRelativeSym &RegRel) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000630 DictScope S(W, "RegRelativeSym");
631
Zachary Turner46225b12016-12-16 22:48:14 +0000632 W.printHex("Offset", RegRel.Offset);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000633 printTypeIndex("Type", RegRel.Type);
Zachary Turner46225b12016-12-16 22:48:14 +0000634 W.printHex("Register", RegRel.Register);
Zachary Turneraaad5742016-05-23 23:41:13 +0000635 W.printString("VarName", RegRel.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000636 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000637}
638
Zachary Turner0d840742016-10-07 21:34:46 +0000639Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
640 ThreadLocalDataSym &Data) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000641 DictScope S(W, "ThreadLocalDataSym");
642
643 StringRef LinkageName;
644 if (ObjDelegate) {
645 ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000646 Data.DataOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000647 }
Zachary Turner629cb7d2017-01-11 23:24:22 +0000648 printTypeIndex("Type", Data.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000649 W.printString("DisplayName", Data.Name);
650 if (!LinkageName.empty())
651 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000652 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000653}
654
Zachary Turner0d840742016-10-07 21:34:46 +0000655Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, UDTSym &UDT) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000656 DictScope S(W, "UDT");
Zachary Turner629cb7d2017-01-11 23:24:22 +0000657 printTypeIndex("Type", UDT.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000658 W.printString("UDTName", UDT.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000659 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000660}
661
Zachary Turner0d840742016-10-07 21:34:46 +0000662Error CVSymbolDumperImpl::visitUnknownSymbol(CVSymbol &CVR) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000663 DictScope S(W, "UnknownSym");
Zachary Turner0d840742016-10-07 21:34:46 +0000664 W.printEnum("Kind", uint16_t(CVR.kind()), getSymbolTypeNames());
665 W.printNumber("Length", CVR.length());
666 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000667}
668
Zachary Turner0d840742016-10-07 21:34:46 +0000669Error CVSymbolDumper::dump(CVRecord<SymbolKind> &Record) {
670 SymbolVisitorCallbackPipeline Pipeline;
671 SymbolDeserializer Deserializer(ObjDelegate.get());
Zachary Turner629cb7d2017-01-11 23:24:22 +0000672 CVSymbolDumperImpl Dumper(TypeDB, ObjDelegate.get(), W, PrintRecordBytes);
Zachary Turner0d840742016-10-07 21:34:46 +0000673
674 Pipeline.addCallbackToPipeline(Deserializer);
675 Pipeline.addCallbackToPipeline(Dumper);
676 CVSymbolVisitor Visitor(Pipeline);
677 return Visitor.visitSymbolRecord(Record);
Zachary Turneraaad5742016-05-23 23:41:13 +0000678}
679
Zachary Turner0d840742016-10-07 21:34:46 +0000680Error CVSymbolDumper::dump(const CVSymbolArray &Symbols) {
681 SymbolVisitorCallbackPipeline Pipeline;
682 SymbolDeserializer Deserializer(ObjDelegate.get());
Zachary Turner629cb7d2017-01-11 23:24:22 +0000683 CVSymbolDumperImpl Dumper(TypeDB, ObjDelegate.get(), W, PrintRecordBytes);
Zachary Turner0d840742016-10-07 21:34:46 +0000684
685 Pipeline.addCallbackToPipeline(Deserializer);
686 Pipeline.addCallbackToPipeline(Dumper);
687 CVSymbolVisitor Visitor(Pipeline);
688 return Visitor.visitSymbolStream(Symbols);
Zachary Turneraaad5742016-05-23 23:41:13 +0000689}