1 //===- MinimalSymbolDumper.cpp -------------------------------- *- C++ --*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "MinimalSymbolDumper.h"
12 #include "FormatUtil.h"
13 #include "LinePrinter.h"
15 #include "llvm/DebugInfo/CodeView/CVRecord.h"
16 #include "llvm/DebugInfo/CodeView/CodeView.h"
17 #include "llvm/DebugInfo/CodeView/Formatters.h"
18 #include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
19 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
20 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
21 #include "llvm/Support/FormatVariadic.h"
24 using namespace llvm::codeview;
25 using namespace llvm::pdb;
27 static std::string formatLocalSymFlags(uint32_t IndentLevel,
28 LocalSymFlags Flags) {
29 std::vector<std::string> Opts;
30 if (Flags == LocalSymFlags::None)
33 PUSH_FLAG(LocalSymFlags, IsParameter, Flags, "param");
34 PUSH_FLAG(LocalSymFlags, IsAddressTaken, Flags, "address is taken");
35 PUSH_FLAG(LocalSymFlags, IsCompilerGenerated, Flags, "compiler generated");
36 PUSH_FLAG(LocalSymFlags, IsAggregate, Flags, "aggregate");
37 PUSH_FLAG(LocalSymFlags, IsAggregated, Flags, "aggregated");
38 PUSH_FLAG(LocalSymFlags, IsAliased, Flags, "aliased");
39 PUSH_FLAG(LocalSymFlags, IsAlias, Flags, "alias");
40 PUSH_FLAG(LocalSymFlags, IsReturnValue, Flags, "return val");
41 PUSH_FLAG(LocalSymFlags, IsOptimizedOut, Flags, "optimized away");
42 PUSH_FLAG(LocalSymFlags, IsEnregisteredGlobal, Flags, "enreg global");
43 PUSH_FLAG(LocalSymFlags, IsEnregisteredStatic, Flags, "enreg static");
44 return typesetItemList(Opts, 4, IndentLevel, " | ");
47 static std::string formatExportFlags(uint32_t IndentLevel, ExportFlags Flags) {
48 std::vector<std::string> Opts;
49 if (Flags == ExportFlags::None)
52 PUSH_FLAG(ExportFlags, IsConstant, Flags, "constant");
53 PUSH_FLAG(ExportFlags, IsData, Flags, "data");
54 PUSH_FLAG(ExportFlags, IsPrivate, Flags, "private");
55 PUSH_FLAG(ExportFlags, HasNoName, Flags, "no name");
56 PUSH_FLAG(ExportFlags, HasExplicitOrdinal, Flags, "explicit ord");
57 PUSH_FLAG(ExportFlags, IsForwarder, Flags, "forwarder");
59 return typesetItemList(Opts, 4, IndentLevel, " | ");
62 static std::string formatCompileSym2Flags(uint32_t IndentLevel,
63 CompileSym2Flags Flags) {
64 std::vector<std::string> Opts;
65 Flags &= ~CompileSym2Flags::SourceLanguageMask;
66 if (Flags == CompileSym2Flags::None)
69 PUSH_FLAG(CompileSym2Flags, EC, Flags, "edit and continue");
70 PUSH_FLAG(CompileSym2Flags, NoDbgInfo, Flags, "no dbg info");
71 PUSH_FLAG(CompileSym2Flags, LTCG, Flags, "ltcg");
72 PUSH_FLAG(CompileSym2Flags, NoDataAlign, Flags, "no data align");
73 PUSH_FLAG(CompileSym2Flags, ManagedPresent, Flags, "has managed code");
74 PUSH_FLAG(CompileSym2Flags, SecurityChecks, Flags, "security checks");
75 PUSH_FLAG(CompileSym2Flags, HotPatch, Flags, "hot patchable");
76 PUSH_FLAG(CompileSym2Flags, CVTCIL, Flags, "cvtcil");
77 PUSH_FLAG(CompileSym2Flags, MSILModule, Flags, "msil module");
78 return typesetItemList(Opts, 4, IndentLevel, " | ");
81 static std::string formatCompileSym3Flags(uint32_t IndentLevel,
82 CompileSym3Flags Flags) {
83 std::vector<std::string> Opts;
84 Flags &= ~CompileSym3Flags::SourceLanguageMask;
86 if (Flags == CompileSym3Flags::None)
89 PUSH_FLAG(CompileSym3Flags, EC, Flags, "edit and continue");
90 PUSH_FLAG(CompileSym3Flags, NoDbgInfo, Flags, "no dbg info");
91 PUSH_FLAG(CompileSym3Flags, LTCG, Flags, "ltcg");
92 PUSH_FLAG(CompileSym3Flags, NoDataAlign, Flags, "no data align");
93 PUSH_FLAG(CompileSym3Flags, ManagedPresent, Flags, "has managed code");
94 PUSH_FLAG(CompileSym3Flags, SecurityChecks, Flags, "security checks");
95 PUSH_FLAG(CompileSym3Flags, HotPatch, Flags, "hot patchable");
96 PUSH_FLAG(CompileSym3Flags, CVTCIL, Flags, "cvtcil");
97 PUSH_FLAG(CompileSym3Flags, MSILModule, Flags, "msil module");
98 PUSH_FLAG(CompileSym3Flags, Sdl, Flags, "sdl");
99 PUSH_FLAG(CompileSym3Flags, PGO, Flags, "pgo");
100 PUSH_FLAG(CompileSym3Flags, Exp, Flags, "exp");
101 return typesetItemList(Opts, 4, IndentLevel, " | ");
104 static std::string formatFrameProcedureOptions(uint32_t IndentLevel,
105 FrameProcedureOptions FPO) {
106 std::vector<std::string> Opts;
107 if (FPO == FrameProcedureOptions::None)
110 PUSH_FLAG(FrameProcedureOptions, HasAlloca, FPO, "has alloca");
111 PUSH_FLAG(FrameProcedureOptions, HasSetJmp, FPO, "has setjmp");
112 PUSH_FLAG(FrameProcedureOptions, HasLongJmp, FPO, "has longjmp");
113 PUSH_FLAG(FrameProcedureOptions, HasInlineAssembly, FPO, "has inline asm");
114 PUSH_FLAG(FrameProcedureOptions, HasExceptionHandling, FPO, "has eh");
115 PUSH_FLAG(FrameProcedureOptions, MarkedInline, FPO, "marked inline");
116 PUSH_FLAG(FrameProcedureOptions, HasStructuredExceptionHandling, FPO,
118 PUSH_FLAG(FrameProcedureOptions, Naked, FPO, "naked");
119 PUSH_FLAG(FrameProcedureOptions, SecurityChecks, FPO, "secure checks");
120 PUSH_FLAG(FrameProcedureOptions, AsynchronousExceptionHandling, FPO,
122 PUSH_FLAG(FrameProcedureOptions, NoStackOrderingForSecurityChecks, FPO,
124 PUSH_FLAG(FrameProcedureOptions, Inlined, FPO, "inlined");
125 PUSH_FLAG(FrameProcedureOptions, StrictSecurityChecks, FPO,
126 "strict secure checks");
127 PUSH_FLAG(FrameProcedureOptions, SafeBuffers, FPO, "safe buffers");
128 PUSH_FLAG(FrameProcedureOptions, ProfileGuidedOptimization, FPO, "pgo");
129 PUSH_FLAG(FrameProcedureOptions, ValidProfileCounts, FPO,
130 "has profile counts");
131 PUSH_FLAG(FrameProcedureOptions, OptimizedForSpeed, FPO, "opt speed");
132 PUSH_FLAG(FrameProcedureOptions, GuardCfg, FPO, "guard cfg");
133 PUSH_FLAG(FrameProcedureOptions, GuardCfw, FPO, "guard cfw");
134 return typesetItemList(Opts, 4, IndentLevel, " | ");
137 static std::string formatPublicSymFlags(uint32_t IndentLevel,
138 PublicSymFlags Flags) {
139 std::vector<std::string> Opts;
140 if (Flags == PublicSymFlags::None)
143 PUSH_FLAG(PublicSymFlags, Code, Flags, "code");
144 PUSH_FLAG(PublicSymFlags, Function, Flags, "function");
145 PUSH_FLAG(PublicSymFlags, Managed, Flags, "managed");
146 PUSH_FLAG(PublicSymFlags, MSIL, Flags, "msil");
147 return typesetItemList(Opts, 4, IndentLevel, " | ");
150 static std::string formatProcSymFlags(uint32_t IndentLevel,
151 ProcSymFlags Flags) {
152 std::vector<std::string> Opts;
153 if (Flags == ProcSymFlags::None)
156 PUSH_FLAG(ProcSymFlags, HasFP, Flags, "has fp");
157 PUSH_FLAG(ProcSymFlags, HasIRET, Flags, "has iret");
158 PUSH_FLAG(ProcSymFlags, HasFRET, Flags, "has fret");
159 PUSH_FLAG(ProcSymFlags, IsNoReturn, Flags, "noreturn");
160 PUSH_FLAG(ProcSymFlags, IsUnreachable, Flags, "unreachable");
161 PUSH_FLAG(ProcSymFlags, HasCustomCallingConv, Flags, "custom calling conv");
162 PUSH_FLAG(ProcSymFlags, IsNoInline, Flags, "noinline");
163 PUSH_FLAG(ProcSymFlags, HasOptimizedDebugInfo, Flags, "opt debuginfo");
164 return typesetItemList(Opts, 4, IndentLevel, " | ");
167 static std::string formatThunkOrdinal(ThunkOrdinal Ordinal) {
169 RETURN_CASE(ThunkOrdinal, Standard, "thunk");
170 RETURN_CASE(ThunkOrdinal, ThisAdjustor, "this adjustor");
171 RETURN_CASE(ThunkOrdinal, Vcall, "vcall");
172 RETURN_CASE(ThunkOrdinal, Pcode, "pcode");
173 RETURN_CASE(ThunkOrdinal, UnknownLoad, "unknown load");
174 RETURN_CASE(ThunkOrdinal, TrampIncremental, "tramp incremental");
175 RETURN_CASE(ThunkOrdinal, BranchIsland, "branch island");
177 return formatUnknownEnum(Ordinal);
180 static std::string formatTrampolineType(TrampolineType Tramp) {
182 RETURN_CASE(TrampolineType, TrampIncremental, "tramp incremental");
183 RETURN_CASE(TrampolineType, BranchIsland, "branch island");
185 return formatUnknownEnum(Tramp);
188 static std::string formatSourceLanguage(SourceLanguage Lang) {
190 RETURN_CASE(SourceLanguage, C, "c");
191 RETURN_CASE(SourceLanguage, Cpp, "c++");
192 RETURN_CASE(SourceLanguage, Fortran, "fortran");
193 RETURN_CASE(SourceLanguage, Masm, "masm");
194 RETURN_CASE(SourceLanguage, Pascal, "pascal");
195 RETURN_CASE(SourceLanguage, Basic, "basic");
196 RETURN_CASE(SourceLanguage, Cobol, "cobol");
197 RETURN_CASE(SourceLanguage, Link, "link");
198 RETURN_CASE(SourceLanguage, VB, "vb");
199 RETURN_CASE(SourceLanguage, Cvtres, "cvtres");
200 RETURN_CASE(SourceLanguage, Cvtpgd, "cvtpgd");
201 RETURN_CASE(SourceLanguage, CSharp, "c#");
202 RETURN_CASE(SourceLanguage, ILAsm, "il asm");
203 RETURN_CASE(SourceLanguage, Java, "java");
204 RETURN_CASE(SourceLanguage, JScript, "javascript");
205 RETURN_CASE(SourceLanguage, MSIL, "msil");
206 RETURN_CASE(SourceLanguage, HLSL, "hlsl");
207 RETURN_CASE(SourceLanguage, D, "d");
209 return formatUnknownEnum(Lang);
212 static std::string formatMachineType(CPUType Cpu) {
214 RETURN_CASE(CPUType, Intel8080, "intel 8080");
215 RETURN_CASE(CPUType, Intel8086, "intel 8086");
216 RETURN_CASE(CPUType, Intel80286, "intel 80286");
217 RETURN_CASE(CPUType, Intel80386, "intel 80386");
218 RETURN_CASE(CPUType, Intel80486, "intel 80486");
219 RETURN_CASE(CPUType, Pentium, "intel pentium");
220 RETURN_CASE(CPUType, PentiumPro, "intel pentium pro");
221 RETURN_CASE(CPUType, Pentium3, "intel pentium 3");
222 RETURN_CASE(CPUType, MIPS, "mips");
223 RETURN_CASE(CPUType, MIPS16, "mips-16");
224 RETURN_CASE(CPUType, MIPS32, "mips-32");
225 RETURN_CASE(CPUType, MIPS64, "mips-64");
226 RETURN_CASE(CPUType, MIPSI, "mips i");
227 RETURN_CASE(CPUType, MIPSII, "mips ii");
228 RETURN_CASE(CPUType, MIPSIII, "mips iii");
229 RETURN_CASE(CPUType, MIPSIV, "mips iv");
230 RETURN_CASE(CPUType, MIPSV, "mips v");
231 RETURN_CASE(CPUType, M68000, "motorola 68000");
232 RETURN_CASE(CPUType, M68010, "motorola 68010");
233 RETURN_CASE(CPUType, M68020, "motorola 68020");
234 RETURN_CASE(CPUType, M68030, "motorola 68030");
235 RETURN_CASE(CPUType, M68040, "motorola 68040");
236 RETURN_CASE(CPUType, Alpha, "alpha");
237 RETURN_CASE(CPUType, Alpha21164, "alpha 21164");
238 RETURN_CASE(CPUType, Alpha21164A, "alpha 21164a");
239 RETURN_CASE(CPUType, Alpha21264, "alpha 21264");
240 RETURN_CASE(CPUType, Alpha21364, "alpha 21364");
241 RETURN_CASE(CPUType, PPC601, "powerpc 601");
242 RETURN_CASE(CPUType, PPC603, "powerpc 603");
243 RETURN_CASE(CPUType, PPC604, "powerpc 604");
244 RETURN_CASE(CPUType, PPC620, "powerpc 620");
245 RETURN_CASE(CPUType, PPCFP, "powerpc fp");
246 RETURN_CASE(CPUType, PPCBE, "powerpc be");
247 RETURN_CASE(CPUType, SH3, "sh3");
248 RETURN_CASE(CPUType, SH3E, "sh3e");
249 RETURN_CASE(CPUType, SH3DSP, "sh3 dsp");
250 RETURN_CASE(CPUType, SH4, "sh4");
251 RETURN_CASE(CPUType, SHMedia, "shmedia");
252 RETURN_CASE(CPUType, ARM3, "arm 3");
253 RETURN_CASE(CPUType, ARM4, "arm 4");
254 RETURN_CASE(CPUType, ARM4T, "arm 4t");
255 RETURN_CASE(CPUType, ARM5, "arm 5");
256 RETURN_CASE(CPUType, ARM5T, "arm 5t");
257 RETURN_CASE(CPUType, ARM6, "arm 6");
258 RETURN_CASE(CPUType, ARM_XMAC, "arm xmac");
259 RETURN_CASE(CPUType, ARM_WMMX, "arm wmmx");
260 RETURN_CASE(CPUType, ARM7, "arm 7");
261 RETURN_CASE(CPUType, ARM64, "arm64");
262 RETURN_CASE(CPUType, Omni, "omni");
263 RETURN_CASE(CPUType, Ia64, "intel itanium ia64");
264 RETURN_CASE(CPUType, Ia64_2, "intel itanium ia64 2");
265 RETURN_CASE(CPUType, CEE, "cee");
266 RETURN_CASE(CPUType, AM33, "am33");
267 RETURN_CASE(CPUType, M32R, "m32r");
268 RETURN_CASE(CPUType, TriCore, "tri-core");
269 RETURN_CASE(CPUType, X64, "intel x86-x64");
270 RETURN_CASE(CPUType, EBC, "ebc");
271 RETURN_CASE(CPUType, Thumb, "thumb");
272 RETURN_CASE(CPUType, ARMNT, "arm nt");
273 RETURN_CASE(CPUType, D3D11_Shader, "d3d11 shader");
275 return formatUnknownEnum(Cpu);
278 static std::string formatCookieKind(FrameCookieKind Kind) {
280 RETURN_CASE(FrameCookieKind, Copy, "copy");
281 RETURN_CASE(FrameCookieKind, XorStackPointer, "xor stack ptr");
282 RETURN_CASE(FrameCookieKind, XorFramePointer, "xor frame ptr");
283 RETURN_CASE(FrameCookieKind, XorR13, "xor rot13");
285 return formatUnknownEnum(Kind);
288 static std::string formatRegisterId(RegisterId Id) {
290 #define CV_REGISTER(name, val) RETURN_CASE(RegisterId, name, #name)
291 #include "llvm/DebugInfo/CodeView/CodeViewRegisters.def"
294 return formatUnknownEnum(Id);
297 static std::string formatRange(LocalVariableAddrRange Range) {
298 return formatv("[{0},+{1})",
299 formatSegmentOffset(Range.ISectStart, Range.OffsetStart),
304 static std::string formatGaps(uint32_t IndentLevel,
305 ArrayRef<LocalVariableAddrGap> Gaps) {
306 std::vector<std::string> GapStrs;
307 for (const auto &G : Gaps) {
308 GapStrs.push_back(formatv("({0},{1})", G.GapStartOffset, G.Range).str());
310 return typesetItemList(GapStrs, 7, IndentLevel, ", ");
313 Error MinimalSymbolDumper::visitSymbolBegin(codeview::CVSymbol &Record) {
314 return visitSymbolBegin(Record, 0);
317 Error MinimalSymbolDumper::visitSymbolBegin(codeview::CVSymbol &Record,
319 // formatLine puts the newline at the beginning, so we use formatLine here
320 // to start a new line, and then individual visit methods use format to
321 // append to the existing line.
322 P.formatLine("{0} | {1} [size = {2}]",
323 fmt_align(Offset, AlignStyle::Right, 6),
324 formatSymbolKind(Record.Type), Record.length());
326 return Error::success();
329 Error MinimalSymbolDumper::visitSymbolEnd(CVSymbol &Record) {
331 AutoIndent Indent(P, 7);
332 P.formatBinary("bytes", Record.content(), 0);
335 return Error::success();
338 std::string MinimalSymbolDumper::typeOrIdIndex(codeview::TypeIndex TI,
340 if (TI.isSimple() || TI.isDecoratedItemId())
341 return formatv("{0}", TI).str();
342 auto &Container = IsType ? Types : Ids;
343 StringRef Name = Container.getTypeName(TI);
344 if (Name.size() > 32) {
345 Name = Name.take_front(32);
346 return formatv("{0} ({1}...)", TI, Name);
348 return formatv("{0} ({1})", TI, Name);
351 std::string MinimalSymbolDumper::idIndex(codeview::TypeIndex TI) const {
352 return typeOrIdIndex(TI, false);
355 std::string MinimalSymbolDumper::typeIndex(TypeIndex TI) const {
356 return typeOrIdIndex(TI, true);
359 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, BlockSym &Block) {
360 P.format(" `{0}`", Block.Name);
361 AutoIndent Indent(P, 7);
362 P.formatLine("parent = {0}, end = {1}", Block.Parent, Block.End);
363 P.formatLine("code size = {0}, addr = {1}", Block.CodeSize,
364 formatSegmentOffset(Block.Segment, Block.CodeOffset));
365 return Error::success();
368 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Thunk32Sym &Thunk) {
369 P.format(" `{0}`", Thunk.Name);
370 AutoIndent Indent(P, 7);
371 P.formatLine("parent = {0}, end = {1}, next = {2}", Thunk.Parent, Thunk.End,
373 P.formatLine("kind = {0}, size = {1}, addr = {2}",
374 formatThunkOrdinal(Thunk.Thunk), Thunk.Length,
375 formatSegmentOffset(Thunk.Segment, Thunk.Offset));
377 return Error::success();
380 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
381 TrampolineSym &Tramp) {
382 AutoIndent Indent(P, 7);
383 P.formatLine("type = {0}, size = {1}, source = {2}, target = {3}",
384 formatTrampolineType(Tramp.Type), Tramp.Size,
385 formatSegmentOffset(Tramp.ThunkSection, Tramp.ThunkOffset),
386 formatSegmentOffset(Tramp.TargetSection, Tramp.ThunkOffset));
388 return Error::success();
391 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
392 SectionSym &Section) {
393 P.format(" `{0}`", Section.Name);
394 AutoIndent Indent(P, 7);
395 P.formatLine("length = {0}, alignment = {1}, rva = {2}, section # = {3}",
396 Section.Length, Section.Alignment, Section.Rva,
397 Section.SectionNumber);
398 P.printLine("characteristics =");
399 AutoIndent Indent2(P, 2);
400 P.printLine(formatSectionCharacteristics(P.getIndentLevel(),
401 Section.Characteristics, 1, "",
402 CharacteristicStyle::Descriptive));
403 return Error::success();
406 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, CoffGroupSym &CG) {
407 P.format(" `{0}`", CG.Name);
408 AutoIndent Indent(P, 7);
409 P.formatLine("length = {0}, addr = {1}", CG.Size,
410 formatSegmentOffset(CG.Segment, CG.Offset));
411 P.printLine("characteristics =");
412 AutoIndent Indent2(P, 2);
413 P.printLine(formatSectionCharacteristics(P.getIndentLevel(),
414 CG.Characteristics, 1, "",
415 CharacteristicStyle::Descriptive));
416 return Error::success();
419 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
420 BPRelativeSym &BPRel) {
421 P.format(" `{0}`", BPRel.Name);
422 AutoIndent Indent(P, 7);
423 P.formatLine("type = {0}, offset = {1}", typeIndex(BPRel.Type), BPRel.Offset);
424 return Error::success();
427 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
428 BuildInfoSym &BuildInfo) {
429 P.format(" BuildId = `{0}`", BuildInfo.BuildId);
430 return Error::success();
433 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
434 CallSiteInfoSym &CSI) {
435 AutoIndent Indent(P, 7);
436 P.formatLine("type = {0}, addr = {1}", typeIndex(CSI.Type),
437 formatSegmentOffset(CSI.Segment, CSI.CodeOffset));
438 return Error::success();
441 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
442 EnvBlockSym &EnvBlock) {
443 AutoIndent Indent(P, 7);
444 for (const auto &Entry : EnvBlock.Fields) {
445 P.formatLine("- {0}", Entry);
447 return Error::success();
450 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, FileStaticSym &FS) {
451 P.format(" `{0}`", FS.Name);
452 AutoIndent Indent(P, 7);
453 P.formatLine("type = {0}, file name offset = {1}, flags = {2}",
454 typeIndex(FS.Index), FS.ModFilenameOffset,
455 formatLocalSymFlags(P.getIndentLevel() + 9, FS.Flags));
456 return Error::success();
459 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, ExportSym &Export) {
460 P.format(" `{0}`", Export.Name);
461 AutoIndent Indent(P, 7);
462 P.formatLine("ordinal = {0}, flags = {1}", Export.Ordinal,
463 formatExportFlags(P.getIndentLevel() + 9, Export.Flags));
464 return Error::success();
467 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
468 Compile2Sym &Compile2) {
469 AutoIndent Indent(P, 7);
470 SourceLanguage Lang = static_cast<SourceLanguage>(
471 Compile2.Flags & CompileSym2Flags::SourceLanguageMask);
472 P.formatLine("machine = {0}, ver = {1}, language = {2}",
473 formatMachineType(Compile2.Machine), Compile2.Version,
474 formatSourceLanguage(Lang));
475 P.formatLine("frontend = {0}.{1}.{2}, backend = {3}.{4}.{5}",
476 Compile2.VersionFrontendMajor, Compile2.VersionFrontendMinor,
477 Compile2.VersionFrontendBuild, Compile2.VersionBackendMajor,
478 Compile2.VersionBackendMinor, Compile2.VersionBackendBuild);
479 P.formatLine("flags = {0}",
480 formatCompileSym2Flags(P.getIndentLevel() + 9, Compile2.Flags));
482 "extra strings = {0}",
483 typesetStringList(P.getIndentLevel() + 9 + 2, Compile2.ExtraStrings));
484 return Error::success();
487 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
488 Compile3Sym &Compile3) {
489 AutoIndent Indent(P, 7);
490 SourceLanguage Lang = static_cast<SourceLanguage>(
491 Compile3.Flags & CompileSym3Flags::SourceLanguageMask);
492 P.formatLine("machine = {0}, Ver = {1}, language = {2}",
493 formatMachineType(Compile3.Machine), Compile3.Version,
494 formatSourceLanguage(Lang));
495 P.formatLine("frontend = {0}.{1}.{2}.{3}, backend = {4}.{5}.{6}.{7}",
496 Compile3.VersionFrontendMajor, Compile3.VersionFrontendMinor,
497 Compile3.VersionFrontendBuild, Compile3.VersionFrontendQFE,
498 Compile3.VersionBackendMajor, Compile3.VersionBackendMinor,
499 Compile3.VersionBackendBuild, Compile3.VersionBackendQFE);
500 P.formatLine("flags = {0}",
501 formatCompileSym3Flags(P.getIndentLevel() + 9, Compile3.Flags));
502 return Error::success();
505 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
506 ConstantSym &Constant) {
507 P.format(" `{0}`", Constant.Name);
508 AutoIndent Indent(P, 7);
509 P.formatLine("type = {0}, value = {1}", typeIndex(Constant.Type),
510 Constant.Value.toString(10));
511 return Error::success();
514 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, DataSym &Data) {
515 P.format(" `{0}`", Data.Name);
516 AutoIndent Indent(P, 7);
517 P.formatLine("type = {0}, addr = {1}", typeIndex(Data.Type),
518 formatSegmentOffset(Data.Segment, Data.DataOffset));
519 return Error::success();
522 Error MinimalSymbolDumper::visitKnownRecord(
523 CVSymbol &CVR, DefRangeFramePointerRelFullScopeSym &Def) {
524 P.format(" offset = {0}", Def.Offset);
525 return Error::success();
528 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
529 DefRangeFramePointerRelSym &Def) {
530 AutoIndent Indent(P, 7);
531 P.formatLine("offset = {0}, range = {1}", Def.Offset, formatRange(Def.Range));
532 P.formatLine("gaps = {2}", Def.Offset,
533 formatGaps(P.getIndentLevel() + 9, Def.Gaps));
534 return Error::success();
537 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
538 DefRangeRegisterRelSym &Def) {
539 AutoIndent Indent(P, 7);
540 P.formatLine("register = {0}, base ptr = {1}, offset in parent = {2}, has "
542 uint16_t(Def.Hdr.Register), int32_t(Def.Hdr.BasePointerOffset),
543 Def.offsetInParent(), Def.hasSpilledUDTMember());
544 P.formatLine("range = {0}, gaps = {1}", formatRange(Def.Range),
545 formatGaps(P.getIndentLevel() + 9, Def.Gaps));
546 return Error::success();
549 Error MinimalSymbolDumper::visitKnownRecord(
550 CVSymbol &CVR, DefRangeRegisterSym &DefRangeRegister) {
551 AutoIndent Indent(P, 7);
552 P.formatLine("register = {0}, may have no name = {1}, range start = "
554 uint16_t(DefRangeRegister.Hdr.Register),
555 uint16_t(DefRangeRegister.Hdr.MayHaveNoName),
556 formatSegmentOffset(DefRangeRegister.Range.ISectStart,
557 DefRangeRegister.Range.OffsetStart),
558 DefRangeRegister.Range.Range);
559 P.formatLine("gaps = [{0}]",
560 formatGaps(P.getIndentLevel() + 9, DefRangeRegister.Gaps));
561 return Error::success();
564 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
565 DefRangeSubfieldRegisterSym &Def) {
566 AutoIndent Indent(P, 7);
567 bool NoName = !!(Def.Hdr.MayHaveNoName == 0);
568 P.formatLine("register = {0}, may have no name = {1}, offset in parent = {2}",
569 uint16_t(Def.Hdr.Register), NoName,
570 uint32_t(Def.Hdr.OffsetInParent));
571 P.formatLine("range = {0}, gaps = {1}", formatRange(Def.Range),
572 formatGaps(P.getIndentLevel() + 9, Def.Gaps));
573 return Error::success();
576 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
577 DefRangeSubfieldSym &Def) {
578 AutoIndent Indent(P, 7);
579 P.formatLine("program = {0}, offset in parent = {1}, range = {2}",
580 Def.Program, Def.OffsetInParent, formatRange(Def.Range));
581 P.formatLine("gaps = {0}", formatGaps(P.getIndentLevel() + 9, Def.Gaps));
582 return Error::success();
585 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, DefRangeSym &Def) {
586 AutoIndent Indent(P, 7);
587 P.formatLine("program = {0}, range = {1}", Def.Program,
588 formatRange(Def.Range));
589 P.formatLine("gaps = {0}", formatGaps(P.getIndentLevel() + 9, Def.Gaps));
590 return Error::success();
593 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, FrameCookieSym &FC) {
594 AutoIndent Indent(P, 7);
595 P.formatLine("code offset = {0}, Register = {1}, kind = {2}, flags = {3}",
596 FC.CodeOffset, FC.Register, formatCookieKind(FC.CookieKind),
598 return Error::success();
601 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, FrameProcSym &FP) {
602 AutoIndent Indent(P, 7);
603 P.formatLine("size = {0}, padding size = {1}, offset to padding = {2}",
604 FP.TotalFrameBytes, FP.PaddingFrameBytes, FP.OffsetToPadding);
605 P.formatLine("bytes of callee saved registers = {0}, exception handler addr "
607 FP.BytesOfCalleeSavedRegisters,
608 formatSegmentOffset(FP.SectionIdOfExceptionHandler,
609 FP.OffsetOfExceptionHandler));
610 P.formatLine("flags = {0}",
611 formatFrameProcedureOptions(P.getIndentLevel() + 9, FP.Flags));
612 return Error::success();
615 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
616 HeapAllocationSiteSym &HAS) {
617 AutoIndent Indent(P, 7);
618 P.formatLine("type = {0}, addr = {1} call size = {2}", typeIndex(HAS.Type),
619 formatSegmentOffset(HAS.Segment, HAS.CodeOffset),
620 HAS.CallInstructionSize);
621 return Error::success();
624 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, InlineSiteSym &IS) {
625 AutoIndent Indent(P, 7);
626 auto Bytes = makeArrayRef(IS.AnnotationData);
627 StringRef Annotations(reinterpret_cast<const char *>(Bytes.begin()),
630 P.formatLine("inlinee = {0}, parent = {1}, end = {2}", idIndex(IS.Inlinee),
632 P.formatLine("annotations = {0}", toHex(Annotations));
633 return Error::success();
636 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
637 RegisterSym &Register) {
638 P.format(" `{0}`", Register.Name);
639 AutoIndent Indent(P, 7);
640 P.formatLine("register = {0}, type = {1}",
641 formatRegisterId(Register.Register), typeIndex(Register.Index));
642 return Error::success();
645 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
646 PublicSym32 &Public) {
647 P.format(" `{0}`", Public.Name);
648 AutoIndent Indent(P, 7);
649 P.formatLine("flags = {0}, addr = {1}",
650 formatPublicSymFlags(P.getIndentLevel() + 9, Public.Flags),
651 formatSegmentOffset(Public.Segment, Public.Offset));
652 return Error::success();
655 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, ProcRefSym &PR) {
656 P.format(" `{0}`", PR.Name);
657 AutoIndent Indent(P, 7);
658 P.formatLine("module = {0}, sum name = {1}, offset = {2}", PR.Module,
659 PR.SumName, PR.SymOffset);
660 return Error::success();
663 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, LabelSym &Label) {
664 P.format(" `{0}` (addr = {1})", Label.Name,
665 formatSegmentOffset(Label.Segment, Label.CodeOffset));
666 AutoIndent Indent(P, 7);
667 P.formatLine("flags = {0}",
668 formatProcSymFlags(P.getIndentLevel() + 9, Label.Flags));
669 return Error::success();
672 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, LocalSym &Local) {
673 P.format(" `{0}`", Local.Name);
674 AutoIndent Indent(P, 7);
676 std::string FlagStr =
677 formatLocalSymFlags(P.getIndentLevel() + 9, Local.Flags);
678 P.formatLine("type={0}, flags = {1}", typeIndex(Local.Type), FlagStr);
679 return Error::success();
682 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
683 ObjNameSym &ObjName) {
684 P.format(" sig={0}, `{1}`", ObjName.Signature, ObjName.Name);
685 return Error::success();
688 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, ProcSym &Proc) {
689 P.format(" `{0}`", Proc.Name);
690 AutoIndent Indent(P, 7);
691 P.formatLine("parent = {0}, end = {1}, addr = {2}, code size = {3}",
692 Proc.Parent, Proc.End,
693 formatSegmentOffset(Proc.Segment, Proc.CodeOffset),
696 switch (Proc.getKind()) {
697 case SymbolRecordKind::GlobalProcIdSym:
698 case SymbolRecordKind::ProcIdSym:
699 case SymbolRecordKind::DPCProcIdSym:
705 P.formatLine("type = `{0}`, debug start = {1}, debug end = {2}, flags = {3}",
706 typeOrIdIndex(Proc.FunctionType, IsType), Proc.DbgStart,
708 formatProcSymFlags(P.getIndentLevel() + 9, Proc.Flags));
709 return Error::success();
712 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
713 ScopeEndSym &ScopeEnd) {
714 return Error::success();
717 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, CallerSym &Caller) {
718 AutoIndent Indent(P, 7);
719 for (const auto &I : Caller.Indices) {
720 P.formatLine("callee: {0}", idIndex(I));
722 return Error::success();
725 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
726 RegRelativeSym &RegRel) {
727 P.format(" `{0}`", RegRel.Name);
728 AutoIndent Indent(P, 7);
729 P.formatLine("type = {0}, register = {1}, offset = {2}",
730 typeIndex(RegRel.Type), formatRegisterId(RegRel.Register),
732 return Error::success();
735 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR,
736 ThreadLocalDataSym &Data) {
737 P.format(" `{0}`", Data.Name);
738 AutoIndent Indent(P, 7);
739 P.formatLine("type = {0}, addr = {1}", typeIndex(Data.Type),
740 formatSegmentOffset(Data.Segment, Data.DataOffset));
741 return Error::success();
744 Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, UDTSym &UDT) {
745 P.format(" `{0}`", UDT.Name);
746 AutoIndent Indent(P, 7);
747 P.formatLine("original type = {0}", UDT.Type);
748 return Error::success();