LLVM 24.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
17#include <cinttypes>
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};
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,
82 Pentium = 0x5,
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,
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,
137 ARM64EC = 0xf8,
138 ARM64X = 0xf9,
139 Unknown = 0xff,
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#define CV_LANGUAGE(NAME, ID) NAME = ID,
148#include "CodeViewLanguages.def"
149};
150
151/// These values correspond to the CV_call_e enumeration, and are documented
152/// at the following locations:
153/// https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx
154/// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680207(v=vs.85).aspx
155///
157 NearC = 0x00, // near right to left push, caller pops stack
158 FarC = 0x01, // far right to left push, caller pops stack
159 NearPascal = 0x02, // near left to right push, callee pops stack
160 FarPascal = 0x03, // far left to right push, callee pops stack
161 NearFast = 0x04, // near left to right push with regs, callee pops stack
162 FarFast = 0x05, // far left to right push with regs, callee pops stack
163 NearStdCall = 0x07, // near standard call
164 FarStdCall = 0x08, // far standard call
165 NearSysCall = 0x09, // near sys call
166 FarSysCall = 0x0a, // far sys call
167 ThisCall = 0x0b, // this call (this passed in register)
168 MipsCall = 0x0c, // Mips call
169 Generic = 0x0d, // Generic call sequence
170 AlphaCall = 0x0e, // Alpha call
171 PpcCall = 0x0f, // PPC call
172 SHCall = 0x10, // Hitachi SuperH call
173 ArmCall = 0x11, // ARM call
174 AM33Call = 0x12, // AM33 call
175 TriCall = 0x13, // TriCore Call
176 SH5Call = 0x14, // Hitachi SuperH-5 call
177 M32RCall = 0x15, // M32R Call
178 ClrCall = 0x16, // clr call
180 0x17, // Marker for routines always inlined and thus lacking a convention
181 NearVector = 0x18, // near left to right push with regs, callee pops stack
182 Swift = 0x19, // Swift call
183};
184
201
228CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(FrameProcedureOptions)
229
237
238enum class HfaKind : uint8_t {
239 None = 0x00,
240 Float = 0x01,
241 Double = 0x02,
242 Other = 0x03
243};
244
245/// Source-level access specifier. (CV_access_e)
246enum class MemberAccess : uint8_t {
247 None = 0,
251};
252
253/// Part of member attribute flags. (CV_methodprop_e)
254enum class MethodKind : uint8_t {
255 Vanilla = 0x00,
256 Virtual = 0x01,
257 Static = 0x02,
258 Friend = 0x03,
262};
263
264/// Equivalent to CV_fldattr_t bitfield.
266 None = 0x0000,
267 AccessMask = 0x0003,
269 Pseudo = 0x0020,
270 NoInherit = 0x0040,
271 NoConstruct = 0x0080,
273 Sealed = 0x0200
274};
276
277/// Equivalent to CV_LABEL_TYPE_e.
278enum class LabelType : uint16_t {
279 Near = 0x0,
280 Far = 0x4,
281};
282
283/// Equivalent to CV_modifier_t.
284/// TODO: Add flag for _Atomic modifier
286 None = 0x0000,
287 Const = 0x0001,
288 Volatile = 0x0002,
289 Unaligned = 0x0004
290};
292
293// If the subsection kind has this bit set, then the linker should ignore it.
294enum : uint32_t { SubsectionIgnoreFlag = 0x80000000 };
295
297 None = 0,
298 Symbols = 0xf1,
299 Lines = 0xf2,
302 FrameData = 0xf5,
306
307 // These appear to relate to .Net assembly info.
308 ILLines = 0xf9,
312
314
317};
318
319/// Equivalent to CV_ptrtype_e.
320enum class PointerKind : uint8_t {
321 Near16 = 0x00, // 16 bit pointer
322 Far16 = 0x01, // 16:16 far pointer
323 Huge16 = 0x02, // 16:16 huge pointer
324 BasedOnSegment = 0x03, // based on segment
325 BasedOnValue = 0x04, // based on value of base
326 BasedOnSegmentValue = 0x05, // based on segment value of base
327 BasedOnAddress = 0x06, // based on address of base
328 BasedOnSegmentAddress = 0x07, // based on segment address of base
329 BasedOnType = 0x08, // based on type
330 BasedOnSelf = 0x09, // based on self
331 Near32 = 0x0a, // 32 bit pointer
332 Far32 = 0x0b, // 16:32 pointer
333 Near64 = 0x0c // 64 bit pointer
334};
335
336/// Equivalent to CV_ptrmode_e.
337enum class PointerMode : uint8_t {
338 Pointer = 0x00, // "normal" pointer
339 LValueReference = 0x01, // "old" reference
340 PointerToDataMember = 0x02, // pointer to data member
341 PointerToMemberFunction = 0x03, // pointer to member function
342 RValueReference = 0x04 // r-value reference
343};
344
345/// Equivalent to misc lfPointerAttr bitfields.
347 None = 0x00000000,
348 Flat32 = 0x00000100,
349 Volatile = 0x00000200,
350 Const = 0x00000400,
351 Unaligned = 0x00000800,
352 Restrict = 0x00001000,
353 WinRTSmartPointer = 0x00080000,
356};
358
359/// Equivalent to CV_pmtype_e.
361 Unknown = 0x00, // not specified (pre VC8)
362 SingleInheritanceData = 0x01, // member data, single inheritance
363 MultipleInheritanceData = 0x02, // member data, multiple inheritance
364 VirtualInheritanceData = 0x03, // member data, virtual inheritance
365 GeneralData = 0x04, // member data, most general
366 SingleInheritanceFunction = 0x05, // member function, single inheritance
367 MultipleInheritanceFunction = 0x06, // member function, multiple inheritance
368 VirtualInheritanceFunction = 0x07, // member function, virtual inheritance
369 GeneralFunction = 0x08 // member function, most general
370};
371
373 Near16 = 0x00,
374 Far16 = 0x01,
375 This = 0x02,
376 Outer = 0x03,
377 Meta = 0x04,
378 Near = 0x05,
379 Far = 0x06
380};
381
383 None = 0x00,
384 RefClass = 0x01,
387};
388
389/// Corresponds to CV_LVARFLAGS bitfield.
405
406/// Corresponds to the CV_PUBSYMFLAGS bitfield.
408 None = 0,
409 Code = 1 << 0,
410 Function = 1 << 1,
411 Managed = 1 << 2,
412 MSIL = 1 << 3,
413};
415
416/// Corresponds to the CV_PROCFLAGS bitfield.
417enum class ProcSymFlags : uint8_t {
418 None = 0,
419 HasFP = 1 << 0,
420 HasIRET = 1 << 1,
421 HasFRET = 1 << 2,
422 IsNoReturn = 1 << 3,
425 IsNoInline = 1 << 6,
427};
429
430/// Corresponds to COMPILESYM2::Flags bitfield.
432 None = 0,
434 EC = 1 << 8,
435 NoDbgInfo = 1 << 9,
436 LTCG = 1 << 10,
437 NoDataAlign = 1 << 11,
438 ManagedPresent = 1 << 12,
439 SecurityChecks = 1 << 13,
440 HotPatch = 1 << 14,
441 CVTCIL = 1 << 15,
442 MSILModule = 1 << 16,
443};
445
446/// Corresponds to COMPILESYM3::Flags bitfield.
448 None = 0,
450 EC = 1 << 8,
451 NoDbgInfo = 1 << 9,
452 LTCG = 1 << 10,
453 NoDataAlign = 1 << 11,
454 ManagedPresent = 1 << 12,
455 SecurityChecks = 1 << 13,
456 HotPatch = 1 << 14,
457 CVTCIL = 1 << 15,
458 MSILModule = 1 << 16,
459 Sdl = 1 << 17,
460 PGO = 1 << 18,
461 Exp = 1 << 19,
462};
464
465enum class ExportFlags : uint16_t {
466 None = 0,
467 IsConstant = 1 << 0,
468 IsData = 1 << 1,
469 IsPrivate = 1 << 2,
470 HasNoName = 1 << 3,
472 IsForwarder = 1 << 5
473};
475
476// Corresponds to BinaryAnnotationOpcode enum.
493
494// Corresponds to CV_cookietype_e enum.
501
502// Corresponds to CV_HREG_e enum.
503enum class RegisterId : uint16_t {
504#define CV_REGISTERS_ALL
505#define CV_REGISTER(name, value) name = value,
506#include "CodeViewRegisters.def"
507#undef CV_REGISTER
508#undef CV_REGISTERS_ALL
509};
510
511// Register Ids are shared between architectures in CodeView. CPUType is needed
512// to map register Id to name.
514 CPURegister() = delete;
516 this->Cpu = Cpu;
517 this->Reg = Reg;
518 }
521};
522
523/// Two-bit value indicating which register is the designated frame pointer
524/// register. Appears in the S_FRAMEPROC record flags.
531
532LLVM_ABI RegisterId decodeFramePtrReg(EncodedFramePtrReg EncodedReg,
533 CPUType CPU);
534
535LLVM_ABI EncodedFramePtrReg encodeFramePtrReg(RegisterId Reg, CPUType CPU);
536
537/// These values correspond to the THUNK_ORDINAL enumeration.
547
549
550// These values correspond to the CV_SourceChksum_t enumeration.
552
555 LF_HaveColumns = 1, // CV_LINES_HAVE_COLUMNS
556};
557
558/// Data in the SUBSEC_FRAMEDATA subection.
575
576// Corresponds to LocalIdAndGlobalIdPair structure.
577// This structure information allows cross-referencing between PDBs. For
578// example, when a PDB is being built during compilation it is not yet known
579// what other modules may end up in the PDB at link time. So certain types of
580// IDs may clash between the various compile time PDBs. For each affected
581// module, a subsection would be put into the PDB containing a mapping from its
582// local IDs to a single ID namespace for all items in the PDB file.
587
590 support::ulittle32_t Count; // Number of elements
591 // support::ulittle32_t ids[Count]; // id from referenced module
592};
593
595
597 if (Container == CodeViewContainer::ObjectFile)
598 return 1;
599 return 4;
600}
601
602// Corresponds to CV_armswitchtype enum.
603// This enum represents the different ways that jump tables entries can be
604// encoded to represent the target address to jump to.
605// * Pointer: The absolute address to jump to.
606// * [U]Int[8|16|32]: A value that is added to some "base" address to get the
607// address to jump to.
608// * [U]Int[8|16]ShiftLeft: A value that is shifted left by an implementation
609// specified amount, then added to some "base" address to get the address to
610// jump to.
624
625/// Type of associated symbol in S_ASSOCIATION.
626///
627/// From `CV_AssociationKind_e` (cvconst.h).
630 /// Associated symbol is the primary coroutine function.
632};
633}
634}
635
636#endif
#define CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(Class)
Definition CodeView.h:53
#define LLVM_ABI
Definition Compiler.h:215
Register Reg
This file contains library features backported from future STL versions.
PointerMode
Equivalent to CV_ptrmode_e.
Definition CodeView.h:337
ProcSymFlags
Corresponds to the CV_PROCFLAGS bitfield.
Definition CodeView.h:417
PointerOptions
Equivalent to misc lfPointerAttr bitfields.
Definition CodeView.h:346
LocalSymFlags
Corresponds to CV_LVARFLAGS bitfield.
Definition CodeView.h:390
MethodKind
Part of member attribute flags. (CV_methodprop_e)
Definition CodeView.h:254
CompileSym2Flags
Corresponds to COMPILESYM2::Flags bitfield.
Definition CodeView.h:431
PointerKind
Equivalent to CV_ptrtype_e.
Definition CodeView.h:320
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:447
PointerToMemberRepresentation
Equivalent to CV_pmtype_e.
Definition CodeView.h:360
CallingConvention
These values correspond to the CV_call_e enumeration, and are documented at the following locations: ...
Definition CodeView.h:156
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:596
MethodOptions
Equivalent to CV_fldattr_t bitfield.
Definition CodeView.h:265
AssociationKind
Type of associated symbol in S_ASSOCIATION.
Definition CodeView.h:628
@ Coroutine
Associated symbol is the primary coroutine function.
Definition CodeView.h:631
MemberAccess
Source-level access specifier. (CV_access_e)
Definition CodeView.h:246
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:538
EncodedFramePtrReg
Two-bit value indicating which register is the designated frame pointer register.
Definition CodeView.h:525
LLVM_ABI 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:285
PublicSymFlags
Corresponds to the CV_PUBSYMFLAGS bitfield.
Definition CodeView.h:407
LabelType
Equivalent to CV_LABEL_TYPE_e.
Definition CodeView.h:278
LLVM_ABI 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
detail::packed_endian_specific_integral< uint32_t, llvm::endianness::little, unaligned > ulittle32_t
Definition Endian.h:270
detail::packed_endian_specific_integral< uint16_t, llvm::endianness::little, unaligned > ulittle16_t
Definition Endian.h:267
This is an optimization pass for GlobalISel generic memory operations.
CPURegister(CPUType Cpu, codeview::RegisterId Reg)
Definition CodeView.h:515
support::ulittle32_t Local
Definition CodeView.h:584
support::ulittle32_t Global
Definition CodeView.h:585
support::ulittle32_t Count
Definition CodeView.h:590
support::ulittle32_t ModuleNameOffset
Definition CodeView.h:589
Data in the SUBSEC_FRAMEDATA subection.
Definition CodeView.h:559
support::ulittle16_t PrologSize
Definition CodeView.h:566
support::ulittle32_t ParamsSize
Definition CodeView.h:563
support::ulittle32_t FrameFunc
Definition CodeView.h:565
support::ulittle32_t RvaStart
Definition CodeView.h:560
support::ulittle32_t Flags
Definition CodeView.h:568
support::ulittle32_t LocalSize
Definition CodeView.h:562
support::ulittle32_t CodeSize
Definition CodeView.h:561
support::ulittle16_t SavedRegsSize
Definition CodeView.h:567
support::ulittle32_t MaxStackSize
Definition CodeView.h:564