LLVM  3.7.0
PDBExtras.cpp
Go to the documentation of this file.
1 //===- PDBExtras.cpp - helper functions and classes for PDBs -----*- C++-*-===//
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 
12 #include "llvm/ADT/ArrayRef.h"
13 
14 using namespace llvm;
15 
16 #define CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, Str, Stream) \
17  case Class::Value: \
18  Stream << Str; \
19  break;
20 
21 #define CASE_OUTPUT_ENUM_CLASS_NAME(Class, Value, Stream) \
22  CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, #Value, Stream)
23 
25  switch (Type) {
37  default:
38  OS << "Unknown";
39  }
40  return OS;
41 }
42 
44  OS << "__";
45  switch (Conv) {
71  OS)
72  default:
73  OS << "unknowncall";
74  }
75  return OS;
76 }
77 
79  switch (Data) {
90  }
91  return OS;
92 }
93 
95  switch (Reg) {
143  default:
144  OS << static_cast<int>(Reg);
145  }
146  return OS;
147 }
148 
150  switch (Loc) {
151  CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, Static, "static", OS)
161  default:
162  OS << "Unknown";
163  }
164  return OS;
165 }
166 
168  switch (Thunk) {
176  }
177  return OS;
178 }
179 
181  switch (Checksum) {
185  }
186  return OS;
187 }
188 
190  switch (Lang) {
208  }
209  return OS;
210 }
211 
213  switch (Tag) {
244  default:
245  OS << "Unknown";
246  }
247  return OS;
248 }
249 
251  switch (Access) {
255  }
256  return OS;
257 }
258 
260  switch (Type) {
261  CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Class, "class", OS)
265  }
266  return OS;
267 }
268 
270  static const char *Lookup = "0123456789ABCDEF";
271 
272  static_assert(sizeof(PDB_UniqueId) == 16, "Expected 16-byte GUID");
273  ArrayRef<uint8_t> GuidBytes(reinterpret_cast<const uint8_t*>(&Id), 16);
274  OS << "{";
275  for (int i=0; i < 16;) {
276  uint8_t Byte = GuidBytes[i];
277  uint8_t HighNibble = (Byte >> 4) & 0xF;
278  uint8_t LowNibble = Byte & 0xF;
279  OS << Lookup[HighNibble] << Lookup[LowNibble];
280  ++i;
281  if (i>=4 && i<=10 && i%2==0)
282  OS << "-";
283  }
284  OS << "}";
285  return OS;
286 }
287 
289  switch (Value.Type) {
291  OS << (Value.Bool ? "true" : "false");
292  break;
294  OS << Value.Double;
295  break;
297  OS << Value.Int16;
298  break;
300  OS << Value.Int32;
301  break;
303  OS << Value.Int64;
304  break;
306  OS << static_cast<int>(Value.Int8);
307  break;
309  OS << Value.Single;
310  break;
312  OS << Value.Double;
313  break;
315  OS << Value.UInt32;
316  break;
318  OS << Value.UInt64;
319  break;
321  OS << static_cast<unsigned>(Value.UInt8);
322  break;
323  default:
324  OS << Value.Type;
325  }
326  return OS;
327 }
328 
330  OS << Version.Major << "." << Version.Minor << "." << Version.Build;
331  return OS;
332 }
333 
335  for (auto Tag : Stats) {
336  OS << Tag.first << ":" << Tag.second << " ";
337  }
338  return OS;
339 }
const NoneType None
Definition: None.h:23
uint32_t Build
Definition: PDBTypes.h:438
int32_t Int32
Definition: PDBTypes.h:468
#define CASE_OUTPUT_ENUM_CLASS_NAME(Class, Value, Stream)
Definition: PDBExtras.cpp:21
Defines a 128-bit unique identifier.
Definition: PDBTypes.h:75
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:16
block placement Basic Block Placement Stats
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:255
uint8_t UInt8
Definition: PDBTypes.h:472
ArrayType - Class to represent array types.
Definition: DerivedTypes.h:336
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:336
PointerType - Class to represent pointers.
Definition: DerivedTypes.h:449
PDB_LocType
These values correspond to the LocationType enumeration, and are documented here: https://msdn...
Definition: PDBTypes.h:307
uint32_t Major
Definition: PDBTypes.h:436
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
This is an important base class in LLVM.
Definition: Constant.h:41
PDB_RegisterId
Definition: PDBTypes.h:369
double Double
Definition: PDBTypes.h:471
static int Lookup(const TableEntry *Table, unsigned N, unsigned Opcode)
PDB_CallingConv
These values correspond to the CV_call_e enumeration, and are documented at the following locations: ...
Definition: PDBTypes.h:202
PDB_VariantType Type
Definition: PDBTypes.h:463
int8_t Int8
Definition: PDBTypes.h:466
uint64_t UInt64
Definition: PDBTypes.h:475
int64_t Int64
Definition: PDBTypes.h:469
PDB_Checksum
Specifies the hash algorithm that a source file from a PDB was hashed with.
Definition: PDBTypes.h:106
float Single
Definition: PDBTypes.h:470
uint32_t UInt32
Definition: PDBTypes.h:474
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:270
PDB_ThunkOrdinal
These values correspond to the THUNK_ORDINAL enumeration, and are documented here: https://msdn...
Definition: PDBTypes.h:324
PDB_Lang
These values correspond to the CV_CFL_LANG enumeration, and are documented here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx.
Definition: PDBTypes.h:233
Definition: MD5.h:37
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
Definition: APInt.h:1738
uint32_t Minor
Definition: PDBTypes.h:437
LLVM Value Representation.
Definition: Value.h:69
int16_t Int16
Definition: PDBTypes.h:467
PDB_MemberAccess
Definition: PDBTypes.h:421
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
PDB_VariantType
Definition: PDBTypes.h:442
std::unordered_map< PDB_SymType, int > TagStats
Definition: PDBExtras.h:18