]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/llvm/DebugInfo/PDB/PDBTypes.h
Vendor import of llvm trunk r351319 (just before the release_80 branch
[FreeBSD/FreeBSD.git] / include / llvm / DebugInfo / PDB / PDBTypes.h
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/DebugInfo/CodeView/CodeView.h"
14 #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
15 #include "llvm/DebugInfo/PDB/IPDBFrameData.h"
16 #include "llvm/DebugInfo/PDB/Native/RawTypes.h"
17 #include <cctype>
18 #include <cstddef>
19 #include <cstdint>
20 #include <cstring>
21 #include <functional>
22
23 namespace llvm {
24 namespace pdb {
25
26 typedef uint32_t SymIndexId;
27
28 class IPDBDataStream;
29 class IPDBInjectedSource;
30 class IPDBLineNumber;
31 class IPDBSectionContrib;
32 class IPDBSourceFile;
33 class IPDBTable;
34 class PDBSymDumper;
35 class PDBSymbol;
36 class PDBSymbolExe;
37 class PDBSymbolCompiland;
38 class PDBSymbolCompilandDetails;
39 class PDBSymbolCompilandEnv;
40 class PDBSymbolFunc;
41 class PDBSymbolBlock;
42 class PDBSymbolData;
43 class PDBSymbolAnnotation;
44 class PDBSymbolLabel;
45 class PDBSymbolPublicSymbol;
46 class PDBSymbolTypeUDT;
47 class PDBSymbolTypeEnum;
48 class PDBSymbolTypeFunctionSig;
49 class PDBSymbolTypePointer;
50 class PDBSymbolTypeArray;
51 class PDBSymbolTypeBuiltin;
52 class PDBSymbolTypeTypedef;
53 class PDBSymbolTypeBaseClass;
54 class PDBSymbolTypeFriend;
55 class PDBSymbolTypeFunctionArg;
56 class PDBSymbolFuncDebugStart;
57 class PDBSymbolFuncDebugEnd;
58 class PDBSymbolUsingNamespace;
59 class PDBSymbolTypeVTableShape;
60 class PDBSymbolTypeVTable;
61 class PDBSymbolCustom;
62 class PDBSymbolThunk;
63 class PDBSymbolTypeCustom;
64 class PDBSymbolTypeManaged;
65 class PDBSymbolTypeDimension;
66 class PDBSymbolUnknown;
67
68 using IPDBEnumSymbols = IPDBEnumChildren<PDBSymbol>;
69 using IPDBEnumSourceFiles = IPDBEnumChildren<IPDBSourceFile>;
70 using IPDBEnumDataStreams = IPDBEnumChildren<IPDBDataStream>;
71 using IPDBEnumLineNumbers = IPDBEnumChildren<IPDBLineNumber>;
72 using IPDBEnumTables = IPDBEnumChildren<IPDBTable>;
73 using IPDBEnumInjectedSources = IPDBEnumChildren<IPDBInjectedSource>;
74 using IPDBEnumSectionContribs = IPDBEnumChildren<IPDBSectionContrib>;
75 using IPDBEnumFrameData = IPDBEnumChildren<IPDBFrameData>;
76
77 /// Specifies which PDB reader implementation is to be used.  Only a value
78 /// of PDB_ReaderType::DIA is currently supported, but Native is in the works.
79 enum class PDB_ReaderType {
80   DIA = 0,
81   Native = 1,
82 };
83
84 /// An enumeration indicating the type of data contained in this table.
85 enum class PDB_TableType {
86   TableInvalid = 0,
87   Symbols,
88   SourceFiles,
89   LineNumbers,
90   SectionContribs,
91   Segments,
92   InjectedSources,
93   FrameData,
94   InputAssemblyFiles,
95   Dbg
96 };
97
98 /// Defines flags used for enumerating child symbols.  This corresponds to the
99 /// NameSearchOptions enumeration which is documented here:
100 /// https://msdn.microsoft.com/en-us/library/yat28ads.aspx
101 enum PDB_NameSearchFlags {
102   NS_Default = 0x0,
103   NS_CaseSensitive = 0x1,
104   NS_CaseInsensitive = 0x2,
105   NS_FileNameExtMatch = 0x4,
106   NS_Regex = 0x8,
107   NS_UndecoratedName = 0x10,
108
109   // For backward compatibility.
110   NS_CaseInFileNameExt = NS_CaseInsensitive | NS_FileNameExtMatch,
111   NS_CaseRegex = NS_Regex | NS_CaseSensitive,
112   NS_CaseInRex = NS_Regex | NS_CaseInsensitive
113 };
114
115 /// Specifies the hash algorithm that a source file from a PDB was hashed with.
116 /// This corresponds to the CV_SourceChksum_t enumeration and are documented
117 /// here: https://msdn.microsoft.com/en-us/library/e96az21x.aspx
118 enum class PDB_Checksum { None = 0, MD5 = 1, SHA1 = 2, SHA256 = 3 };
119
120 /// These values correspond to the CV_CPU_TYPE_e enumeration, and are documented
121 /// here: https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
122 using PDB_Cpu = codeview::CPUType;
123
124 enum class PDB_Machine {
125   Invalid = 0xffff,
126   Unknown = 0x0,
127   Am33 = 0x13,
128   Amd64 = 0x8664,
129   Arm = 0x1C0,
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 enum class PDB_SourceCompression {
150   None,
151   RunLengthEncoded,
152   Huffman,
153   LZ,
154 };
155
156 /// These values correspond to the CV_call_e enumeration, and are documented
157 /// at the following locations:
158 ///   https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
159 ///   https://msdn.microsoft.com/en-us/library/windows/desktop/ms680207(v=vs.85).aspx
160 using PDB_CallingConv = codeview::CallingConvention;
161
162 /// These values correspond to the CV_CFL_LANG enumeration, and are documented
163 /// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx
164 using PDB_Lang = codeview::SourceLanguage;
165
166 /// These values correspond to the DataKind enumeration, and are documented
167 /// here: https://msdn.microsoft.com/en-us/library/b2x2t313.aspx
168 enum class PDB_DataKind {
169   Unknown,
170   Local,
171   StaticLocal,
172   Param,
173   ObjectPtr,
174   FileStatic,
175   Global,
176   Member,
177   StaticMember,
178   Constant
179 };
180
181 /// These values correspond to the SymTagEnum enumeration, and are documented
182 /// here: https://msdn.microsoft.com/en-us/library/bkedss5f.aspx
183 enum class PDB_SymType {
184   None,
185   Exe,
186   Compiland,
187   CompilandDetails,
188   CompilandEnv,
189   Function,
190   Block,
191   Data,
192   Annotation,
193   Label,
194   PublicSymbol,
195   UDT,
196   Enum,
197   FunctionSig,
198   PointerType,
199   ArrayType,
200   BuiltinType,
201   Typedef,
202   BaseClass,
203   Friend,
204   FunctionArg,
205   FuncDebugStart,
206   FuncDebugEnd,
207   UsingNamespace,
208   VTableShape,
209   VTable,
210   Custom,
211   Thunk,
212   CustomType,
213   ManagedType,
214   Dimension,
215   CallSite,
216   InlineSite,
217   BaseInterface,
218   VectorType,
219   MatrixType,
220   HLSLType,
221   Caller,
222   Callee,
223   Export,
224   HeapAllocationSite,
225   CoffGroup,
226   Inlinee,
227   Max
228 };
229
230 /// These values correspond to the LocationType enumeration, and are documented
231 /// here: https://msdn.microsoft.com/en-us/library/f57kaez3.aspx
232 enum class PDB_LocType {
233   Null,
234   Static,
235   TLS,
236   RegRel,
237   ThisRel,
238   Enregistered,
239   BitField,
240   Slot,
241   IlRel,
242   MetaData,
243   Constant,
244   RegRelAliasIndir,
245   Max
246 };
247
248 /// These values correspond to the UdtKind enumeration, and are documented
249 /// here: https://msdn.microsoft.com/en-us/library/wcstk66t.aspx
250 enum class PDB_UdtType { Struct, Class, Union, Interface };
251
252 /// These values correspond to the StackFrameTypeEnum enumeration, and are
253 /// documented here: https://msdn.microsoft.com/en-us/library/bc5207xw.aspx.
254 enum class PDB_StackFrameType : uint16_t {
255   FPO,
256   KernelTrap,
257   KernelTSS,
258   EBP,
259   FrameData,
260   Unknown = 0xffff
261 };
262
263 /// These values correspond to the MemoryTypeEnum enumeration, and are
264 /// documented here: https://msdn.microsoft.com/en-us/library/ms165609.aspx.
265 enum class PDB_MemoryType : uint16_t {
266   Code,
267   Data,
268   Stack,
269   HeapCode,
270   Any = 0xffff
271 };
272
273 /// These values correspond to the Basictype enumeration, and are documented
274 /// here: https://msdn.microsoft.com/en-us/library/4szdtzc3.aspx
275 enum class PDB_BuiltinType {
276   None = 0,
277   Void = 1,
278   Char = 2,
279   WCharT = 3,
280   Int = 6,
281   UInt = 7,
282   Float = 8,
283   BCD = 9,
284   Bool = 10,
285   Long = 13,
286   ULong = 14,
287   Currency = 25,
288   Date = 26,
289   Variant = 27,
290   Complex = 28,
291   Bitfield = 29,
292   BSTR = 30,
293   HResult = 31,
294   Char16 = 32,
295   Char32 = 33
296 };
297
298 /// These values correspond to the flags that can be combined to control the
299 /// return of an undecorated name for a C++ decorated name, and are documented
300 /// here: https://msdn.microsoft.com/en-us/library/kszfk0fs.aspx
301 enum PDB_UndnameFlags : uint32_t {
302   Undname_Complete = 0x0,
303   Undname_NoLeadingUnderscores = 0x1,
304   Undname_NoMsKeywords = 0x2,
305   Undname_NoFuncReturns = 0x4,
306   Undname_NoAllocModel = 0x8,
307   Undname_NoAllocLang = 0x10,
308   Undname_Reserved1 = 0x20,
309   Undname_Reserved2 = 0x40,
310   Undname_NoThisType = 0x60,
311   Undname_NoAccessSpec = 0x80,
312   Undname_NoThrowSig = 0x100,
313   Undname_NoMemberType = 0x200,
314   Undname_NoReturnUDTModel = 0x400,
315   Undname_32BitDecode = 0x800,
316   Undname_NameOnly = 0x1000,
317   Undname_TypeOnly = 0x2000,
318   Undname_HaveParams = 0x4000,
319   Undname_NoECSU = 0x8000,
320   Undname_NoIdentCharCheck = 0x10000,
321   Undname_NoPTR64 = 0x20000
322 };
323
324 enum class PDB_MemberAccess { Private = 1, Protected = 2, Public = 3 };
325
326 struct VersionInfo {
327   uint32_t Major;
328   uint32_t Minor;
329   uint32_t Build;
330   uint32_t QFE;
331 };
332
333 enum PDB_VariantType {
334   Empty,
335   Unknown,
336   Int8,
337   Int16,
338   Int32,
339   Int64,
340   Single,
341   Double,
342   UInt8,
343   UInt16,
344   UInt32,
345   UInt64,
346   Bool,
347   String
348 };
349
350 struct Variant {
351   Variant() = default;
352
353   explicit Variant(bool V) : Type(PDB_VariantType::Bool) { Value.Bool = V; }
354   explicit Variant(int8_t V) : Type(PDB_VariantType::Int8) { Value.Int8 = V; }
355   explicit Variant(int16_t V) : Type(PDB_VariantType::Int16) {
356     Value.Int16 = V;
357   }
358   explicit Variant(int32_t V) : Type(PDB_VariantType::Int32) {
359     Value.Int32 = V;
360   }
361   explicit Variant(int64_t V) : Type(PDB_VariantType::Int64) {
362     Value.Int64 = V;
363   }
364   explicit Variant(float V) : Type(PDB_VariantType::Single) {
365     Value.Single = V;
366   }
367   explicit Variant(double V) : Type(PDB_VariantType::Double) {
368     Value.Double = V;
369   }
370   explicit Variant(uint8_t V) : Type(PDB_VariantType::UInt8) {
371     Value.UInt8 = V;
372   }
373   explicit Variant(uint16_t V) : Type(PDB_VariantType::UInt16) {
374     Value.UInt16 = V;
375   }
376   explicit Variant(uint32_t V) : Type(PDB_VariantType::UInt32) {
377     Value.UInt32 = V;
378   }
379   explicit Variant(uint64_t V) : Type(PDB_VariantType::UInt64) {
380     Value.UInt64 = V;
381   }
382
383   Variant(const Variant &Other) {
384     *this = Other;
385   }
386
387   ~Variant() {
388     if (Type == PDB_VariantType::String)
389       delete[] Value.String;
390   }
391
392   PDB_VariantType Type = PDB_VariantType::Empty;
393   union {
394     bool Bool;
395     int8_t Int8;
396     int16_t Int16;
397     int32_t Int32;
398     int64_t Int64;
399     float Single;
400     double Double;
401     uint8_t UInt8;
402     uint16_t UInt16;
403     uint32_t UInt32;
404     uint64_t UInt64;
405     char *String;
406   } Value;
407
408 #define VARIANT_EQUAL_CASE(Enum)                                               \
409   case PDB_VariantType::Enum:                                                  \
410     return Value.Enum == Other.Value.Enum;
411
412   bool operator==(const Variant &Other) const {
413     if (Type != Other.Type)
414       return false;
415     switch (Type) {
416       VARIANT_EQUAL_CASE(Bool)
417       VARIANT_EQUAL_CASE(Int8)
418       VARIANT_EQUAL_CASE(Int16)
419       VARIANT_EQUAL_CASE(Int32)
420       VARIANT_EQUAL_CASE(Int64)
421       VARIANT_EQUAL_CASE(Single)
422       VARIANT_EQUAL_CASE(Double)
423       VARIANT_EQUAL_CASE(UInt8)
424       VARIANT_EQUAL_CASE(UInt16)
425       VARIANT_EQUAL_CASE(UInt32)
426       VARIANT_EQUAL_CASE(UInt64)
427       VARIANT_EQUAL_CASE(String)
428     default:
429       return true;
430     }
431   }
432
433 #undef VARIANT_EQUAL_CASE
434
435   bool operator!=(const Variant &Other) const { return !(*this == Other); }
436   Variant &operator=(const Variant &Other) {
437     if (this == &Other)
438       return *this;
439     if (Type == PDB_VariantType::String)
440       delete[] Value.String;
441     Type = Other.Type;
442     Value = Other.Value;
443     if (Other.Type == PDB_VariantType::String &&
444         Other.Value.String != nullptr) {
445       Value.String = new char[strlen(Other.Value.String) + 1];
446       ::strcpy(Value.String, Other.Value.String);
447     }
448     return *this;
449   }
450 };
451
452 } // end namespace pdb
453 } // end namespace llvm
454
455 namespace std {
456
457 template <> struct hash<llvm::pdb::PDB_SymType> {
458   using argument_type = llvm::pdb::PDB_SymType;
459   using result_type = std::size_t;
460
461   result_type operator()(const argument_type &Arg) const {
462     return std::hash<int>()(static_cast<int>(Arg));
463   }
464 };
465
466 } // end namespace std
467
468 #endif // LLVM_DEBUGINFO_PDB_PDBTYPES_H