]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/DebugInfo/CodeView/CodeView.h
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r304222, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / DebugInfo / CodeView / CodeView.h
1 //===- CodeView.h -----------------------------------------------*- C++ -*-===//
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_CODEVIEW_CODEVIEW_H
11 #define LLVM_DEBUGINFO_CODEVIEW_CODEVIEW_H
12
13 #include <cinttypes>
14 #include <type_traits>
15
16 #include "llvm/Support/Endian.h"
17
18 namespace llvm {
19 namespace codeview {
20
21 /// Distinguishes individual records in .debug$T section or PDB type stream. The
22 /// documentation and headers talk about this as the "leaf" type.
23 enum class TypeRecordKind : uint16_t {
24 #define TYPE_RECORD(lf_ename, value, name) name = value,
25 #include "TypeRecords.def"
26 };
27
28 /// Duplicate copy of the above enum, but using the official CV names. Useful
29 /// for reference purposes and when dealing with unknown record types.
30 enum TypeLeafKind : uint16_t {
31 #define CV_TYPE(name, val) name = val,
32 #include "TypeRecords.def"
33 };
34
35 /// Distinguishes individual records in the Symbols subsection of a .debug$S
36 /// section. Equivalent to SYM_ENUM_e in cvinfo.h.
37 enum class SymbolRecordKind : uint16_t {
38 #define SYMBOL_RECORD(lf_ename, value, name) name = value,
39 #include "CVSymbolTypes.def"
40 };
41
42 /// Duplicate copy of the above enum, but using the official CV names. Useful
43 /// for reference purposes and when dealing with unknown record types.
44 enum SymbolKind : uint16_t {
45 #define CV_SYMBOL(name, val) name = val,
46 #include "CVSymbolTypes.def"
47 };
48
49 #define CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(Class)                            \
50   inline Class operator|(Class a, Class b) {                                   \
51     return static_cast<Class>(                                                 \
52         static_cast<std::underlying_type<Class>::type>(a) |                    \
53         static_cast<std::underlying_type<Class>::type>(b));                    \
54   }                                                                            \
55   inline Class operator&(Class a, Class b) {                                   \
56     return static_cast<Class>(                                                 \
57         static_cast<std::underlying_type<Class>::type>(a) &                    \
58         static_cast<std::underlying_type<Class>::type>(b));                    \
59   }                                                                            \
60   inline Class operator~(Class a) {                                            \
61     return static_cast<Class>(                                                 \
62         ~static_cast<std::underlying_type<Class>::type>(a));                   \
63   }                                                                            \
64   inline Class &operator|=(Class &a, Class b) {                                \
65     a = a | b;                                                                 \
66     return a;                                                                  \
67   }                                                                            \
68   inline Class &operator&=(Class &a, Class b) {                                \
69     a = a & b;                                                                 \
70     return a;                                                                  \
71   }
72
73 /// These values correspond to the CV_CPU_TYPE_e enumeration, and are documented
74 /// here: https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
75 enum class CPUType : uint16_t {
76   Intel8080 = 0x0,
77   Intel8086 = 0x1,
78   Intel80286 = 0x2,
79   Intel80386 = 0x3,
80   Intel80486 = 0x4,
81   Pentium = 0x5,
82   PentiumPro = 0x6,
83   Pentium3 = 0x7,
84   MIPS = 0x10,
85   MIPS16 = 0x11,
86   MIPS32 = 0x12,
87   MIPS64 = 0x13,
88   MIPSI = 0x14,
89   MIPSII = 0x15,
90   MIPSIII = 0x16,
91   MIPSIV = 0x17,
92   MIPSV = 0x18,
93   M68000 = 0x20,
94   M68010 = 0x21,
95   M68020 = 0x22,
96   M68030 = 0x23,
97   M68040 = 0x24,
98   Alpha = 0x30,
99   Alpha21164 = 0x31,
100   Alpha21164A = 0x32,
101   Alpha21264 = 0x33,
102   Alpha21364 = 0x34,
103   PPC601 = 0x40,
104   PPC603 = 0x41,
105   PPC604 = 0x42,
106   PPC620 = 0x43,
107   PPCFP = 0x44,
108   PPCBE = 0x45,
109   SH3 = 0x50,
110   SH3E = 0x51,
111   SH3DSP = 0x52,
112   SH4 = 0x53,
113   SHMedia = 0x54,
114   ARM3 = 0x60,
115   ARM4 = 0x61,
116   ARM4T = 0x62,
117   ARM5 = 0x63,
118   ARM5T = 0x64,
119   ARM6 = 0x65,
120   ARM_XMAC = 0x66,
121   ARM_WMMX = 0x67,
122   ARM7 = 0x68,
123   Omni = 0x70,
124   Ia64 = 0x80,
125   Ia64_2 = 0x81,
126   CEE = 0x90,
127   AM33 = 0xa0,
128   M32R = 0xb0,
129   TriCore = 0xc0,
130   X64 = 0xd0,
131   EBC = 0xe0,
132   Thumb = 0xf0,
133   ARMNT = 0xf4,
134   D3D11_Shader = 0x100,
135 };
136
137 /// These values correspond to the CV_CFL_LANG enumeration, and are documented
138 /// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx
139 enum SourceLanguage : uint8_t {
140   C = 0x00,
141   Cpp = 0x01,
142   Fortran = 0x02,
143   Masm = 0x03,
144   Pascal = 0x04,
145   Basic = 0x05,
146   Cobol = 0x06,
147   Link = 0x07,
148   Cvtres = 0x08,
149   Cvtpgd = 0x09,
150   CSharp = 0x0a,
151   VB = 0x0b,
152   ILAsm = 0x0c,
153   Java = 0x0d,
154   JScript = 0x0e,
155   MSIL = 0x0f,
156   HLSL = 0x10
157 };
158
159 /// These values correspond to the CV_call_e enumeration, and are documented
160 /// at the following locations:
161 ///   https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
162 ///   https://msdn.microsoft.com/en-us/library/windows/desktop/ms680207(v=vs.85).aspx
163 ///
164 enum class CallingConvention : uint8_t {
165   NearC = 0x00,       // near right to left push, caller pops stack
166   FarC = 0x01,        // far right to left push, caller pops stack
167   NearPascal = 0x02,  // near left to right push, callee pops stack
168   FarPascal = 0x03,   // far left to right push, callee pops stack
169   NearFast = 0x04,    // near left to right push with regs, callee pops stack
170   FarFast = 0x05,     // far left to right push with regs, callee pops stack
171   NearStdCall = 0x07, // near standard call
172   FarStdCall = 0x08,  // far standard call
173   NearSysCall = 0x09, // near sys call
174   FarSysCall = 0x0a,  // far sys call
175   ThisCall = 0x0b,    // this call (this passed in register)
176   MipsCall = 0x0c,    // Mips call
177   Generic = 0x0d,     // Generic call sequence
178   AlphaCall = 0x0e,   // Alpha call
179   PpcCall = 0x0f,     // PPC call
180   SHCall = 0x10,      // Hitachi SuperH call
181   ArmCall = 0x11,     // ARM call
182   AM33Call = 0x12,    // AM33 call
183   TriCall = 0x13,     // TriCore Call
184   SH5Call = 0x14,     // Hitachi SuperH-5 call
185   M32RCall = 0x15,    // M32R Call
186   ClrCall = 0x16,     // clr call
187   Inline =
188       0x17, // Marker for routines always inlined and thus lacking a convention
189   NearVector = 0x18 // near left to right push with regs, callee pops stack
190 };
191
192 enum class ClassOptions : uint16_t {
193   None = 0x0000,
194   Packed = 0x0001,
195   HasConstructorOrDestructor = 0x0002,
196   HasOverloadedOperator = 0x0004,
197   Nested = 0x0008,
198   ContainsNestedClass = 0x0010,
199   HasOverloadedAssignmentOperator = 0x0020,
200   HasConversionOperator = 0x0040,
201   ForwardReference = 0x0080,
202   Scoped = 0x0100,
203   HasUniqueName = 0x0200,
204   Sealed = 0x0400,
205   Intrinsic = 0x2000
206 };
207 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ClassOptions)
208
209 enum class FrameProcedureOptions : uint32_t {
210   None = 0x00000000,
211   HasAlloca = 0x00000001,
212   HasSetJmp = 0x00000002,
213   HasLongJmp = 0x00000004,
214   HasInlineAssembly = 0x00000008,
215   HasExceptionHandling = 0x00000010,
216   MarkedInline = 0x00000020,
217   HasStructuredExceptionHandling = 0x00000040,
218   Naked = 0x00000080,
219   SecurityChecks = 0x00000100,
220   AsynchronousExceptionHandling = 0x00000200,
221   NoStackOrderingForSecurityChecks = 0x00000400,
222   Inlined = 0x00000800,
223   StrictSecurityChecks = 0x00001000,
224   SafeBuffers = 0x00002000,
225   ProfileGuidedOptimization = 0x00040000,
226   ValidProfileCounts = 0x00080000,
227   OptimizedForSpeed = 0x00100000,
228   GuardCfg = 0x00200000,
229   GuardCfw = 0x00400000
230 };
231 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(FrameProcedureOptions)
232
233 enum class FunctionOptions : uint8_t {
234   None = 0x00,
235   CxxReturnUdt = 0x01,
236   Constructor = 0x02,
237   ConstructorWithVirtualBases = 0x04
238 };
239 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(FunctionOptions)
240
241 enum class HfaKind : uint8_t {
242   None = 0x00,
243   Float = 0x01,
244   Double = 0x02,
245   Other = 0x03
246 };
247
248 /// Source-level access specifier. (CV_access_e)
249 enum class MemberAccess : uint8_t {
250   None = 0,
251   Private = 1,
252   Protected = 2,
253   Public = 3
254 };
255
256 /// Part of member attribute flags. (CV_methodprop_e)
257 enum class MethodKind : uint8_t {
258   Vanilla = 0x00,
259   Virtual = 0x01,
260   Static = 0x02,
261   Friend = 0x03,
262   IntroducingVirtual = 0x04,
263   PureVirtual = 0x05,
264   PureIntroducingVirtual = 0x06
265 };
266
267 /// Equivalent to CV_fldattr_t bitfield.
268 enum class MethodOptions : uint16_t {
269   None = 0x0000,
270   AccessMask = 0x0003,
271   MethodKindMask = 0x001c,
272   Pseudo = 0x0020,
273   NoInherit = 0x0040,
274   NoConstruct = 0x0080,
275   CompilerGenerated = 0x0100,
276   Sealed = 0x0200
277 };
278 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(MethodOptions)
279
280 /// Equivalent to CV_LABEL_TYPE_e.
281 enum class LabelType : uint16_t {
282   Near = 0x0,
283   Far  = 0x4,
284 };
285
286 /// Equivalent to CV_modifier_t.
287 /// TODO: Add flag for _Atomic modifier
288 enum class ModifierOptions : uint16_t {
289   None = 0x0000,
290   Const = 0x0001,
291   Volatile = 0x0002,
292   Unaligned = 0x0004
293 };
294 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ModifierOptions)
295
296 enum class DebugSubsectionKind : uint32_t {
297   None = 0,
298   Symbols = 0xf1,
299   Lines = 0xf2,
300   StringTable = 0xf3,
301   FileChecksums = 0xf4,
302   FrameData = 0xf5,
303   InlineeLines = 0xf6,
304   CrossScopeImports = 0xf7,
305   CrossScopeExports = 0xf8,
306
307   // These appear to relate to .Net assembly info.
308   ILLines = 0xf9,
309   FuncMDTokenMap = 0xfa,
310   TypeMDTokenMap = 0xfb,
311   MergedAssemblyInput = 0xfc,
312
313   CoffSymbolRVA = 0xfd,
314 };
315
316 /// Equivalent to CV_ptrtype_e.
317 enum class PointerKind : uint8_t {
318   Near16 = 0x00,                // 16 bit pointer
319   Far16 = 0x01,                 // 16:16 far pointer
320   Huge16 = 0x02,                // 16:16 huge pointer
321   BasedOnSegment = 0x03,        // based on segment
322   BasedOnValue = 0x04,          // based on value of base
323   BasedOnSegmentValue = 0x05,   // based on segment value of base
324   BasedOnAddress = 0x06,        // based on address of base
325   BasedOnSegmentAddress = 0x07, // based on segment address of base
326   BasedOnType = 0x08,           // based on type
327   BasedOnSelf = 0x09,           // based on self
328   Near32 = 0x0a,                // 32 bit pointer
329   Far32 = 0x0b,                 // 16:32 pointer
330   Near64 = 0x0c                 // 64 bit pointer
331 };
332
333 /// Equivalent to CV_ptrmode_e.
334 enum class PointerMode : uint8_t {
335   Pointer = 0x00,                 // "normal" pointer
336   LValueReference = 0x01,         // "old" reference
337   PointerToDataMember = 0x02,     // pointer to data member
338   PointerToMemberFunction = 0x03, // pointer to member function
339   RValueReference = 0x04          // r-value reference
340 };
341
342 /// Equivalent to misc lfPointerAttr bitfields.
343 enum class PointerOptions : uint32_t {
344   None = 0x00000000,
345   Flat32 = 0x00000100,
346   Volatile = 0x00000200,
347   Const = 0x00000400,
348   Unaligned = 0x00000800,
349   Restrict = 0x00001000,
350   WinRTSmartPointer = 0x00080000
351 };
352 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(PointerOptions)
353
354 /// Equivalent to CV_pmtype_e.
355 enum class PointerToMemberRepresentation : uint16_t {
356   Unknown = 0x00,                     // not specified (pre VC8)
357   SingleInheritanceData = 0x01,       // member data, single inheritance
358   MultipleInheritanceData = 0x02,     // member data, multiple inheritance
359   VirtualInheritanceData = 0x03,      // member data, virtual inheritance
360   GeneralData = 0x04,                 // member data, most general
361   SingleInheritanceFunction = 0x05,   // member function, single inheritance
362   MultipleInheritanceFunction = 0x06, // member function, multiple inheritance
363   VirtualInheritanceFunction = 0x07,  // member function, virtual inheritance
364   GeneralFunction = 0x08              // member function, most general
365 };
366
367 enum class VFTableSlotKind : uint8_t {
368   Near16 = 0x00,
369   Far16 = 0x01,
370   This = 0x02,
371   Outer = 0x03,
372   Meta = 0x04,
373   Near = 0x05,
374   Far = 0x06
375 };
376
377 enum class WindowsRTClassKind : uint8_t {
378   None = 0x00,
379   RefClass = 0x01,
380   ValueClass = 0x02,
381   Interface = 0x03
382 };
383
384 /// Corresponds to CV_LVARFLAGS bitfield.
385 enum class LocalSymFlags : uint16_t {
386   None = 0,
387   IsParameter = 1 << 0,
388   IsAddressTaken = 1 << 1,
389   IsCompilerGenerated = 1 << 2,
390   IsAggregate = 1 << 3,
391   IsAggregated = 1 << 4,
392   IsAliased = 1 << 5,
393   IsAlias = 1 << 6,
394   IsReturnValue = 1 << 7,
395   IsOptimizedOut = 1 << 8,
396   IsEnregisteredGlobal = 1 << 9,
397   IsEnregisteredStatic = 1 << 10,
398 };
399 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(LocalSymFlags)
400
401 /// Corresponds to the CV_PROCFLAGS bitfield.
402 enum class ProcSymFlags : uint8_t {
403   None = 0,
404   HasFP = 1 << 0,
405   HasIRET = 1 << 1,
406   HasFRET = 1 << 2,
407   IsNoReturn = 1 << 3,
408   IsUnreachable = 1 << 4,
409   HasCustomCallingConv = 1 << 5,
410   IsNoInline = 1 << 6,
411   HasOptimizedDebugInfo = 1 << 7,
412 };
413 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ProcSymFlags)
414
415 /// Corresponds to COMPILESYM2::Flags bitfield.
416 enum class CompileSym2Flags : uint32_t {
417   EC = 1 << 8,
418   NoDbgInfo = 1 << 9,
419   LTCG = 1 << 10,
420   NoDataAlign = 1 << 11,
421   ManagedPresent = 1 << 12,
422   SecurityChecks = 1 << 13,
423   HotPatch = 1 << 14,
424   CVTCIL = 1 << 15,
425   MSILModule = 1 << 16,
426 };
427 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(CompileSym2Flags)
428
429 /// Corresponds to COMPILESYM3::Flags bitfield.
430 enum class CompileSym3Flags : uint32_t {
431   EC = 1 << 8,
432   NoDbgInfo = 1 << 9,
433   LTCG = 1 << 10,
434   NoDataAlign = 1 << 11,
435   ManagedPresent = 1 << 12,
436   SecurityChecks = 1 << 13,
437   HotPatch = 1 << 14,
438   CVTCIL = 1 << 15,
439   MSILModule = 1 << 16,
440   Sdl = 1 << 17,
441   PGO = 1 << 18,
442   Exp = 1 << 19,
443 };
444 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(CompileSym3Flags)
445
446 enum class ExportFlags : uint16_t {
447   IsConstant = 1 << 0,
448   IsData = 1 << 1,
449   IsPrivate = 1 << 2,
450   HasNoName = 1 << 3,
451   HasExplicitOrdinal = 1 << 4,
452   IsForwarder = 1 << 5
453 };
454 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ExportFlags)
455
456 // Corresponds to BinaryAnnotationOpcode enum.
457 enum class BinaryAnnotationsOpCode : uint32_t {
458   Invalid,
459   CodeOffset,
460   ChangeCodeOffsetBase,
461   ChangeCodeOffset,
462   ChangeCodeLength,
463   ChangeFile,
464   ChangeLineOffset,
465   ChangeLineEndDelta,
466   ChangeRangeKind,
467   ChangeColumnStart,
468   ChangeColumnEndDelta,
469   ChangeCodeOffsetAndLineOffset,
470   ChangeCodeLengthAndCodeOffset,
471   ChangeColumnEnd,
472 };
473
474 // Corresponds to CV_cookietype_e enum.
475 enum class FrameCookieKind : uint8_t {
476   Copy,
477   XorStackPointer,
478   XorFramePointer,
479   XorR13,
480 };
481
482 // Corresponds to CV_HREG_e enum.
483 enum class RegisterId : uint16_t {
484   Unknown = 0,
485   VFrame = 30006,
486   AL = 1,
487   CL = 2,
488   DL = 3,
489   BL = 4,
490   AH = 5,
491   CH = 6,
492   DH = 7,
493   BH = 8,
494   AX = 9,
495   CX = 10,
496   DX = 11,
497   BX = 12,
498   SP = 13,
499   BP = 14,
500   SI = 15,
501   DI = 16,
502   EAX = 17,
503   ECX = 18,
504   EDX = 19,
505   EBX = 20,
506   ESP = 21,
507   EBP = 22,
508   ESI = 23,
509   EDI = 24,
510   ES = 25,
511   CS = 26,
512   SS = 27,
513   DS = 28,
514   FS = 29,
515   GS = 30,
516   IP = 31,
517   RAX = 328,
518   RBX = 329,
519   RCX = 330,
520   RDX = 331,
521   RSI = 332,
522   RDI = 333,
523   RBP = 334,
524   RSP = 335,
525   R8 = 336,
526   R9 = 337,
527   R10 = 338,
528   R11 = 339,
529   R12 = 340,
530   R13 = 341,
531   R14 = 342,
532   R15 = 343,
533 };
534
535 /// These values correspond to the THUNK_ORDINAL enumeration.
536 enum class ThunkOrdinal : uint8_t {
537   Standard,
538   ThisAdjustor,
539   Vcall,
540   Pcode,
541   UnknownLoad,
542   TrampIncremental,
543   BranchIsland
544 };
545
546 enum class TrampolineType : uint16_t { TrampIncremental, BranchIsland };
547
548 // These values correspond to the CV_SourceChksum_t enumeration.
549 enum class FileChecksumKind : uint8_t { None, MD5, SHA1, SHA256 };
550
551 enum LineFlags : uint16_t {
552   LF_None = 0,
553   LF_HaveColumns = 1, // CV_LINES_HAVE_COLUMNS
554 };
555
556 /// Data in the the SUBSEC_FRAMEDATA subection.
557 struct FrameData {
558   support::ulittle32_t RvaStart;
559   support::ulittle32_t CodeSize;
560   support::ulittle32_t LocalSize;
561   support::ulittle32_t ParamsSize;
562   support::ulittle32_t MaxStackSize;
563   support::ulittle32_t FrameFunc;
564   support::ulittle16_t PrologSize;
565   support::ulittle16_t SavedRegsSize;
566   support::ulittle32_t Flags;
567   enum : uint32_t {
568     HasSEH = 1 << 0,
569     HasEH = 1 << 1,
570     IsFunctionStart = 1 << 2,
571   };
572 };
573 }
574 }
575
576 #endif