LLVM 17.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
12using namespace llvm;
13using 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) {
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) {
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) {
181 "regrelaliasindir", OS)
182 default:
183 OS << "Unknown";
184 }
185 return OS;
186}
187
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) {
236 CASE_OUTPUT_ENUM_CLASS_STR(PDB_Lang, ObjCpp, "ObjC++", OS)
237 }
238 return OS;
239}
240
242 switch (Tag) {
285 default:
286 OS << "Unknown SymTag " << uint32_t(Tag);
287 }
288 return OS;
289}
290
292 const PDB_MemberAccess &Access) {
293 switch (Access) {
297 }
298 return OS;
299}
300
302 switch (Type) {
307 }
308 return OS;
309}
310
312 const PDB_Machine &Machine) {
313 switch (Machine) {
334 default:
335 OS << "Unknown";
336 }
337 return OS;
338}
339
341 uint32_t Compression) {
342 switch (Compression) {
346 CASE_OUTPUT_ENUM_CLASS_STR(PDB_SourceCompression, RunLengthEncoded, "RLE",
347 OS)
349 default:
350 OS << "Unknown (" << Compression << ")";
351 }
352 return OS;
353}
354
356 switch (Value.Type) {
357 case PDB_VariantType::Bool:
358 OS << (Value.Value.Bool ? "true" : "false");
359 break;
360 case PDB_VariantType::Double:
361 OS << Value.Value.Double;
362 break;
363 case PDB_VariantType::Int16:
364 OS << Value.Value.Int16;
365 break;
366 case PDB_VariantType::Int32:
367 OS << Value.Value.Int32;
368 break;
369 case PDB_VariantType::Int64:
370 OS << Value.Value.Int64;
371 break;
372 case PDB_VariantType::Int8:
373 OS << static_cast<int>(Value.Value.Int8);
374 break;
375 case PDB_VariantType::Single:
376 OS << Value.Value.Single;
377 break;
378 case PDB_VariantType::UInt16:
379 OS << Value.Value.UInt16;
380 break;
381 case PDB_VariantType::UInt32:
382 OS << Value.Value.UInt32;
383 break;
384 case PDB_VariantType::UInt64:
385 OS << Value.Value.UInt64;
386 break;
387 case PDB_VariantType::UInt8:
388 OS << static_cast<unsigned>(Value.Value.UInt8);
389 break;
390 case PDB_VariantType::String:
391 OS << Value.Value.String;
392 break;
393 default:
394 OS << Value.Type;
395 }
396 return OS;
397}
398
400 const VersionInfo &Version) {
401 OS << Version.Major << "." << Version.Minor << "." << Version.Build;
402 return OS;
403}
404
406 for (auto Tag : Stats) {
407 OS << Tag.first << ":" << Tag.second << " ";
408 }
409 return OS;
410}
@ Generic
amdgpu Simplify well known AMD library false FunctionCallee Callee
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
block placement Basic Block Placement Stats
#define CASE_OUTPUT_ENUM_CLASS_NAME(Class, Value, Stream)
Definition: PDBExtras.cpp:20
#define CASE_OUTPUT_ENUM_CLASS_STR(Class, Value, Str, Stream)
Definition: PDBExtras.cpp:15
raw_pwrite_stream & OS
@ Struct
Class to represent array types.
Definition: DerivedTypes.h:368
This is an important base class in LLVM.
Definition: Constant.h:41
Definition: MD5.h:41
Class to represent pointers.
Definition: DerivedTypes.h:643
A class that wrap the SHA1 algorithm.
Definition: SHA1.h:26
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
LLVM Value Representation.
Definition: Value.h:74
Value(Type *Ty, unsigned scid)
Definition: Value.cpp:53
Base class of all SIMD vector types.
Definition: DerivedTypes.h:400
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
@ Swift
Calling convention for Swift.
Definition: CallingConv.h:69
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
CallingConvention
These values correspond to the CV_call_e enumeration, and are documented at the following locations: ...
Definition: CodeView.h:177
ThunkOrdinal
These values correspond to the THUNK_ORDINAL enumeration.
Definition: CodeView.h:555
SourceLanguage
These values correspond to the CV_CFL_LANG enumeration in the Microsoft Debug Interface Access SDK.
Definition: CodeView.h:143
PDB_Checksum
Specifies the hash algorithm that a source file from a PDB was hashed with.
Definition: PDBTypes.h:119
std::unordered_map< PDB_SymType, int > TagStats
Definition: PDBExtras.h:23
PDB_BuiltinType
These values correspond to the Basictype enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:335
PDB_MemberAccess
Definition: PDBTypes.h:385
PDB_UdtType
These values correspond to the UdtKind enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:310
PDB_SymType
These values correspond to the SymTagEnum enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:243
PDB_VariantType
Definition: PDBTypes.h:394
PDB_LocType
These values correspond to the LocationType enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:292
raw_ostream & operator<<(LinePrinter &Printer, const T &Item)
Definition: LinePrinter.h:151
PDB_DataKind
These values correspond to the DataKind enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:228
raw_ostream & dumpPDBSourceCompression(raw_ostream &OS, uint32_t Compression)
Definition: PDBExtras.cpp:340
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::tuple< uint64_t, uint32_t > InlineSite
Definition: MCPseudoProbe.h:99
constexpr std::nullopt_t None
Definition: None.h:28
Holds functions to get, set or test bitfields.
Definition: Bitfields.h:212