LLVM 22.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
42
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
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
188
202
213
244
246 switch (Tag) {
289 default:
290 OS << "Unknown SymTag " << uint32_t(Tag);
291 }
292 return OS;
293}
294
304
314
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) {
362 OS << (Value.Value.Bool ? "true" : "false");
363 break;
365 OS << Value.Value.Double;
366 break;
368 OS << Value.Value.Int16;
369 break;
371 OS << Value.Value.Int32;
372 break;
374 OS << Value.Value.Int64;
375 break;
377 OS << static_cast<int>(Value.Value.Int8);
378 break;
380 OS << Value.Value.Single;
381 break;
383 OS << Value.Value.UInt16;
384 break;
386 OS << Value.Value.UInt32;
387 break;
389 OS << Value.Value.UInt64;
390 break;
392 OS << static_cast<unsigned>(Value.Value.UInt8);
393 break;
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")
DXIL Resource Access
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
Function const char TargetMachine * Machine
LLVM Value Representation.
Definition Value.h:75
LLVM_ABI Value(Type *Ty, unsigned scid)
Definition Value.cpp:53
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
@ Swift
Calling convention for Swift.
Definition CallingConv.h:69
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
ThunkOrdinal
These values correspond to the THUNK_ORDINAL enumeration.
Definition CodeView.h:537
PDB_Checksum
Specifies the hash algorithm that a source file from a PDB was hashed with.
Definition PDBTypes.h:119
PDB_BuiltinType
These values correspond to the Basictype enumeration, and are documented here: https://msdn....
Definition PDBTypes.h:335
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_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)
PDB_DataKind
These values correspond to the DataKind enumeration, and are documented here: https://msdn....
Definition PDBTypes.h:228
LLVM_ABI raw_ostream & dumpPDBSourceCompression(raw_ostream &OS, uint32_t Compression)
codeview::SourceLanguage PDB_Lang
These values correspond to the CV_CFL_LANG enumeration, and are documented here: https://msdn....
Definition PDBTypes.h:224
std::unordered_map< PDB_SymType, int > TagStats
Definition PDBExtras.h:24
codeview::CallingConvention PDB_CallingConv
These values correspond to the CV_call_e enumeration, and are documented at the following locations: ...
Definition PDBTypes.h:220
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr uintptr_t uintptr_t Version
Definition InstrProf.h:302