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