LLVM  9.0.0svn
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 
16 #include <cctype>
17 #include <cstddef>
18 #include <cstdint>
19 #include <cstring>
20 #include <functional>
21 
22 namespace llvm {
23 namespace pdb {
24 
26 
27 class IPDBDataStream;
28 class IPDBInjectedSource;
29 class IPDBLineNumber;
30 class IPDBSectionContrib;
31 class IPDBSourceFile;
32 class IPDBTable;
33 class PDBSymDumper;
34 class PDBSymbol;
35 class PDBSymbolExe;
36 class PDBSymbolCompiland;
39 class PDBSymbolFunc;
40 class PDBSymbolBlock;
41 class PDBSymbolData;
43 class PDBSymbolLabel;
45 class PDBSymbolTypeUDT;
46 class PDBSymbolTypeEnum;
49 class PDBSymbolTypeArray;
60 class PDBSymbolCustom;
61 class PDBSymbolThunk;
65 class PDBSymbolUnknown;
66 
75 
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 {
79  DIA = 0,
80  Native = 1,
81 };
82 
83 /// An enumeration indicating the type of data contained in this table.
84 enum class PDB_TableType {
85  TableInvalid = 0,
86  Symbols,
90  Segments,
92  FrameData,
94  Dbg
95 };
96 
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
101  NS_Default = 0x0,
105  NS_Regex = 0x8,
107 
108  // For backward compatibility.
112 };
113 
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 };
118 
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
122 
123 enum class PDB_Machine {
124  Invalid = 0xffff,
125  Unknown = 0x0,
126  Am33 = 0x13,
127  Amd64 = 0x8664,
128  Arm = 0x1C0,
129  Arm64 = 0xaa64,
130  ArmNT = 0x1C4,
131  Ebc = 0xEBC,
132  x86 = 0x14C,
133  Ia64 = 0x200,
134  M32R = 0x9041,
135  Mips16 = 0x266,
136  MipsFpu = 0x366,
137  MipsFpu16 = 0x466,
138  PowerPC = 0x1F0,
139  PowerPCFP = 0x1F1,
140  R4000 = 0x166,
141  SH3 = 0x1A2,
142  SH3DSP = 0x1A3,
143  SH4 = 0x1A6,
144  SH5 = 0x1A8,
145  Thumb = 0x1C2,
146  WceMipsV2 = 0x169
147 };
148 
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.
153  enum : uint32_t {
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.
161  LZ,
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.
172  //
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.
181  //
182  // A GUID is 16 bytes, stored in the usual
183  // uint32_t
184  // uint16_t
185  // uint16_t
186  // uint8_t[24]
187  // layout.
188  //
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
199  //
200  // Well-known GUIDs for LanguageVendorGuid are:
201  // 994b45c4-e6e9-11d2-903f-00c04fa302a1 Microsoft
202  //
203  // Well-known GUIDs for DocumentTypeGuid are:
204  // 5a869d0b-6611-11d3-bd2a-0000f80849bd Text
205  //
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)
210  DotNet = 101,
211  };
212 };
213 
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
219 
220 /// These values correspond to the CV_CFL_LANG enumeration, and are documented
221 /// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx
223 
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 {
227  Unknown,
228  Local,
229  StaticLocal,
230  Param,
231  ObjectPtr,
232  FileStatic,
233  Global,
234  Member,
235  StaticMember,
236  Constant
237 };
238 
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 {
242  None,
243  Exe,
244  Compiland,
246  CompilandEnv,
247  Function,
248  Block,
249  Data,
250  Annotation,
251  Label,
252  PublicSymbol,
253  UDT,
254  Enum,
255  FunctionSig,
256  PointerType,
257  ArrayType,
258  BuiltinType,
259  Typedef,
260  BaseClass,
261  Friend,
262  FunctionArg,
264  FuncDebugEnd,
266  VTableShape,
267  VTable,
268  Custom,
269  Thunk,
270  CustomType,
271  ManagedType,
272  Dimension,
273  CallSite,
274  InlineSite,
276  VectorType,
277  MatrixType,
278  HLSLType,
279  Caller,
280  Callee,
281  Export,
283  CoffGroup,
284  Inlinee,
285  Max
286 };
287 
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 {
291  Null,
292  Static,
293  TLS,
294  RegRel,
295  ThisRel,
296  Enregistered,
297  BitField,
298  Slot,
299  IlRel,
300  MetaData,
301  Constant,
303  Max
304 };
305 
306 /// These values correspond to the UdtKind enumeration, and are documented
307 /// here: https://msdn.microsoft.com/en-us/library/wcstk66t.aspx
309 
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 {
313  FPO,
314  KernelTrap,
315  KernelTSS,
316  EBP,
317  FrameData,
318  Unknown = 0xffff
319 };
320 
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 {
324  Code,
325  Data,
326  Stack,
327  HeapCode,
328  Any = 0xffff
329 };
330 
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 {
334  None = 0,
335  Void = 1,
336  Char = 2,
337  WCharT = 3,
338  Int = 6,
339  UInt = 7,
340  Float = 8,
341  BCD = 9,
342  Bool = 10,
343  Long = 13,
344  ULong = 14,
345  Currency = 25,
346  Date = 26,
347  Variant = 27,
348  Complex = 28,
349  Bitfield = 29,
350  BSTR = 30,
351  HResult = 31,
352  Char16 = 32,
353  Char32 = 33
354 };
355 
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
377  Undname_NoECSU = 0x8000,
379  Undname_NoPTR64 = 0x20000
380 };
381 
382 enum class PDB_MemberAccess { Private = 1, Protected = 2, Public = 3 };
383 
384 struct VersionInfo {
389 };
390 
406 };
407 
408 struct Variant {
409  Variant() = default;
410 
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) {
414  Value.Int16 = V;
415  }
416  explicit Variant(int32_t V) : Type(PDB_VariantType::Int32) {
417  Value.Int32 = V;
418  }
419  explicit Variant(int64_t V) : Type(PDB_VariantType::Int64) {
420  Value.Int64 = V;
421  }
422  explicit Variant(float V) : Type(PDB_VariantType::Single) {
423  Value.Single = V;
424  }
425  explicit Variant(double V) : Type(PDB_VariantType::Double) {
426  Value.Double = V;
427  }
428  explicit Variant(uint8_t V) : Type(PDB_VariantType::UInt8) {
429  Value.UInt8 = V;
430  }
431  explicit Variant(uint16_t V) : Type(PDB_VariantType::UInt16) {
432  Value.UInt16 = V;
433  }
435  Value.UInt32 = V;
436  }
437  explicit Variant(uint64_t V) : Type(PDB_VariantType::UInt64) {
438  Value.UInt64 = V;
439  }
440 
441  Variant(const Variant &Other) {
442  *this = Other;
443  }
444 
447  delete[] Value.String;
448  }
449 
451  union {
452  bool Bool;
453  int8_t Int8;
454  int16_t Int16;
455  int32_t Int32;
456  int64_t Int64;
457  float Single;
458  double Double;
459  uint8_t UInt8;
460  uint16_t UInt16;
462  uint64_t UInt64;
463  char *String;
464  } Value;
465 
466 #define VARIANT_EQUAL_CASE(Enum) \
467  case PDB_VariantType::Enum: \
468  return Value.Enum == Other.Value.Enum;
469 
470  bool operator==(const Variant &Other) const {
471  if (Type != Other.Type)
472  return false;
473  switch (Type) {
486  default:
487  return true;
488  }
489  }
490 
491 #undef VARIANT_EQUAL_CASE
492 
493  bool operator!=(const Variant &Other) const { return !(*this == Other); }
494  Variant &operator=(const Variant &Other) {
495  if (this == &Other)
496  return *this;
497  if (Type == PDB_VariantType::String)
498  delete[] Value.String;
499  Type = Other.Type;
500  Value = Other.Value;
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);
505  }
506  return *this;
507  }
508 };
509 
510 } // end namespace pdb
511 } // end namespace llvm
512 
513 namespace std {
514 
515 template <> struct hash<llvm::pdb::PDB_SymType> {
517  using result_type = std::size_t;
518 
520  return std::hash<int>()(static_cast<int>(Arg));
521  }
522 };
523 
524 } // end namespace std
525 
526 #endif // LLVM_DEBUGINFO_PDB_PDBTYPES_H
Variant(double V)
Definition: PDBTypes.h:425
Definition: Any.h:26
Variant(uint16_t V)
Definition: PDBTypes.h:431
This class represents lattice values for constants.
Definition: AllocatorList.h:23
PDB_UdtType
These values correspond to the UdtKind enumeration, and are documented here: https://msdn.microsoft.com/en-us/library/wcstk66t.aspx.
Definition: PDBTypes.h:308
PDBSymbolCustom represents symbols that are compiler-specific and do not fit anywhere else in the lex...
result_type operator()(const argument_type &Arg) const
Definition: PDBTypes.h:519
Variant(int8_t V)
Definition: PDBTypes.h:412
PDB_NameSearchFlags
Defines flags used for enumerating child symbols.
Definition: PDBTypes.h:100
PDB_ReaderType
Specifies which PDB reader implementation is to be used.
Definition: PDBTypes.h:78
A class that wrap the SHA1 algorithm.
Definition: SHA1.h:28
bool operator!=(const Variant &Other) const
Definition: PDBTypes.h:493
PDB_Checksum
Specifies the hash algorithm that a source file from a PDB was hashed with.
Definition: PDBTypes.h:117
IPDBSourceFile defines an interface used to represent source files whose information are stored in th...
Variant(uint64_t V)
Definition: PDBTypes.h:437
Definition: BitVector.h:937
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...
PDB_UndnameFlags
These values correspond to the flags that can be combined to control the return of an undecorated nam...
Definition: PDBTypes.h:359
Variant(uint8_t V)
Definition: PDBTypes.h:428
PDB_SymType
These values correspond to the SymTagEnum enumeration, and are documented here: https://msdn.microsoft.com/en-us/library/bkedss5f.aspx.
Definition: PDBTypes.h:241
uint32_t UInt32
Definition: PDBTypes.h:461
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
This is an important base class in LLVM.
Definition: Constant.h:41
Variant(int32_t V)
Definition: PDBTypes.h:416
PDB_DataKind
These values correspond to the DataKind enumeration, and are documented here: https://msdn.microsoft.com/en-us/library/b2x2t313.aspx.
Definition: PDBTypes.h:226
#define VARIANT_EQUAL_CASE(Enum)
Definition: PDBTypes.h:466
Variant(uint32_t V)
Definition: PDBTypes.h:434
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
PDB_LocType
These values correspond to the LocationType enumeration, and are documented here: https://msdn...
Definition: PDBTypes.h:290
uint64_t UInt64
Definition: PDBTypes.h:462
IPDBDataStream defines an interface used to represent a stream consisting of a name and a series of r...
Variant(int64_t V)
Definition: PDBTypes.h:419
SourceLanguage
These values correspond to the CV_CFL_LANG enumeration, and are documented here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx.
Definition: CodeView.h:143
Variant(const Variant &Other)
Definition: PDBTypes.h:441
CPUType
These values correspond to the CV_CPU_TYPE_e enumeration, and are documented here: https://msdn...
Definition: CodeView.h:78
PDBSymbol defines the base of the inheritance hierarchy for concrete symbol types (e...
Definition: PDBSymbol.h:73
PDB_TableType
An enumeration indicating the type of data contained in this table.
Definition: PDBTypes.h:84
PDB_MemoryType
These values correspond to the MemoryTypeEnum enumeration, and are documented here: https://msdn...
Definition: PDBTypes.h:323
PDB_VariantType
Definition: PDBTypes.h:391
union llvm::pdb::Variant::@228 Value
uint32_t SymIndexId
Definition: PDBTypes.h:25
uint16_t UInt16
Definition: PDBTypes.h:460
Definition: MD5.h:41
PDB_StackFrameType
These values correspond to the StackFrameTypeEnum enumeration, and are documented here: https://msdn...
Definition: PDBTypes.h:312
PDB_BuiltinType
These values correspond to the Basictype enumeration, and are documented here: https://msdn.microsoft.com/en-us/library/4szdtzc3.aspx.
Definition: PDBTypes.h:333
LLVM Value Representation.
Definition: Value.h:72
CallingConvention
These values correspond to the CV_call_e enumeration, and are documented at the following locations: ...
Definition: CodeView.h:173
Variant & operator=(const Variant &Other)
Definition: PDBTypes.h:494
bool operator==(const Variant &Other) const
Definition: PDBTypes.h:470
Variant(int16_t V)
Definition: PDBTypes.h:413
PDB_VariantType Type
Definition: PDBTypes.h:450
Variant(float V)
Definition: PDBTypes.h:422
PDB_MemberAccess
Definition: PDBTypes.h:382