1 //===- PDBTypes.h - Defines enums for various fields contained in PDB ----====//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_DEBUGINFO_PDB_PDBTYPES_H
10 #define LLVM_DEBUGINFO_PDB_PDBTYPES_H
12 #include "llvm/DebugInfo/CodeView/CodeView.h"
13 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
14 #include "llvm/DebugInfo/PDB/IPDBFrameData.h"
15 #include "llvm/DebugInfo/PDB/Native/RawTypes.h"
25 typedef uint32_t SymIndexId
;
28 class IPDBInjectedSource
;
30 class IPDBSectionContrib
;
36 class PDBSymbolCompiland
;
37 class PDBSymbolCompilandDetails
;
38 class PDBSymbolCompilandEnv
;
42 class PDBSymbolAnnotation
;
44 class PDBSymbolPublicSymbol
;
45 class PDBSymbolTypeUDT
;
46 class PDBSymbolTypeEnum
;
47 class PDBSymbolTypeFunctionSig
;
48 class PDBSymbolTypePointer
;
49 class PDBSymbolTypeArray
;
50 class PDBSymbolTypeBuiltin
;
51 class PDBSymbolTypeTypedef
;
52 class PDBSymbolTypeBaseClass
;
53 class PDBSymbolTypeFriend
;
54 class PDBSymbolTypeFunctionArg
;
55 class PDBSymbolFuncDebugStart
;
56 class PDBSymbolFuncDebugEnd
;
57 class PDBSymbolUsingNamespace
;
58 class PDBSymbolTypeVTableShape
;
59 class PDBSymbolTypeVTable
;
60 class PDBSymbolCustom
;
62 class PDBSymbolTypeCustom
;
63 class PDBSymbolTypeManaged
;
64 class PDBSymbolTypeDimension
;
65 class PDBSymbolUnknown
;
67 using IPDBEnumSymbols
= IPDBEnumChildren
<PDBSymbol
>;
68 using IPDBEnumSourceFiles
= IPDBEnumChildren
<IPDBSourceFile
>;
69 using IPDBEnumDataStreams
= IPDBEnumChildren
<IPDBDataStream
>;
70 using IPDBEnumLineNumbers
= IPDBEnumChildren
<IPDBLineNumber
>;
71 using IPDBEnumTables
= IPDBEnumChildren
<IPDBTable
>;
72 using IPDBEnumInjectedSources
= IPDBEnumChildren
<IPDBInjectedSource
>;
73 using IPDBEnumSectionContribs
= IPDBEnumChildren
<IPDBSectionContrib
>;
74 using IPDBEnumFrameData
= IPDBEnumChildren
<IPDBFrameData
>;
76 /// Specifies which PDB reader implementation is to be used. Only a value
77 /// of PDB_ReaderType::DIA is currently supported, but Native is in the works.
78 enum class PDB_ReaderType
{
83 /// An enumeration indicating the type of data contained in this table.
84 enum class PDB_TableType
{
97 /// Defines flags used for enumerating child symbols. This corresponds to the
98 /// NameSearchOptions enumeration which is documented here:
99 /// https://msdn.microsoft.com/en-us/library/yat28ads.aspx
100 enum PDB_NameSearchFlags
{
102 NS_CaseSensitive
= 0x1,
103 NS_CaseInsensitive
= 0x2,
104 NS_FileNameExtMatch
= 0x4,
106 NS_UndecoratedName
= 0x10,
108 // For backward compatibility.
109 NS_CaseInFileNameExt
= NS_CaseInsensitive
| NS_FileNameExtMatch
,
110 NS_CaseRegex
= NS_Regex
| NS_CaseSensitive
,
111 NS_CaseInRex
= NS_Regex
| NS_CaseInsensitive
114 /// Specifies the hash algorithm that a source file from a PDB was hashed with.
115 /// This corresponds to the CV_SourceChksum_t enumeration and are documented
116 /// here: https://msdn.microsoft.com/en-us/library/e96az21x.aspx
117 enum class PDB_Checksum
{ None
= 0, MD5
= 1, SHA1
= 2, SHA256
= 3 };
119 /// These values correspond to the CV_CPU_TYPE_e enumeration, and are documented
120 /// here: https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
121 using PDB_Cpu
= codeview::CPUType
;
123 enum class PDB_Machine
{
149 // A struct with an inner unnamed enum with explicit underlying type resuls
150 // in an enum class that can implicitly convert to the underlying type, which
151 // is convenient for this enum.
152 struct PDB_SourceCompression
{
154 // No compression. Produced e.g. by `link.exe /natvis:foo.natvis`.
156 // Not known what produces this.
158 // Not known what produces this.
160 // Not known what produces this.
162 // Produced e.g. by `csc /debug`. The encoded data is its own mini-stream
163 // with the following layout (in little endian):
164 // GUID LanguageTypeGuid;
165 // GUID LanguageVendorGuid;
166 // GUID DocumentTypeGuid;
167 // GUID HashFunctionGuid;
168 // uint32_t HashDataSize;
169 // uint32_t CompressedDataSize;
170 // Followed by HashDataSize bytes containing a hash checksum,
171 // followed by CompressedDataSize bytes containing source contents.
173 // CompressedDataSize can be 0, in this case only the hash data is present.
174 // (CompressedDataSize is != 0 e.g. if `/embed` is passed to csc.exe.)
175 // The compressed data format is:
176 // uint32_t UncompressedDataSize;
177 // If UncompressedDataSize is 0, the data is stored uncompressed and
178 // CompressedDataSize stores the uncompressed size.
179 // If UncompressedDataSize is != 0, then the data is in raw deflate
180 // encoding as described in rfc1951.
182 // A GUID is 16 bytes, stored in the usual
189 // Well-known GUIDs for LanguageTypeGuid are:
190 // 63a08714-fc37-11d2-904c-00c04fa302a1 C
191 // 3a12d0b7-c26c-11d0-b442-00a0244a1dd2 C++
192 // 3f5162f8-07c6-11d3-9053-00c04fa302a1 C#
193 // af046cd1-d0e1-11d2-977c-00a0c9b4d50c Cobol
194 // ab4f38c9-b6e6-43ba-be3b-58080b2ccce3 F#
195 // 3a12d0b4-c26c-11d0-b442-00a0244a1dd2 Java
196 // 3a12d0b6-c26c-11d0-b442-00a0244a1dd2 JScript
197 // af046cd2-d0e1-11d2-977c-00a0c9b4d50c Pascal
198 // 3a12d0b8-c26c-11d0-b442-00a0244a1dd2 Visual Basic
200 // Well-known GUIDs for LanguageVendorGuid are:
201 // 994b45c4-e6e9-11d2-903f-00c04fa302a1 Microsoft
203 // Well-known GUIDs for DocumentTypeGuid are:
204 // 5a869d0b-6611-11d3-bd2a-0000f80849bd Text
206 // Well-known GUIDs for HashFunctionGuid are:
207 // 406ea660-64cf-4c82-b6f0-42d48172a799 MD5 (HashDataSize is 16)
208 // ff1816ec-aa5e-4d10-87f7-6f4963833460 SHA1 (HashDataSize is 20)
209 // 8829d00f-11b8-4213-878b-770e8597ac16 SHA256 (HashDataSize is 32)
214 /// These values correspond to the CV_call_e enumeration, and are documented
215 /// at the following locations:
216 /// https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
217 /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680207(v=vs.85).aspx
218 using PDB_CallingConv
= codeview::CallingConvention
;
220 /// These values correspond to the CV_CFL_LANG enumeration, and are documented
221 /// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx
222 using PDB_Lang
= codeview::SourceLanguage
;
224 /// These values correspond to the DataKind enumeration, and are documented
225 /// here: https://msdn.microsoft.com/en-us/library/b2x2t313.aspx
226 enum class PDB_DataKind
{
239 /// These values correspond to the SymTagEnum enumeration, and are documented
240 /// here: https://msdn.microsoft.com/en-us/library/bkedss5f.aspx
241 enum class PDB_SymType
{
288 /// These values correspond to the LocationType enumeration, and are documented
289 /// here: https://msdn.microsoft.com/en-us/library/f57kaez3.aspx
290 enum class PDB_LocType
{
306 /// These values correspond to the UdtKind enumeration, and are documented
307 /// here: https://msdn.microsoft.com/en-us/library/wcstk66t.aspx
308 enum class PDB_UdtType
{ Struct
, Class
, Union
, Interface
};
310 /// These values correspond to the StackFrameTypeEnum enumeration, and are
311 /// documented here: https://msdn.microsoft.com/en-us/library/bc5207xw.aspx.
312 enum class PDB_StackFrameType
: uint16_t {
321 /// These values correspond to the MemoryTypeEnum enumeration, and are
322 /// documented here: https://msdn.microsoft.com/en-us/library/ms165609.aspx.
323 enum class PDB_MemoryType
: uint16_t {
331 /// These values correspond to the Basictype enumeration, and are documented
332 /// here: https://msdn.microsoft.com/en-us/library/4szdtzc3.aspx
333 enum class PDB_BuiltinType
{
356 /// These values correspond to the flags that can be combined to control the
357 /// return of an undecorated name for a C++ decorated name, and are documented
358 /// here: https://msdn.microsoft.com/en-us/library/kszfk0fs.aspx
359 enum PDB_UndnameFlags
: uint32_t {
360 Undname_Complete
= 0x0,
361 Undname_NoLeadingUnderscores
= 0x1,
362 Undname_NoMsKeywords
= 0x2,
363 Undname_NoFuncReturns
= 0x4,
364 Undname_NoAllocModel
= 0x8,
365 Undname_NoAllocLang
= 0x10,
366 Undname_Reserved1
= 0x20,
367 Undname_Reserved2
= 0x40,
368 Undname_NoThisType
= 0x60,
369 Undname_NoAccessSpec
= 0x80,
370 Undname_NoThrowSig
= 0x100,
371 Undname_NoMemberType
= 0x200,
372 Undname_NoReturnUDTModel
= 0x400,
373 Undname_32BitDecode
= 0x800,
374 Undname_NameOnly
= 0x1000,
375 Undname_TypeOnly
= 0x2000,
376 Undname_HaveParams
= 0x4000,
377 Undname_NoECSU
= 0x8000,
378 Undname_NoIdentCharCheck
= 0x10000,
379 Undname_NoPTR64
= 0x20000
382 enum class PDB_MemberAccess
{ Private
= 1, Protected
= 2, Public
= 3 };
391 enum PDB_VariantType
{
411 explicit Variant(bool V
) : Type(PDB_VariantType::Bool
) { Value
.Bool
= V
; }
412 explicit Variant(int8_t V
) : Type(PDB_VariantType::Int8
) { Value
.Int8
= V
; }
413 explicit Variant(int16_t V
) : Type(PDB_VariantType::Int16
) {
416 explicit Variant(int32_t V
) : Type(PDB_VariantType::Int32
) {
419 explicit Variant(int64_t V
) : Type(PDB_VariantType::Int64
) {
422 explicit Variant(float V
) : Type(PDB_VariantType::Single
) {
425 explicit Variant(double V
) : Type(PDB_VariantType::Double
) {
428 explicit Variant(uint8_t V
) : Type(PDB_VariantType::UInt8
) {
431 explicit Variant(uint16_t V
) : Type(PDB_VariantType::UInt16
) {
434 explicit Variant(uint32_t V
) : Type(PDB_VariantType::UInt32
) {
437 explicit Variant(uint64_t V
) : Type(PDB_VariantType::UInt64
) {
441 Variant(const Variant
&Other
) {
446 if (Type
== PDB_VariantType::String
)
447 delete[] Value
.String
;
450 PDB_VariantType Type
= PDB_VariantType::Empty
;
466 #define VARIANT_EQUAL_CASE(Enum) \
467 case PDB_VariantType::Enum: \
468 return Value.Enum == Other.Value.Enum;
470 bool operator==(const Variant
&Other
) const {
471 if (Type
!= Other
.Type
)
474 VARIANT_EQUAL_CASE(Bool
)
475 VARIANT_EQUAL_CASE(Int8
)
476 VARIANT_EQUAL_CASE(Int16
)
477 VARIANT_EQUAL_CASE(Int32
)
478 VARIANT_EQUAL_CASE(Int64
)
479 VARIANT_EQUAL_CASE(Single
)
480 VARIANT_EQUAL_CASE(Double
)
481 VARIANT_EQUAL_CASE(UInt8
)
482 VARIANT_EQUAL_CASE(UInt16
)
483 VARIANT_EQUAL_CASE(UInt32
)
484 VARIANT_EQUAL_CASE(UInt64
)
485 VARIANT_EQUAL_CASE(String
)
491 #undef VARIANT_EQUAL_CASE
493 bool operator!=(const Variant
&Other
) const { return !(*this == Other
); }
494 Variant
&operator=(const Variant
&Other
) {
497 if (Type
== PDB_VariantType::String
)
498 delete[] Value
.String
;
501 if (Other
.Type
== PDB_VariantType::String
&&
502 Other
.Value
.String
!= nullptr) {
503 Value
.String
= new char[strlen(Other
.Value
.String
) + 1];
504 ::strcpy(Value
.String
, Other
.Value
.String
);
510 } // end namespace pdb
511 } // end namespace llvm
515 template <> struct hash
<llvm::pdb::PDB_SymType
> {
516 using argument_type
= llvm::pdb::PDB_SymType
;
517 using result_type
= std::size_t;
519 result_type
operator()(const argument_type
&Arg
) const {
520 return std::hash
<int>()(static_cast<int>(Arg
));
524 } // end namespace std
526 #endif // LLVM_DEBUGINFO_PDB_PDBTYPES_H