LLVM 20.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.
86enum class PDB_TableType {
87 TableInvalid = 0,
88 Symbols,
96 Dbg
97};
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
107 NS_Regex = 0x8,
109
110 // For backward compatibility.
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
228enum class PDB_DataKind {
229 Unknown,
230 Local,
232 Param,
233 ObjectPtr,
235 Global,
236 Member,
239};
240
241/// These values correspond to the SymTagEnum enumeration, and are documented
242/// here: https://msdn.microsoft.com/en-us/library/bkedss5f.aspx
243enum class PDB_SymType {
244 None,
245 Exe,
246 Compiland,
249 Function,
250 Block,
251 Data,
253 Label,
255 UDT,
256 Enum,
259 ArrayType,
261 Typedef,
262 BaseClass,
263 Friend,
269 VTable,
270 Custom,
271 Thunk,
274 Dimension,
275 CallSite,
280 HLSLType,
281 Caller,
282 Callee,
283 Export,
285 CoffGroup,
286 Inlinee,
287 Max
288};
289
290/// These values correspond to the LocationType enumeration, and are documented
291/// here: https://msdn.microsoft.com/en-us/library/f57kaez3.aspx
292enum class PDB_LocType {
293 Null,
294 Static,
295 TLS,
296 RegRel,
297 ThisRel,
299 BitField,
300 Slot,
301 IlRel,
302 MetaData,
303 Constant,
305 Max
306};
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.
315 FPO,
317 KernelTSS,
318 EBP,
319 FrameData,
320 Unknown = 0xffff
321};
322
323/// These values correspond to the MemoryTypeEnum enumeration, and are
324/// documented here: https://msdn.microsoft.com/en-us/library/ms165609.aspx.
326 Code,
327 Data,
328 Stack,
329 HeapCode,
330 Any = 0xffff
331};
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,
339 WCharT = 3,
340 Int = 6,
341 UInt = 7,
342 Float = 8,
343 BCD = 9,
344 Bool = 10,
345 Long = 13,
346 ULong = 14,
347 Currency = 25,
348 Date = 26,
349 Variant = 27,
350 Complex = 28,
351 Bitfield = 29,
352 BSTR = 30,
353 HResult = 31,
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
382 Undname_NoPTR64 = 0x20000
384
385enum class PDB_MemberAccess { Private = 1, Protected = 2, Public = 3 };
386
392};
393
408 String
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 }
431 explicit Variant(uint8_t V) : Type(PDB_VariantType::UInt8) {
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;
462 uint8_t UInt8;
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(APInt(NumBits, Value.Enum), IsUnsigned);
514
515 APSInt toAPSInt() const {
516 switch (Type) {
517 VARIANT_APSINT(Bool, 1u, true)
518 VARIANT_APSINT(Int8, 8u, false)
519 VARIANT_APSINT(Int16, 16u, false)
520 VARIANT_APSINT(Int32, 32u, false)
521 VARIANT_APSINT(Int64, 64u, false)
522 VARIANT_APSINT(UInt8, 8u, true)
523 VARIANT_APSINT(UInt16, 16u, true)
524 VARIANT_APSINT(UInt32, 32u, true)
525 VARIANT_APSINT(UInt64, 64u, true)
526 default:
527 assert(false && "Variant::toAPSInt called on non-integral type");
528 return APSInt();
529 }
530 }
531
532#undef VARIANT_APSINT
533
535 // Float constants may be tagged as integers.
536 switch (Type) {
540 return APFloat(Value.Single);
544 return APFloat(Value.Double);
545 default:
546 assert(false && "Variant::toAPFloat called on non-floating-point type");
548 }
549 }
550
551#define VARIANT_EQUAL_CASE(Enum) \
552 case PDB_VariantType::Enum: \
553 return Value.Enum == Other.Value.Enum;
554
555 bool operator==(const Variant &Other) const {
556 if (Type != Other.Type)
557 return false;
558 switch (Type) {
571 default:
572 return true;
573 }
574 }
575
576#undef VARIANT_EQUAL_CASE
577
578 bool operator!=(const Variant &Other) const { return !(*this == Other); }
580 if (this == &Other)
581 return *this;
583 delete[] Value.String;
584 Type = Other.Type;
585 Value = Other.Value;
586 if (Other.Type == PDB_VariantType::String &&
587 Other.Value.String != nullptr) {
588 Value.String = new char[strlen(Other.Value.String) + 1];
589 ::strcpy(Value.String, Other.Value.String);
590 }
591 return *this;
592 }
593};
594
595} // end namespace pdb
596} // end namespace llvm
597
598namespace std {
599
600template <> struct hash<llvm::pdb::PDB_SymType> {
602 using result_type = std::size_t;
603
605 return std::hash<int>()(static_cast<int>(Arg));
606 }
607};
608
609} // end namespace std
610
611#endif // LLVM_DEBUGINFO_PDB_PDBTYPES_H
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:551
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
Definition: APFloat.h:994
An arbitrary precision integer that knows its signedness.
Definition: APSInt.h:23
Definition: Any.h:28
This is an important base class in LLVM.
Definition: Constant.h:42
Definition: MD5.h:41
A class that wrap the SHA1 algorithm.
Definition: SHA1.h:26
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
LLVM Value Representation.
Definition: Value.h:74
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:25
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:71
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:184
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: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_Default
Definition: PDBTypes.h:103
@ 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
@ NS_Regex
Definition: PDBTypes.h:107
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
PDB_MemberAccess
Definition: PDBTypes.h:385
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_VariantType
Definition: PDBTypes.h:394
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
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
PDB_StackFrameType
These values correspond to the StackFrameTypeEnum enumeration, and are documented here: https://msdn....
Definition: PDBTypes.h:314
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Other
Any other memory.
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
static const fltSemantics & IEEEsingle() LLVM_READNONE
Definition: APFloat.cpp:281
Holds functions to get, set or test bitfields.
Definition: Bitfields.h:212
bool operator==(const Variant &Other) const
Definition: PDBTypes.h:555
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
union llvm::pdb::Variant::@288 Value
APFloat toAPFloat() const
Definition: PDBTypes.h:534
uint16_t UInt16
Definition: PDBTypes.h:463
uint32_t UInt32
Definition: PDBTypes.h:464
Variant & operator=(const Variant &Other)
Definition: PDBTypes.h:579
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:515
unsigned getBitWidth() const
Definition: PDBTypes.h:490
uint64_t UInt64
Definition: PDBTypes.h:465
Variant(float V)
Definition: PDBTypes.h:425
bool operator!=(const Variant &Other) const
Definition: PDBTypes.h:578
Variant(const Variant &Other)
Definition: PDBTypes.h:444
Variant(uint8_t V)
Definition: PDBTypes.h:431
Variant(uint16_t V)
Definition: PDBTypes.h:434
result_type operator()(const argument_type &Arg) const
Definition: PDBTypes.h:604