LLVM 22.0.0git
PDBTypes.h
Go to the documentation of this file.
1//===- PDBTypes.h - Defines enums for various fields contained in PDB ----====//
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
9#ifndef LLVM_DEBUGINFO_PDB_PDBTYPES_H
10#define LLVM_DEBUGINFO_PDB_PDBTYPES_H
11
12#include "llvm/ADT/APFloat.h"
17#include <cctype>
18#include <cstddef>
19#include <cstdint>
20#include <cstring>
21#include <functional>
22
23namespace llvm {
24namespace pdb {
25
27
28class IPDBDataStream;
30class IPDBLineNumber;
32class IPDBSession;
33class IPDBSourceFile;
34class IPDBTable;
35class PDBSymDumper;
36class PDBSymbol;
37class PDBSymbolExe;
41class PDBSymbolFunc;
42class PDBSymbolBlock;
43class PDBSymbolData;
45class PDBSymbolLabel;
62class PDBSymbolCustom;
63class PDBSymbolThunk;
68
77
78/// Specifies which PDB reader implementation is to be used. Only a value
79/// of PDB_ReaderType::DIA is currently supported, but Native is in the works.
80enum class PDB_ReaderType {
81 DIA = 0,
82 Native = 1,
83};
84
85/// An enumeration indicating the type of data contained in this table.
98
99/// Defines flags used for enumerating child symbols. This corresponds to the
100/// NameSearchOptions enumeration which is documented here:
101/// https://msdn.microsoft.com/en-us/library/yat28ads.aspx
115
116/// Specifies the hash algorithm that a source file from a PDB was hashed with.
117/// This corresponds to the CV_SourceChksum_t enumeration and are documented
118/// here: https://msdn.microsoft.com/en-us/library/e96az21x.aspx
119enum class PDB_Checksum { None = 0, MD5 = 1, SHA1 = 2, SHA256 = 3 };
120
121/// These values correspond to the CV_CPU_TYPE_e enumeration, and are documented
122/// here: https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
124
125enum class PDB_Machine {
126 Invalid = 0xffff,
127 Unknown = 0x0,
128 Am33 = 0x13,
129 Amd64 = 0x8664,
130 Arm = 0x1C0,
131 Arm64 = 0xaa64,
132 ArmNT = 0x1C4,
133 Ebc = 0xEBC,
134 x86 = 0x14C,
135 Ia64 = 0x200,
136 M32R = 0x9041,
137 Mips16 = 0x266,
138 MipsFpu = 0x366,
139 MipsFpu16 = 0x466,
140 PowerPC = 0x1F0,
141 PowerPCFP = 0x1F1,
142 R4000 = 0x166,
143 SH3 = 0x1A2,
144 SH3DSP = 0x1A3,
145 SH4 = 0x1A6,
146 SH5 = 0x1A8,
147 Thumb = 0x1C2,
148 WceMipsV2 = 0x169
149};
150
151// A struct with an inner unnamed enum with explicit underlying type resuls
152// in an enum class that can implicitly convert to the underlying type, which
153// is convenient for this enum.
155 enum : uint32_t {
156 // No compression. Produced e.g. by `link.exe /natvis:foo.natvis`.
158 // Not known what produces this.
160 // Not known what produces this.
162 // Not known what produces this.
164 // Produced e.g. by `csc /debug`. The encoded data is its own mini-stream
165 // with the following layout (in little endian):
166 // GUID LanguageTypeGuid;
167 // GUID LanguageVendorGuid;
168 // GUID DocumentTypeGuid;
169 // GUID HashFunctionGuid;
170 // uint32_t HashDataSize;
171 // uint32_t CompressedDataSize;
172 // Followed by HashDataSize bytes containing a hash checksum,
173 // followed by CompressedDataSize bytes containing source contents.
174 //
175 // CompressedDataSize can be 0, in this case only the hash data is present.
176 // (CompressedDataSize is != 0 e.g. if `/embed` is passed to csc.exe.)
177 // The compressed data format is:
178 // uint32_t UncompressedDataSize;
179 // If UncompressedDataSize is 0, the data is stored uncompressed and
180 // CompressedDataSize stores the uncompressed size.
181 // If UncompressedDataSize is != 0, then the data is in raw deflate
182 // encoding as described in rfc1951.
183 //
184 // A GUID is 16 bytes, stored in the usual
185 // uint32_t
186 // uint16_t
187 // uint16_t
188 // uint8_t[24]
189 // layout.
190 //
191 // Well-known GUIDs for LanguageTypeGuid are:
192 // 63a08714-fc37-11d2-904c-00c04fa302a1 C
193 // 3a12d0b7-c26c-11d0-b442-00a0244a1dd2 C++
194 // 3f5162f8-07c6-11d3-9053-00c04fa302a1 C#
195 // af046cd1-d0e1-11d2-977c-00a0c9b4d50c Cobol
196 // ab4f38c9-b6e6-43ba-be3b-58080b2ccce3 F#
197 // 3a12d0b4-c26c-11d0-b442-00a0244a1dd2 Java
198 // 3a12d0b6-c26c-11d0-b442-00a0244a1dd2 JScript
199 // af046cd2-d0e1-11d2-977c-00a0c9b4d50c Pascal
200 // 3a12d0b8-c26c-11d0-b442-00a0244a1dd2 Visual Basic
201 //
202 // Well-known GUIDs for LanguageVendorGuid are:
203 // 994b45c4-e6e9-11d2-903f-00c04fa302a1 Microsoft
204 //
205 // Well-known GUIDs for DocumentTypeGuid are:
206 // 5a869d0b-6611-11d3-bd2a-0000f80849bd Text
207 //
208 // Well-known GUIDs for HashFunctionGuid are:
209 // 406ea660-64cf-4c82-b6f0-42d48172a799 MD5 (HashDataSize is 16)
210 // ff1816ec-aa5e-4d10-87f7-6f4963833460 SHA1 (HashDataSize is 20)
211 // 8829d00f-11b8-4213-878b-770e8597ac16 SHA256 (HashDataSize is 32)
212 DotNet = 101,
213 };
214};
215
216/// These values correspond to the CV_call_e enumeration, and are documented
217/// at the following locations:
218/// https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
219/// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680207(v=vs.85).aspx
221
222/// These values correspond to the CV_CFL_LANG enumeration, and are documented
223/// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx
225
226/// These values correspond to the DataKind enumeration, and are documented
227/// here: https://msdn.microsoft.com/en-us/library/b2x2t313.aspx
240
241/// These values correspond to the SymTagEnum enumeration, and are documented
242/// here: https://msdn.microsoft.com/en-us/library/bkedss5f.aspx
289
290/// These values correspond to the LocationType enumeration, and are documented
291/// here: https://msdn.microsoft.com/en-us/library/f57kaez3.aspx
307
308/// These values correspond to the UdtKind enumeration, and are documented
309/// here: https://msdn.microsoft.com/en-us/library/wcstk66t.aspx
311
312/// These values correspond to the StackFrameTypeEnum enumeration, and are
313/// documented here: https://msdn.microsoft.com/en-us/library/bc5207xw.aspx.
322
323/// These values correspond to the MemoryTypeEnum enumeration, and are
324/// documented here: https://msdn.microsoft.com/en-us/library/ms165609.aspx.
332
333/// These values correspond to the Basictype enumeration, and are documented
334/// here: https://msdn.microsoft.com/en-us/library/4szdtzc3.aspx
335enum class PDB_BuiltinType {
336 None = 0,
337 Void = 1,
338 Char = 2,
340 Int = 6,
341 UInt = 7,
342 Float = 8,
343 BCD = 9,
344 Bool = 10,
345 Long = 13,
346 ULong = 14,
348 Date = 26,
352 BSTR = 30,
354 Char16 = 32,
355 Char32 = 33,
356 Char8 = 34,
357};
358
359/// These values correspond to the flags that can be combined to control the
360/// return of an undecorated name for a C++ decorated name, and are documented
361/// here: https://msdn.microsoft.com/en-us/library/kszfk0fs.aspx
384
385enum class PDB_MemberAccess { Private = 1, Protected = 2, Public = 3 };
386
393
410
411struct Variant {
412 Variant() = default;
413
414 explicit Variant(bool V) : Type(PDB_VariantType::Bool) { Value.Bool = V; }
415 explicit Variant(int8_t V) : Type(PDB_VariantType::Int8) { Value.Int8 = V; }
416 explicit Variant(int16_t V) : Type(PDB_VariantType::Int16) {
417 Value.Int16 = V;
418 }
419 explicit Variant(int32_t V) : Type(PDB_VariantType::Int32) {
420 Value.Int32 = V;
421 }
422 explicit Variant(int64_t V) : Type(PDB_VariantType::Int64) {
423 Value.Int64 = V;
424 }
425 explicit Variant(float V) : Type(PDB_VariantType::Single) {
426 Value.Single = V;
427 }
428 explicit Variant(double V) : Type(PDB_VariantType::Double) {
429 Value.Double = V;
430 }
432 Value.UInt8 = V;
433 }
435 Value.UInt16 = V;
436 }
438 Value.UInt32 = V;
439 }
441 Value.UInt64 = V;
442 }
443
445 *this = Other;
446 }
447
450 delete[] Value.String;
451 }
452
454 union {
455 bool Bool;
456 int8_t Int8;
457 int16_t Int16;
458 int32_t Int32;
459 int64_t Int64;
460 float Single;
461 double Double;
466 char *String;
468
469 bool isIntegralType() const {
470 switch (Type) {
471 case Bool:
472 case Int8:
473 case Int16:
474 case Int32:
475 case Int64:
476 case UInt8:
477 case UInt16:
478 case UInt32:
479 case UInt64:
480 return true;
481 default:
482 return false;
483 }
484 }
485
486#define VARIANT_WIDTH(Enum, NumBits) \
487 case PDB_VariantType::Enum: \
488 return NumBits;
489
490 unsigned getBitWidth() const {
491 switch (Type) {
494 VARIANT_WIDTH(Int16, 16u)
495 VARIANT_WIDTH(Int32, 32u)
496 VARIANT_WIDTH(Int64, 64u)
503 default:
504 assert(false && "Variant::toAPSInt called on non-numeric type");
505 return 0u;
506 }
507 }
508
509#undef VARIANT_WIDTH
510
511#define VARIANT_APSINT(Enum, NumBits, IsUnsigned) \
512 case PDB_VariantType::Enum: \
513 return APSInt( \
514 APInt(NumBits, static_cast<uint64_t>(Value.Enum), !IsUnsigned), \
515 IsUnsigned);
516
517 APSInt toAPSInt() const {
518 switch (Type) {
519 VARIANT_APSINT(Bool, 1u, true)
520 VARIANT_APSINT(Int8, 8u, false)
521 VARIANT_APSINT(Int16, 16u, false)
522 VARIANT_APSINT(Int32, 32u, false)
523 VARIANT_APSINT(Int64, 64u, false)
524 VARIANT_APSINT(UInt8, 8u, true)
525 VARIANT_APSINT(UInt16, 16u, true)
526 VARIANT_APSINT(UInt32, 32u, true)
527 VARIANT_APSINT(UInt64, 64u, true)
528 default:
529 assert(false && "Variant::toAPSInt called on non-integral type");
530 return APSInt();
531 }
532 }
533
534#undef VARIANT_APSINT
535
537 // Float constants may be tagged as integers.
538 switch (Type) {
542 return APFloat(Value.Single);
546 return APFloat(Value.Double);
547 default:
548 assert(false && "Variant::toAPFloat called on non-floating-point type");
550 }
551 }
552
553#define VARIANT_EQUAL_CASE(Enum) \
554 case PDB_VariantType::Enum: \
555 return Value.Enum == Other.Value.Enum;
556
577
578#undef VARIANT_EQUAL_CASE
579
580 bool operator!=(const Variant &Other) const { return !(*this == Other); }
582 if (this == &Other)
583 return *this;
585 delete[] Value.String;
586 Type = Other.Type;
587 Value = Other.Value;
588 if (Other.Type == PDB_VariantType::String &&
589 Other.Value.String != nullptr) {
590 Value.String = new char[strlen(Other.Value.String) + 1];
591 ::strcpy(Value.String, Other.Value.String);
592 }
593 return *this;
594 }
595};
596
597} // end namespace pdb
598} // end namespace llvm
599
600namespace std {
601
602template <> struct hash<llvm::pdb::PDB_SymType> {
604 using result_type = std::size_t;
605
607 return std::hash<int>()(static_cast<int>(Arg));
608 }
609};
610
611} // end namespace std
612
613#endif // LLVM_DEBUGINFO_PDB_PDBTYPES_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file declares a class to represent arbitrary precision floating point values and provide a varie...
#define VARIANT_APSINT(Enum, NumBits, IsUnsigned)
Definition PDBTypes.h:511
#define VARIANT_WIDTH(Enum, NumBits)
Definition PDBTypes.h:486
#define VARIANT_EQUAL_CASE(Enum)
Definition PDBTypes.h:553
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
Definition APFloat.h:1079
An arbitrary precision integer that knows its signedness.
Definition APSInt.h:24
LLVM Value Representation.
Definition Value.h:75
IPDBDataStream defines an interface used to represent a stream consisting of a name and a series of r...
IPDBInjectedSource defines an interface used to represent source files which were injected directly i...
IPDBSectionContrib defines an interface used to represent section contributions whose information are...
IPDBSession defines an interface used to provide a context for querying debug information from a debu...
Definition IPDBSession.h:26
IPDBSourceFile defines an interface used to represent source files whose information are stored in th...
PDBSymbolCustom represents symbols that are compiler-specific and do not fit anywhere else in the lex...
PDBSymbol defines the base of the inheritance hierarchy for concrete symbol types (e....
Definition PDBSymbol.h:72
CPUType
These values correspond to the CV_CPU_TYPE_e enumeration, and are documented here: https://msdn....
Definition CodeView.h:77
CallingConvention
These values correspond to the CV_call_e enumeration, and are documented at the following locations: ...
Definition CodeView.h:157
SourceLanguage
These values correspond to the CV_CFL_LANG enumeration in the Microsoft Debug Interface Access SDK,...
Definition CodeView.h:147
PDB_Checksum
Specifies the hash algorithm that a source file from a PDB was hashed with.
Definition PDBTypes.h:119
PDB_MemoryType
These values correspond to the MemoryTypeEnum enumeration, and are documented here: https://msdn....
Definition PDBTypes.h:325
uint32_t SymIndexId
Definition PDBTypes.h:26
PDB_NameSearchFlags
Defines flags used for enumerating child symbols.
Definition PDBTypes.h:102
@ NS_CaseRegex
Definition PDBTypes.h:112
@ NS_CaseInFileNameExt
Definition PDBTypes.h:111
@ NS_UndecoratedName
Definition PDBTypes.h:108
@ NS_CaseInsensitive
Definition PDBTypes.h:105
@ NS_CaseSensitive
Definition PDBTypes.h:104
@ NS_CaseInRex
Definition PDBTypes.h:113
@ NS_FileNameExtMatch
Definition PDBTypes.h:106
IPDBEnumChildren< IPDBLineNumber > IPDBEnumLineNumbers
Definition PDBTypes.h:72
PDB_TableType
An enumeration indicating the type of data contained in this table.
Definition PDBTypes.h:86
PDB_BuiltinType
These values correspond to the Basictype enumeration, and are documented here: https://msdn....
Definition PDBTypes.h:335
IPDBEnumChildren< IPDBInjectedSource > IPDBEnumInjectedSources
Definition PDBTypes.h:74
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
IPDBEnumChildren< IPDBDataStream > IPDBEnumDataStreams
Definition PDBTypes.h:71
IPDBEnumChildren< IPDBSectionContrib > IPDBEnumSectionContribs
Definition PDBTypes.h:75
PDB_LocType
These values correspond to the LocationType enumeration, and are documented here: https://msdn....
Definition PDBTypes.h:292
PDB_DataKind
These values correspond to the DataKind enumeration, and are documented here: https://msdn....
Definition PDBTypes.h:228
PDB_ReaderType
Specifies which PDB reader implementation is to be used.
Definition PDBTypes.h:80
IPDBEnumChildren< PDBSymbol > IPDBEnumSymbols
Definition PDBTypes.h:69
IPDBEnumChildren< IPDBTable > IPDBEnumTables
Definition PDBTypes.h:73
PDB_UndnameFlags
These values correspond to the flags that can be combined to control the return of an undecorated nam...
Definition PDBTypes.h:362
@ Undname_NameOnly
Definition PDBTypes.h:377
@ Undname_NoECSU
Definition PDBTypes.h:380
@ Undname_NoAccessSpec
Definition PDBTypes.h:372
@ Undname_NoAllocModel
Definition PDBTypes.h:367
@ Undname_NoMsKeywords
Definition PDBTypes.h:365
@ Undname_NoFuncReturns
Definition PDBTypes.h:366
@ Undname_NoMemberType
Definition PDBTypes.h:374
@ Undname_NoAllocLang
Definition PDBTypes.h:368
@ Undname_Reserved2
Definition PDBTypes.h:370
@ Undname_NoPTR64
Definition PDBTypes.h:382
@ Undname_HaveParams
Definition PDBTypes.h:379
@ Undname_NoIdentCharCheck
Definition PDBTypes.h:381
@ Undname_32BitDecode
Definition PDBTypes.h:376
@ Undname_Complete
Definition PDBTypes.h:363
@ Undname_NoLeadingUnderscores
Definition PDBTypes.h:364
@ Undname_NoThrowSig
Definition PDBTypes.h:373
@ Undname_NoThisType
Definition PDBTypes.h:371
@ Undname_TypeOnly
Definition PDBTypes.h:378
@ Undname_Reserved1
Definition PDBTypes.h:369
@ Undname_NoReturnUDTModel
Definition PDBTypes.h:375
IPDBEnumChildren< IPDBFrameData > IPDBEnumFrameData
Definition PDBTypes.h:76
codeview::CPUType PDB_Cpu
These values correspond to the CV_CPU_TYPE_e enumeration, and are documented here: https://msdn....
Definition PDBTypes.h:123
codeview::SourceLanguage PDB_Lang
These values correspond to the CV_CFL_LANG enumeration, and are documented here: https://msdn....
Definition PDBTypes.h:224
IPDBEnumChildren< IPDBSourceFile > IPDBEnumSourceFiles
Definition PDBTypes.h:70
PDB_StackFrameType
These values correspond to the StackFrameTypeEnum enumeration, and are documented here: https://msdn....
Definition PDBTypes.h:314
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.
@ Other
Any other memory.
Definition ModRef.h:68
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:851
static LLVM_ABI const fltSemantics & IEEEsingle() LLVM_READNONE
Definition APFloat.cpp:266
bool operator==(const Variant &Other) const
Definition PDBTypes.h:557
Variant(uint32_t V)
Definition PDBTypes.h:437
bool isIntegralType() const
Definition PDBTypes.h:469
Variant(int16_t V)
Definition PDBTypes.h:416
Variant(int8_t V)
Definition PDBTypes.h:415
PDB_VariantType Type
Definition PDBTypes.h:453
APFloat toAPFloat() const
Definition PDBTypes.h:536
Variant & operator=(const Variant &Other)
Definition PDBTypes.h:581
Variant(uint64_t V)
Definition PDBTypes.h:440
Variant(int32_t V)
Definition PDBTypes.h:419
Variant(double V)
Definition PDBTypes.h:428
Variant(int64_t V)
Definition PDBTypes.h:422
APSInt toAPSInt() const
Definition PDBTypes.h:517
unsigned getBitWidth() const
Definition PDBTypes.h:490
bool operator!=(const Variant &Other) const
Definition PDBTypes.h:580
Variant(const Variant &Other)
Definition PDBTypes.h:444
Variant(uint8_t V)
Definition PDBTypes.h:431
Variant(uint16_t V)
Definition PDBTypes.h:434
union llvm::pdb::Variant::@200246275201367176165230176113371323105013167275 Value
result_type operator()(const argument_type &Arg) const
Definition PDBTypes.h:606
llvm::pdb::PDB_SymType argument_type
Definition PDBTypes.h:603