LLVM  5.0.0
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"
14 
15 using namespace llvm;
16 using namespace llvm::pdb;
17 
18 #define CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, Str, Stream) \
19  case Class::Value: \
20  Stream << Str; \
21  break;
22 
23 #define CASE_OUTPUT_ENUM_CLASS_NAME(Class, Value, Stream) \
24  CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, #Value, Stream)
25 
27  const PDB_VariantType &Type) {
28  switch (Type) {
40  default:
41  OS << "Unknown";
42  }
43  return OS;
44 }
45 
47  const PDB_CallingConv &Conv) {
48  OS << "__";
49  switch (Conv) {
50  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearC , "cdecl", OS)
51  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarC , "cdecl", OS)
52  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearPascal , "pascal", OS)
53  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarPascal , "pascal", OS)
54  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearFast , "fastcall", OS)
55  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarFast , "fastcall", OS)
56  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearStdCall, "stdcall", OS)
57  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarStdCall , "stdcall", OS)
58  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearSysCall, "syscall", OS)
59  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, FarSysCall , "syscall", OS)
60  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ThisCall , "thiscall", OS)
61  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, MipsCall , "mipscall", OS)
63  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, AlphaCall , "alphacall", OS)
64  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, PpcCall , "ppccall", OS)
65  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, SHCall , "superhcall", OS)
66  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ArmCall , "armcall", OS)
67  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, AM33Call , "am33call", OS)
68  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, TriCall , "tricall", OS)
69  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, SH5Call , "sh5call", OS)
70  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, M32RCall , "m32rcall", OS)
71  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, ClrCall , "clrcall", OS)
72  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, Inline , "inlinecall", OS)
73  CASE_OUTPUT_ENUM_CLASS_STR(PDB_CallingConv, NearVector , "vectorcall", OS)
74  }
75  return OS;
76 }
77 
79  switch (Data) {
90  }
91  return OS;
92 }
93 
95  const codeview::RegisterId &Reg) {
96  switch (Reg) {
144  default:
145  OS << static_cast<int>(Reg);
146  }
147  return OS;
148 }
149 
151  switch (Loc) {
152  CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, Static, "static", OS)
162  default:
163  OS << "Unknown";
164  }
165  return OS;
166 }
167 
169  const codeview::ThunkOrdinal &Thunk) {
170  switch (Thunk) {
178  }
179  return OS;
180 }
181 
183  const PDB_Checksum &Checksum) {
184  switch (Checksum) {
188  }
189  return OS;
190 }
191 
193  switch (Lang) {
211  }
212  return OS;
213 }
214 
216  switch (Tag) {
247  default:
248  OS << "Unknown";
249  }
250  return OS;
251 }
252 
254  const PDB_MemberAccess &Access) {
255  switch (Access) {
256  CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Public, "public", OS)
257  CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Protected, "protected", OS)
258  CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Private, "private", OS)
259  }
260  return OS;
261 }
262 
264  switch (Type) {
265  CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Class, "class", OS)
267  CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Interface, "interface", OS)
269  }
270  return OS;
271 }
272 
274  const PDB_Machine &Machine) {
275  switch (Machine) {
296  default:
297  OS << "Unknown";
298  }
299  return OS;
300 }
301 
303  switch (Value.Type) {
305  OS << (Value.Value.Bool ? "true" : "false");
306  break;
308  OS << Value.Value.Double;
309  break;
311  OS << Value.Value.Int16;
312  break;
314  OS << Value.Value.Int32;
315  break;
317  OS << Value.Value.Int64;
318  break;
320  OS << static_cast<int>(Value.Value.Int8);
321  break;
323  OS << Value.Value.Single;
324  break;
326  OS << Value.Value.Double;
327  break;
329  OS << Value.Value.UInt32;
330  break;
332  OS << Value.Value.UInt64;
333  break;
335  OS << static_cast<unsigned>(Value.Value.UInt8);
336  break;
338  OS << Value.Value.String;
339  break;
340  default:
341  OS << Value.Type;
342  }
343  return OS;
344 }
345 
347  const VersionInfo &Version) {
348  OS << Version.Major << "." << Version.Minor << "." << Version.Build;
349  return OS;
350 }
351 
353  for (auto Tag : Stats) {
354  OS << Tag.first << ":" << Tag.second << " ";
355  }
356  return OS;
357 }
const NoneType None
Definition: None.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:211
DataLayout DL
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:99
raw_ostream & operator<<(raw_ostream &OS, const PDB_VariantType &Value)
Definition: PDBExtras.cpp:26
std::unordered_map< PDB_SymType, int > TagStats
Definition: PDBExtras.h:23
#define CASE_OUTPUT_ENUM_CLASS_NAME(Class, Value, Stream)
Definition: PDBExtras.cpp:23
Reg
All possible values of the reg field in the ModR/M byte.
#define CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, Str, Stream)
Definition: PDBExtras.cpp:18
block placement Basic Block Placement Stats
MachineTypes Machine
Class to represent array types.
Definition: DerivedTypes.h:369
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:157
uint32_t UInt32
Definition: PDBTypes.h:293
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:142
PDB_LocType
These values correspond to the LocationType enumeration, and are documented here: https://msdn...
Definition: PDBTypes.h:194
uint64_t UInt64
Definition: PDBTypes.h:294
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:143
PDB_VariantType
Definition: PDBTypes.h:253
union llvm::pdb::Variant::@173 Value
#define C
Definition: LargeTest.cpp:25
Definition: MD5.h:41
ThunkOrdinal
These values correspond to the THUNK_ORDINAL enumeration.
Definition: CodeView.h:555
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:168
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
PDB_VariantType Type
Definition: PDBTypes.h:282
const uint64_t Version
Definition: InstrProf.h:864
PDB_MemberAccess
Definition: PDBTypes.h:244