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