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