blob: 4cb267e857e215ea19fd63df1bb48f36d65a3628 [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"
Zachary Turneraaad5742016-05-23 23:41:13 +000011#include "llvm/ADT/SmallString.h"
12#include "llvm/DebugInfo/CodeView/CVSymbolVisitor.h"
Zachary Turner591312c2017-05-30 17:13:33 +000013#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.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/TypeIndex.h"
Zachary Turner0d840742016-10-07 21:34:46 +000021#include "llvm/Support/Error.h"
Zachary Turneraaad5742016-05-23 23:41:13 +000022#include "llvm/Support/ScopedPrinter.h"
23
24#include <system_error>
25
26using namespace llvm;
27using namespace llvm::codeview;
28
Zachary Turneraaad5742016-05-23 23:41:13 +000029namespace {
Zachary Turneraaad5742016-05-23 23:41:13 +000030/// Use this private dumper implementation to keep implementation details about
31/// the visitor out of SymbolDumper.h.
Zachary Turner0d840742016-10-07 21:34:46 +000032class CVSymbolDumperImpl : public SymbolVisitorCallbacks {
Zachary Turneraaad5742016-05-23 23:41:13 +000033public:
Zachary Turner526f4f22017-05-19 19:26:58 +000034 CVSymbolDumperImpl(TypeCollection &Types, SymbolDumpDelegate *ObjDelegate,
Reid Klecknera6f64262018-09-11 22:00:50 +000035 ScopedPrinter &W, CPUType CPU, bool PrintRecordBytes)
36 : Types(Types), ObjDelegate(ObjDelegate), W(W), CompilationCPUType(CPU),
Zachary Turner0d840742016-10-07 21:34:46 +000037 PrintRecordBytes(PrintRecordBytes), InFunctionScope(false) {}
Zachary Turneraaad5742016-05-23 23:41:13 +000038
39/// CVSymbolVisitor overrides.
40#define SYMBOL_RECORD(EnumName, EnumVal, Name) \
Zachary Turner0d840742016-10-07 21:34:46 +000041 Error visitKnownRecord(CVSymbol &CVR, Name &Record) override;
Zachary Turneraaad5742016-05-23 23:41:13 +000042#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
Zachary Turnerd4273832017-05-30 21:53:05 +000043#include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
Zachary Turneraaad5742016-05-23 23:41:13 +000044
Zachary Turner0d840742016-10-07 21:34:46 +000045 Error visitSymbolBegin(CVSymbol &Record) override;
46 Error visitSymbolEnd(CVSymbol &Record) override;
47 Error visitUnknownSymbol(CVSymbol &Record) override;
Zachary Turneraaad5742016-05-23 23:41:13 +000048
Reid Klecknera6f64262018-09-11 22:00:50 +000049 CPUType getCompilationCPUType() const { return CompilationCPUType; }
50
Zachary Turneraaad5742016-05-23 23:41:13 +000051private:
52 void printLocalVariableAddrRange(const LocalVariableAddrRange &Range,
53 uint32_t RelocationOffset);
54 void printLocalVariableAddrGap(ArrayRef<LocalVariableAddrGap> Gaps);
Zachary Turner629cb7d2017-01-11 23:24:22 +000055 void printTypeIndex(StringRef FieldName, TypeIndex TI);
Zachary Turneraaad5742016-05-23 23:41:13 +000056
Zachary Turner526f4f22017-05-19 19:26:58 +000057 TypeCollection &Types;
Zachary Turneraaad5742016-05-23 23:41:13 +000058 SymbolDumpDelegate *ObjDelegate;
59 ScopedPrinter &W;
60
Reid Klecknera6f64262018-09-11 22:00:50 +000061 /// Save the machine or CPU type when dumping a compile symbols.
62 CPUType CompilationCPUType = CPUType::X64;
63
Zachary Turneraaad5742016-05-23 23:41:13 +000064 bool PrintRecordBytes;
65 bool InFunctionScope;
66};
67}
68
Reid Kleckner8d8888f2017-07-11 23:41:41 +000069static StringRef getSymbolKindName(SymbolKind Kind) {
70 switch (Kind) {
71#define SYMBOL_RECORD(EnumName, EnumVal, Name) \
72 case EnumName: \
73 return #Name;
74#include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
75 default:
76 break;
77 }
78 return "UnknownSym";
79}
80
Zachary Turneraaad5742016-05-23 23:41:13 +000081void CVSymbolDumperImpl::printLocalVariableAddrRange(
82 const LocalVariableAddrRange &Range, uint32_t RelocationOffset) {
83 DictScope S(W, "LocalVariableAddrRange");
84 if (ObjDelegate)
85 ObjDelegate->printRelocatedField("OffsetStart", RelocationOffset,
86 Range.OffsetStart);
87 W.printHex("ISectStart", Range.ISectStart);
88 W.printHex("Range", Range.Range);
89}
90
91void CVSymbolDumperImpl::printLocalVariableAddrGap(
92 ArrayRef<LocalVariableAddrGap> Gaps) {
93 for (auto &Gap : Gaps) {
94 ListScope S(W, "LocalVariableAddrGap");
95 W.printHex("GapStartOffset", Gap.GapStartOffset);
96 W.printHex("Range", Gap.Range);
97 }
98}
99
Zachary Turner629cb7d2017-01-11 23:24:22 +0000100void CVSymbolDumperImpl::printTypeIndex(StringRef FieldName, TypeIndex TI) {
Zachary Turner526f4f22017-05-19 19:26:58 +0000101 codeview::printTypeIndex(W, FieldName, TI, Types);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000102}
103
Zachary Turner0d840742016-10-07 21:34:46 +0000104Error CVSymbolDumperImpl::visitSymbolBegin(CVSymbol &CVR) {
Reid Kleckner8d8888f2017-07-11 23:41:41 +0000105 W.startLine() << getSymbolKindName(CVR.Type);
106 W.getOStream() << " {\n";
107 W.indent();
108 W.printEnum("Kind", unsigned(CVR.Type), getSymbolTypeNames());
Zachary Turner0d840742016-10-07 21:34:46 +0000109 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000110}
111
Zachary Turner0d840742016-10-07 21:34:46 +0000112Error CVSymbolDumperImpl::visitSymbolEnd(CVSymbol &CVR) {
113 if (PrintRecordBytes && ObjDelegate)
114 ObjDelegate->printBinaryBlockWithRelocs("SymData", CVR.content());
Reid Kleckner8d8888f2017-07-11 23:41:41 +0000115
116 W.unindent();
117 W.startLine() << "}\n";
Zachary Turner0d840742016-10-07 21:34:46 +0000118 return Error::success();
119}
120
121Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, BlockSym &Block) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000122 StringRef LinkageName;
Zachary Turner46225b12016-12-16 22:48:14 +0000123 W.printHex("PtrParent", Block.Parent);
124 W.printHex("PtrEnd", Block.End);
125 W.printHex("CodeSize", Block.CodeSize);
Zachary Turneraaad5742016-05-23 23:41:13 +0000126 if (ObjDelegate) {
127 ObjDelegate->printRelocatedField("CodeOffset", Block.getRelocationOffset(),
Zachary Turner46225b12016-12-16 22:48:14 +0000128 Block.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000129 }
Zachary Turner46225b12016-12-16 22:48:14 +0000130 W.printHex("Segment", Block.Segment);
Zachary Turneraaad5742016-05-23 23:41:13 +0000131 W.printString("BlockName", Block.Name);
132 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000133 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000134}
135
Zachary Turner0d840742016-10-07 21:34:46 +0000136Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, Thunk32Sym &Thunk) {
Brock Wyma94ece8f2018-04-16 16:53:57 +0000137 W.printString("Name", Thunk.Name);
Zachary Turner46225b12016-12-16 22:48:14 +0000138 W.printNumber("Parent", Thunk.Parent);
139 W.printNumber("End", Thunk.End);
140 W.printNumber("Next", Thunk.Next);
141 W.printNumber("Off", Thunk.Offset);
142 W.printNumber("Seg", Thunk.Segment);
143 W.printNumber("Len", Thunk.Length);
144 W.printEnum("Ordinal", uint8_t(Thunk.Thunk), getThunkOrdinalNames());
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,
149 TrampolineSym &Tramp) {
Zachary Turner46225b12016-12-16 22:48:14 +0000150 W.printEnum("Type", uint16_t(Tramp.Type), getTrampolineNames());
151 W.printNumber("Size", Tramp.Size);
152 W.printNumber("ThunkOff", Tramp.ThunkOffset);
153 W.printNumber("TargetOff", Tramp.TargetOffset);
154 W.printNumber("ThunkSection", Tramp.ThunkSection);
155 W.printNumber("TargetSection", Tramp.TargetSection);
Zachary Turner0d840742016-10-07 21:34:46 +0000156 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000157}
158
Zachary Turner0d840742016-10-07 21:34:46 +0000159Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, SectionSym &Section) {
Zachary Turner46225b12016-12-16 22:48:14 +0000160 W.printNumber("SectionNumber", Section.SectionNumber);
161 W.printNumber("Alignment", Section.Alignment);
162 W.printNumber("Rva", Section.Rva);
163 W.printNumber("Length", Section.Length);
164 W.printFlags("Characteristics", Section.Characteristics,
Zachary Turner93839cb2016-06-02 05:07:49 +0000165 getImageSectionCharacteristicNames(),
166 COFF::SectionCharacteristics(0x00F00000));
167
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000168 W.printString("Name", Section.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000169 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000170}
171
Zachary Turner0d840742016-10-07 21:34:46 +0000172Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000173 CoffGroupSym &CoffGroup) {
Zachary Turner46225b12016-12-16 22:48:14 +0000174 W.printNumber("Size", CoffGroup.Size);
175 W.printFlags("Characteristics", CoffGroup.Characteristics,
Zachary Turner93839cb2016-06-02 05:07:49 +0000176 getImageSectionCharacteristicNames(),
177 COFF::SectionCharacteristics(0x00F00000));
Zachary Turner46225b12016-12-16 22:48:14 +0000178 W.printNumber("Offset", CoffGroup.Offset);
179 W.printNumber("Segment", CoffGroup.Segment);
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000180 W.printString("Name", CoffGroup.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000181 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000182}
183
Zachary Turner0d840742016-10-07 21:34:46 +0000184Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
185 BPRelativeSym &BPRel) {
Zachary Turner46225b12016-12-16 22:48:14 +0000186 W.printNumber("Offset", BPRel.Offset);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000187 printTypeIndex("Type", BPRel.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000188 W.printString("VarName", BPRel.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000189 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000190}
191
Zachary Turner0d840742016-10-07 21:34:46 +0000192Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
Zachary Turneraaad5742016-05-23 23:41:13 +0000193 BuildInfoSym &BuildInfo) {
Reid Kleckneraf88a912017-07-15 18:10:39 +0000194 printTypeIndex("BuildId", BuildInfo.BuildId);
Zachary Turner0d840742016-10-07 21:34:46 +0000195 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000196}
197
Zachary Turner0d840742016-10-07 21:34:46 +0000198Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
199 CallSiteInfoSym &CallSiteInfo) {
Zachary Turneraaad5742016-05-23 23:41:13 +0000200 StringRef LinkageName;
201 if (ObjDelegate) {
Zachary Turner46225b12016-12-16 22:48:14 +0000202 ObjDelegate->printRelocatedField("CodeOffset",
203 CallSiteInfo.getRelocationOffset(),
204 CallSiteInfo.CodeOffset, &LinkageName);
Zachary Turneraaad5742016-05-23 23:41:13 +0000205 }
Zachary Turner46225b12016-12-16 22:48:14 +0000206 W.printHex("Segment", CallSiteInfo.Segment);
Zachary Turner629cb7d2017-01-11 23:24:22 +0000207 printTypeIndex("Type", CallSiteInfo.Type);
Zachary Turneraaad5742016-05-23 23:41:13 +0000208 if (!LinkageName.empty())
209 W.printString("LinkageName", LinkageName);
Zachary Turner0d840742016-10-07 21:34:46 +0000210 return Error::success();
Zachary Turneraaad5742016-05-23 23:41:13 +0000211}
212
Zachary Turner0d840742016-10-07 21:34:46 +0000213Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
214 EnvBlockSym &EnvBlock) {
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000215 ListScope L(W, "Entries");
216 for (auto Entry : EnvBlock.Fields) {
217 W.printString(Entry);
218 }
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,
223 FileStaticSym &FileStatic) {
Zachary Turner63055452017-06-15 22:24:24 +0000224 printTypeIndex("Index", FileStatic.Index);
Zachary Turner46225b12016-12-16 22:48:14 +0000225 W.printNumber("ModFilenameOffset", FileStatic.ModFilenameOffset);
226 W.printFlags("Flags", uint16_t(FileStatic.Flags), getLocalFlagNames());
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000227 W.printString("Name", FileStatic.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000228 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000229}
230
Zachary Turner0d840742016-10-07 21:34:46 +0000231Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ExportSym &Export) {
Zachary Turner46225b12016-12-16 22:48:14 +0000232 W.printNumber("Ordinal", Export.Ordinal);
233 W.printFlags("Flags", uint16_t(Export.Flags), getExportSymFlagNames());
Zachary Turner9f054d42016-05-25 00:12:40 +0000234 W.printString("Name", Export.Name);
Zachary Turner0d840742016-10-07 21:34:46 +0000235 return Error::success();
Zachary Turner9f054d42016-05-25 00:12:40 +0000236}
237
Zachary Turner0d840742016-10-07 21:34:46 +0000238Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
239 Compile2Sym &Compile2) {
Zachary Turner46225b12016-12-16 22:48:14 +0000240 W.printEnum("Language", Compile2.getLanguage(), getSourceLanguageNames());
241 W.printFlags("Flags", Compile2.getFlags(), getCompileSym2FlagNames());
242 W.printEnum("Machine", unsigned(Compile2.Machine), getCPUTypeNames());
Reid Klecknera6f64262018-09-11 22:00:50 +0000243 CompilationCPUType = Compile2.Machine;
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000244 std::string FrontendVersion;
245 {
246 raw_string_ostream Out(FrontendVersion);
Zachary Turner46225b12016-12-16 22:48:14 +0000247 Out << Compile2.VersionFrontendMajor << '.' << Compile2.VersionFrontendMinor
248 << '.' << Compile2.VersionFrontendBuild;
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000249 }
250 std::string BackendVersion;
251 {
252 raw_string_ostream Out(BackendVersion);
Zachary Turner46225b12016-12-16 22:48:14 +0000253 Out << Compile2.VersionBackendMajor << '.' << Compile2.VersionBackendMinor
254 << '.' << Compile2.VersionBackendBuild;
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000255 }
256 W.printString("FrontendVersion", FrontendVersion);
257 W.printString("BackendVersion", BackendVersion);
258 W.printString("VersionName", Compile2.Version);
Zachary Turner0d840742016-10-07 21:34:46 +0000259 return Error::success();
Zachary Turner4caa1bf2016-05-24 22:58:46 +0000260}
261
Zachary Turner0d840742016-10-07 21:34:46 +0000262Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR,
263 Compile3Sym &Compile3) {
Zachary Turner46225b12016-12-16 22:48:14 +0000264 W.printEnum("Language", Compile3.getLanguage(), getSourceLanguageNames());
265 W.printFlags("Flags", Compile3.getFlags(), getCompileSym3FlagNames());
266 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}