File indexing completed on 2026-05-10 08:43:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEW_H
0014 #define LLVM_DEBUGINFO_CODEVIEW_CODEVIEW_H
0015
0016 #include <cinttypes>
0017 #include <type_traits>
0018
0019 #include "llvm/ADT/STLForwardCompat.h"
0020 #include "llvm/Support/Endian.h"
0021
0022 namespace llvm {
0023 namespace codeview {
0024
0025
0026
0027 enum class TypeRecordKind : uint16_t {
0028 #define TYPE_RECORD(lf_ename, value, name) name = value,
0029 #include "CodeViewTypes.def"
0030 };
0031
0032
0033
0034 enum TypeLeafKind : uint16_t {
0035 #define CV_TYPE(name, val) name = val,
0036 #include "CodeViewTypes.def"
0037 };
0038
0039
0040
0041 enum class SymbolRecordKind : uint16_t {
0042 #define SYMBOL_RECORD(lf_ename, value, name) name = value,
0043 #include "CodeViewSymbols.def"
0044 };
0045
0046
0047
0048 enum SymbolKind : uint16_t {
0049 #define CV_SYMBOL(name, val) name = val,
0050 #include "CodeViewSymbols.def"
0051 };
0052
0053 #define CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(Class) \
0054 inline Class operator|(Class a, Class b) { \
0055 return static_cast<Class>(llvm::to_underlying(a) | \
0056 llvm::to_underlying(b)); \
0057 } \
0058 inline Class operator&(Class a, Class b) { \
0059 return static_cast<Class>(llvm::to_underlying(a) & \
0060 llvm::to_underlying(b)); \
0061 } \
0062 inline Class operator~(Class a) { \
0063 return static_cast<Class>(~llvm::to_underlying(a)); \
0064 } \
0065 inline Class &operator|=(Class &a, Class b) { \
0066 a = a | b; \
0067 return a; \
0068 } \
0069 inline Class &operator&=(Class &a, Class b) { \
0070 a = a & b; \
0071 return a; \
0072 }
0073
0074
0075
0076 enum class CPUType : uint16_t {
0077 Intel8080 = 0x0,
0078 Intel8086 = 0x1,
0079 Intel80286 = 0x2,
0080 Intel80386 = 0x3,
0081 Intel80486 = 0x4,
0082 Pentium = 0x5,
0083 PentiumPro = 0x6,
0084 Pentium3 = 0x7,
0085 MIPS = 0x10,
0086 MIPS16 = 0x11,
0087 MIPS32 = 0x12,
0088 MIPS64 = 0x13,
0089 MIPSI = 0x14,
0090 MIPSII = 0x15,
0091 MIPSIII = 0x16,
0092 MIPSIV = 0x17,
0093 MIPSV = 0x18,
0094 M68000 = 0x20,
0095 M68010 = 0x21,
0096 M68020 = 0x22,
0097 M68030 = 0x23,
0098 M68040 = 0x24,
0099 Alpha = 0x30,
0100 Alpha21164 = 0x31,
0101 Alpha21164A = 0x32,
0102 Alpha21264 = 0x33,
0103 Alpha21364 = 0x34,
0104 PPC601 = 0x40,
0105 PPC603 = 0x41,
0106 PPC604 = 0x42,
0107 PPC620 = 0x43,
0108 PPCFP = 0x44,
0109 PPCBE = 0x45,
0110 SH3 = 0x50,
0111 SH3E = 0x51,
0112 SH3DSP = 0x52,
0113 SH4 = 0x53,
0114 SHMedia = 0x54,
0115 ARM3 = 0x60,
0116 ARM4 = 0x61,
0117 ARM4T = 0x62,
0118 ARM5 = 0x63,
0119 ARM5T = 0x64,
0120 ARM6 = 0x65,
0121 ARM_XMAC = 0x66,
0122 ARM_WMMX = 0x67,
0123 ARM7 = 0x68,
0124 Omni = 0x70,
0125 Ia64 = 0x80,
0126 Ia64_2 = 0x81,
0127 CEE = 0x90,
0128 AM33 = 0xa0,
0129 M32R = 0xb0,
0130 TriCore = 0xc0,
0131 X64 = 0xd0,
0132 EBC = 0xe0,
0133 Thumb = 0xf0,
0134 ARMNT = 0xf4,
0135 ARM64 = 0xf6,
0136 HybridX86ARM64 = 0xf7,
0137 ARM64EC = 0xf8,
0138 ARM64X = 0xf9,
0139 Unknown = 0xff,
0140 D3D11_Shader = 0x100,
0141 };
0142
0143
0144
0145
0146 enum SourceLanguage : uint8_t {
0147 C = 0x00,
0148 Cpp = 0x01,
0149 Fortran = 0x02,
0150 Masm = 0x03,
0151 Pascal = 0x04,
0152 Basic = 0x05,
0153 Cobol = 0x06,
0154 Link = 0x07,
0155 Cvtres = 0x08,
0156 Cvtpgd = 0x09,
0157 CSharp = 0x0a,
0158 VB = 0x0b,
0159 ILAsm = 0x0c,
0160 Java = 0x0d,
0161 JScript = 0x0e,
0162 MSIL = 0x0f,
0163 HLSL = 0x10,
0164 ObjC = 0x11,
0165 ObjCpp = 0x12,
0166 Swift = 0x13,
0167 AliasObj = 0x14,
0168 Rust = 0x15,
0169 Go = 0x16,
0170
0171
0172
0173 D = 'D',
0174
0175
0176 OldSwift = 'S',
0177 };
0178
0179
0180
0181
0182
0183
0184 enum class CallingConvention : uint8_t {
0185 NearC = 0x00,
0186 FarC = 0x01,
0187 NearPascal = 0x02,
0188 FarPascal = 0x03,
0189 NearFast = 0x04,
0190 FarFast = 0x05,
0191 NearStdCall = 0x07,
0192 FarStdCall = 0x08,
0193 NearSysCall = 0x09,
0194 FarSysCall = 0x0a,
0195 ThisCall = 0x0b,
0196 MipsCall = 0x0c,
0197 Generic = 0x0d,
0198 AlphaCall = 0x0e,
0199 PpcCall = 0x0f,
0200 SHCall = 0x10,
0201 ArmCall = 0x11,
0202 AM33Call = 0x12,
0203 TriCall = 0x13,
0204 SH5Call = 0x14,
0205 M32RCall = 0x15,
0206 ClrCall = 0x16,
0207 Inline =
0208 0x17,
0209 NearVector = 0x18,
0210 Swift = 0x19,
0211 };
0212
0213 enum class ClassOptions : uint16_t {
0214 None = 0x0000,
0215 Packed = 0x0001,
0216 HasConstructorOrDestructor = 0x0002,
0217 HasOverloadedOperator = 0x0004,
0218 Nested = 0x0008,
0219 ContainsNestedClass = 0x0010,
0220 HasOverloadedAssignmentOperator = 0x0020,
0221 HasConversionOperator = 0x0040,
0222 ForwardReference = 0x0080,
0223 Scoped = 0x0100,
0224 HasUniqueName = 0x0200,
0225 Sealed = 0x0400,
0226 Intrinsic = 0x2000
0227 };
0228 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ClassOptions)
0229
0230 enum class FrameProcedureOptions : uint32_t {
0231 None = 0x00000000,
0232 HasAlloca = 0x00000001,
0233 HasSetJmp = 0x00000002,
0234 HasLongJmp = 0x00000004,
0235 HasInlineAssembly = 0x00000008,
0236 HasExceptionHandling = 0x00000010,
0237 MarkedInline = 0x00000020,
0238 HasStructuredExceptionHandling = 0x00000040,
0239 Naked = 0x00000080,
0240 SecurityChecks = 0x00000100,
0241 AsynchronousExceptionHandling = 0x00000200,
0242 NoStackOrderingForSecurityChecks = 0x00000400,
0243 Inlined = 0x00000800,
0244 StrictSecurityChecks = 0x00001000,
0245 SafeBuffers = 0x00002000,
0246 EncodedLocalBasePointerMask = 0x0000C000,
0247 EncodedParamBasePointerMask = 0x00030000,
0248 ProfileGuidedOptimization = 0x00040000,
0249 ValidProfileCounts = 0x00080000,
0250 OptimizedForSpeed = 0x00100000,
0251 GuardCfg = 0x00200000,
0252 GuardCfw = 0x00400000
0253 };
0254 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(FrameProcedureOptions)
0255
0256 enum class FunctionOptions : uint8_t {
0257 None = 0x00,
0258 CxxReturnUdt = 0x01,
0259 Constructor = 0x02,
0260 ConstructorWithVirtualBases = 0x04
0261 };
0262 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(FunctionOptions)
0263
0264 enum class HfaKind : uint8_t {
0265 None = 0x00,
0266 Float = 0x01,
0267 Double = 0x02,
0268 Other = 0x03
0269 };
0270
0271
0272 enum class MemberAccess : uint8_t {
0273 None = 0,
0274 Private = 1,
0275 Protected = 2,
0276 Public = 3
0277 };
0278
0279
0280 enum class MethodKind : uint8_t {
0281 Vanilla = 0x00,
0282 Virtual = 0x01,
0283 Static = 0x02,
0284 Friend = 0x03,
0285 IntroducingVirtual = 0x04,
0286 PureVirtual = 0x05,
0287 PureIntroducingVirtual = 0x06
0288 };
0289
0290
0291 enum class MethodOptions : uint16_t {
0292 None = 0x0000,
0293 AccessMask = 0x0003,
0294 MethodKindMask = 0x001c,
0295 Pseudo = 0x0020,
0296 NoInherit = 0x0040,
0297 NoConstruct = 0x0080,
0298 CompilerGenerated = 0x0100,
0299 Sealed = 0x0200
0300 };
0301 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(MethodOptions)
0302
0303
0304 enum class LabelType : uint16_t {
0305 Near = 0x0,
0306 Far = 0x4,
0307 };
0308
0309
0310
0311 enum class ModifierOptions : uint16_t {
0312 None = 0x0000,
0313 Const = 0x0001,
0314 Volatile = 0x0002,
0315 Unaligned = 0x0004
0316 };
0317 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ModifierOptions)
0318
0319
0320 enum : uint32_t { SubsectionIgnoreFlag = 0x80000000 };
0321
0322 enum class DebugSubsectionKind : uint32_t {
0323 None = 0,
0324 Symbols = 0xf1,
0325 Lines = 0xf2,
0326 StringTable = 0xf3,
0327 FileChecksums = 0xf4,
0328 FrameData = 0xf5,
0329 InlineeLines = 0xf6,
0330 CrossScopeImports = 0xf7,
0331 CrossScopeExports = 0xf8,
0332
0333
0334 ILLines = 0xf9,
0335 FuncMDTokenMap = 0xfa,
0336 TypeMDTokenMap = 0xfb,
0337 MergedAssemblyInput = 0xfc,
0338
0339 CoffSymbolRVA = 0xfd,
0340
0341 XfgHashType = 0xff,
0342 XfgHashVirtual = 0x100,
0343 };
0344
0345
0346 enum class PointerKind : uint8_t {
0347 Near16 = 0x00,
0348 Far16 = 0x01,
0349 Huge16 = 0x02,
0350 BasedOnSegment = 0x03,
0351 BasedOnValue = 0x04,
0352 BasedOnSegmentValue = 0x05,
0353 BasedOnAddress = 0x06,
0354 BasedOnSegmentAddress = 0x07,
0355 BasedOnType = 0x08,
0356 BasedOnSelf = 0x09,
0357 Near32 = 0x0a,
0358 Far32 = 0x0b,
0359 Near64 = 0x0c
0360 };
0361
0362
0363 enum class PointerMode : uint8_t {
0364 Pointer = 0x00,
0365 LValueReference = 0x01,
0366 PointerToDataMember = 0x02,
0367 PointerToMemberFunction = 0x03,
0368 RValueReference = 0x04
0369 };
0370
0371
0372 enum class PointerOptions : uint32_t {
0373 None = 0x00000000,
0374 Flat32 = 0x00000100,
0375 Volatile = 0x00000200,
0376 Const = 0x00000400,
0377 Unaligned = 0x00000800,
0378 Restrict = 0x00001000,
0379 WinRTSmartPointer = 0x00080000,
0380 LValueRefThisPointer = 0x00100000,
0381 RValueRefThisPointer = 0x00200000
0382 };
0383 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(PointerOptions)
0384
0385
0386 enum class PointerToMemberRepresentation : uint16_t {
0387 Unknown = 0x00,
0388 SingleInheritanceData = 0x01,
0389 MultipleInheritanceData = 0x02,
0390 VirtualInheritanceData = 0x03,
0391 GeneralData = 0x04,
0392 SingleInheritanceFunction = 0x05,
0393 MultipleInheritanceFunction = 0x06,
0394 VirtualInheritanceFunction = 0x07,
0395 GeneralFunction = 0x08
0396 };
0397
0398 enum class VFTableSlotKind : uint8_t {
0399 Near16 = 0x00,
0400 Far16 = 0x01,
0401 This = 0x02,
0402 Outer = 0x03,
0403 Meta = 0x04,
0404 Near = 0x05,
0405 Far = 0x06
0406 };
0407
0408 enum class WindowsRTClassKind : uint8_t {
0409 None = 0x00,
0410 RefClass = 0x01,
0411 ValueClass = 0x02,
0412 Interface = 0x03
0413 };
0414
0415
0416 enum class LocalSymFlags : uint16_t {
0417 None = 0,
0418 IsParameter = 1 << 0,
0419 IsAddressTaken = 1 << 1,
0420 IsCompilerGenerated = 1 << 2,
0421 IsAggregate = 1 << 3,
0422 IsAggregated = 1 << 4,
0423 IsAliased = 1 << 5,
0424 IsAlias = 1 << 6,
0425 IsReturnValue = 1 << 7,
0426 IsOptimizedOut = 1 << 8,
0427 IsEnregisteredGlobal = 1 << 9,
0428 IsEnregisteredStatic = 1 << 10,
0429 };
0430 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(LocalSymFlags)
0431
0432
0433 enum class PublicSymFlags : uint32_t {
0434 None = 0,
0435 Code = 1 << 0,
0436 Function = 1 << 1,
0437 Managed = 1 << 2,
0438 MSIL = 1 << 3,
0439 };
0440 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(PublicSymFlags)
0441
0442
0443 enum class ProcSymFlags : uint8_t {
0444 None = 0,
0445 HasFP = 1 << 0,
0446 HasIRET = 1 << 1,
0447 HasFRET = 1 << 2,
0448 IsNoReturn = 1 << 3,
0449 IsUnreachable = 1 << 4,
0450 HasCustomCallingConv = 1 << 5,
0451 IsNoInline = 1 << 6,
0452 HasOptimizedDebugInfo = 1 << 7,
0453 };
0454 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ProcSymFlags)
0455
0456
0457 enum class CompileSym2Flags : uint32_t {
0458 None = 0,
0459 SourceLanguageMask = 0xFF,
0460 EC = 1 << 8,
0461 NoDbgInfo = 1 << 9,
0462 LTCG = 1 << 10,
0463 NoDataAlign = 1 << 11,
0464 ManagedPresent = 1 << 12,
0465 SecurityChecks = 1 << 13,
0466 HotPatch = 1 << 14,
0467 CVTCIL = 1 << 15,
0468 MSILModule = 1 << 16,
0469 };
0470 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(CompileSym2Flags)
0471
0472
0473 enum class CompileSym3Flags : uint32_t {
0474 None = 0,
0475 SourceLanguageMask = 0xFF,
0476 EC = 1 << 8,
0477 NoDbgInfo = 1 << 9,
0478 LTCG = 1 << 10,
0479 NoDataAlign = 1 << 11,
0480 ManagedPresent = 1 << 12,
0481 SecurityChecks = 1 << 13,
0482 HotPatch = 1 << 14,
0483 CVTCIL = 1 << 15,
0484 MSILModule = 1 << 16,
0485 Sdl = 1 << 17,
0486 PGO = 1 << 18,
0487 Exp = 1 << 19,
0488 };
0489 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(CompileSym3Flags)
0490
0491 enum class ExportFlags : uint16_t {
0492 None = 0,
0493 IsConstant = 1 << 0,
0494 IsData = 1 << 1,
0495 IsPrivate = 1 << 2,
0496 HasNoName = 1 << 3,
0497 HasExplicitOrdinal = 1 << 4,
0498 IsForwarder = 1 << 5
0499 };
0500 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ExportFlags)
0501
0502
0503 enum class BinaryAnnotationsOpCode : uint32_t {
0504 Invalid,
0505 CodeOffset,
0506 ChangeCodeOffsetBase,
0507 ChangeCodeOffset,
0508 ChangeCodeLength,
0509 ChangeFile,
0510 ChangeLineOffset,
0511 ChangeLineEndDelta,
0512 ChangeRangeKind,
0513 ChangeColumnStart,
0514 ChangeColumnEndDelta,
0515 ChangeCodeOffsetAndLineOffset,
0516 ChangeCodeLengthAndCodeOffset,
0517 ChangeColumnEnd,
0518 };
0519
0520
0521 enum class FrameCookieKind : uint8_t {
0522 Copy,
0523 XorStackPointer,
0524 XorFramePointer,
0525 XorR13,
0526 };
0527
0528
0529 enum class RegisterId : uint16_t {
0530 #define CV_REGISTERS_ALL
0531 #define CV_REGISTER(name, value) name = value,
0532 #include "CodeViewRegisters.def"
0533 #undef CV_REGISTER
0534 #undef CV_REGISTERS_ALL
0535 };
0536
0537
0538
0539 struct CPURegister {
0540 CPURegister() = delete;
0541 CPURegister(CPUType Cpu, codeview::RegisterId Reg) {
0542 this->Cpu = Cpu;
0543 this->Reg = Reg;
0544 }
0545 CPUType Cpu;
0546 RegisterId Reg;
0547 };
0548
0549
0550
0551 enum class EncodedFramePtrReg : uint8_t {
0552 None = 0,
0553 StackPtr = 1,
0554 FramePtr = 2,
0555 BasePtr = 3,
0556 };
0557
0558 RegisterId decodeFramePtrReg(EncodedFramePtrReg EncodedReg, CPUType CPU);
0559
0560 EncodedFramePtrReg encodeFramePtrReg(RegisterId Reg, CPUType CPU);
0561
0562
0563 enum class ThunkOrdinal : uint8_t {
0564 Standard,
0565 ThisAdjustor,
0566 Vcall,
0567 Pcode,
0568 UnknownLoad,
0569 TrampIncremental,
0570 BranchIsland
0571 };
0572
0573 enum class TrampolineType : uint16_t { TrampIncremental, BranchIsland };
0574
0575
0576 enum class FileChecksumKind : uint8_t { None, MD5, SHA1, SHA256 };
0577
0578 enum LineFlags : uint16_t {
0579 LF_None = 0,
0580 LF_HaveColumns = 1,
0581 };
0582
0583
0584 struct FrameData {
0585 support::ulittle32_t RvaStart;
0586 support::ulittle32_t CodeSize;
0587 support::ulittle32_t LocalSize;
0588 support::ulittle32_t ParamsSize;
0589 support::ulittle32_t MaxStackSize;
0590 support::ulittle32_t FrameFunc;
0591 support::ulittle16_t PrologSize;
0592 support::ulittle16_t SavedRegsSize;
0593 support::ulittle32_t Flags;
0594 enum : uint32_t {
0595 HasSEH = 1 << 0,
0596 HasEH = 1 << 1,
0597 IsFunctionStart = 1 << 2,
0598 };
0599 };
0600
0601
0602
0603
0604
0605
0606
0607
0608 struct CrossModuleExport {
0609 support::ulittle32_t Local;
0610 support::ulittle32_t Global;
0611 };
0612
0613 struct CrossModuleImport {
0614 support::ulittle32_t ModuleNameOffset;
0615 support::ulittle32_t Count;
0616
0617 };
0618
0619 enum class CodeViewContainer { ObjectFile, Pdb };
0620
0621 inline uint32_t alignOf(CodeViewContainer Container) {
0622 if (Container == CodeViewContainer::ObjectFile)
0623 return 1;
0624 return 4;
0625 }
0626
0627
0628
0629
0630
0631
0632
0633
0634
0635
0636 enum class JumpTableEntrySize : uint16_t {
0637 Int8 = 0,
0638 UInt8 = 1,
0639 Int16 = 2,
0640 UInt16 = 3,
0641 Int32 = 4,
0642 UInt32 = 5,
0643 Pointer = 6,
0644 UInt8ShiftLeft = 7,
0645 UInt16ShiftLeft = 8,
0646 Int8ShiftLeft = 9,
0647 Int16ShiftLeft = 10,
0648 };
0649 }
0650 }
0651
0652 #endif