xref: /freebsd/contrib/llvm-project/llvm/lib/DebugInfo/PDB/PDBExtras.cpp (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
1 //===- PDBExtras.cpp - helper functions and classes for PDBs --------------===//
2 //
3 // 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
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "llvm/DebugInfo/PDB/PDBExtras.h"
10 #include "llvm/Support/raw_ostream.h"
11 
12 using namespace llvm;
13 using namespace llvm::pdb;
14 
15 #define CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, Str, Stream)                  \
16   case Class::Value:                                                           \
17     Stream << Str;                                                             \
18     break;
19 
20 #define CASE_OUTPUT_ENUM_CLASS_NAME(Class, Value, Stream)                      \
21   CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, #Value, Stream)
22 
23 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
24                                    const PDB_VariantType &Type) {
25   switch (Type) {
26     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Bool, OS)
27     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Single, OS)
28     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Double, OS)
29     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Int8, OS)
30     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Int16, OS)
31     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Int32, OS)
32     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, Int64, OS)
33     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, UInt8, OS)
34     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, UInt16, OS)
35     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, UInt32, OS)
36     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_VariantType, UInt64, OS)
37     default:
38       OS << "Unknown";
39   }
40   return OS;
41 }
42 
43 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
44                                    const PDB_BuiltinType &Type) {
45   switch (Type) {
46     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, None, OS)
47     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Void, OS)
48     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Char, OS)
49     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, WCharT, OS)
50     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Int, OS)
51     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, UInt, OS)
52     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Float, OS)
53     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, BCD, OS)
54     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Bool, OS)
55     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Long, OS)
56     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, ULong, OS)
57     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Currency, OS)
58     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Date, OS)
59     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Variant, OS)
60     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Complex, OS)
61     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Bitfield, OS)
62     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, BSTR, OS)
63     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, HResult, OS)
64     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Char16, OS)
65     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Char32, OS)
66     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_BuiltinType, Char8, OS)
67   }
68   return OS;
69 }
70 
71 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
72                                    const PDB_CallingConv &Conv) {
73   OS << "__";
74   switch (Conv) {
75     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearC      , "cdecl", OS)
76     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarC       , "cdecl", OS)
77     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearPascal , "pascal", OS)
78     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarPascal  , "pascal", OS)
79     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearFast   , "fastcall", OS)
80     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarFast    , "fastcall", OS)
81     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearStdCall, "stdcall", OS)
82     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarStdCall , "stdcall", OS)
83     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearSysCall, "syscall", OS)
84     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarSysCall , "syscall", OS)
85     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ThisCall   , "thiscall", OS)
86     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, MipsCall   , "mipscall", OS)
87     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Generic    , "genericcall", OS)
88     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, AlphaCall  , "alphacall", OS)
89     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, PpcCall    , "ppccall", OS)
90     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, SHCall     , "superhcall", OS)
91     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ArmCall    , "armcall", OS)
92     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, AM33Call   , "am33call", OS)
93     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, TriCall    , "tricall", OS)
94     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, SH5Call    , "sh5call", OS)
95     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, M32RCall   , "m32rcall", OS)
96     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ClrCall    , "clrcall", OS)
97     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Inline     , "inlinecall", OS)
98     CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearVector , "vectorcall", OS)
99   }
100   return OS;
101 }
102 
103 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_DataKind &Data) {
104   switch (Data) {
105     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Unknown, "unknown", OS)
106     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Local, "local", OS)
107     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, StaticLocal, "static local", OS)
108     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Param, "param", OS)
109     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, ObjectPtr, "this ptr", OS)
110     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, FileStatic, "static global", OS)
111     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Global, "global", OS)
112     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Member, "member", OS)
113     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, StaticMember, "static member", OS)
114     CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, Constant, "const", OS)
115   }
116   return OS;
117 }
118 
119 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
120                                    const llvm::codeview::CPURegister &CpuReg) {
121   if (CpuReg.Cpu == llvm::codeview::CPUType::ARMNT) {
122     switch (CpuReg.Reg) {
123 #define CV_REGISTERS_ARM
124 #define CV_REGISTER(name, val)                                                 \
125   case codeview::RegisterId::name:                                             \
126     OS << #name;                                                               \
127     return OS;
128 #include "llvm/DebugInfo/CodeView/CodeViewRegisters.def"
129 #undef CV_REGISTER
130 #undef CV_REGISTERS_ARM
131 
132     default:
133       break;
134     }
135   } else if (CpuReg.Cpu == llvm::codeview::CPUType::ARM64) {
136     switch (CpuReg.Reg) {
137 #define CV_REGISTERS_ARM64
138 #define CV_REGISTER(name, val)                                                 \
139   case codeview::RegisterId::name:                                             \
140     OS << #name;                                                               \
141     return OS;
142 #include "llvm/DebugInfo/CodeView/CodeViewRegisters.def"
143 #undef CV_REGISTER
144 #undef CV_REGISTERS_ARM64
145 
146     default:
147       break;
148     }
149   } else {
150     switch (CpuReg.Reg) {
151 #define CV_REGISTERS_X86
152 #define CV_REGISTER(name, val)                                                 \
153   case codeview::RegisterId::name:                                             \
154     OS << #name;                                                               \
155     return OS;
156 #include "llvm/DebugInfo/CodeView/CodeViewRegisters.def"
157 #undef CV_REGISTER
158 #undef CV_REGISTERS_X86
159 
160     default:
161       break;
162     }
163   }
164   OS << static_cast<int>(CpuReg.Reg);
165   return OS;
166 }
167 
168 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_LocType &Loc) {
169   switch (Loc) {
170     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, Static, "static", OS)
171     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, TLS, "tls", OS)
172     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, RegRel, "regrel", OS)
173     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, ThisRel, "thisrel", OS)
174     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, Enregistered, "register", OS)
175     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, BitField, "bitfield", OS)
176     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, Slot, "slot", OS)
177     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, IlRel, "IL rel", OS)
178     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, MetaData, "metadata", OS)
179     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, Constant, "constant", OS)
180     CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, RegRelAliasIndir,
181                                "regrelaliasindir", OS)
182   default:
183     OS << "Unknown";
184   }
185   return OS;
186 }
187 
188 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
189                                    const codeview::ThunkOrdinal &Thunk) {
190   switch (Thunk) {
191     CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, BranchIsland, OS)
192     CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, Pcode, OS)
193     CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, Standard, OS)
194     CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, ThisAdjustor, OS)
195     CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, TrampIncremental, OS)
196     CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, UnknownLoad, OS)
197     CASE_OUTPUT_ENUM_CLASS_NAME(codeview::ThunkOrdinal, Vcall, OS)
198   }
199   return OS;
200 }
201 
202 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
203                                    const PDB_Checksum &Checksum) {
204   switch (Checksum) {
205     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Checksum, None, OS)
206     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Checksum, MD5, OS)
207     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Checksum, SHA1, OS)
208     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Checksum, SHA256, OS)
209   }
210   return OS;
211 }
212 
213 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_Lang &Lang) {
214   switch (Lang) {
215     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, C, OS)
216     CASE_OUTPUT_ENUM_CLASS_STR(PDB_Lang, Cpp, "C++", OS)
217     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Fortran, OS)
218     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Masm, OS)
219     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Pascal, OS)
220     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Basic, OS)
221     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Cobol, OS)
222     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Link, OS)
223     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Cvtres, OS)
224     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Cvtpgd, OS)
225     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, CSharp, OS)
226     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, VB, OS)
227     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, ILAsm, OS)
228     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Java, OS)
229     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, JScript, OS)
230     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, MSIL, OS)
231     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, HLSL, OS)
232     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, D, OS)
233     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Swift, OS)
234     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, Rust, OS)
235     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Lang, ObjC, OS)
236     CASE_OUTPUT_ENUM_CLASS_STR(PDB_Lang, ObjCpp, "ObjC++", OS)
237   }
238   return OS;
239 }
240 
241 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_SymType &Tag) {
242   switch (Tag) {
243     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Exe, OS)
244     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Compiland, OS)
245     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, CompilandDetails, OS)
246     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, CompilandEnv, OS)
247     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Function, OS)
248     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Block, OS)
249     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Data, OS)
250     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Annotation, OS)
251     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Label, OS)
252     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, PublicSymbol, OS)
253     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, UDT, OS)
254     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Enum, OS)
255     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, FunctionSig, OS)
256     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, PointerType, OS)
257     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, ArrayType, OS)
258     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, BuiltinType, OS)
259     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Typedef, OS)
260     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, BaseClass, OS)
261     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Friend, OS)
262     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, FunctionArg, OS)
263     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, FuncDebugStart, OS)
264     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, FuncDebugEnd, OS)
265     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, UsingNamespace, OS)
266     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, VTableShape, OS)
267     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, VTable, OS)
268     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Custom, OS)
269     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Thunk, OS)
270     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, CustomType, OS)
271     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, ManagedType, OS)
272     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Dimension, OS)
273     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, CallSite, OS)
274     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, InlineSite, OS)
275     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, BaseInterface, OS)
276     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, VectorType, OS)
277     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, MatrixType, OS)
278     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, HLSLType, OS)
279     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Caller, OS)
280     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Callee, OS)
281     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Export, OS)
282     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, HeapAllocationSite, OS)
283     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, CoffGroup, OS)
284     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SymType, Inlinee, OS)
285   default:
286     OS << "Unknown SymTag " << uint32_t(Tag);
287   }
288   return OS;
289 }
290 
291 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
292                                    const PDB_MemberAccess &Access) {
293   switch (Access) {
294     CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Public, "public", OS)
295     CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Protected, "protected", OS)
296     CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Private, "private", OS)
297   }
298   return OS;
299 }
300 
301 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const PDB_UdtType &Type) {
302   switch (Type) {
303     CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Class, "class", OS)
304     CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Struct, "struct", OS)
305     CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Interface, "interface", OS)
306     CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Union, "union", OS)
307   }
308   return OS;
309 }
310 
311 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
312                                    const PDB_Machine &Machine) {
313   switch (Machine) {
314     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Am33, OS)
315     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Amd64, OS)
316     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Arm, OS)
317     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, ArmNT, OS)
318     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Ebc, OS)
319     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, x86, OS)
320     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Ia64, OS)
321     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, M32R, OS)
322     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Mips16, OS)
323     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, MipsFpu, OS)
324     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, MipsFpu16, OS)
325     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, PowerPC, OS)
326     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, PowerPCFP, OS)
327     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, R4000, OS)
328     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, SH3, OS)
329     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, SH3DSP, OS)
330     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, SH4, OS)
331     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, SH5, OS)
332     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, Thumb, OS)
333     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_Machine, WceMipsV2, OS)
334   default:
335     OS << "Unknown";
336   }
337   return OS;
338 }
339 
340 raw_ostream &llvm::pdb::dumpPDBSourceCompression(raw_ostream &OS,
341                                                  uint32_t Compression) {
342   switch (Compression) {
343     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SourceCompression, None, OS)
344     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SourceCompression, Huffman, OS)
345     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SourceCompression, LZ, OS)
346     CASE_OUTPUT_ENUM_CLASS_STR(PDB_SourceCompression, RunLengthEncoded, "RLE",
347                                OS)
348     CASE_OUTPUT_ENUM_CLASS_NAME(PDB_SourceCompression, DotNet, OS)
349   default:
350     OS << "Unknown (" << Compression << ")";
351   }
352   return OS;
353 }
354 
355 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const Variant &Value) {
356   switch (Value.Type) {
357     case PDB_VariantType::Bool:
358       OS << (Value.Value.Bool ? "true" : "false");
359       break;
360     case PDB_VariantType::Double:
361       OS << Value.Value.Double;
362       break;
363     case PDB_VariantType::Int16:
364       OS << Value.Value.Int16;
365       break;
366     case PDB_VariantType::Int32:
367       OS << Value.Value.Int32;
368       break;
369     case PDB_VariantType::Int64:
370       OS << Value.Value.Int64;
371       break;
372     case PDB_VariantType::Int8:
373       OS << static_cast<int>(Value.Value.Int8);
374       break;
375     case PDB_VariantType::Single:
376       OS << Value.Value.Single;
377       break;
378     case PDB_VariantType::UInt16:
379       OS << Value.Value.UInt16;
380       break;
381     case PDB_VariantType::UInt32:
382       OS << Value.Value.UInt32;
383       break;
384     case PDB_VariantType::UInt64:
385       OS << Value.Value.UInt64;
386       break;
387     case PDB_VariantType::UInt8:
388       OS << static_cast<unsigned>(Value.Value.UInt8);
389       break;
390     case PDB_VariantType::String:
391       OS << Value.Value.String;
392       break;
393     default:
394       OS << Value.Type;
395   }
396   return OS;
397 }
398 
399 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS,
400                                    const VersionInfo &Version) {
401   OS << Version.Major << "." << Version.Minor << "." << Version.Build;
402   return OS;
403 }
404 
405 raw_ostream &llvm::pdb::operator<<(raw_ostream &OS, const TagStats &Stats) {
406   for (auto Tag : Stats) {
407     OS << Tag.first << ":" << Tag.second << " ";
408   }
409   return OS;
410 }
411