LLVM 24.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 Arm64EC = 0xa641,
133 Arm64X = 0xa64e,
134 ArmNT = 0x1C4,
135 Ebc = 0xEBC,
136 x86 = 0x14C,
137 Ia64 = 0x200,
138 M32R = 0x9041,
139 Mips16 = 0x266,
140 MipsFpu = 0x366,
141 MipsFpu16 = 0x466,
142 PowerPC = 0x1F0,
143 PowerPCFP = 0x1F1,
144 R4000 = 0x166,
145 SH3 = 0x1A2,
146 SH3DSP = 0x1A3,
147 SH4 = 0x1A6,
148 SH5 = 0x1A8,
149 Thumb = 0x1C2,
150 WceMipsV2 = 0x169
151};
152
153// A struct with an inner unnamed enum with explicit underlying type resuls
154// in an enum class that can implicitly convert to the underlying type, which
155// is convenient for this enum.
157 enum : uint32_t {
158 // No compression. Produced e.g. by `link.exe /natvis:foo.natvis`.
160 // Not known what produces this.
162 // Not known what produces this.
164 // Not known what produces this.
166 // Produced e.g. by `csc /debug`. The encoded data is its own mini-stream
167 // with the following layout (in little endian):
168 // GUID LanguageTypeGuid;
169 // GUID LanguageVendorGuid;
170 // GUID DocumentTypeGuid;
171 // GUID HashFunctionGuid;
172 // uint32_t HashDataSize;
173 // uint32_t CompressedDataSize;
174 // Followed by HashDataSize bytes containing a hash checksum,
175 // followed by CompressedDataSize bytes containing source contents.
176 //
177 // CompressedDataSize can be 0, in this case only the hash data is present.
178 // (CompressedDataSize is != 0 e.g. if `/embed` is passed to csc.exe.)
179 // The compressed data format is:
180 // uint32_t UncompressedDataSize;
181 // If UncompressedDataSize is 0, the data is stored uncompressed and
182 // CompressedDataSize stores the uncompressed size.
183 // If UncompressedDataSize is != 0, then the data is in raw deflate
184 // encoding as described in rfc1951.
185 //
186 // A GUID is 16 bytes, stored in the usual
187 // uint32_t
188 // uint16_t
189 // uint16_t
190 // uint8_t[24]
191 // layout.
192 //
193 // Well-known GUIDs for LanguageTypeGuid are:
194 // 63a08714-fc37-11d2-904c-00c04fa302a1 C
195 // 3a12d0b7-c26c-11d0-b442-00a0244a1dd2 C++
196 // 3f5162f8-07c6-11d3-9053-00c04fa302a1 C#
197 // af046cd1-d0e1-11d2-977c-00a0c9b4d50c Cobol
198 // ab4f38c9-b6e6-43ba-be3b-58080b2ccce3 F#
199 // 3a12d0b4-c26c-11d0-b442-00a0244a1dd2 Java
200 // 3a12d0b6-c26c-11d0-b442-00a0244a1dd2 JScript
201 // af046cd2-d0e1-11d2-977c-00a0c9b4d50c Pascal
202 // 3a12d0b8-c26c-11d0-b442-00a0244a1dd2 Visual Basic
203 //
204 // Well-known GUIDs for LanguageVendorGuid are:
205 // 994b45c4-e6e9-11d2-903f-00c04fa302a1 Microsoft
206 //
207 // Well-known GUIDs for DocumentTypeGuid are:
208 // 5a869d0b-6611-11d3-bd2a-0000f80849bd Text
209 //
210 // Well-known GUIDs for HashFunctionGuid are:
211 // 406ea660-64cf-4c82-b6f0-42d48172a799 MD5 (HashDataSize is 16)
212 // ff1816ec-aa5e-4d10-87f7-6f4963833460 SHA1 (HashDataSize is 20)
213 // 8829d00f-11b8-4213-878b-770e8597ac16 SHA256 (HashDataSize is 32)
214 DotNet = 101,
215 };
216};
217
218/// These values correspond to the CV_call_e enumeration, and are documented
219/// at the following locations:
220/// https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
221/// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680207(v=vs.85).aspx
223
224/// These values correspond to the CV_CFL_LANG enumeration, and are documented
225/// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx
227
228/// These values correspond to the DataKind enumeration, and are documented
229/// here: https://msdn.microsoft.com/en-us/library/b2x2t313.aspx
242
243/// These values correspond to the SymTagEnum enumeration, and are documented
244/// here: https://msdn.microsoft.com/en-us/library/bkedss5f.aspx
291
292/// These values correspond to the LocationType enumeration, and are documented
293/// here: https://msdn.microsoft.com/en-us/library/f57kaez3.aspx
309
310/// These values correspond to the UdtKind enumeration, and are documented
311/// here: https://msdn.microsoft.com/en-us/library/wcstk66t.aspx
313
314/// These values correspond to the StackFrameTypeEnum enumeration, and are
315/// documented here: https://msdn.microsoft.com/en-us/library/bc5207xw.aspx.
324
325/// These values correspond to the MemoryTypeEnum enumeration, and are
326/// documented here: https://msdn.microsoft.com/en-us/library/ms165609.aspx.
334
335/// These values correspond to the Basictype enumeration, and are documented
336/// here: https://msdn.microsoft.com/en-us/library/4szdtzc3.aspx
337enum class PDB_BuiltinType {
338 None = 0,
339 Void = 1,
340 Char = 2,
342 Int = 6,
343 UInt = 7,
344 Float = 8,
345 BCD = 9,
346 Bool = 10,
347 Long = 13,
348 ULong = 14,
350 Date = 26,
354 BSTR = 30,
356 Char16 = 32,
357 Char32 = 33,
358 Char8 = 34,
359};
360
361/// These values correspond to the flags that can be combined to control the
362/// return of an undecorated name for a C++ decorated name, and are documented
363/// here: https://msdn.microsoft.com/en-us/library/kszfk0fs.aspx
386
387enum class PDB_MemberAccess { Private = 1, Protected = 2, Public = 3 };
388
395
412
413struct Variant {
414 Variant() = default;
415
416 explicit Variant(bool V) : Type(PDB_VariantType::Bool) { Value.Bool = V; }
417 explicit Variant(int8_t V) : Type(PDB_VariantType::Int8) { Value.Int8 = V; }
418 explicit Variant(int16_t V) : Type(PDB_VariantType::Int16) {
419 Value.Int16 = V;
420 }
421 explicit Variant(int32_t V) : Type(PDB_VariantType::Int32) {
422 Value.Int32 = V;
423 }
424 explicit Variant(int64_t V) : Type(PDB_VariantType::Int64) {
425 Value.Int64 = V;
426 }
427 explicit Variant(float V) : Type(PDB_VariantType::Single) {
428 Value.Single = V;
429 }
430 explicit Variant(double V) : Type(PDB_VariantType::Double) {
431 Value.Double = V;
432 }
434 Value.UInt8 = V;
435 }
437 Value.UInt16 = V;
438 }
440 Value.UInt32 = V;
441 }
443 Value.UInt64 = V;
444 }
445
447 *this = Other;
448 }
449
452 delete[] Value.String;
453 }
454
456 union {
457 bool Bool;
458 int8_t Int8;
459 int16_t Int16;
460 int32_t Int32;
461 int64_t Int64;
462 float Single;
463 double Double;
468 char *String;
470
471 bool isIntegralType() const {
472 switch (Type) {
473 case Bool:
474 case Int8:
475 case Int16:
476 case Int32:
477 case Int64:
478 case UInt8:
479 case UInt16:
480 case UInt32:
481 case UInt64:
482 return true;
483 default:
484 return false;
485 }
486 }
487
488#define VARIANT_WIDTH(Enum, NumBits) \
489 case PDB_VariantType::Enum: \
490 return NumBits;
491
492 unsigned getBitWidth() const {
493 switch (Type) {
496 VARIANT_WIDTH(Int16, 16u)
497 VARIANT_WIDTH(Int32, 32u)
498 VARIANT_WIDTH(Int64, 64u)
505 default:
506 assert(false && "Variant::toAPSInt called on non-numeric type");
507 return 0u;
508 }
509 }
510
511#undef VARIANT_WIDTH
512
513#define VARIANT_APSINT(Enum, NumBits, IsUnsigned) \
514 case PDB_VariantType::Enum: \
515 return APSInt( \
516 APInt(NumBits, static_cast<uint64_t>(Value.Enum), !IsUnsigned), \
517 IsUnsigned);
518
519 APSInt toAPSInt() const {
520 switch (Type) {
521 VARIANT_APSINT(Bool, 1u, true)
522 VARIANT_APSINT(Int8, 8u, false)
523 VARIANT_APSINT(Int16, 16u, false)
524 VARIANT_APSINT(Int32, 32u, false)
525 VARIANT_APSINT(Int64, 64u, false)
526 VARIANT_APSINT(UInt8, 8u, true)
527 VARIANT_APSINT(UInt16, 16u, true)
528 VARIANT_APSINT(UInt32, 32u, true)
529 VARIANT_APSINT(UInt64, 64u, true)
530 default:
531 assert(false && "Variant::toAPSInt called on non-integral type");
532 return APSInt();
533 }
534 }
535
536#undef VARIANT_APSINT
537
539 // Float constants may be tagged as integers.
540 switch (Type) {
544 return APFloat(Value.Single);
548 return APFloat(Value.Double);
549 default:
550 assert(false && "Variant::toAPFloat called on non-floating-point type");
552 }
553 }
554
555#define VARIANT_EQUAL_CASE(Enum) \
556 case PDB_VariantType::Enum: \
557 return Value.Enum == Other.Value.Enum;
558
579
580#undef VARIANT_EQUAL_CASE
581
582 bool operator!=(const Variant &Other) const { return !(*this == Other); }
584 if (this == &Other)
585 return *this;
587 delete[] Value.String;
588 Type = Other.Type;
589 Value = Other.Value;
590 if (Other.Type == PDB_VariantType::String &&
591 Other.Value.String != nullptr) {
592 Value.String = new char[strlen(Other.Value.String) + 1];
593 ::strcpy(Value.String, Other.Value.String);
594 }
595 return *this;
596 }
597};
598
599} // end namespace pdb
600} // end namespace llvm
601
602template <> struct std::hash<llvm::pdb::PDB_SymType> {
603 std::size_t operator()(const llvm::pdb::PDB_SymType &Arg) const {
604 return std::hash<int>()(static_cast<int>(Arg));
605 }
606};
607
608#endif // LLVM_DEBUGINFO_PDB_PDBTYPES_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
uint64_t uint64_t
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:513
#define VARIANT_WIDTH(Enum, NumBits)
Definition PDBTypes.h:488
#define VARIANT_EQUAL_CASE(Enum)
Definition PDBTypes.h:555
static constexpr const fltSemantics & IEEEsingle()
Definition APFloat.h:304
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
Definition APFloat.h:1216
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:76
CallingConvention
These values correspond to the CV_call_e enumeration, and are documented at the following locations: ...
Definition CodeView.h:156
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
PDB_MemoryType
These values correspond to the MemoryTypeEnum enumeration, and are documented here: https://msdn....
Definition PDBTypes.h:327
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:337
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:312
PDB_SymType
These values correspond to the SymTagEnum enumeration, and are documented here: https://msdn....
Definition PDBTypes.h:245
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:294
PDB_DataKind
These values correspond to the DataKind enumeration, and are documented here: https://msdn....
Definition PDBTypes.h:230
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:364
@ Undname_NameOnly
Definition PDBTypes.h:379
@ Undname_NoECSU
Definition PDBTypes.h:382
@ Undname_NoAccessSpec
Definition PDBTypes.h:374
@ Undname_NoAllocModel
Definition PDBTypes.h:369
@ Undname_NoMsKeywords
Definition PDBTypes.h:367
@ Undname_NoFuncReturns
Definition PDBTypes.h:368
@ Undname_NoMemberType
Definition PDBTypes.h:376
@ Undname_NoAllocLang
Definition PDBTypes.h:370
@ Undname_Reserved2
Definition PDBTypes.h:372
@ Undname_NoPTR64
Definition PDBTypes.h:384
@ Undname_HaveParams
Definition PDBTypes.h:381
@ Undname_NoIdentCharCheck
Definition PDBTypes.h:383
@ Undname_32BitDecode
Definition PDBTypes.h:378
@ Undname_Complete
Definition PDBTypes.h:365
@ Undname_NoLeadingUnderscores
Definition PDBTypes.h:366
@ Undname_NoThrowSig
Definition PDBTypes.h:375
@ Undname_NoThisType
Definition PDBTypes.h:373
@ Undname_TypeOnly
Definition PDBTypes.h:380
@ Undname_Reserved1
Definition PDBTypes.h:371
@ Undname_NoReturnUDTModel
Definition PDBTypes.h:377
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:226
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:316
codeview::CallingConvention PDB_CallingConv
These values correspond to the CV_call_e enumeration, and are documented at the following locations: ...
Definition PDBTypes.h:222
This is an optimization pass for GlobalISel generic memory operations.
@ Other
Any other memory.
Definition ModRef.h:68
bool operator==(const Variant &Other) const
Definition PDBTypes.h:559
Variant(uint32_t V)
Definition PDBTypes.h:439
bool isIntegralType() const
Definition PDBTypes.h:471
Variant(int16_t V)
Definition PDBTypes.h:418
Variant(int8_t V)
Definition PDBTypes.h:417
PDB_VariantType Type
Definition PDBTypes.h:455
APFloat toAPFloat() const
Definition PDBTypes.h:538
Variant & operator=(const Variant &Other)
Definition PDBTypes.h:583
Variant(uint64_t V)
Definition PDBTypes.h:442
Variant(int32_t V)
Definition PDBTypes.h:421
Variant(double V)
Definition PDBTypes.h:430
Variant(int64_t V)
Definition PDBTypes.h:424
APSInt toAPSInt() const
Definition PDBTypes.h:519
unsigned getBitWidth() const
Definition PDBTypes.h:492
bool operator!=(const Variant &Other) const
Definition PDBTypes.h:582
Variant(const Variant &Other)
Definition PDBTypes.h:446
Variant(uint8_t V)
Definition PDBTypes.h:433
Variant(uint16_t V)
Definition PDBTypes.h:436
union llvm::pdb::Variant::@200246275201367176165230176113371323105013167275 Value
std::size_t operator()(const llvm::pdb::PDB_SymType &Arg) const
Definition PDBTypes.h:603