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