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