File indexing completed on 2026-05-10 08:43:46
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_DEBUGINFO_PDB_PDBTYPES_H
0010 #define LLVM_DEBUGINFO_PDB_PDBTYPES_H
0011
0012 #include "llvm/ADT/APFloat.h"
0013 #include "llvm/DebugInfo/CodeView/CodeView.h"
0014 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
0015 #include "llvm/DebugInfo/PDB/IPDBFrameData.h"
0016 #include "llvm/DebugInfo/PDB/Native/RawTypes.h"
0017 #include <cctype>
0018 #include <cstddef>
0019 #include <cstdint>
0020 #include <cstring>
0021 #include <functional>
0022
0023 namespace llvm {
0024 namespace pdb {
0025
0026 typedef uint32_t SymIndexId;
0027
0028 class IPDBDataStream;
0029 class IPDBInjectedSource;
0030 class IPDBLineNumber;
0031 class IPDBSectionContrib;
0032 class IPDBSession;
0033 class IPDBSourceFile;
0034 class IPDBTable;
0035 class PDBSymDumper;
0036 class PDBSymbol;
0037 class PDBSymbolExe;
0038 class PDBSymbolCompiland;
0039 class PDBSymbolCompilandDetails;
0040 class PDBSymbolCompilandEnv;
0041 class PDBSymbolFunc;
0042 class PDBSymbolBlock;
0043 class PDBSymbolData;
0044 class PDBSymbolAnnotation;
0045 class PDBSymbolLabel;
0046 class PDBSymbolPublicSymbol;
0047 class PDBSymbolTypeUDT;
0048 class PDBSymbolTypeEnum;
0049 class PDBSymbolTypeFunctionSig;
0050 class PDBSymbolTypePointer;
0051 class PDBSymbolTypeArray;
0052 class PDBSymbolTypeBuiltin;
0053 class PDBSymbolTypeTypedef;
0054 class PDBSymbolTypeBaseClass;
0055 class PDBSymbolTypeFriend;
0056 class PDBSymbolTypeFunctionArg;
0057 class PDBSymbolFuncDebugStart;
0058 class PDBSymbolFuncDebugEnd;
0059 class PDBSymbolUsingNamespace;
0060 class PDBSymbolTypeVTableShape;
0061 class PDBSymbolTypeVTable;
0062 class PDBSymbolCustom;
0063 class PDBSymbolThunk;
0064 class PDBSymbolTypeCustom;
0065 class PDBSymbolTypeManaged;
0066 class PDBSymbolTypeDimension;
0067 class PDBSymbolUnknown;
0068
0069 using IPDBEnumSymbols = IPDBEnumChildren<PDBSymbol>;
0070 using IPDBEnumSourceFiles = IPDBEnumChildren<IPDBSourceFile>;
0071 using IPDBEnumDataStreams = IPDBEnumChildren<IPDBDataStream>;
0072 using IPDBEnumLineNumbers = IPDBEnumChildren<IPDBLineNumber>;
0073 using IPDBEnumTables = IPDBEnumChildren<IPDBTable>;
0074 using IPDBEnumInjectedSources = IPDBEnumChildren<IPDBInjectedSource>;
0075 using IPDBEnumSectionContribs = IPDBEnumChildren<IPDBSectionContrib>;
0076 using IPDBEnumFrameData = IPDBEnumChildren<IPDBFrameData>;
0077
0078
0079
0080 enum class PDB_ReaderType {
0081 DIA = 0,
0082 Native = 1,
0083 };
0084
0085
0086 enum class PDB_TableType {
0087 TableInvalid = 0,
0088 Symbols,
0089 SourceFiles,
0090 LineNumbers,
0091 SectionContribs,
0092 Segments,
0093 InjectedSources,
0094 FrameData,
0095 InputAssemblyFiles,
0096 Dbg
0097 };
0098
0099
0100
0101
0102 enum PDB_NameSearchFlags {
0103 NS_Default = 0x0,
0104 NS_CaseSensitive = 0x1,
0105 NS_CaseInsensitive = 0x2,
0106 NS_FileNameExtMatch = 0x4,
0107 NS_Regex = 0x8,
0108 NS_UndecoratedName = 0x10,
0109
0110
0111 NS_CaseInFileNameExt = NS_CaseInsensitive | NS_FileNameExtMatch,
0112 NS_CaseRegex = NS_Regex | NS_CaseSensitive,
0113 NS_CaseInRex = NS_Regex | NS_CaseInsensitive
0114 };
0115
0116
0117
0118
0119 enum class PDB_Checksum { None = 0, MD5 = 1, SHA1 = 2, SHA256 = 3 };
0120
0121
0122
0123 using PDB_Cpu = codeview::CPUType;
0124
0125 enum class PDB_Machine {
0126 Invalid = 0xffff,
0127 Unknown = 0x0,
0128 Am33 = 0x13,
0129 Amd64 = 0x8664,
0130 Arm = 0x1C0,
0131 Arm64 = 0xaa64,
0132 ArmNT = 0x1C4,
0133 Ebc = 0xEBC,
0134 x86 = 0x14C,
0135 Ia64 = 0x200,
0136 M32R = 0x9041,
0137 Mips16 = 0x266,
0138 MipsFpu = 0x366,
0139 MipsFpu16 = 0x466,
0140 PowerPC = 0x1F0,
0141 PowerPCFP = 0x1F1,
0142 R4000 = 0x166,
0143 SH3 = 0x1A2,
0144 SH3DSP = 0x1A3,
0145 SH4 = 0x1A6,
0146 SH5 = 0x1A8,
0147 Thumb = 0x1C2,
0148 WceMipsV2 = 0x169
0149 };
0150
0151
0152
0153
0154 struct PDB_SourceCompression {
0155 enum : uint32_t {
0156
0157 None,
0158
0159 RunLengthEncoded,
0160
0161 Huffman,
0162
0163 LZ,
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212 DotNet = 101,
0213 };
0214 };
0215
0216
0217
0218
0219
0220 using PDB_CallingConv = codeview::CallingConvention;
0221
0222
0223
0224 using PDB_Lang = codeview::SourceLanguage;
0225
0226
0227
0228 enum class PDB_DataKind {
0229 Unknown,
0230 Local,
0231 StaticLocal,
0232 Param,
0233 ObjectPtr,
0234 FileStatic,
0235 Global,
0236 Member,
0237 StaticMember,
0238 Constant
0239 };
0240
0241
0242
0243 enum class PDB_SymType {
0244 None,
0245 Exe,
0246 Compiland,
0247 CompilandDetails,
0248 CompilandEnv,
0249 Function,
0250 Block,
0251 Data,
0252 Annotation,
0253 Label,
0254 PublicSymbol,
0255 UDT,
0256 Enum,
0257 FunctionSig,
0258 PointerType,
0259 ArrayType,
0260 BuiltinType,
0261 Typedef,
0262 BaseClass,
0263 Friend,
0264 FunctionArg,
0265 FuncDebugStart,
0266 FuncDebugEnd,
0267 UsingNamespace,
0268 VTableShape,
0269 VTable,
0270 Custom,
0271 Thunk,
0272 CustomType,
0273 ManagedType,
0274 Dimension,
0275 CallSite,
0276 InlineSite,
0277 BaseInterface,
0278 VectorType,
0279 MatrixType,
0280 HLSLType,
0281 Caller,
0282 Callee,
0283 Export,
0284 HeapAllocationSite,
0285 CoffGroup,
0286 Inlinee,
0287 Max
0288 };
0289
0290
0291
0292 enum class PDB_LocType {
0293 Null,
0294 Static,
0295 TLS,
0296 RegRel,
0297 ThisRel,
0298 Enregistered,
0299 BitField,
0300 Slot,
0301 IlRel,
0302 MetaData,
0303 Constant,
0304 RegRelAliasIndir,
0305 Max
0306 };
0307
0308
0309
0310 enum class PDB_UdtType { Struct, Class, Union, Interface };
0311
0312
0313
0314 enum class PDB_StackFrameType : uint16_t {
0315 FPO,
0316 KernelTrap,
0317 KernelTSS,
0318 EBP,
0319 FrameData,
0320 Unknown = 0xffff
0321 };
0322
0323
0324
0325 enum class PDB_MemoryType : uint16_t {
0326 Code,
0327 Data,
0328 Stack,
0329 HeapCode,
0330 Any = 0xffff
0331 };
0332
0333
0334
0335 enum class PDB_BuiltinType {
0336 None = 0,
0337 Void = 1,
0338 Char = 2,
0339 WCharT = 3,
0340 Int = 6,
0341 UInt = 7,
0342 Float = 8,
0343 BCD = 9,
0344 Bool = 10,
0345 Long = 13,
0346 ULong = 14,
0347 Currency = 25,
0348 Date = 26,
0349 Variant = 27,
0350 Complex = 28,
0351 Bitfield = 29,
0352 BSTR = 30,
0353 HResult = 31,
0354 Char16 = 32,
0355 Char32 = 33,
0356 Char8 = 34,
0357 };
0358
0359
0360
0361
0362 enum PDB_UndnameFlags : uint32_t {
0363 Undname_Complete = 0x0,
0364 Undname_NoLeadingUnderscores = 0x1,
0365 Undname_NoMsKeywords = 0x2,
0366 Undname_NoFuncReturns = 0x4,
0367 Undname_NoAllocModel = 0x8,
0368 Undname_NoAllocLang = 0x10,
0369 Undname_Reserved1 = 0x20,
0370 Undname_Reserved2 = 0x40,
0371 Undname_NoThisType = 0x60,
0372 Undname_NoAccessSpec = 0x80,
0373 Undname_NoThrowSig = 0x100,
0374 Undname_NoMemberType = 0x200,
0375 Undname_NoReturnUDTModel = 0x400,
0376 Undname_32BitDecode = 0x800,
0377 Undname_NameOnly = 0x1000,
0378 Undname_TypeOnly = 0x2000,
0379 Undname_HaveParams = 0x4000,
0380 Undname_NoECSU = 0x8000,
0381 Undname_NoIdentCharCheck = 0x10000,
0382 Undname_NoPTR64 = 0x20000
0383 };
0384
0385 enum class PDB_MemberAccess { Private = 1, Protected = 2, Public = 3 };
0386
0387 struct VersionInfo {
0388 uint32_t Major;
0389 uint32_t Minor;
0390 uint32_t Build;
0391 uint32_t QFE;
0392 };
0393
0394 enum PDB_VariantType {
0395 Empty,
0396 Unknown,
0397 Int8,
0398 Int16,
0399 Int32,
0400 Int64,
0401 Single,
0402 Double,
0403 UInt8,
0404 UInt16,
0405 UInt32,
0406 UInt64,
0407 Bool,
0408 String
0409 };
0410
0411 struct Variant {
0412 Variant() = default;
0413
0414 explicit Variant(bool V) : Type(PDB_VariantType::Bool) { Value.Bool = V; }
0415 explicit Variant(int8_t V) : Type(PDB_VariantType::Int8) { Value.Int8 = V; }
0416 explicit Variant(int16_t V) : Type(PDB_VariantType::Int16) {
0417 Value.Int16 = V;
0418 }
0419 explicit Variant(int32_t V) : Type(PDB_VariantType::Int32) {
0420 Value.Int32 = V;
0421 }
0422 explicit Variant(int64_t V) : Type(PDB_VariantType::Int64) {
0423 Value.Int64 = V;
0424 }
0425 explicit Variant(float V) : Type(PDB_VariantType::Single) {
0426 Value.Single = V;
0427 }
0428 explicit Variant(double V) : Type(PDB_VariantType::Double) {
0429 Value.Double = V;
0430 }
0431 explicit Variant(uint8_t V) : Type(PDB_VariantType::UInt8) {
0432 Value.UInt8 = V;
0433 }
0434 explicit Variant(uint16_t V) : Type(PDB_VariantType::UInt16) {
0435 Value.UInt16 = V;
0436 }
0437 explicit Variant(uint32_t V) : Type(PDB_VariantType::UInt32) {
0438 Value.UInt32 = V;
0439 }
0440 explicit Variant(uint64_t V) : Type(PDB_VariantType::UInt64) {
0441 Value.UInt64 = V;
0442 }
0443
0444 Variant(const Variant &Other) {
0445 *this = Other;
0446 }
0447
0448 ~Variant() {
0449 if (Type == PDB_VariantType::String)
0450 delete[] Value.String;
0451 }
0452
0453 PDB_VariantType Type = PDB_VariantType::Empty;
0454 union {
0455 bool Bool;
0456 int8_t Int8;
0457 int16_t Int16;
0458 int32_t Int32;
0459 int64_t Int64;
0460 float Single;
0461 double Double;
0462 uint8_t UInt8;
0463 uint16_t UInt16;
0464 uint32_t UInt32;
0465 uint64_t UInt64;
0466 char *String;
0467 } Value;
0468
0469 bool isIntegralType() const {
0470 switch (Type) {
0471 case Bool:
0472 case Int8:
0473 case Int16:
0474 case Int32:
0475 case Int64:
0476 case UInt8:
0477 case UInt16:
0478 case UInt32:
0479 case UInt64:
0480 return true;
0481 default:
0482 return false;
0483 }
0484 }
0485
0486 #define VARIANT_WIDTH(Enum, NumBits) \
0487 case PDB_VariantType::Enum: \
0488 return NumBits;
0489
0490 unsigned getBitWidth() const {
0491 switch (Type) {
0492 VARIANT_WIDTH(Bool, 1u)
0493 VARIANT_WIDTH(Int8, 8u)
0494 VARIANT_WIDTH(Int16, 16u)
0495 VARIANT_WIDTH(Int32, 32u)
0496 VARIANT_WIDTH(Int64, 64u)
0497 VARIANT_WIDTH(Single, 32u)
0498 VARIANT_WIDTH(Double, 64u)
0499 VARIANT_WIDTH(UInt8, 8u)
0500 VARIANT_WIDTH(UInt16, 16u)
0501 VARIANT_WIDTH(UInt32, 32u)
0502 VARIANT_WIDTH(UInt64, 64u)
0503 default:
0504 assert(false && "Variant::toAPSInt called on non-numeric type");
0505 return 0u;
0506 }
0507 }
0508
0509 #undef VARIANT_WIDTH
0510
0511 #define VARIANT_APSINT(Enum, NumBits, IsUnsigned) \
0512 case PDB_VariantType::Enum: \
0513 return APSInt(APInt(NumBits, Value.Enum), IsUnsigned);
0514
0515 APSInt toAPSInt() const {
0516 switch (Type) {
0517 VARIANT_APSINT(Bool, 1u, true)
0518 VARIANT_APSINT(Int8, 8u, false)
0519 VARIANT_APSINT(Int16, 16u, false)
0520 VARIANT_APSINT(Int32, 32u, false)
0521 VARIANT_APSINT(Int64, 64u, false)
0522 VARIANT_APSINT(UInt8, 8u, true)
0523 VARIANT_APSINT(UInt16, 16u, true)
0524 VARIANT_APSINT(UInt32, 32u, true)
0525 VARIANT_APSINT(UInt64, 64u, true)
0526 default:
0527 assert(false && "Variant::toAPSInt called on non-integral type");
0528 return APSInt();
0529 }
0530 }
0531
0532 #undef VARIANT_APSINT
0533
0534 APFloat toAPFloat() const {
0535
0536 switch (Type) {
0537 case PDB_VariantType::Single:
0538 case PDB_VariantType::UInt32:
0539 case PDB_VariantType::Int32:
0540 return APFloat(Value.Single);
0541 case PDB_VariantType::Double:
0542 case PDB_VariantType::UInt64:
0543 case PDB_VariantType::Int64:
0544 return APFloat(Value.Double);
0545 default:
0546 assert(false && "Variant::toAPFloat called on non-floating-point type");
0547 return APFloat::getZero(APFloat::IEEEsingle());
0548 }
0549 }
0550
0551 #define VARIANT_EQUAL_CASE(Enum) \
0552 case PDB_VariantType::Enum: \
0553 return Value.Enum == Other.Value.Enum;
0554
0555 bool operator==(const Variant &Other) const {
0556 if (Type != Other.Type)
0557 return false;
0558 switch (Type) {
0559 VARIANT_EQUAL_CASE(Bool)
0560 VARIANT_EQUAL_CASE(Int8)
0561 VARIANT_EQUAL_CASE(Int16)
0562 VARIANT_EQUAL_CASE(Int32)
0563 VARIANT_EQUAL_CASE(Int64)
0564 VARIANT_EQUAL_CASE(Single)
0565 VARIANT_EQUAL_CASE(Double)
0566 VARIANT_EQUAL_CASE(UInt8)
0567 VARIANT_EQUAL_CASE(UInt16)
0568 VARIANT_EQUAL_CASE(UInt32)
0569 VARIANT_EQUAL_CASE(UInt64)
0570 VARIANT_EQUAL_CASE(String)
0571 default:
0572 return true;
0573 }
0574 }
0575
0576 #undef VARIANT_EQUAL_CASE
0577
0578 bool operator!=(const Variant &Other) const { return !(*this == Other); }
0579 Variant &operator=(const Variant &Other) {
0580 if (this == &Other)
0581 return *this;
0582 if (Type == PDB_VariantType::String)
0583 delete[] Value.String;
0584 Type = Other.Type;
0585 Value = Other.Value;
0586 if (Other.Type == PDB_VariantType::String &&
0587 Other.Value.String != nullptr) {
0588 Value.String = new char[strlen(Other.Value.String) + 1];
0589 ::strcpy(Value.String, Other.Value.String);
0590 }
0591 return *this;
0592 }
0593 };
0594
0595 }
0596 }
0597
0598 namespace std {
0599
0600 template <> struct hash<llvm::pdb::PDB_SymType> {
0601 using argument_type = llvm::pdb::PDB_SymType;
0602 using result_type = std::size_t;
0603
0604 result_type operator()(const argument_type &Arg) const {
0605 return std::hash<int>()(static_cast<int>(Arg));
0606 }
0607 };
0608
0609 }
0610
0611 #endif