LLVM  10.0.0svn
PDBExtras.cpp
Go to the documentation of this file.
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 
10 #include "llvm/ADT/ArrayRef.h"
12 
13 using namespace llvm;
14 using namespace llvm::pdb;
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  const PDB_VariantType &Type) {
26  switch (Type) {
38  default:
39  OS << "Unknown";
40  }
41  return OS;
42 }
43 
45  const PDB_BuiltinType &Type) {
46  switch (Type) {
67  }
68  return OS;
69 }
70 
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)
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 
104  switch (Data) {
110  CASE_OUTPUT_ENUM_CLASS_STR(PDB_DataKind, FileStatic, "static global", OS)
115  }
116  return OS;
117 }
118 
120  const llvm::codeview::CPURegister &CpuReg) {
121  if (CpuReg.Cpu == llvm::codeview::CPUType::ARM64) {
122  switch (CpuReg.Reg) {
123 #define CV_REGISTERS_ARM64
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_ARM64
131 
132  default:
133  break;
134  }
135  } else {
136  switch (CpuReg.Reg) {
137 #define CV_REGISTERS_X86
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_X86
145 
146  default:
147  break;
148  }
149  }
150  OS << static_cast<int>(CpuReg.Reg);
151  return OS;
152 }
153 
155  switch (Loc) {
156  CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, Static, "static", OS)
167  "regrelaliasindir", OS)
168  default:
169  OS << "Unknown";
170  }
171  return OS;
172 }
173 
175  const codeview::ThunkOrdinal &Thunk) {
176  switch (Thunk) {
184  }
185  return OS;
186 }
187 
189  const PDB_Checksum &Checksum) {
190  switch (Checksum) {
195  }
196  return OS;
197 }
198 
200  switch (Lang) {
220  }
221  return OS;
222 }
223 
225  switch (Tag) {
268  default:
269  OS << "Unknown SymTag " << uint32_t(Tag);
270  }
271  return OS;
272 }
273 
275  const PDB_MemberAccess &Access) {
276  switch (Access) {
277  CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Public, "public", OS)
278  CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Protected, "protected", OS)
279  CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Private, "private", OS)
280  }
281  return OS;
282 }
283 
285  switch (Type) {
286  CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Class, "class", OS)
288  CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Interface, "interface", OS)
290  }
291  return OS;
292 }
293 
295  const PDB_Machine &Machine) {
296  switch (Machine) {
317  default:
318  OS << "Unknown";
319  }
320  return OS;
321 }
322 
324  uint32_t Compression) {
325  switch (Compression) {
329  CASE_OUTPUT_ENUM_CLASS_STR(PDB_SourceCompression, RunLengthEncoded, "RLE",
330  OS)
332  default:
333  OS << "Unknown (" << Compression << ")";
334  }
335  return OS;
336 }
337 
339  switch (Value.Type) {
341  OS << (Value.Value.Bool ? "true" : "false");
342  break;
344  OS << Value.Value.Double;
345  break;
347  OS << Value.Value.Int16;
348  break;
350  OS << Value.Value.Int32;
351  break;
353  OS << Value.Value.Int64;
354  break;
356  OS << static_cast<int>(Value.Value.Int8);
357  break;
359  OS << Value.Value.Single;
360  break;
362  OS << Value.Value.UInt16;
363  break;
365  OS << Value.Value.UInt32;
366  break;
368  OS << Value.Value.UInt64;
369  break;
371  OS << static_cast<unsigned>(Value.Value.UInt8);
372  break;
374  OS << Value.Value.String;
375  break;
376  default:
377  OS << Value.Type;
378  }
379  return OS;
380 }
381 
383  const VersionInfo &Version) {
384  OS << Version.Major << "." << Version.Minor << "." << Version.Build;
385  return OS;
386 }
387 
389  for (auto Tag : Stats) {
390  OS << Tag.first << ":" << Tag.second << " ";
391  }
392  return OS;
393 }
const NoneType None
Definition: None.h:23
uint64_t CallInst * C
This class represents lattice values for constants.
Definition: AllocatorList.h:23
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:308
union llvm::pdb::Variant::@231 Value
A class that wrap the SHA1 algorithm.
Definition: SHA1.h:28
PDB_Checksum
Specifies the hash algorithm that a source file from a PDB was hashed with.
Definition: PDBTypes.h:117
raw_ostream & operator<<(raw_ostream &OS, const PDB_VariantType &Value)
Definition: PDBExtras.cpp:24
std::unordered_map< PDB_SymType, int > TagStats
Definition: PDBExtras.h:24
#define CASE_OUTPUT_ENUM_CLASS_NAME(Class, Value, Stream)
Definition: PDBExtras.cpp:21
#define CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, Str, Stream)
Definition: PDBExtras.cpp:16
block placement Basic Block Placement Stats
Class to represent array types.
Definition: DerivedTypes.h:403
COFF::MachineTypes Machine
Definition: COFFYAML.cpp:365
Class to represent pointers.
Definition: DerivedTypes.h:570
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:241
uint32_t UInt32
Definition: PDBTypes.h:461
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_DataKind
These values correspond to the DataKind enumeration, and are documented here: https://msdn.microsoft.com/en-us/library/b2x2t313.aspx.
Definition: PDBTypes.h:226
PDB_LocType
These values correspond to the LocationType enumeration, and are documented here: https://msdn...
Definition: PDBTypes.h:290
uint64_t UInt64
Definition: PDBTypes.h:462
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
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Class to represent vector types.
Definition: DerivedTypes.h:427
amdgpu Simplify well known AMD library false FunctionCallee Callee
PDB_VariantType
Definition: PDBTypes.h:391
raw_ostream & dumpPDBSourceCompression(raw_ostream &OS, uint32_t Compression)
Definition: PDBExtras.cpp:323
uint16_t UInt16
Definition: PDBTypes.h:460
Definition: MD5.h:41
ThunkOrdinal
These values correspond to the THUNK_ORDINAL enumeration.
Definition: CodeView.h:548
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:333
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:45
PDB_VariantType Type
Definition: PDBTypes.h:450
const uint64_t Version
Definition: InstrProf.h:984
PDB_MemberAccess
Definition: PDBTypes.h:382