blob: 39cc18a19171475f49a84af6b92f35c01dddd56e [file] [log] [blame]
Zachary Turneraaad5742016-05-23 23:41:13 +00001//===-- SymbolDumper.cpp - CodeView symbol info dumper ----------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Zachary Turneraaad5742016-05-23 23:41:13 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "llvm/DebugInfo/CodeView/SymbolDumper.h"
Zachary Turneraaad5742016-05-23 23:41:13 +000010#include "llvm/ADT/SmallString.h"
11#include "llvm/DebugInfo/CodeView/CVSymbolVisitor.h"
Zachary Turner591312c2017-05-30 17:13:33 +000012#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
Zachary Turner93839cb2016-06-02 05:07:49 +000013#include "llvm/DebugInfo/CodeView/EnumTables.h"
Zachary Turner0d840742016-10-07 21:34:46 +000014#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
Zachary Turneraaad5742016-05-23 23:41:13 +000015#include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h"
16#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
Zachary Turner0d840742016-10-07 21:34:46 +000017#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h"
18#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h"
Zachary Turneraaad5742016-05-23 23:41:13 +000019#include "llvm/DebugInfo/CodeView/TypeIndex.h"
Zachary Turner0d840742016-10-07 21:34:46 +000020#include "llvm/Support/Error.h"
Zachary Turneraaad5742016-05-23 23:41:13 +000021#include "llvm/Support/ScopedPrinter.h"
22
23#include <system_error>
24
25using namespace llvm;
26using namespace llvm::codeview;
27
Zachary Turneraaad5742016-05-23 23:41:13 +000028namespace {
Zachary Turneraaad5742016-05-23 23:41:13 +000029/// Use this private dumper implementation to keep implementation details about
30/// the visitor out of SymbolDumper.h.
Zachary Turner0d840742016-10-07 21:34:46 +000031class CVSymbolDumperImpl : public SymbolVisitorCallbacks {
Zachary Turneraaad5742016-05-23 23:41:13 +000032public:
Zachary Turner526f4f22017-05-19 19:26:58 +000033 CVSymbolDumperImpl(TypeCollection &Types, SymbolDumpDelegate *ObjDelegate,
Reid Klecknera6f64262018-09-11 22:00:50 +000034 ScopedPrinter &W, CPUType CPU, bool PrintRecordBytes)
35 : Types(Types), ObjDelegate(ObjDelegate), W(W), CompilationCPUType(CPU),
Zachary Turner0d840742016-10-07 21:34:46 +000036 PrintRecordBytes(PrintRecordBytes), InFunctionScope(false) {}
Zachary Turneraaad5742016-05-23 23:41:13 +000037
38/// CVSymbolVisitor overrides.
39#define SYMBOL_RECORD(EnumName, EnumVal, Name) \
Zachary Turner0d840742016-10-07 21:34:46 +000040 Error visitKnownRecord(CVSymbol &CVR, Name &Record) override;
Zachary Turneraaad5742016-05-23 23:41:13 +000041#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
Zachary Turnerd4273832017-05-30 21:53:05 +000042#include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
Zachary Turneraaad5742016-05-23 23:41:13 +000043
Zachary Turner0d840742016-10-07 21:34:46 +000044 Error visitSymbolBegin(CVSymbol &Record) override;
45 Error visitSymbolEnd(CVSymbol &Record) override;
46 Error visitUnknownSymbol(CVSymbol &Record) override;
Zachary Turneraaad5742016-05-23 23:41:13 +000047
Reid Klecknera6f64262018-09-11 22:00:50 +000048 CPUType getCompilationCPUType() const { return CompilationCPUType; }
49
Zachary Turneraaad5742016-05-23 23:41:13 +000050private:
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 Turner526f4f22017-05-19 19:26:58 +000056 TypeCollection &Types;
Zachary Turneraaad5742016-05-23 23:41:13 +000057 SymbolDumpDelegate *ObjDelegate;
58 ScopedPrinter &W;
59
Reid Klecknera6f64262018-09-11 22:00:50 +000060 /// Save the machine or CPU type when dumping a compile symbols.
61 CPUType CompilationCPUType = CPUType::X64;
62
Zachary Turneraaad5742016-05-23 23:41:13 +000063 bool PrintRecordBytes;
64 bool InFunctionScope;
65};
66}
67
Reid Kleckner8d8888f2017-07-11 23:41:41 +000068static StringRef getSymbolKindName(SymbolKind Kind) {
69 switch (Kind) {
70#define SYMBOL_RECORD(EnumName, EnumVal, Name) \
71 case EnumName: \
72 return #Name;
73#include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
74 default:
75 break;
76 }
77 return "UnknownSym";
78}
79
Zachary Turneraaad5742016-05-23 23:41:13 +000080void CVSymbolDumperImpl::printLocalVariableAddrRange(
81 const LocalVariableAddrRange &Range, uint32_t RelocationOffset) {
82 DictScope S(W, "LocalVariableAddrRange");
83 if (ObjDelegate)
84 ObjDelegate->printRelocatedField("OffsetStart", RelocationOffset,
85 Range.OffsetStart);
86 W.printHex("ISectStart", Range.ISectStart);
87 W.printHex("Range", Range.Range);
88}
89
90void CVSymbolDumperImpl::printLocalVariableAddrGap(
91 ArrayRef<LocalVariableAddrGap> Gaps) {
92 for (auto &Gap : Gaps) {
93 ListScope S(W, "LocalVariableAddrGap");
94 W.printHex("GapStartOffset", Gap.GapStartOffset);
95 W.printHex("Range", Gap.Range);
96 }
97}
98
Zachary Turner629cb7d2017-01-11 23:24:22 +000099void CVSymbolDumperImpl::printTypeIndex(StringRef FieldName, TypeIndex TI) {
Zachary Turner526f4f22017-05-19 19:26:58 +0000100 codeview::printTypeIndex(W, FieldName, TI, Types);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000101}
102
Zachary Turner0d840742016-10-07 21:34:46 +0000103Error CVSymbolDumperImpl::visitSymbolBegin(CVSymbol &CVR) {
Reid Kleckner8d8888f2017-07-11 23:41:41 +0000104 W.startLine() << getSymbolKindName(CVR.Type);
105 W.getOStream() << " {\n";
106 W.indent();
107 W.printEnum("Kind", unsigned(CVR.Type), getSymbolTypeNames());
Zachary Turner0d840742016-10-07 21:34:46 +0000108 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000109}
110
Zachary Turner0d840742016-10-07 21:34:46 +0000111Error CVSymbolDumperImpl::visitSymbolEnd(CVSymbol &CVR) {
112 if (PrintRecordBytes && ObjDelegate)
113 ObjDelegate->printBinaryBlockWithRelocs("SymData", CVR.content());
Reid Kleckner8d8888f2017-07-11 23:41:41 +0000114
115 W.unindent();
116 W.startLine() << "}\n";
Zachary Turner0d840742016-10-07 21:34:46 +0000117 return Error::success();
118}
119
120Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, BlockSym &Block) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000121 StringRef LinkageName;
Zachary Turner46225b12016-12-16 22:48:14 +0000122 W.printHex("PtrParent", Block.Parent);
123 W.printHex("PtrEnd", Block.End);
124 W.printHex("CodeSize", Block.CodeSize);
Zachary Turneraaad5742016-05-23 23:41:13 +0000125 if (ObjDelegate) {
126 ObjDelegate->printRelocatedField("CodeOffset", Block.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000127 Block.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000128 }
Zachary Turner46225b12016-12-16 22:48:14 +0000129 W.printHex("Segment", Block.Segment);
Zachary Turneraaad5742016-05-23 23:41:13 +0000130 W.printString("BlockName", Block.Name);
131 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000132 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000133}
134
Zachary Turner0d840742016-10-07 21:34:46 +0000135Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, Thunk32Sym &Thunk) {
Brock Wyma94ece8f2018-04-16 16:53:57 +0000136 W.printString("Name", Thunk.Name);
Zachary Turner46225b12016-12-16 22:48:14 +0000137 W.printNumber("Parent", Thunk.Parent);
138 W.printNumber("End", Thunk.End);
139 W.printNumber("Next", Thunk.Next);
140 W.printNumber("Off", Thunk.Offset);
141 W.printNumber("Seg", Thunk.Segment);
142 W.printNumber("Len", Thunk.Length);
143 W.printEnum("Ordinal", uint8_t(Thunk.Thunk), getThunkOrdinalNames());
Zachary Turner0d840742016-10-07 21:34:46 +0000144 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000145}
146
Zachary Turner0d840742016-10-07 21:34:46 +0000147Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
148 TrampolineSym &Tramp) {
Zachary Turner46225b12016-12-16 22:48:14 +0000149 W.printEnum("Type", uint16_t(Tramp.Type), getTrampolineNames());
150 W.printNumber("Size", Tramp.Size);
151 W.printNumber("ThunkOff", Tramp.ThunkOffset);
152 W.printNumber("TargetOff", Tramp.TargetOffset);
153 W.printNumber("ThunkSection", Tramp.ThunkSection);
154 W.printNumber("TargetSection", Tramp.TargetSection);
Zachary Turner0d840742016-10-07 21:34:46 +0000155 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000156}
157
Zachary Turner0d840742016-10-07 21:34:46 +0000158Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, SectionSym &Section) {
Zachary Turner46225b12016-12-16 22:48:14 +0000159 W.printNumber("SectionNumber", Section.SectionNumber);
160 W.printNumber("Alignment", Section.Alignment);
161 W.printNumber("Rva", Section.Rva);
162 W.printNumber("Length", Section.Length);
163 W.printFlags("Characteristics", Section.Characteristics,
Zachary Turner93839cb2016-06-02 05:07:49 +0000164 getImageSectionCharacteristicNames(),
165 COFF::SectionCharacteristics(0x00F00000));
166
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000167 W.printString("Name", Section.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000168 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000169}
170
Zachary Turner0d840742016-10-07 21:34:46 +0000171Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000172 CoffGroupSym &CoffGroup) {
Zachary Turner46225b12016-12-16 22:48:14 +0000173 W.printNumber("Size", CoffGroup.Size);
174 W.printFlags("Characteristics", CoffGroup.Characteristics,
Zachary Turner93839cb2016-06-02 05:07:49 +0000175 getImageSectionCharacteristicNames(),
176 COFF::SectionCharacteristics(0x00F00000));
Zachary Turner46225b12016-12-16 22:48:14 +0000177 W.printNumber("Offset", CoffGroup.Offset);
178 W.printNumber("Segment", CoffGroup.Segment);
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000179 W.printString("Name", CoffGroup.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000180 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000181}
182
Zachary Turner0d840742016-10-07 21:34:46 +0000183Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
184 BPRelativeSym &BPRel) {
Zachary Turner46225b12016-12-16 22:48:14 +0000185 W.printNumber("Offset", BPRel.Offset);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000186 printTypeIndex("Type", BPRel.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000187 W.printString("VarName", BPRel.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000188 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000189}
190
Zachary Turner0d840742016-10-07 21:34:46 +0000191Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
Zachary Turneraaad5742016-05-23 23:41:13 +0000192 BuildInfoSym &BuildInfo) {
Reid Kleckneraf88a912017-07-15 18:10:39 +0000193 printTypeIndex("BuildId", BuildInfo.BuildId);
Zachary Turner0d840742016-10-07 21:34:46 +0000194 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000195}
196
Zachary Turner0d840742016-10-07 21:34:46 +0000197Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
198 CallSiteInfoSym &CallSiteInfo) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000199 StringRef LinkageName;
200 if (ObjDelegate) {
Zachary Turner46225b12016-12-16 22:48:14 +0000201 ObjDelegate->printRelocatedField("CodeOffset",
202 CallSiteInfo.getRelocationOffset(),
203 CallSiteInfo.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000204 }
Zachary Turner46225b12016-12-16 22:48:14 +0000205 W.printHex("Segment", CallSiteInfo.Segment);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000206 printTypeIndex("Type", CallSiteInfo.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000207 if (!LinkageName.empty())
208 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000209 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000210}
211
Zachary Turner0d840742016-10-07 21:34:46 +0000212Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
213 EnvBlockSym &EnvBlock) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000214 ListScope L(W, "Entries");
215 for (auto Entry : EnvBlock.Fields) {
216 W.printString(Entry);
217 }
Zachary Turner0d840742016-10-07 21:34:46 +0000218 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000219}
220
Zachary Turner0d840742016-10-07 21:34:46 +0000221Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
222 FileStaticSym &FileStatic) {
Zachary Turner63055452017-06-15 22:24:24 +0000223 printTypeIndex("Index", FileStatic.Index);
Zachary Turner46225b12016-12-16 22:48:14 +0000224 W.printNumber("ModFilenameOffset", FileStatic.ModFilenameOffset);
225 W.printFlags("Flags", uint16_t(FileStatic.Flags), getLocalFlagNames());
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000226 W.printString("Name", FileStatic.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000227 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000228}
229
Zachary Turner0d840742016-10-07 21:34:46 +0000230Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ExportSym &Export) {
Zachary Turner46225b12016-12-16 22:48:14 +0000231 W.printNumber("Ordinal", Export.Ordinal);
232 W.printFlags("Flags", uint16_t(Export.Flags), getExportSymFlagNames());
Zachary Turner9f054d42016-05-25 00:12:40 +0000233 W.printString("Name", Export.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000234 return Error::success();
Zachary Turner9f054d42016-05-25 00:12:40 +0000235}
236
Zachary Turner0d840742016-10-07 21:34:46 +0000237Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
238 Compile2Sym &Compile2) {
Zachary Turner46225b12016-12-16 22:48:14 +0000239 W.printEnum("Language", Compile2.getLanguage(), getSourceLanguageNames());
240 W.printFlags("Flags", Compile2.getFlags(), getCompileSym2FlagNames());
241 W.printEnum("Machine", unsigned(Compile2.Machine), getCPUTypeNames());
Reid Klecknera6f64262018-09-11 22:00:50 +0000242 CompilationCPUType = Compile2.Machine;
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000243 std::string FrontendVersion;
244 {
245 raw_string_ostream Out(FrontendVersion);
Zachary Turner46225b12016-12-16 22:48:14 +0000246 Out << Compile2.VersionFrontendMajor << '.' << Compile2.VersionFrontendMinor
247 << '.' << Compile2.VersionFrontendBuild;
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000248 }
249 std::string BackendVersion;
250 {
251 raw_string_ostream Out(BackendVersion);
Zachary Turner46225b12016-12-16 22:48:14 +0000252 Out << Compile2.VersionBackendMajor << '.' << Compile2.VersionBackendMinor
253 << '.' << Compile2.VersionBackendBuild;
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000254 }
255 W.printString("FrontendVersion", FrontendVersion);
256 W.printString("BackendVersion", BackendVersion);
257 W.printString("VersionName", Compile2.Version);
Zachary Turner0d840742016-10-07 21:34:46 +0000258 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000259}
260
Zachary Turner0d840742016-10-07 21:34:46 +0000261Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
262 Compile3Sym &Compile3) {
Zachary Turner9f6ac4c2018-10-08 04:34:41 +0000263 W.printEnum("Language", uint8_t(Compile3.getLanguage()), getSourceLanguageNames());
Zachary Turner94926a62018-10-08 04:19:16 +0000264 W.printFlags("Flags", uint32_t(Compile3.getFlags()),
265 getCompileSym3FlagNames());
Zachary Turner46225b12016-12-16 22:48:14 +0000266 W.printEnum("Machine", unsigned(Compile3.Machine), getCPUTypeNames());
Reid Klecknera6f64262018-09-11 22:00:50 +0000267 CompilationCPUType = Compile3.Machine;
Zachary Turneraaad5742016-05-23 23:41:13 +0000268 std::string FrontendVersion;
269 {
270 raw_string_ostream Out(FrontendVersion);
Zachary Turner46225b12016-12-16 22:48:14 +0000271 Out << Compile3.VersionFrontendMajor << '.' << Compile3.VersionFrontendMinor
272 << '.' << Compile3.VersionFrontendBuild << '.'
273 << Compile3.VersionFrontendQFE;
Zachary Turneraaad5742016-05-23 23:41:13 +0000274 }
275 std::string BackendVersion;
276 {
277 raw_string_ostream Out(BackendVersion);
Zachary Turner46225b12016-12-16 22:48:14 +0000278 Out << Compile3.VersionBackendMajor << '.' << Compile3.VersionBackendMinor
279 << '.' << Compile3.VersionBackendBuild << '.'
280 << Compile3.VersionBackendQFE;
Zachary Turneraaad5742016-05-23 23:41:13 +0000281 }
282 W.printString("FrontendVersion", FrontendVersion);
283 W.printString("BackendVersion", BackendVersion);
284 W.printString("VersionName", Compile3.Version);
Zachary Turner0d840742016-10-07 21:34:46 +0000285 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000286}
287
Zachary Turner0d840742016-10-07 21:34:46 +0000288Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
289 ConstantSym &Constant) {
Zachary Turner629cb7d2017-01-11 23:24:22 +0000290 printTypeIndex("Type", Constant.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000291 W.printNumber("Value", Constant.Value);
292 W.printString("Name", Constant.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000293 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000294}
295
Zachary Turner0d840742016-10-07 21:34:46 +0000296Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, DataSym &Data) {
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) {
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 Turner46225b12016-12-16 22:48:14 +0000318 W.printNumber("Offset", DefRangeFramePointerRel.Offset);
319 printLocalVariableAddrRange(DefRangeFramePointerRel.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000320 DefRangeFramePointerRel.getRelocationOffset());
321 printLocalVariableAddrGap(DefRangeFramePointerRel.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000322 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000323}
324
Zachary Turner0d840742016-10-07 21:34:46 +0000325Error CVSymbolDumperImpl::visitKnownRecord(
326 CVSymbol &CVR, DefRangeRegisterRelSym &DefRangeRegisterRel) {
Hans Wennborgea89ff72017-10-02 17:44:47 +0000327 W.printEnum("BaseRegister", uint16_t(DefRangeRegisterRel.Hdr.Register),
328 getRegisterNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000329 W.printBoolean("HasSpilledUDTMember",
330 DefRangeRegisterRel.hasSpilledUDTMember());
331 W.printNumber("OffsetInParent", DefRangeRegisterRel.offsetInParent());
Zachary Turner46225b12016-12-16 22:48:14 +0000332 W.printNumber("BasePointerOffset", DefRangeRegisterRel.Hdr.BasePointerOffset);
333 printLocalVariableAddrRange(DefRangeRegisterRel.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000334 DefRangeRegisterRel.getRelocationOffset());
335 printLocalVariableAddrGap(DefRangeRegisterRel.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000336 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000337}
338
Zachary Turner0d840742016-10-07 21:34:46 +0000339Error CVSymbolDumperImpl::visitKnownRecord(
340 CVSymbol &CVR, DefRangeRegisterSym &DefRangeRegister) {
Hans Wennborgea89ff72017-10-02 17:44:47 +0000341 W.printEnum("Register", uint16_t(DefRangeRegister.Hdr.Register),
342 getRegisterNames());
Zachary Turner46225b12016-12-16 22:48:14 +0000343 W.printNumber("MayHaveNoName", DefRangeRegister.Hdr.MayHaveNoName);
344 printLocalVariableAddrRange(DefRangeRegister.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000345 DefRangeRegister.getRelocationOffset());
346 printLocalVariableAddrGap(DefRangeRegister.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000347 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000348}
349
Zachary Turner0d840742016-10-07 21:34:46 +0000350Error CVSymbolDumperImpl::visitKnownRecord(
351 CVSymbol &CVR, DefRangeSubfieldRegisterSym &DefRangeSubfieldRegister) {
Hans Wennborgea89ff72017-10-02 17:44:47 +0000352 W.printEnum("Register", uint16_t(DefRangeSubfieldRegister.Hdr.Register),
353 getRegisterNames());
Zachary Turner46225b12016-12-16 22:48:14 +0000354 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 if (ObjDelegate) {
Zachary Turner591312c2017-05-30 17:13:33 +0000365 DebugStringTableSubsectionRef Strings = ObjDelegate->getStringTable();
Zachary Turner2d5c2cd2017-05-03 17:11:11 +0000366 auto ExpectedProgram = Strings.getString(DefRangeSubfield.Program);
367 if (!ExpectedProgram) {
368 consumeError(ExpectedProgram.takeError());
Zachary Turner0d840742016-10-07 21:34:46 +0000369 return llvm::make_error<CodeViewError>(
370 "String table offset outside of bounds of String Table!");
Zachary Turner2d5c2cd2017-05-03 17:11:11 +0000371 }
372 W.printString("Program", *ExpectedProgram);
Zachary Turneraaad5742016-05-23 23:41:13 +0000373 }
Zachary Turner46225b12016-12-16 22:48:14 +0000374 W.printNumber("OffsetInParent", DefRangeSubfield.OffsetInParent);
375 printLocalVariableAddrRange(DefRangeSubfield.Range,
Zachary Turneraaad5742016-05-23 23:41:13 +0000376 DefRangeSubfield.getRelocationOffset());
377 printLocalVariableAddrGap(DefRangeSubfield.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000378 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000379}
380
Zachary Turner0d840742016-10-07 21:34:46 +0000381Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
382 DefRangeSym &DefRange) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000383 if (ObjDelegate) {
Zachary Turner591312c2017-05-30 17:13:33 +0000384 DebugStringTableSubsectionRef Strings = ObjDelegate->getStringTable();
Zachary Turner2d5c2cd2017-05-03 17:11:11 +0000385 auto ExpectedProgram = Strings.getString(DefRange.Program);
386 if (!ExpectedProgram) {
387 consumeError(ExpectedProgram.takeError());
Zachary Turner0d840742016-10-07 21:34:46 +0000388 return llvm::make_error<CodeViewError>(
389 "String table offset outside of bounds of String Table!");
Zachary Turner2d5c2cd2017-05-03 17:11:11 +0000390 }
391 W.printString("Program", *ExpectedProgram);
Zachary Turneraaad5742016-05-23 23:41:13 +0000392 }
Zachary Turner46225b12016-12-16 22:48:14 +0000393 printLocalVariableAddrRange(DefRange.Range, DefRange.getRelocationOffset());
Zachary Turneraaad5742016-05-23 23:41:13 +0000394 printLocalVariableAddrGap(DefRange.Gaps);
Zachary Turner0d840742016-10-07 21:34:46 +0000395 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000396}
397
Zachary Turner0d840742016-10-07 21:34:46 +0000398Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
399 FrameCookieSym &FrameCookie) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000400 StringRef LinkageName;
401 if (ObjDelegate) {
Zachary Turner46225b12016-12-16 22:48:14 +0000402 ObjDelegate->printRelocatedField("CodeOffset",
403 FrameCookie.getRelocationOffset(),
404 FrameCookie.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000405 }
Hans Wennborgea89ff72017-10-02 17:44:47 +0000406 W.printEnum("Register", uint16_t(FrameCookie.Register), getRegisterNames());
Zachary Turner46225b12016-12-16 22:48:14 +0000407 W.printEnum("CookieKind", uint16_t(FrameCookie.CookieKind),
Zachary Turner93839cb2016-06-02 05:07:49 +0000408 getFrameCookieKindNames());
Zachary Turner46225b12016-12-16 22:48:14 +0000409 W.printHex("Flags", FrameCookie.Flags);
Zachary Turner0d840742016-10-07 21:34:46 +0000410 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000411}
412
Zachary Turner0d840742016-10-07 21:34:46 +0000413Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
Zachary Turneraaad5742016-05-23 23:41:13 +0000414 FrameProcSym &FrameProc) {
Zachary Turner46225b12016-12-16 22:48:14 +0000415 W.printHex("TotalFrameBytes", FrameProc.TotalFrameBytes);
416 W.printHex("PaddingFrameBytes", FrameProc.PaddingFrameBytes);
417 W.printHex("OffsetToPadding", FrameProc.OffsetToPadding);
Zachary Turneraaad5742016-05-23 23:41:13 +0000418 W.printHex("BytesOfCalleeSavedRegisters",
Zachary Turner46225b12016-12-16 22:48:14 +0000419 FrameProc.BytesOfCalleeSavedRegisters);
420 W.printHex("OffsetOfExceptionHandler", FrameProc.OffsetOfExceptionHandler);
Zachary Turneraaad5742016-05-23 23:41:13 +0000421 W.printHex("SectionIdOfExceptionHandler",
Zachary Turner46225b12016-12-16 22:48:14 +0000422 FrameProc.SectionIdOfExceptionHandler);
423 W.printFlags("Flags", static_cast<uint32_t>(FrameProc.Flags),
424 getFrameProcSymFlagNames());
Reid Klecknera6f64262018-09-11 22:00:50 +0000425 W.printEnum("LocalFramePtrReg",
426 uint16_t(FrameProc.getLocalFramePtrReg(CompilationCPUType)),
427 getRegisterNames());
428 W.printEnum("ParamFramePtrReg",
429 uint16_t(FrameProc.getParamFramePtrReg(CompilationCPUType)),
430 getRegisterNames());
Zachary Turner0d840742016-10-07 21:34:46 +0000431 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000432}
433
Zachary Turner0d840742016-10-07 21:34:46 +0000434Error CVSymbolDumperImpl::visitKnownRecord(
435 CVSymbol &CVR, HeapAllocationSiteSym &HeapAllocSite) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000436 StringRef LinkageName;
437 if (ObjDelegate) {
Zachary Turner46225b12016-12-16 22:48:14 +0000438 ObjDelegate->printRelocatedField("CodeOffset",
439 HeapAllocSite.getRelocationOffset(),
440 HeapAllocSite.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000441 }
Zachary Turner46225b12016-12-16 22:48:14 +0000442 W.printHex("Segment", HeapAllocSite.Segment);
443 W.printHex("CallInstructionSize", HeapAllocSite.CallInstructionSize);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000444 printTypeIndex("Type", HeapAllocSite.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000445 if (!LinkageName.empty())
446 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000447 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000448}
449
Zachary Turner0d840742016-10-07 21:34:46 +0000450Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
451 InlineSiteSym &InlineSite) {
Zachary Turner46225b12016-12-16 22:48:14 +0000452 W.printHex("PtrParent", InlineSite.Parent);
453 W.printHex("PtrEnd", InlineSite.End);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000454 printTypeIndex("Inlinee", InlineSite.Inlinee);
Zachary Turneraaad5742016-05-23 23:41:13 +0000455
456 ListScope BinaryAnnotations(W, "BinaryAnnotations");
457 for (auto &Annotation : InlineSite.annotations()) {
458 switch (Annotation.OpCode) {
459 case BinaryAnnotationsOpCode::Invalid:
Zachary Turner42cb87f2017-03-17 00:15:27 +0000460 W.printString("(Annotation Padding)");
461 break;
Zachary Turneraaad5742016-05-23 23:41:13 +0000462 case BinaryAnnotationsOpCode::CodeOffset:
463 case BinaryAnnotationsOpCode::ChangeCodeOffset:
464 case BinaryAnnotationsOpCode::ChangeCodeLength:
465 W.printHex(Annotation.Name, Annotation.U1);
466 break;
467 case BinaryAnnotationsOpCode::ChangeCodeOffsetBase:
468 case BinaryAnnotationsOpCode::ChangeLineEndDelta:
469 case BinaryAnnotationsOpCode::ChangeRangeKind:
470 case BinaryAnnotationsOpCode::ChangeColumnStart:
471 case BinaryAnnotationsOpCode::ChangeColumnEnd:
472 W.printNumber(Annotation.Name, Annotation.U1);
473 break;
474 case BinaryAnnotationsOpCode::ChangeLineOffset:
475 case BinaryAnnotationsOpCode::ChangeColumnEndDelta:
476 W.printNumber(Annotation.Name, Annotation.S1);
477 break;
478 case BinaryAnnotationsOpCode::ChangeFile:
479 if (ObjDelegate) {
480 W.printHex("ChangeFile",
481 ObjDelegate->getFileNameForFileOffset(Annotation.U1),
482 Annotation.U1);
483 } else {
484 W.printHex("ChangeFile", Annotation.U1);
485 }
486
487 break;
488 case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset: {
489 W.startLine() << "ChangeCodeOffsetAndLineOffset: {CodeOffset: "
490 << W.hex(Annotation.U1) << ", LineOffset: " << Annotation.S1
491 << "}\n";
492 break;
493 }
494 case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset: {
495 W.startLine() << "ChangeCodeLengthAndCodeOffset: {CodeOffset: "
496 << W.hex(Annotation.U2)
497 << ", Length: " << W.hex(Annotation.U1) << "}\n";
498 break;
499 }
500 }
501 }
Zachary Turner0d840742016-10-07 21:34:46 +0000502 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000503}
504
Zachary Turner0d840742016-10-07 21:34:46 +0000505Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
506 RegisterSym &Register) {
Zachary Turner63055452017-06-15 22:24:24 +0000507 printTypeIndex("Type", Register.Index);
Zachary Turner46225b12016-12-16 22:48:14 +0000508 W.printEnum("Seg", uint16_t(Register.Register), getRegisterNames());
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000509 W.printString("Name", Register.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000510 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000511}
512
Zachary Turner0d840742016-10-07 21:34:46 +0000513Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, PublicSym32 &Public) {
Reid Kleckner18d90e12017-06-19 16:54:51 +0000514 W.printFlags("Flags", uint32_t(Public.Flags), getPublicSymFlagNames());
Zachary Turner46225b12016-12-16 22:48:14 +0000515 W.printNumber("Seg", Public.Segment);
516 W.printNumber("Off", Public.Offset);
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000517 W.printString("Name", Public.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000518 return Error::success();
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000519}
520
Zachary Turner0d840742016-10-07 21:34:46 +0000521Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ProcRefSym &ProcRef) {
Zachary Turner46225b12016-12-16 22:48:14 +0000522 W.printNumber("SumName", ProcRef.SumName);
523 W.printNumber("SymOffset", ProcRef.SymOffset);
524 W.printNumber("Mod", ProcRef.Module);
Zachary Turner9e33e6f2016-05-24 18:55:14 +0000525 W.printString("Name", ProcRef.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, LabelSym &Label) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000530 StringRef LinkageName;
531 if (ObjDelegate) {
532 ObjDelegate->printRelocatedField("CodeOffset", Label.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000533 Label.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000534 }
Zachary Turner46225b12016-12-16 22:48:14 +0000535 W.printHex("Segment", Label.Segment);
536 W.printHex("Flags", uint8_t(Label.Flags));
537 W.printFlags("Flags", uint8_t(Label.Flags), getProcSymFlagNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000538 W.printString("DisplayName", Label.Name);
539 if (!LinkageName.empty())
540 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000541 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000542}
543
Zachary Turner0d840742016-10-07 21:34:46 +0000544Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LocalSym &Local) {
Zachary Turner629cb7d2017-01-11 23:24:22 +0000545 printTypeIndex("Type", Local.Type);
Zachary Turner46225b12016-12-16 22:48:14 +0000546 W.printFlags("Flags", uint16_t(Local.Flags), getLocalFlagNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000547 W.printString("VarName", Local.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000548 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000549}
550
Zachary Turner0d840742016-10-07 21:34:46 +0000551Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ObjNameSym &ObjName) {
Zachary Turner46225b12016-12-16 22:48:14 +0000552 W.printHex("Signature", ObjName.Signature);
Zachary Turneraaad5742016-05-23 23:41:13 +0000553 W.printString("ObjectName", ObjName.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000554 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000555}
556
Zachary Turner0d840742016-10-07 21:34:46 +0000557Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ProcSym &Proc) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000558 if (InFunctionScope)
Zachary Turner0d840742016-10-07 21:34:46 +0000559 return llvm::make_error<CodeViewError>(
560 "Visiting a ProcSym while inside function scope!");
Zachary Turneraaad5742016-05-23 23:41:13 +0000561
562 InFunctionScope = true;
563
564 StringRef LinkageName;
Zachary Turner46225b12016-12-16 22:48:14 +0000565 W.printHex("PtrParent", Proc.Parent);
566 W.printHex("PtrEnd", Proc.End);
567 W.printHex("PtrNext", Proc.Next);
568 W.printHex("CodeSize", Proc.CodeSize);
569 W.printHex("DbgStart", Proc.DbgStart);
570 W.printHex("DbgEnd", Proc.DbgEnd);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000571 printTypeIndex("FunctionType", Proc.FunctionType);
Zachary Turneraaad5742016-05-23 23:41:13 +0000572 if (ObjDelegate) {
573 ObjDelegate->printRelocatedField("CodeOffset", Proc.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000574 Proc.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000575 }
Zachary Turner46225b12016-12-16 22:48:14 +0000576 W.printHex("Segment", Proc.Segment);
577 W.printFlags("Flags", static_cast<uint8_t>(Proc.Flags),
Zachary Turner93839cb2016-06-02 05:07:49 +0000578 getProcSymFlagNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000579 W.printString("DisplayName", Proc.Name);
580 if (!LinkageName.empty())
581 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000582 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000583}
584
Zachary Turner0d840742016-10-07 21:34:46 +0000585Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
586 ScopeEndSym &ScopeEnd) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000587 InFunctionScope = false;
Zachary Turner0d840742016-10-07 21:34:46 +0000588 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000589}
590
Zachary Turner0d840742016-10-07 21:34:46 +0000591Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, CallerSym &Caller) {
592 ListScope S(W, CVR.kind() == S_CALLEES ? "Callees" : "Callers");
Zachary Turneraaad5742016-05-23 23:41:13 +0000593 for (auto FuncID : Caller.Indices)
Zachary Turner629cb7d2017-01-11 23:24:22 +0000594 printTypeIndex("FuncID", FuncID);
Zachary Turner0d840742016-10-07 21:34:46 +0000595 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000596}
597
Zachary Turner0d840742016-10-07 21:34:46 +0000598Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
599 RegRelativeSym &RegRel) {
Zachary Turner46225b12016-12-16 22:48:14 +0000600 W.printHex("Offset", RegRel.Offset);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000601 printTypeIndex("Type", RegRel.Type);
Zachary Turner63055452017-06-15 22:24:24 +0000602 W.printEnum("Register", uint16_t(RegRel.Register), getRegisterNames());
Zachary Turneraaad5742016-05-23 23:41:13 +0000603 W.printString("VarName", RegRel.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000604 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000605}
606
Zachary Turner0d840742016-10-07 21:34:46 +0000607Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
608 ThreadLocalDataSym &Data) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000609 StringRef LinkageName;
610 if (ObjDelegate) {
611 ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000612 Data.DataOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000613 }
Zachary Turner629cb7d2017-01-11 23:24:22 +0000614 printTypeIndex("Type", Data.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000615 W.printString("DisplayName", Data.Name);
616 if (!LinkageName.empty())
617 W.printString("LinkageName", LinkageName);
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, UDTSym &UDT) {
Zachary Turner629cb7d2017-01-11 23:24:22 +0000622 printTypeIndex("Type", UDT.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000623 W.printString("UDTName", UDT.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000624 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000625}
626
Alexandre Ganeaee8a7202018-07-31 19:15:50 +0000627Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
628 UsingNamespaceSym &UN) {
629 W.printString("Namespace", UN.Name);
630 return Error::success();
631}
632
Zachary Turner0d840742016-10-07 21:34:46 +0000633Error CVSymbolDumperImpl::visitUnknownSymbol(CVSymbol &CVR) {
Zachary Turner0d840742016-10-07 21:34:46 +0000634 W.printNumber("Length", CVR.length());
635 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000636}
637
Zachary Turner0d840742016-10-07 21:34:46 +0000638Error CVSymbolDumper::dump(CVRecord<SymbolKind> &Record) {
639 SymbolVisitorCallbackPipeline Pipeline;
Zachary Turnerebd3ae82017-06-01 21:52:41 +0000640 SymbolDeserializer Deserializer(ObjDelegate.get(), Container);
Reid Klecknera6f64262018-09-11 22:00:50 +0000641 CVSymbolDumperImpl Dumper(Types, ObjDelegate.get(), W, CompilationCPUType,
642 PrintRecordBytes);
Zachary Turner0d840742016-10-07 21:34:46 +0000643
644 Pipeline.addCallbackToPipeline(Deserializer);
645 Pipeline.addCallbackToPipeline(Dumper);
646 CVSymbolVisitor Visitor(Pipeline);
Reid Klecknera6f64262018-09-11 22:00:50 +0000647 auto Err = Visitor.visitSymbolRecord(Record);
648 CompilationCPUType = Dumper.getCompilationCPUType();
649 return Err;
Zachary Turneraaad5742016-05-23 23:41:13 +0000650}
651
Zachary Turner0d840742016-10-07 21:34:46 +0000652Error CVSymbolDumper::dump(const CVSymbolArray &Symbols) {
653 SymbolVisitorCallbackPipeline Pipeline;
Zachary Turnerebd3ae82017-06-01 21:52:41 +0000654 SymbolDeserializer Deserializer(ObjDelegate.get(), Container);
Reid Klecknera6f64262018-09-11 22:00:50 +0000655 CVSymbolDumperImpl Dumper(Types, ObjDelegate.get(), W, CompilationCPUType,
656 PrintRecordBytes);
Zachary Turner0d840742016-10-07 21:34:46 +0000657
658 Pipeline.addCallbackToPipeline(Deserializer);
659 Pipeline.addCallbackToPipeline(Dumper);
660 CVSymbolVisitor Visitor(Pipeline);
Reid Klecknera6f64262018-09-11 22:00:50 +0000661 auto Err = Visitor.visitSymbolStream(Symbols);
662 CompilationCPUType = Dumper.getCompilationCPUType();
663 return Err;
Zachary Turneraaad5742016-05-23 23:41:13 +0000664}