LLVM 22.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
203 None = 0x00000000,
204 HasAlloca = 0x00000001,
205 HasSetJmp = 0x00000002,
206 HasLongJmp = 0x00000004,
207 HasInlineAssembly = 0x00000008,
209 MarkedInline = 0x00000020,
211 Naked = 0x00000080,
212 SecurityChecks = 0x00000100,
215 Inlined = 0x00000800,
217 SafeBuffers = 0x00002000,
221 ValidProfileCounts = 0x00080000,
222 OptimizedForSpeed = 0x00100000,
223 GuardCfg = 0x00200000,
224 GuardCfw = 0x00400000
225};
226CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(FrameProcedureOptions)
227
235
236enum class HfaKind : uint8_t {
237 None = 0x00,
238 Float = 0x01,
239 Double = 0x02,
240 Other = 0x03
241};
242
243/// Source-level access specifier. (CV_access_e)
244enum class MemberAccess : uint8_t {
245 None = 0,
249};
250
251/// Part of member attribute flags. (CV_methodprop_e)
252enum class MethodKind : uint8_t {
253 Vanilla = 0x00,
254 Virtual = 0x01,
255 Static = 0x02,
256 Friend = 0x03,
260};
261
262/// Equivalent to CV_fldattr_t bitfield.
264 None = 0x0000,
265 AccessMask = 0x0003,
267 Pseudo = 0x0020,
268 NoInherit = 0x0040,
269 NoConstruct = 0x0080,
271 Sealed = 0x0200
272};
274
275/// Equivalent to CV_LABEL_TYPE_e.
276enum class LabelType : uint16_t {
277 Near = 0x0,
278 Far = 0x4,
279};
280
281/// Equivalent to CV_modifier_t.
282/// TODO: Add flag for _Atomic modifier
284 None = 0x0000,
285 Const = 0x0001,
286 Volatile = 0x0002,
287 Unaligned = 0x0004
288};
290
291// If the subsection kind has this bit set, then the linker should ignore it.
292enum : uint32_t { SubsectionIgnoreFlag = 0x80000000 };
293
295 None = 0,
296 Symbols = 0xf1,
297 Lines = 0xf2,
300 FrameData = 0xf5,
304
305 // These appear to relate to .Net assembly info.
306 ILLines = 0xf9,
310
312
315};
316
317/// Equivalent to CV_ptrtype_e.
318enum class PointerKind : uint8_t {
319 Near16 = 0x00, // 16 bit pointer
320 Far16 = 0x01, // 16:16 far pointer
321 Huge16 = 0x02, // 16:16 huge pointer
322 BasedOnSegment = 0x03, // based on segment
323 BasedOnValue = 0x04, // based on value of base
324 BasedOnSegmentValue = 0x05, // based on segment value of base
325 BasedOnAddress = 0x06, // based on address of base
326 BasedOnSegmentAddress = 0x07, // based on segment address of base
327 BasedOnType = 0x08, // based on type
328 BasedOnSelf = 0x09, // based on self
329 Near32 = 0x0a, // 32 bit pointer
330 Far32 = 0x0b, // 16:32 pointer
331 Near64 = 0x0c // 64 bit pointer
332};
333
334/// Equivalent to CV_ptrmode_e.
335enum class PointerMode : uint8_t {
336 Pointer = 0x00, // "normal" pointer
337 LValueReference = 0x01, // "old" reference
338 PointerToDataMember = 0x02, // pointer to data member
339 PointerToMemberFunction = 0x03, // pointer to member function
340 RValueReference = 0x04 // r-value reference
341};
342
343/// Equivalent to misc lfPointerAttr bitfields.
345 None = 0x00000000,
346 Flat32 = 0x00000100,
347 Volatile = 0x00000200,
348 Const = 0x00000400,
349 Unaligned = 0x00000800,
350 Restrict = 0x00001000,
351 WinRTSmartPointer = 0x00080000,
354};
356
357/// Equivalent to CV_pmtype_e.
359 Unknown = 0x00, // not specified (pre VC8)
360 SingleInheritanceData = 0x01, // member data, single inheritance
361 MultipleInheritanceData = 0x02, // member data, multiple inheritance
362 VirtualInheritanceData = 0x03, // member data, virtual inheritance
363 GeneralData = 0x04, // member data, most general
364 SingleInheritanceFunction = 0x05, // member function, single inheritance
365 MultipleInheritanceFunction = 0x06, // member function, multiple inheritance
366 VirtualInheritanceFunction = 0x07, // member function, virtual inheritance
367 GeneralFunction = 0x08 // member function, most general
368};
369
371 Near16 = 0x00,
372 Far16 = 0x01,
373 This = 0x02,
374 Outer = 0x03,
375 Meta = 0x04,
376 Near = 0x05,
377 Far = 0x06
378};
379
381 None = 0x00,
382 RefClass = 0x01,
385};
386
387/// Corresponds to CV_LVARFLAGS bitfield.
403
404/// Corresponds to the CV_PUBSYMFLAGS bitfield.
406 None = 0,
407 Code = 1 << 0,
408 Function = 1 << 1,
409 Managed = 1 << 2,
410 MSIL = 1 << 3,
411};
413
414/// Corresponds to the CV_PROCFLAGS bitfield.
415enum class ProcSymFlags : uint8_t {
416 None = 0,
417 HasFP = 1 << 0,
418 HasIRET = 1 << 1,
419 HasFRET = 1 << 2,
420 IsNoReturn = 1 << 3,
423 IsNoInline = 1 << 6,
425};
427
428/// Corresponds to COMPILESYM2::Flags bitfield.
430 None = 0,
432 EC = 1 << 8,
433 NoDbgInfo = 1 << 9,
434 LTCG = 1 << 10,
435 NoDataAlign = 1 << 11,
436 ManagedPresent = 1 << 12,
437 SecurityChecks = 1 << 13,
438 HotPatch = 1 << 14,
439 CVTCIL = 1 << 15,
440 MSILModule = 1 << 16,
441};
443
444/// Corresponds to COMPILESYM3::Flags bitfield.
446 None = 0,
448 EC = 1 << 8,
449 NoDbgInfo = 1 << 9,
450 LTCG = 1 << 10,
451 NoDataAlign = 1 << 11,
452 ManagedPresent = 1 << 12,
453 SecurityChecks = 1 << 13,
454 HotPatch = 1 << 14,
455 CVTCIL = 1 << 15,
456 MSILModule = 1 << 16,
457 Sdl = 1 << 17,
458 PGO = 1 << 18,
459 Exp = 1 << 19,
460};
462
463enum class ExportFlags : uint16_t {
464 None = 0,
465 IsConstant = 1 << 0,
466 IsData = 1 << 1,
467 IsPrivate = 1 << 2,
468 HasNoName = 1 << 3,
470 IsForwarder = 1 << 5
471};
473
474// Corresponds to BinaryAnnotationOpcode enum.
491
492// Corresponds to CV_cookietype_e enum.
499
500// Corresponds to CV_HREG_e enum.
501enum class RegisterId : uint16_t {
502#define CV_REGISTERS_ALL
503#define CV_REGISTER(name, value) name = value,
504#include "CodeViewRegisters.def"
505#undef CV_REGISTER
506#undef CV_REGISTERS_ALL
507};
508
509// Register Ids are shared between architectures in CodeView. CPUType is needed
510// to map register Id to name.
512 CPURegister() = delete;
514 this->Cpu = Cpu;
515 this->Reg = Reg;
516 }
519};
520
521/// Two-bit value indicating which register is the designated frame pointer
522/// register. Appears in the S_FRAMEPROC record flags.
529
530LLVM_ABI RegisterId decodeFramePtrReg(EncodedFramePtrReg EncodedReg,
531 CPUType CPU);
532
533LLVM_ABI EncodedFramePtrReg encodeFramePtrReg(RegisterId Reg, CPUType CPU);
534
535/// These values correspond to the THUNK_ORDINAL enumeration.
545
547
548// These values correspond to the CV_SourceChksum_t enumeration.
550
553 LF_HaveColumns = 1, // CV_LINES_HAVE_COLUMNS
554};
555
556/// Data in the SUBSEC_FRAMEDATA subection.
573
574// Corresponds to LocalIdAndGlobalIdPair structure.
575// This structure information allows cross-referencing between PDBs. For
576// example, when a PDB is being built during compilation it is not yet known
577// what other modules may end up in the PDB at link time. So certain types of
578// IDs may clash between the various compile time PDBs. For each affected
579// module, a subsection would be put into the PDB containing a mapping from its
580// local IDs to a single ID namespace for all items in the PDB file.
585
588 support::ulittle32_t Count; // Number of elements
589 // support::ulittle32_t ids[Count]; // id from referenced module
590};
591
593
595 if (Container == CodeViewContainer::ObjectFile)
596 return 1;
597 return 4;
598}
599
600// Corresponds to CV_armswitchtype enum.
601// This enum represents the different ways that jump tables entries can be
602// encoded to represent the target address to jump to.
603// * Pointer: The absolute address to jump to.
604// * [U]Int[8|16|32]: A value that is added to some "base" address to get the
605// address to jump to.
606// * [U]Int[8|16]ShiftLeft: A value that is shifted left by an implementation
607// specified amount, then added to some "base" address to get the address to
608// jump to.
622}
623}
624
625#endif
#define CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(Class)
Definition CodeView.h:53
#define LLVM_ABI
Definition Compiler.h:213
Register Reg
This file contains library features backported from future STL versions.
PointerMode
Equivalent to CV_ptrmode_e.
Definition CodeView.h:335
ProcSymFlags
Corresponds to the CV_PROCFLAGS bitfield.
Definition CodeView.h:415
PointerOptions
Equivalent to misc lfPointerAttr bitfields.
Definition CodeView.h:344
LocalSymFlags
Corresponds to CV_LVARFLAGS bitfield.
Definition CodeView.h:388
MethodKind
Part of member attribute flags. (CV_methodprop_e)
Definition CodeView.h:252
CompileSym2Flags
Corresponds to COMPILESYM2::Flags bitfield.
Definition CodeView.h:429
PointerKind
Equivalent to CV_ptrtype_e.
Definition CodeView.h:318
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:445
PointerToMemberRepresentation
Equivalent to CV_pmtype_e.
Definition CodeView.h:358
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:594
MethodOptions
Equivalent to CV_fldattr_t bitfield.
Definition CodeView.h:263
MemberAccess
Source-level access specifier. (CV_access_e)
Definition CodeView.h:244
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:536
EncodedFramePtrReg
Two-bit value indicating which register is the designated frame pointer register.
Definition CodeView.h:523
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:283
PublicSymFlags
Corresponds to the CV_PUBSYMFLAGS bitfield.
Definition CodeView.h:405
LabelType
Equivalent to CV_LABEL_TYPE_e.
Definition CodeView.h:276
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:290
detail::packed_endian_specific_integral< uint16_t, llvm::endianness::little, unaligned > ulittle16_t
Definition Endian.h:287
This is an optimization pass for GlobalISel generic memory operations.
CPURegister(CPUType Cpu, codeview::RegisterId Reg)
Definition CodeView.h:513
support::ulittle32_t Local
Definition CodeView.h:582
support::ulittle32_t Global
Definition CodeView.h:583
support::ulittle32_t Count
Definition CodeView.h:588
support::ulittle32_t ModuleNameOffset
Definition CodeView.h:587
Data in the SUBSEC_FRAMEDATA subection.
Definition CodeView.h:557
support::ulittle16_t PrologSize
Definition CodeView.h:564
support::ulittle32_t ParamsSize
Definition CodeView.h:561
support::ulittle32_t FrameFunc
Definition CodeView.h:563
support::ulittle32_t RvaStart
Definition CodeView.h:558
support::ulittle32_t Flags
Definition CodeView.h:566
support::ulittle32_t LocalSize
Definition CodeView.h:560
support::ulittle32_t CodeSize
Definition CodeView.h:559
support::ulittle16_t SavedRegsSize
Definition CodeView.h:565
support::ulittle32_t MaxStackSize
Definition CodeView.h:562