LLVM  7.0.0svn
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_CallingConv &Conv) {
47  OS << "__";
48  switch (Conv) {
49  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearC , "cdecl", OS)
50  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarC , "cdecl", OS)
51  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearPascal , "pascal", OS)
52  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarPascal , "pascal", OS)
53  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearFast , "fastcall", OS)
54  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarFast , "fastcall", OS)
55  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearStdCall, "stdcall", OS)
56  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarStdCall , "stdcall", OS)
57  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearSysCall, "syscall", OS)
58  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarSysCall , "syscall", OS)
59  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ThisCall , "thiscall", OS)
60  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, MipsCall , "mipscall", OS)
62  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, AlphaCall , "alphacall", OS)
63  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, PpcCall , "ppccall", OS)
64  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, SHCall , "superhcall", OS)
65  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ArmCall , "armcall", OS)
66  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, AM33Call , "am33call", OS)
67  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, TriCall , "tricall", OS)
68  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, SH5Call , "sh5call", OS)
69  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, M32RCall , "m32rcall", OS)
70  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ClrCall , "clrcall", OS)
71  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Inline , "inlinecall", OS)
72  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearVector , "vectorcall", OS)
73  }
74  return OS;
75 }
76 
78  switch (Data) {
89  }
90  return OS;
91 }
92 
94  const codeview::RegisterId &Reg) {
95  switch (Reg) {
96 #define CV_REGISTER(name, val) case codeview::RegisterId::name: OS << #name; return OS;
97 #include "llvm/DebugInfo/CodeView/CodeViewRegisters.def"
98 #undef CV_REGISTER
99  }
100  OS << static_cast<int>(Reg);
101  return OS;
102 }
103 
105  switch (Loc) {
106  CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, Static, "static", OS)
117  "regrelaliasindir", OS)
118  default:
119  OS << "Unknown";
120  }
121  return OS;
122 }
123 
125  const codeview::ThunkOrdinal &Thunk) {
126  switch (Thunk) {
134  }
135  return OS;
136 }
137 
139  const PDB_Checksum &Checksum) {
140  switch (Checksum) {
145  }
146  return OS;
147 }
148 
150  switch (Lang) {
169  }
170  return OS;
171 }
172 
174  switch (Tag) {
205  default:
206  OS << "Unknown";
207  }
208  return OS;
209 }
210 
212  const PDB_MemberAccess &Access) {
213  switch (Access) {
214  CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Public, "public", OS)
215  CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Protected, "protected", OS)
216  CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Private, "private", OS)
217  }
218  return OS;
219 }
220 
222  switch (Type) {
223  CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Class, "class", OS)
225  CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Interface, "interface", OS)
227  }
228  return OS;
229 }
230 
232  const PDB_Machine &Machine) {
233  switch (Machine) {
254  default:
255  OS << "Unknown";
256  }
257  return OS;
258 }
259 
261  const PDB_SourceCompression &Compression) {
262  switch (Compression) {
267  OS)
268  }
269  return OS;
270 }
271 
273  switch (Value.Type) {
275  OS << (Value.Value.Bool ? "true" : "false");
276  break;
278  OS << Value.Value.Double;
279  break;
281  OS << Value.Value.Int16;
282  break;
284  OS << Value.Value.Int32;
285  break;
287  OS << Value.Value.Int64;
288  break;
290  OS << static_cast<int>(Value.Value.Int8);
291  break;
293  OS << Value.Value.Single;
294  break;
296  OS << Value.Value.Double;
297  break;
299  OS << Value.Value.UInt32;
300  break;
302  OS << Value.Value.UInt64;
303  break;
305  OS << static_cast<unsigned>(Value.Value.UInt8);
306  break;
308  OS << Value.Value.String;
309  break;
310  default:
311  OS << Value.Type;
312  }
313  return OS;
314 }
315 
317  const VersionInfo &Version) {
318  OS << Version.Major << "." << Version.Minor << "." << Version.Build;
319  return OS;
320 }
321 
323  for (auto Tag : Stats) {
324  OS << Tag.first << ":" << Tag.second << " ";
325  }
326  return OS;
327 }
const NoneType None
Definition: None.h:24
uint64_t CallInst * C
Compute iterated dominance frontiers using a linear time algorithm.
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:234
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:114
raw_ostream & operator<<(raw_ostream &OS, const PDB_VariantType &Value)
Definition: PDBExtras.cpp:25
std::unordered_map< PDB_SymType, int > TagStats
Definition: PDBExtras.h:23
#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
union llvm::pdb::Variant::@191 Value
COFF::MachineTypes Machine
Definition: COFFYAML.cpp:363
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:179
uint32_t UInt32
Definition: PDBTypes.h:357
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:164
PDB_SourceCompression
Definition: PDBTypes.h:145
PDB_LocType
These values correspond to the LocationType enumeration, and are documented here: https://msdn...
Definition: PDBTypes.h:216
uint64_t UInt64
Definition: PDBTypes.h:358
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
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
PDB_VariantType
Definition: PDBTypes.h:317
Definition: MD5.h:41
ThunkOrdinal
These values correspond to the THUNK_ORDINAL enumeration.
Definition: CodeView.h:514
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:346
const uint64_t Version
Definition: InstrProf.h:895
PDB_MemberAccess
Definition: PDBTypes.h:308