LLVM  8.0.1
PDBExtras.cpp
Go to the documentation of this file.
1 //===- PDBExtras.cpp - helper functions and classes for PDBs --------------===//
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 
11 #include "llvm/ADT/ArrayRef.h"
13 
14 using namespace llvm;
15 using namespace llvm::pdb;
16 
17 #define CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, Str, Stream) \
18  case Class::Value: \
19  Stream << Str; \
20  break;
21 
22 #define CASE_OUTPUT_ENUM_CLASS_NAME(Class, Value, Stream) \
23  CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, #Value, Stream)
24 
26  const PDB_VariantType &Type) {
27  switch (Type) {
39  default:
40  OS << "Unknown";
41  }
42  return OS;
43 }
44 
46  const PDB_BuiltinType &Type) {
47  switch (Type) {
68  }
69  return OS;
70 }
71 
73  const PDB_CallingConv &Conv) {
74  OS << "__";
75  switch (Conv) {
76  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearC , "cdecl", OS)
77  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarC , "cdecl", OS)
78  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearPascal , "pascal", OS)
79  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarPascal , "pascal", OS)
80  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearFast , "fastcall", OS)
81  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarFast , "fastcall", OS)
82  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearStdCall, "stdcall", OS)
83  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarStdCall , "stdcall", OS)
84  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearSysCall, "syscall", OS)
85  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarSysCall , "syscall", OS)
86  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ThisCall , "thiscall", OS)
87  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, MipsCall , "mipscall", OS)
89  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, AlphaCall , "alphacall", OS)
90  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, PpcCall , "ppccall", OS)
91  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, SHCall , "superhcall", OS)
92  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ArmCall , "armcall", OS)
93  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, AM33Call , "am33call", OS)
94  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, TriCall , "tricall", OS)
95  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, SH5Call , "sh5call", OS)
96  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, M32RCall , "m32rcall", OS)
97  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ClrCall , "clrcall", OS)
98  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Inline , "inlinecall", OS)
99  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearVector , "vectorcall", OS)
100  }
101  return OS;
102 }
103 
105  switch (Data) {
111  CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, FileStatic, "static global", OS)
116  }
117  return OS;
118 }
119 
121  const codeview::RegisterId &Reg) {
122  switch (Reg) {
123 #define CV_REGISTER(name, val) case codeview::RegisterId::name: OS << #name; return OS;
124 #include "llvm/DebugInfo/CodeView/CodeViewRegisters.def"
125 #undef CV_REGISTER
126  }
127  OS << static_cast<int>(Reg);
128  return OS;
129 }
130 
132  switch (Loc) {
133  CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, Static, "static", OS)
144  "regrelaliasindir", OS)
145  default:
146  OS << "Unknown";
147  }
148  return OS;
149 }
150 
152  const codeview::ThunkOrdinal &Thunk) {
153  switch (Thunk) {
161  }
162  return OS;
163 }
164 
166  const PDB_Checksum &Checksum) {
167  switch (Checksum) {
172  }
173  return OS;
174 }
175 
177  switch (Lang) {
196  }
197  return OS;
198 }
199 
201  switch (Tag) {
244  default:
245  OS << "Unknown SymTag " << uint32_t(Tag);
246  }
247  return OS;
248 }
249 
251  const PDB_MemberAccess &Access) {
252  switch (Access) {
253  CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Public, "public", OS)
254  CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Protected, "protected", OS)
255  CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Private, "private", OS)
256  }
257  return OS;
258 }
259 
261  switch (Type) {
262  CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Class, "class", OS)
264  CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Interface, "interface", OS)
266  }
267  return OS;
268 }
269 
271  const PDB_Machine &Machine) {
272  switch (Machine) {
293  default:
294  OS << "Unknown";
295  }
296  return OS;
297 }
298 
300  const PDB_SourceCompression &Compression) {
301  switch (Compression) {
306  OS)
307  }
308  return OS;
309 }
310 
312  switch (Value.Type) {
314  OS << (Value.Value.Bool ? "true" : "false");
315  break;
317  OS << Value.Value.Double;
318  break;
320  OS << Value.Value.Int16;
321  break;
323  OS << Value.Value.Int32;
324  break;
326  OS << Value.Value.Int64;
327  break;
329  OS << static_cast<int>(Value.Value.Int8);
330  break;
332  OS << Value.Value.Single;
333  break;
335  OS << Value.Value.UInt16;
336  break;
338  OS << Value.Value.UInt32;
339  break;
341  OS << Value.Value.UInt64;
342  break;
344  OS << static_cast<unsigned>(Value.Value.UInt8);
345  break;
347  OS << Value.Value.String;
348  break;
349  default:
350  OS << Value.Type;
351  }
352  return OS;
353 }
354 
356  const VersionInfo &Version) {
357  OS << Version.Major << "." << Version.Minor << "." << Version.Build;
358  return OS;
359 }
360 
362  for (auto Tag : Stats) {
363  OS << Tag.first << ":" << Tag.second << " ";
364  }
365  return OS;
366 }
const NoneType None
Definition: None.h:24
uint64_t CallInst * C
This class represents lattice values for constants.
Definition: AllocatorList.h:24
PDB_UdtType
These values correspond to the UdtKind enumeration, and are documented here: https://msdn.microsoft.com/en-us/library/wcstk66t.aspx.
Definition: PDBTypes.h:250
unsigned Reg
A class that wrap the SHA1 algorithm.
Definition: SHA1.h:29
PDB_Checksum
Specifies the hash algorithm that a source file from a PDB was hashed with.
Definition: PDBTypes.h:118
raw_ostream & operator<<(raw_ostream &OS, const PDB_VariantType &Value)
Definition: PDBExtras.cpp:25
std::unordered_map< PDB_SymType, int > TagStats
Definition: PDBExtras.h:25
#define CASE_OUTPUT_ENUM_CLASS_NAME(Class, Value, Stream)
Definition: PDBExtras.cpp:22
#define CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, Str, Stream)
Definition: PDBExtras.cpp:17
block placement Basic Block Placement Stats
Class to represent array types.
Definition: DerivedTypes.h:369
COFF::MachineTypes Machine
Definition: COFFYAML.cpp:363
amdgpu Simplify well known AMD library false Value * Callee
Class to represent pointers.
Definition: DerivedTypes.h:467
PDB_SymType
These values correspond to the SymTagEnum enumeration, and are documented here: https://msdn.microsoft.com/en-us/library/bkedss5f.aspx.
Definition: PDBTypes.h:183
uint32_t UInt32
Definition: PDBTypes.h:403
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
This is an important base class in LLVM.
Definition: Constant.h:42
PDB_DataKind
These values correspond to the DataKind enumeration, and are documented here: https://msdn.microsoft.com/en-us/library/b2x2t313.aspx.
Definition: PDBTypes.h:168
PDB_SourceCompression
Definition: PDBTypes.h:149
PDB_LocType
These values correspond to the LocationType enumeration, and are documented here: https://msdn...
Definition: PDBTypes.h:232
uint64_t UInt64
Definition: PDBTypes.h:404
SourceLanguage
These values correspond to the CV_CFL_LANG enumeration, and are documented here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx.
Definition: CodeView.h:144
union llvm::pdb::Variant::@215 Value
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Class to represent vector types.
Definition: DerivedTypes.h:393
PDB_VariantType
Definition: PDBTypes.h:333
uint16_t UInt16
Definition: PDBTypes.h:402
Definition: MD5.h:41
ThunkOrdinal
These values correspond to the THUNK_ORDINAL enumeration.
Definition: CodeView.h:531
PDB_BuiltinType
These values correspond to the Basictype enumeration, and are documented here: https://msdn.microsoft.com/en-us/library/4szdtzc3.aspx.
Definition: PDBTypes.h:275
LLVM Value Representation.
Definition: Value.h:73
CallingConvention
These values correspond to the CV_call_e enumeration, and are documented at the following locations: ...
Definition: CodeView.h:173
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
PDB_VariantType Type
Definition: PDBTypes.h:392
const uint64_t Version
Definition: InstrProf.h:895
PDB_MemberAccess
Definition: PDBTypes.h:324