LLVM  15.0.0git
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 
11 
12 using namespace llvm;
13 using namespace llvm::pdb;
14 
15 #define CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, Str, Stream) \
16  case Class::Value: \
17  Stream << Str; \
18  break;
19 
20 #define CASE_OUTPUT_ENUM_CLASS_NAME(Class, Value, Stream) \
21  CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, #Value, Stream)
22 
24  const PDB_VariantType &Type) {
25  switch (Type) {
37  default:
38  OS << "Unknown";
39  }
40  return OS;
41 }
42 
44  const PDB_BuiltinType &Type) {
45  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::ARMNT) {
122  switch (CpuReg.Reg) {
123 #define CV_REGISTERS_ARM
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_ARM
131 
132  default:
133  break;
134  }
135  } else if (CpuReg.Cpu == llvm::codeview::CPUType::ARM64) {
136  switch (CpuReg.Reg) {
137 #define CV_REGISTERS_ARM64
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_ARM64
145 
146  default:
147  break;
148  }
149  } else {
150  switch (CpuReg.Reg) {
151 #define CV_REGISTERS_X86
152 #define CV_REGISTER(name, val) \
153  case codeview::RegisterId::name: \
154  OS << #name; \
155  return OS;
156 #include "llvm/DebugInfo/CodeView/CodeViewRegisters.def"
157 #undef CV_REGISTER
158 #undef CV_REGISTERS_X86
159 
160  default:
161  break;
162  }
163  }
164  OS << static_cast<int>(CpuReg.Reg);
165  return OS;
166 }
167 
169  switch (Loc) {
170  CASE_OUTPUT_ENUM_CLASS_STR(PDB_LocType, Static, "static", OS)
181  "regrelaliasindir", OS)
182  default:
183  OS << "Unknown";
184  }
185  return OS;
186 }
187 
189  const codeview::ThunkOrdinal &Thunk) {
190  switch (Thunk) {
198  }
199  return OS;
200 }
201 
203  const PDB_Checksum &Checksum) {
204  switch (Checksum) {
209  }
210  return OS;
211 }
212 
214  switch (Lang) {
235  }
236  return OS;
237 }
238 
240  switch (Tag) {
283  default:
284  OS << "Unknown SymTag " << uint32_t(Tag);
285  }
286  return OS;
287 }
288 
290  const PDB_MemberAccess &Access) {
291  switch (Access) {
292  CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Public, "public", OS)
293  CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Protected, "protected", OS)
294  CASE_OUTPUT_ENUM_CLASS_STR(PDB_MemberAccess, Private, "private", OS)
295  }
296  return OS;
297 }
298 
300  switch (Type) {
301  CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Class, "class", OS)
303  CASE_OUTPUT_ENUM_CLASS_STR(PDB_UdtType, Interface, "interface", OS)
305  }
306  return OS;
307 }
308 
310  const PDB_Machine &Machine) {
311  switch (Machine) {
332  default:
333  OS << "Unknown";
334  }
335  return OS;
336 }
337 
339  uint32_t Compression) {
340  switch (Compression) {
344  CASE_OUTPUT_ENUM_CLASS_STR(PDB_SourceCompression, RunLengthEncoded, "RLE",
345  OS)
347  default:
348  OS << "Unknown (" << Compression << ")";
349  }
350  return OS;
351 }
352 
354  switch (Value.Type) {
356  OS << (Value.Value.Bool ? "true" : "false");
357  break;
359  OS << Value.Value.Double;
360  break;
362  OS << Value.Value.Int16;
363  break;
365  OS << Value.Value.Int32;
366  break;
368  OS << Value.Value.Int64;
369  break;
371  OS << static_cast<int>(Value.Value.Int8);
372  break;
374  OS << Value.Value.Single;
375  break;
377  OS << Value.Value.UInt16;
378  break;
380  OS << Value.Value.UInt32;
381  break;
383  OS << Value.Value.UInt64;
384  break;
386  OS << static_cast<unsigned>(Value.Value.UInt8);
387  break;
389  OS << Value.Value.String;
390  break;
391  default:
392  OS << Value.Type;
393  }
394  return OS;
395 }
396 
398  const VersionInfo &Version) {
399  OS << Version.Major << "." << Version.Minor << "." << Version.Build;
400  return OS;
401 }
402 
404  for (auto Tag : Stats) {
405  OS << Tag.first << ":" << Tag.second << " ";
406  }
407  return OS;
408 }
llvm::codeview::JScript
@ JScript
Definition: CodeView.h:161
llvm::codeview::CPUType::ARM64
@ ARM64
llvm::pdb::PDB_SymType::UsingNamespace
@ UsingNamespace
llvm::pdb::PDB_SymType::CustomType
@ CustomType
llvm::pdb::PDB_BuiltinType::ULong
@ ULong
llvm::pdb::PDB_UdtType::Struct
@ Struct
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::pdb::PDB_DataKind::FileStatic
@ FileStatic
llvm::InlineSite
std::tuple< uint64_t, uint32_t > InlineSite
Definition: MCPseudoProbe.h:89
llvm::pdb::PDB_BuiltinType::Char
@ Char
llvm::pdb::PDB_SymType::FunctionSig
@ FunctionSig
llvm::pdb::PDB_SymType::BaseClass
@ BaseClass
llvm::pdb::PDB_DataKind::Member
@ Member
llvm::pdb::PDB_SymType::MatrixType
@ MatrixType
llvm::Function
Definition: Function.h:60
llvm::pdb::Int64
@ Int64
Definition: PDBTypes.h:400
llvm::pdb::PDB_Machine::PowerPC
@ PowerPC
llvm::pdb::PDB_SymType::CoffGroup
@ CoffGroup
llvm::pdb::PDB_SymType::HeapAllocationSite
@ HeapAllocationSite
llvm::pdb::PDB_BuiltinType::Char8
@ Char8
llvm::SHA256
Definition: SHA256.h:33
llvm::pdb::UInt16
@ UInt16
Definition: PDBTypes.h:404
llvm::pdb::PDB_DataKind::StaticMember
@ StaticMember
llvm::pdb::PDB_BuiltinType::Char32
@ Char32
llvm::pdb::PDB_UdtType
PDB_UdtType
These values correspond to the UdtKind enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:310
llvm::pdb::PDB_LocType
PDB_LocType
These values correspond to the LocationType enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:292
llvm::pdb::PDB_SymType::BaseInterface
@ BaseInterface
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::pdb::VersionInfo
Definition: PDBTypes.h:387
llvm::pdb::PDB_Machine::PowerPCFP
@ PowerPCFP
llvm::codeview::Link
@ Link
Definition: CodeView.h:154
llvm::ArrayType
Class to represent array types.
Definition: DerivedTypes.h:357
llvm::dwarf::Tag
Tag
Definition: Dwarf.h:105
x86
Note that only the low bits of effective_addr2 are used On bit we don t eliminate the computation of the top half of effective_addr2 because we don t have whole function selection dags On x86
Definition: README.txt:318
llvm::codeview::CPUType::ARMNT
@ ARMNT
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::Bitfield
Holds functions to get, set or test bitfields.
Definition: Bitfields.h:212
llvm::pdb::Double
@ Double
Definition: PDBTypes.h:402
llvm::pdb::PDB_SymType
PDB_SymType
These values correspond to the SymTagEnum enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:243
llvm::pdb::PDB_Machine::SH5
@ SH5
llvm::pdb::PDB_SymType::FuncDebugStart
@ FuncDebugStart
llvm::pdb::PDB_LocType::BitField
@ BitField
llvm::pdb::PDB_Machine::Am33
@ Am33
llvm::codeview::Cvtres
@ Cvtres
Definition: CodeView.h:155
llvm::pdb::PDB_Machine::Ebc
@ Ebc
llvm::pdb::PDB_BuiltinType::Currency
@ Currency
llvm::pdb::PDB_LocType::RegRel
@ RegRel
llvm::pdb::PDB_DataKind::StaticLocal
@ StaticLocal
llvm::SHA1
A class that wrap the SHA1 algorithm.
Definition: SHA1.h:26
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::pdb::PDB_DataKind
PDB_DataKind
These values correspond to the DataKind enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:228
llvm::codeview::Masm
@ Masm
Definition: CodeView.h:150
llvm::pdb::PDB_SymType::FunctionArg
@ FunctionArg
llvm::codeview::CPURegister::Cpu
CPUType Cpu
Definition: CodeView.h:535
Param
Value * Param
Definition: NVPTXLowerArgs.cpp:164
llvm::pdb::PDB_SourceCompression
Definition: PDBTypes.h:154
llvm::pdb::PDB_SymType::UDT
@ UDT
llvm::pdb::UInt32
@ UInt32
Definition: PDBTypes.h:405
llvm::pdb::PDB_SymType::Caller
@ Caller
llvm::pdb::PDB_SymType::CompilandDetails
@ CompilandDetails
llvm::pdb::Int8
@ Int8
Definition: PDBTypes.h:397
llvm::pdb::PDB_Machine::MipsFpu16
@ MipsFpu16
llvm::codeview::CPURegister
Definition: CodeView.h:529
llvm::pdb::PDB_Machine::Arm
@ Arm
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
llvm::pdb::PDB_BuiltinType::BCD
@ BCD
llvm::pdb::PDB_LocType::TLS
@ TLS
llvm::IndexedInstrProf::Version
const uint64_t Version
Definition: InstrProf.h:1027
llvm::pdb::PDB_Machine::Mips16
@ Mips16
llvm::codeview::Java
@ Java
Definition: CodeView.h:160
llvm::None
const NoneType None
Definition: None.h:24
llvm::pdb::PDB_SymType::VTableShape
@ VTableShape
llvm::pdb
Definition: ConcreteSymbolEnumerator.h:20
llvm::pdb::PDB_BuiltinType::Char16
@ Char16
llvm::VectorType
Base class of all SIMD vector types.
Definition: DerivedTypes.h:389
llvm::pdb::PDB_Machine::R4000
@ R4000
llvm::codeview::Fortran
@ Fortran
Definition: CodeView.h:149
llvm::Value::Value
Value(Type *Ty, unsigned scid)
Definition: Value.cpp:49
llvm::pdb::PDB_BuiltinType::Date
@ Date
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::pdb::PDB_Machine::ArmNT
@ ArmNT
llvm::pdb::Unknown
@ Unknown
Definition: PDBTypes.h:396
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
llvm::pdb::PDB_BuiltinType::WCharT
@ WCharT
Generic
@ Generic
Definition: AArch64MCAsmInfo.cpp:23
llvm::MD5
Definition: MD5.h:41
CASE_OUTPUT_ENUM_CLASS_NAME
#define CASE_OUTPUT_ENUM_CLASS_NAME(Class, Value, Stream)
Definition: PDBExtras.cpp:20
llvm::pdb::Int32
@ Int32
Definition: PDBTypes.h:399
llvm::codeview::Cvtpgd
@ Cvtpgd
Definition: CodeView.h:156
llvm::pdb::PDB_LocType::Enregistered
@ Enregistered
llvm::PointerType
Class to represent pointers.
Definition: DerivedTypes.h:632
llvm::pdb::PDB_SymType::VTable
@ VTable
llvm::codeview::ILAsm
@ ILAsm
Definition: CodeView.h:159
llvm::pdb::PDB_VariantType
PDB_VariantType
Definition: PDBTypes.h:394
llvm::pdb::PDB_SymType::Thunk
@ Thunk
llvm::pdb::PDB_SymType::Dimension
@ Dimension
llvm::pdb::PDB_Machine::WceMipsV2
@ WceMipsV2
llvm::pdb::PDB_UdtType::Union
@ Union
llvm::codeview::SourceLanguage
SourceLanguage
These values correspond to the CV_CFL_LANG enumeration, and are documented here: https://msdn....
Definition: CodeView.h:146
llvm::codeview::CPURegister::Reg
RegisterId Reg
Definition: CodeView.h:536
llvm::pdb::PDB_Machine::Amd64
@ Amd64
llvm::pdb::PDB_Machine
PDB_Machine
Definition: PDBTypes.h:125
llvm::pdb::PDB_LocType::MetaData
@ MetaData
llvm::pdb::PDB_SymType::FuncDebugEnd
@ FuncDebugEnd
uint32_t
llvm::pdb::PDB_BuiltinType
PDB_BuiltinType
These values correspond to the Basictype enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:335
llvm::pdb::PDB_SymType::Enum
@ Enum
llvm::pdb::Bool
@ Bool
Definition: PDBTypes.h:407
llvm::pdb::PDB_BuiltinType::Complex
@ Complex
llvm::pdb::TagStats
std::unordered_map< PDB_SymType, int > TagStats
Definition: PDBExtras.h:23
llvm::pdb::Single
@ Single
Definition: PDBTypes.h:401
llvm::pdb::PDB_SymType::HLSLType
@ HLSLType
Callee
amdgpu Simplify well known AMD library false FunctionCallee Callee
Definition: AMDGPULibCalls.cpp:186
llvm::pdb::PDB_DataKind::Local
@ Local
llvm::pdb::PDB_SymType::Annotation
@ Annotation
llvm::pdb::Variant
Definition: PDBTypes.h:411
CASE_OUTPUT_ENUM_CLASS_STR
#define CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, Str, Stream)
Definition: PDBExtras.cpp:15
llvm::pdb::PDB_SymType::Label
@ Label
llvm::pdb::PDB_SymType::CompilandEnv
@ CompilandEnv
llvm::pdb::PDB_SymType::Inlinee
@ Inlinee
Stats
block placement Basic Block Placement Stats
Definition: MachineBlockPlacement.cpp:3656
llvm::pdb::operator<<
raw_ostream & operator<<(LinePrinter &Printer, const T &Item)
Definition: LinePrinter.h:151
llvm::pdb::PDB_Checksum
PDB_Checksum
Specifies the hash algorithm that a source file from a PDB was hashed with.
Definition: PDBTypes.h:119
llvm::pdb::PDB_LocType::Slot
@ Slot
llvm::pdb::PDB_SymType::Compiland
@ Compiland
llvm::pdb::PDB_SymType::ManagedType
@ ManagedType
llvm::pdb::PDB_SymType::CallSite
@ CallSite
llvm::pdb::Int16
@ Int16
Definition: PDBTypes.h:398
llvm::pdb::PDB_LocType::ThisRel
@ ThisRel
llvm::pdb::dumpPDBSourceCompression
raw_ostream & dumpPDBSourceCompression(raw_ostream &OS, uint32_t Compression)
Definition: PDBExtras.cpp:338
llvm::codeview::CSharp
@ CSharp
Definition: CodeView.h:157
llvm::pdb::PDB_Machine::MipsFpu
@ MipsFpu
llvm::codeview::VB
@ VB
Definition: CodeView.h:158
llvm::codeview::Cobol
@ Cobol
Definition: CodeView.h:153
llvm::pdb::PDB_BuiltinType::Long
@ Long
llvm::codeview::ThunkOrdinal
ThunkOrdinal
These values correspond to the THUNK_ORDINAL enumeration.
Definition: CodeView.h:553
llvm::pdb::PDB_MemberAccess
PDB_MemberAccess
Definition: PDBTypes.h:385
llvm::codeview::Cpp
@ Cpp
Definition: CodeView.h:148
llvm::pdb::PDB_SymType::BuiltinType
@ BuiltinType
Machine
COFF::MachineTypes Machine
Definition: COFFYAML.cpp:369
llvm::pdb::PDB_SymType::Typedef
@ Typedef
llvm::pdb::PDB_LocType::RegRelAliasIndir
@ RegRelAliasIndir
llvm::pdb::PDB_SymType::Exe
@ Exe
PDBExtras.h
llvm::codeview::CallingConvention
CallingConvention
These values correspond to the CV_call_e enumeration, and are documented at the following locations: ...
Definition: CodeView.h:178
llvm::pdb::PDB_DataKind::Global
@ Global
llvm::pdb::PDB_DataKind::ObjectPtr
@ ObjectPtr
llvm::pdb::PDB_SymType::PublicSymbol
@ PublicSymbol
llvm::pdb::String
@ String
Definition: PDBTypes.h:408
raw_ostream.h
llvm::pdb::UInt64
@ UInt64
Definition: PDBTypes.h:406
llvm::pdb::UInt8
@ UInt8
Definition: PDBTypes.h:403
llvm::pdb::PDB_SymType::Block
@ Block
llvm::pdb::PDB_BuiltinType::BSTR
@ BSTR
llvm::pdb::PDB_LocType::IlRel
@ IlRel
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::pdb::PDB_SymType::Export
@ Export