1//===- PDBTypes.h - Defines enums for various fields contained in PDB ---*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLVM_DEBUGINFO_PDB_PDBTYPES_H
11#define LLVM_DEBUGINFO_PDB_PDBTYPES_H
12
13#include "llvm/Config/llvm-config.h"
14#include <functional>
15#include <stdint.h>
16
17namespace llvm {
18
19class PDBSymDumper;
20class PDBSymbol;
21
22class IPDBDataStream;
23template <class T> class IPDBEnumChildren;
24class IPDBRawSymbol;
25class IPDBSession;
26class IPDBSourceFile;
27
28typedef IPDBEnumChildren<PDBSymbol> IPDBEnumSymbols;
29typedef IPDBEnumChildren<IPDBSourceFile> IPDBEnumSourceFiles;
30typedef IPDBEnumChildren<IPDBDataStream> IPDBEnumDataStreams;
31
32class PDBSymbolExe;
33class PDBSymbolCompiland;
34class PDBSymbolCompilandDetails;
35class PDBSymbolCompilandEnv;
36class PDBSymbolFunc;
37class PDBSymbolBlock;
38class PDBSymbolData;
39class PDBSymbolAnnotation;
40class PDBSymbolLabel;
41class PDBSymbolPublicSymbol;
42class PDBSymbolTypeUDT;
43class PDBSymbolTypeEnum;
44class PDBSymbolTypeFunctionSig;
45class PDBSymbolTypePointer;
46class PDBSymbolTypeArray;
47class PDBSymbolTypeBuiltin;
48class PDBSymbolTypeTypedef;
49class PDBSymbolTypeBaseClass;
50class PDBSymbolTypeFriend;
51class PDBSymbolTypeFunctionArg;
52class PDBSymbolFuncDebugStart;
53class PDBSymbolFuncDebugEnd;
54class PDBSymbolUsingNamespace;
55class PDBSymbolTypeVTableShape;
56class PDBSymbolTypeVTable;
57class PDBSymbolCustom;
58class PDBSymbolThunk;
59class PDBSymbolTypeCustom;
60class PDBSymbolTypeManaged;
61class PDBSymbolTypeDimension;
62class PDBSymbolUnknown;
63
64/// Specifies which PDB reader implementation is to be used.  Only a value
65/// of PDB_ReaderType::DIA is supported.
66enum class PDB_ReaderType {
67  DIA = 0,
68};
69
70/// Defines a 128-bit unique identifier.  This maps to a GUID on Windows, but
71/// is abstracted here for the purposes of non-Windows platforms that don't have
72/// the GUID structure defined.
73struct PDB_UniqueId {
74  uint64_t HighPart;
75  uint64_t LowPart;
76};
77
78/// An enumeration indicating the type of data contained in this table.
79enum class PDB_TableType {
80  Symbols,
81  SourceFiles,
82  LineNumbers,
83  SectionContribs,
84  Segments,
85  InjectedSources,
86  FrameData
87};
88
89/// Defines flags used for enumerating child symbols.  This corresponds to the
90/// NameSearchOptions enumeration which is documented here:
91/// https://msdn.microsoft.com/en-us/library/yat28ads.aspx
92enum PDB_NameSearchFlags {
93  NS_Default = 0x0,
94  NS_CaseSensitive = 0x1,
95  NS_CaseInsensitive = 0x2,
96  NS_FileNameExtMatch = 0x4,
97  NS_Regex = 0x8,
98  NS_UndecoratedName = 0x10
99};
100
101/// Specifies the hash algorithm that a source file from a PDB was hashed with.
102/// This corresponds to the CV_SourceChksum_t enumeration and are documented
103/// here: https://msdn.microsoft.com/en-us/library/e96az21x.aspx
104enum class PDB_Checksum { None = 0, MD5 = 1, SHA1 = 2 };
105
106/// These values correspond to the CV_CPU_TYPE_e enumeration, and are documented
107/// here: https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
108enum class PDB_Cpu {
109  Intel8080 = 0x0,
110  Intel8086 = 0x1,
111  Intel80286 = 0x2,
112  Intel80386 = 0x3,
113  Intel80486 = 0x4,
114  Pentium = 0x5,
115  PentiumPro = 0x6,
116  Pentium3 = 0x7,
117  MIPS = 0x10,
118  MIPS16 = 0x11,
119  MIPS32 = 0x12,
120  MIPS64 = 0x13,
121  MIPSI = 0x14,
122  MIPSII = 0x15,
123  MIPSIII = 0x16,
124  MIPSIV = 0x17,
125  MIPSV = 0x18,
126  M68000 = 0x20,
127  M68010 = 0x21,
128  M68020 = 0x22,
129  M68030 = 0x23,
130  M68040 = 0x24,
131  Alpha = 0x30,
132  Alpha21164 = 0x31,
133  Alpha21164A = 0x32,
134  Alpha21264 = 0x33,
135  Alpha21364 = 0x34,
136  PPC601 = 0x40,
137  PPC603 = 0x41,
138  PPC604 = 0x42,
139  PPC620 = 0x43,
140  PPCFP = 0x44,
141  PPCBE = 0x45,
142  SH3 = 0x50,
143  SH3E = 0x51,
144  SH3DSP = 0x52,
145  SH4 = 0x53,
146  SHMedia = 0x54,
147  ARM3 = 0x60,
148  ARM4 = 0x61,
149  ARM4T = 0x62,
150  ARM5 = 0x63,
151  ARM5T = 0x64,
152  ARM6 = 0x65,
153  ARM_XMAC = 0x66,
154  ARM_WMMX = 0x67,
155  ARM7 = 0x68,
156  Omni = 0x70,
157  Ia64 = 0x80,
158  Ia64_2 = 0x81,
159  CEE = 0x90,
160  AM33 = 0xa0,
161  M32R = 0xb0,
162  TriCore = 0xc0,
163  X64 = 0xd0,
164  EBC = 0xe0,
165  Thumb = 0xf0,
166  ARMNT = 0xf4,
167  D3D11_Shader = 0x100,
168};
169
170enum class PDB_Machine {
171  Invalid = 0xffff,
172  Unknown = 0x0,
173  Am33 = 0x13,
174  Amd64 = 0x8664,
175  Arm = 0x1C0,
176  ArmNT = 0x1C4,
177  Ebc = 0xEBC,
178  x86 = 0x14C,
179  Ia64 = 0x200,
180  M32R = 0x9041,
181  Mips16 = 0x266,
182  MipsFpu = 0x366,
183  MipsFpu16 = 0x466,
184  PowerPC = 0x1F0,
185  PowerPCFP = 0x1F1,
186  R4000 = 0x166,
187  SH3 = 0x1A2,
188  SH3DSP = 0x1A3,
189  SH4 = 0x1A6,
190  SH5 = 0x1A8,
191  Thumb = 0x1C2,
192  WceMipsV2 = 0x169
193};
194
195/// These values correspond to the CV_call_e enumeration, and are documented
196/// at the following locations:
197///   https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
198///   https://msdn.microsoft.com/en-us/library/windows/desktop/ms680207(v=vs.85).aspx
199///
200enum class PDB_CallingConv {
201  NearCdecl = 0x00,
202  FarCdecl = 0x01,
203  NearPascal = 0x02,
204  FarPascal = 0x03,
205  NearFastcall = 0x04,
206  FarFastcall = 0x05,
207  Skipped = 0x06,
208  NearStdcall = 0x07,
209  FarStdcall = 0x08,
210  NearSyscall = 0x09,
211  FarSyscall = 0x0a,
212  Thiscall = 0x0b,
213  MipsCall = 0x0c,
214  Generic = 0x0d,
215  Alphacall = 0x0e,
216  Ppccall = 0x0f,
217  SuperHCall = 0x10,
218  Armcall = 0x11,
219  AM33call = 0x12,
220  Tricall = 0x13,
221  Sh5call = 0x14,
222  M32R = 0x15,
223  Clrcall = 0x16,
224  Inline = 0x17,
225  NearVectorcall = 0x18,
226  Reserved = 0x19,
227};
228
229/// These values correspond to the CV_CFL_LANG enumeration, and are documented
230/// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx
231enum class PDB_Lang {
232  C = 0x00,
233  Cpp = 0x01,
234  Fortran = 0x02,
235  Masm = 0x03,
236  Pascal = 0x04,
237  Basic = 0x05,
238  Cobol = 0x06,
239  Link = 0x07,
240  Cvtres = 0x08,
241  Cvtpgd = 0x09,
242  CSharp = 0x0a,
243  VB = 0x0b,
244  ILAsm = 0x0c,
245  Java = 0x0d,
246  JScript = 0x0e,
247  MSIL = 0x0f,
248  HLSL = 0x10
249};
250
251/// These values correspond to the DataKind enumeration, and are documented
252/// here: https://msdn.microsoft.com/en-us/library/b2x2t313.aspx
253enum class PDB_DataKind {
254  Unknown,
255  Local,
256  StaticLocal,
257  Param,
258  ObjectPtr,
259  FileStatic,
260  Global,
261  Member,
262  StaticMember,
263  Constant
264};
265
266/// These values correspond to the SymTagEnum enumeration, and are documented
267/// here: https://msdn.microsoft.com/en-us/library/bkedss5f.aspx
268enum class PDB_SymType {
269  None,
270  Exe,
271  Compiland,
272  CompilandDetails,
273  CompilandEnv,
274  Function,
275  Block,
276  Data,
277  Annotation,
278  Label,
279  PublicSymbol,
280  UDT,
281  Enum,
282  FunctionSig,
283  PointerType,
284  ArrayType,
285  BuiltinType,
286  Typedef,
287  BaseClass,
288  Friend,
289  FunctionArg,
290  FuncDebugStart,
291  FuncDebugEnd,
292  UsingNamespace,
293  VTableShape,
294  VTable,
295  Custom,
296  Thunk,
297  CustomType,
298  ManagedType,
299  Dimension,
300  Max
301};
302
303/// These values correspond to the LocationType enumeration, and are documented
304/// here: https://msdn.microsoft.com/en-us/library/f57kaez3.aspx
305enum class PDB_LocType {
306  Null,
307  Static,
308  TLS,
309  RegRel,
310  ThisRel,
311  Enregistered,
312  BitField,
313  Slot,
314  IlRel,
315  MetaData,
316  Constant,
317  Max
318};
319
320/// These values correspond to the THUNK_ORDINAL enumeration, and are documented
321/// here: https://msdn.microsoft.com/en-us/library/dh0k8hft.aspx
322enum class PDB_ThunkOrdinal {
323  Standard,
324  ThisAdjustor,
325  Vcall,
326  Pcode,
327  UnknownLoad,
328  TrampIncremental,
329  BranchIsland
330};
331
332/// These values correspond to the UdtKind enumeration, and are documented
333/// here: https://msdn.microsoft.com/en-us/library/wcstk66t.aspx
334enum class PDB_UdtType { Struct, Class, Union, Interface };
335
336/// These values correspond to the StackFrameTypeEnum enumeration, and are
337/// documented here: https://msdn.microsoft.com/en-us/library/bc5207xw.aspx.
338enum class PDB_StackFrameType { FPO, KernelTrap, KernelTSS, EBP, FrameData };
339
340/// These values correspond to the StackFrameTypeEnum enumeration, and are
341/// documented here: https://msdn.microsoft.com/en-us/library/bc5207xw.aspx.
342enum class PDB_MemoryType { Code, Data, Stack, HeapCode };
343
344/// These values correspond to the Basictype enumeration, and are documented
345/// here: https://msdn.microsoft.com/en-us/library/4szdtzc3.aspx
346enum class PDB_BuiltinType {
347  None = 0,
348  Void = 1,
349  Char = 2,
350  WCharT = 3,
351  Int = 6,
352  UInt = 7,
353  Float = 8,
354  BCD = 9,
355  Bool = 10,
356  Long = 13,
357  ULong = 14,
358  Currency = 25,
359  Date = 26,
360  Variant = 27,
361  Complex = 28,
362  Bitfield = 29,
363  BSTR = 30,
364  HResult = 31
365};
366
367enum class PDB_RegisterId {
368  Unknown = 0,
369  VFrame = 30006,
370  AL = 1,
371  CL = 2,
372  DL = 3,
373  BL = 4,
374  AH = 5,
375  CH = 6,
376  DH = 7,
377  BH = 8,
378  AX = 9,
379  CX = 10,
380  DX = 11,
381  BX = 12,
382  SP = 13,
383  BP = 14,
384  SI = 15,
385  DI = 16,
386  EAX = 17,
387  ECX = 18,
388  EDX = 19,
389  EBX = 20,
390  ESP = 21,
391  EBP = 22,
392  ESI = 23,
393  EDI = 24,
394  ES = 25,
395  CS = 26,
396  SS = 27,
397  DS = 28,
398  FS = 29,
399  GS = 30,
400  IP = 31,
401  RAX = 328,
402  RBX = 329,
403  RCX = 330,
404  RDX = 331,
405  RSI = 332,
406  RDI = 333,
407  RBP = 334,
408  RSP = 335,
409  R8 = 336,
410  R9 = 337,
411  R10 = 338,
412  R11 = 339,
413  R12 = 340,
414  R13 = 341,
415  R14 = 342,
416  R15 = 343,
417};
418
419enum class PDB_MemberAccess { Private = 1, Protected = 2, Public = 3 };
420
421enum class PDB_ErrorCode {
422  Success,
423  NoPdbImpl,
424  InvalidPath,
425  InvalidFileFormat,
426  InvalidParameter,
427  AlreadyLoaded,
428  UnknownError,
429  NoMemory
430};
431
432struct VersionInfo {
433  uint32_t Major;
434  uint32_t Minor;
435  uint32_t Build;
436  uint32_t QFE;
437};
438
439enum PDB_VariantType {
440  Empty,
441  Unknown,
442  Int8,
443  Int16,
444  Int32,
445  Int64,
446  Single,
447  Double,
448  UInt8,
449  UInt16,
450  UInt32,
451  UInt64,
452  Bool,
453};
454
455struct Variant {
456  Variant()
457    : Type(PDB_VariantType::Empty) {
458  }
459
460  PDB_VariantType Type;
461  union {
462    bool Bool;
463    int8_t Int8;
464    int16_t Int16;
465    int32_t Int32;
466    int64_t Int64;
467    float Single;
468    double Double;
469    uint8_t UInt8;
470    uint16_t UInt16;
471    uint32_t UInt32;
472    uint64_t UInt64;
473  };
474#define VARIANT_EQUAL_CASE(Enum)                                               \
475  case PDB_VariantType::Enum:                                                  \
476    return Enum == Other.Enum;
477  bool operator==(const Variant &Other) const {
478    if (Type != Other.Type)
479      return false;
480    switch (Type) {
481      VARIANT_EQUAL_CASE(Bool)
482      VARIANT_EQUAL_CASE(Int8)
483      VARIANT_EQUAL_CASE(Int16)
484      VARIANT_EQUAL_CASE(Int32)
485      VARIANT_EQUAL_CASE(Int64)
486      VARIANT_EQUAL_CASE(Single)
487      VARIANT_EQUAL_CASE(Double)
488      VARIANT_EQUAL_CASE(UInt8)
489      VARIANT_EQUAL_CASE(UInt16)
490      VARIANT_EQUAL_CASE(UInt32)
491      VARIANT_EQUAL_CASE(UInt64)
492    default:
493      return true;
494    }
495  }
496#undef VARIANT_EQUAL_CASE
497  bool operator!=(const Variant &Other) const { return !(*this == Other); }
498};
499
500} // namespace llvm
501
502namespace std {
503template <> struct hash<llvm::PDB_SymType> {
504  typedef llvm::PDB_SymType argument_type;
505  typedef std::size_t result_type;
506
507  result_type operator()(const argument_type &Arg) const {
508    return std::hash<int>()(static_cast<int>(Arg));
509  }
510};
511}
512
513#endif
514