LLVM 19.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)
100 }
101 return OS;
102}
103
105 switch (Data) {
116 }
117 return OS;
118}
119
121 const llvm::codeview::CPURegister &CpuReg) {
122 if (CpuReg.Cpu == llvm::codeview::CPUType::ARMNT) {
123 switch (CpuReg.Reg) {
124#define CV_REGISTERS_ARM
125#define CV_REGISTER(name, val) \
126 case codeview::RegisterId::name: \
127 OS << #name; \
128 return OS;
129#include "llvm/DebugInfo/CodeView/CodeViewRegisters.def"
130#undef CV_REGISTER
131#undef CV_REGISTERS_ARM
132
133 default:
134 break;
135 }
136 } else if (CpuReg.Cpu == llvm::codeview::CPUType::ARM64) {
137 switch (CpuReg.Reg) {
138#define CV_REGISTERS_ARM64
139#define CV_REGISTER(name, val) \
140 case codeview::RegisterId::name: \
141 OS << #name; \
142 return OS;
143#include "llvm/DebugInfo/CodeView/CodeViewRegisters.def"
144#undef CV_REGISTER
145#undef CV_REGISTERS_ARM64
146
147 default:
148 break;
149 }
150 } else {
151 switch (CpuReg.Reg) {
152#define CV_REGISTERS_X86
153#define CV_REGISTER(name, val) \
154 case codeview::RegisterId::name: \
155 OS << #name; \
156 return OS;
157#include "llvm/DebugInfo/CodeView/CodeViewRegisters.def"
158#undef CV_REGISTER
159#undef CV_REGISTERS_X86
160
161 default:
162 break;
163 }
164 }
165 OS << static_cast<int>(CpuReg.Reg);
166 return OS;
167}
168
170 switch (Loc) {
182 "regrelaliasindir", OS)
183 default:
184 OS << "Unknown";
185 }
186 return OS;
187}
188
191 switch (Thunk) {
199 }
200 return OS;
201}
202
204 const PDB_Checksum &Checksum) {
205 switch (Checksum) {
210 }
211 return OS;
212}
213
215 switch (Lang) {
237 CASE_OUTPUT_ENUM_CLASS_STR(PDB_Lang, ObjCpp, "ObjC++", OS)
240 CASE_OUTPUT_ENUM_CLASS_STR(PDB_Lang, OldSwift, "Swift", OS)
241 }
242 return OS;
243}
244
246 switch (Tag) {
289 default:
290 OS << "Unknown SymTag " << uint32_t(Tag);
291 }
292 return OS;
293}
294
296 const PDB_MemberAccess &Access) {
297 switch (Access) {
301 }
302 return OS;
303}
304
306 switch (Type) {
311 }
312 return OS;
313}
314
316 const PDB_Machine &Machine) {
317 switch (Machine) {
338 default:
339 OS << "Unknown";
340 }
341 return OS;
342}
343
345 uint32_t Compression) {
346 switch (Compression) {
350 CASE_OUTPUT_ENUM_CLASS_STR(PDB_SourceCompression, RunLengthEncoded, "RLE",
351 OS)
353 default:
354 OS << "Unknown (" << Compression << ")";
355 }
356 return OS;
357}
358
360 switch (Value.Type) {
361 case PDB_VariantType::Bool:
362 OS << (Value.Value.Bool ? "true" : "false");
363 break;
364 case PDB_VariantType::Double:
365 OS << Value.Value.Double;
366 break;
367 case PDB_VariantType::Int16:
368 OS << Value.Value.Int16;
369 break;
370 case PDB_VariantType::Int32:
371 OS << Value.Value.Int32;
372 break;
373 case PDB_VariantType::Int64:
374 OS << Value.Value.Int64;
375 break;
376 case PDB_VariantType::Int8:
377 OS << static_cast<int>(Value.Value.Int8);
378 break;
379 case PDB_VariantType::Single:
380 OS << Value.Value.Single;
381 break;
382 case PDB_VariantType::UInt16:
383 OS << Value.Value.UInt16;
384 break;
385 case PDB_VariantType::UInt32:
386 OS << Value.Value.UInt32;
387 break;
388 case PDB_VariantType::UInt64:
389 OS << Value.Value.UInt64;
390 break;
391 case PDB_VariantType::UInt8:
392 OS << static_cast<unsigned>(Value.Value.UInt8);
393 break;
394 case PDB_VariantType::String:
395 OS << Value.Value.String;
396 break;
397 default:
398 OS << Value.Type;
399 }
400 return OS;
401}
402
404 const VersionInfo &Version) {
405 OS << Version.Major << "." << Version.Minor << "." << Version.Build;
406 return OS;
407}
408
410 for (auto Tag : Stats) {
411 OS << Tag.first << ":" << Tag.second << " ";
412 }
413 return OS;
414}
@ Generic
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
COFF::MachineTypes Machine
Definition: COFFYAML.cpp:371
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
@ None
Class to represent array types.
Definition: DerivedTypes.h:371
This is an important base class in LLVM.
Definition: Constant.h:41
Definition: MD5.h:41
Class to represent pointers.
Definition: DerivedTypes.h:646
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:403
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:184
ThunkOrdinal
These values correspond to the THUNK_ORDINAL enumeration.
Definition: CodeView.h:563
SourceLanguage
These values correspond to the CV_CFL_LANG enumeration in the Microsoft Debug Interface Access SDK,...
Definition: CodeView.h:146
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:344
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
Holds functions to get, set or test bitfields.
Definition: Bitfields.h:212