1 //===- CodeView.h -----------------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEW_H 11 #define LLVM_DEBUGINFO_CODEVIEW_CODEVIEW_H 12 13 #include <cinttypes> 14 #include <type_traits> 15 16 namespace llvm { 17 namespace codeview { 18 19 /// Distinguishes individual records in .debug$T section or PDB type stream. The 20 /// documentation and headers talk about this as the "leaf" type. 21 enum class TypeRecordKind : uint16_t { 22 #define TYPE_RECORD(lf_ename, value, name) name = value, 23 #include "TypeRecords.def" 24 }; 25 26 /// Duplicate copy of the above enum, but using the official CV names. Useful 27 /// for reference purposes and when dealing with unknown record types. 28 enum TypeLeafKind : uint16_t { 29 #define CV_TYPE(name, val) name = val, 30 #include "TypeRecords.def" 31 }; 32 33 /// Distinguishes individual records in the Symbols subsection of a .debug$S 34 /// section. Equivalent to SYM_ENUM_e in cvinfo.h. 35 enum class SymbolRecordKind : uint16_t { 36 #define SYMBOL_RECORD(lf_ename, value, name) name = value, 37 #include "CVSymbolTypes.def" 38 }; 39 40 /// Duplicate copy of the above enum, but using the official CV names. Useful 41 /// for reference purposes and when dealing with unknown record types. 42 enum SymbolKind : uint16_t { 43 #define CV_SYMBOL(name, val) name = val, 44 #include "CVSymbolTypes.def" 45 }; 46 47 #define CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(Class) \ 48 inline Class operator|(Class a, Class b) { \ 49 return static_cast<Class>( \ 50 static_cast<std::underlying_type<Class>::type>(a) | \ 51 static_cast<std::underlying_type<Class>::type>(b)); \ 52 } \ 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) { \ 59 return static_cast<Class>( \ 60 ~static_cast<std::underlying_type<Class>::type>(a)); \ 61 } \ 62 inline Class &operator|=(Class &a, Class b) { \ 63 a = a | b; \ 64 return a; \ 65 } \ 66 inline Class &operator&=(Class &a, Class b) { \ 67 a = a & b; \ 68 return a; \ 69 } 70 71 /// These values correspond to the CV_CPU_TYPE_e enumeration, and are documented 72 /// here: https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx 73 enum class CPUType : uint16_t { 74 Intel8080 = 0x0, 75 Intel8086 = 0x1, 76 Intel80286 = 0x2, 77 Intel80386 = 0x3, 78 Intel80486 = 0x4, 79 Pentium = 0x5, 80 PentiumPro = 0x6, 81 Pentium3 = 0x7, 82 MIPS = 0x10, 83 MIPS16 = 0x11, 84 MIPS32 = 0x12, 85 MIPS64 = 0x13, 86 MIPSI = 0x14, 87 MIPSII = 0x15, 88 MIPSIII = 0x16, 89 MIPSIV = 0x17, 90 MIPSV = 0x18, 91 M68000 = 0x20, 92 M68010 = 0x21, 93 M68020 = 0x22, 94 M68030 = 0x23, 95 M68040 = 0x24, 96 Alpha = 0x30, 97 Alpha21164 = 0x31, 98 Alpha21164A = 0x32, 99 Alpha21264 = 0x33, 100 Alpha21364 = 0x34, 101 PPC601 = 0x40, 102 PPC603 = 0x41, 103 PPC604 = 0x42, 104 PPC620 = 0x43, 105 PPCFP = 0x44, 106 PPCBE = 0x45, 107 SH3 = 0x50, 108 SH3E = 0x51, 109 SH3DSP = 0x52, 110 SH4 = 0x53, 111 SHMedia = 0x54, 112 ARM3 = 0x60, 113 ARM4 = 0x61, 114 ARM4T = 0x62, 115 ARM5 = 0x63, 116 ARM5T = 0x64, 117 ARM6 = 0x65, 118 ARM_XMAC = 0x66, 119 ARM_WMMX = 0x67, 120 ARM7 = 0x68, 121 Omni = 0x70, 122 Ia64 = 0x80, 123 Ia64_2 = 0x81, 124 CEE = 0x90, 125 AM33 = 0xa0, 126 M32R = 0xb0, 127 TriCore = 0xc0, 128 X64 = 0xd0, 129 EBC = 0xe0, 130 Thumb = 0xf0, 131 ARMNT = 0xf4, 132 D3D11_Shader = 0x100, 133 }; 134 135 /// These values correspond to the CV_CFL_LANG enumeration, and are documented 136 /// here: https://msdn.microsoft.com/en-us/library/bw3aekw6.aspx 137 enum SourceLanguage : uint8_t { 138 C = 0x00, 139 Cpp = 0x01, 140 Fortran = 0x02, 141 Masm = 0x03, 142 Pascal = 0x04, 143 Basic = 0x05, 144 Cobol = 0x06, 145 Link = 0x07, 146 Cvtres = 0x08, 147 Cvtpgd = 0x09, 148 CSharp = 0x0a, 149 VB = 0x0b, 150 ILAsm = 0x0c, 151 Java = 0x0d, 152 JScript = 0x0e, 153 MSIL = 0x0f, 154 HLSL = 0x10 155 }; 156 157 /// These values correspond to the CV_call_e enumeration, and are documented 158 /// at the following locations: 159 /// https://msdn.microsoft.com/en-us/library/b2fc64ek.aspx 160 /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680207(v=vs.85).aspx 161 /// 162 enum class CallingConvention : uint8_t { 163 NearC = 0x00, // near right to left push, caller pops stack 164 FarC = 0x01, // far right to left push, caller pops stack 165 NearPascal = 0x02, // near left to right push, callee pops stack 166 FarPascal = 0x03, // far left to right push, callee pops stack 167 NearFast = 0x04, // near left to right push with regs, callee pops stack 168 FarFast = 0x05, // far left to right push with regs, callee pops stack 169 NearStdCall = 0x07, // near standard call 170 FarStdCall = 0x08, // far standard call 171 NearSysCall = 0x09, // near sys call 172 FarSysCall = 0x0a, // far sys call 173 ThisCall = 0x0b, // this call (this passed in register) 174 MipsCall = 0x0c, // Mips call 175 Generic = 0x0d, // Generic call sequence 176 AlphaCall = 0x0e, // Alpha call 177 PpcCall = 0x0f, // PPC call 178 SHCall = 0x10, // Hitachi SuperH call 179 ArmCall = 0x11, // ARM call 180 AM33Call = 0x12, // AM33 call 181 TriCall = 0x13, // TriCore Call 182 SH5Call = 0x14, // Hitachi SuperH-5 call 183 M32RCall = 0x15, // M32R Call 184 ClrCall = 0x16, // clr call 185 Inline = 186 0x17, // Marker for routines always inlined and thus lacking a convention 187 NearVector = 0x18 // near left to right push with regs, callee pops stack 188 }; 189 190 enum class ClassOptions : uint16_t { 191 None = 0x0000, 192 Packed = 0x0001, 193 HasConstructorOrDestructor = 0x0002, 194 HasOverloadedOperator = 0x0004, 195 Nested = 0x0008, 196 ContainsNestedClass = 0x0010, 197 HasOverloadedAssignmentOperator = 0x0020, 198 HasConversionOperator = 0x0040, 199 ForwardReference = 0x0080, 200 Scoped = 0x0100, 201 HasUniqueName = 0x0200, 202 Sealed = 0x0400, 203 Intrinsic = 0x2000 204 }; 205 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ClassOptions) 206 207 enum class FrameProcedureOptions : uint32_t { 208 None = 0x00000000, 209 HasAlloca = 0x00000001, 210 HasSetJmp = 0x00000002, 211 HasLongJmp = 0x00000004, 212 HasInlineAssembly = 0x00000008, 213 HasExceptionHandling = 0x00000010, 214 MarkedInline = 0x00000020, 215 HasStructuredExceptionHandling = 0x00000040, 216 Naked = 0x00000080, 217 SecurityChecks = 0x00000100, 218 AsynchronousExceptionHandling = 0x00000200, 219 NoStackOrderingForSecurityChecks = 0x00000400, 220 Inlined = 0x00000800, 221 StrictSecurityChecks = 0x00001000, 222 SafeBuffers = 0x00002000, 223 ProfileGuidedOptimization = 0x00040000, 224 ValidProfileCounts = 0x00080000, 225 OptimizedForSpeed = 0x00100000, 226 GuardCfg = 0x00200000, 227 GuardCfw = 0x00400000 228 }; 229 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(FrameProcedureOptions) 230 231 enum class FunctionOptions : uint8_t { 232 None = 0x00, 233 CxxReturnUdt = 0x01, 234 Constructor = 0x02, 235 ConstructorWithVirtualBases = 0x04 236 }; 237 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(FunctionOptions) 238 239 enum class HfaKind : uint8_t { 240 None = 0x00, 241 Float = 0x01, 242 Double = 0x02, 243 Other = 0x03 244 }; 245 246 /// Source-level access specifier. (CV_access_e) 247 enum class MemberAccess : uint8_t { 248 None = 0, 249 Private = 1, 250 Protected = 2, 251 Public = 3 252 }; 253 254 /// Part of member attribute flags. (CV_methodprop_e) 255 enum class MethodKind : uint8_t { 256 Vanilla = 0x00, 257 Virtual = 0x01, 258 Static = 0x02, 259 Friend = 0x03, 260 IntroducingVirtual = 0x04, 261 PureVirtual = 0x05, 262 PureIntroducingVirtual = 0x06 263 }; 264 265 /// Equivalent to CV_fldattr_t bitfield. 266 enum class MethodOptions : uint16_t { 267 None = 0x0000, 268 AccessMask = 0x0003, 269 MethodKindMask = 0x001c, 270 Pseudo = 0x0020, 271 NoInherit = 0x0040, 272 NoConstruct = 0x0080, 273 CompilerGenerated = 0x0100, 274 Sealed = 0x0200 275 }; 276 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(MethodOptions) 277 278 /// Equivalent to CV_LABEL_TYPE_e. 279 enum class LabelType : uint16_t { 280 Near = 0x0, 281 Far = 0x4, 282 }; 283 284 /// Equivalent to CV_modifier_t. 285 /// TODO: Add flag for _Atomic modifier 286 enum class ModifierOptions : uint16_t { 287 None = 0x0000, 288 Const = 0x0001, 289 Volatile = 0x0002, 290 Unaligned = 0x0004 291 }; 292 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ModifierOptions) 293 294 enum class ModuleSubstreamKind : uint32_t { 295 None = 0, 296 Symbols = 0xf1, 297 Lines = 0xf2, 298 StringTable = 0xf3, 299 FileChecksums = 0xf4, 300 FrameData = 0xf5, 301 InlineeLines = 0xf6, 302 CrossScopeImports = 0xf7, 303 CrossScopeExports = 0xf8, 304 305 // These appear to relate to .Net assembly info. 306 ILLines = 0xf9, 307 FuncMDTokenMap = 0xfa, 308 TypeMDTokenMap = 0xfb, 309 MergedAssemblyInput = 0xfc, 310 311 CoffSymbolRVA = 0xfd, 312 }; 313 314 /// Equivalent to CV_ptrtype_e. 315 enum class PointerKind : uint8_t { 316 Near16 = 0x00, // 16 bit pointer 317 Far16 = 0x01, // 16:16 far pointer 318 Huge16 = 0x02, // 16:16 huge pointer 319 BasedOnSegment = 0x03, // based on segment 320 BasedOnValue = 0x04, // based on value of base 321 BasedOnSegmentValue = 0x05, // based on segment value of base 322 BasedOnAddress = 0x06, // based on address of base 323 BasedOnSegmentAddress = 0x07, // based on segment address of base 324 BasedOnType = 0x08, // based on type 325 BasedOnSelf = 0x09, // based on self 326 Near32 = 0x0a, // 32 bit pointer 327 Far32 = 0x0b, // 16:32 pointer 328 Near64 = 0x0c // 64 bit pointer 329 }; 330 331 /// Equivalent to CV_ptrmode_e. 332 enum class PointerMode : uint8_t { 333 Pointer = 0x00, // "normal" pointer 334 LValueReference = 0x01, // "old" reference 335 PointerToDataMember = 0x02, // pointer to data member 336 PointerToMemberFunction = 0x03, // pointer to member function 337 RValueReference = 0x04 // r-value reference 338 }; 339 340 /// Equivalent to misc lfPointerAttr bitfields. 341 enum class PointerOptions : uint32_t { 342 None = 0x00000000, 343 Flat32 = 0x00000100, 344 Volatile = 0x00000200, 345 Const = 0x00000400, 346 Unaligned = 0x00000800, 347 Restrict = 0x00001000, 348 WinRTSmartPointer = 0x00080000 349 }; 350 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(PointerOptions) 351 352 /// Equivalent to CV_pmtype_e. 353 enum class PointerToMemberRepresentation : uint16_t { 354 Unknown = 0x00, // not specified (pre VC8) 355 SingleInheritanceData = 0x01, // member data, single inheritance 356 MultipleInheritanceData = 0x02, // member data, multiple inheritance 357 VirtualInheritanceData = 0x03, // member data, virtual inheritance 358 GeneralData = 0x04, // member data, most general 359 SingleInheritanceFunction = 0x05, // member function, single inheritance 360 MultipleInheritanceFunction = 0x06, // member function, multiple inheritance 361 VirtualInheritanceFunction = 0x07, // member function, virtual inheritance 362 GeneralFunction = 0x08 // member function, most general 363 }; 364 365 enum class VFTableSlotKind : uint8_t { 366 Near16 = 0x00, 367 Far16 = 0x01, 368 This = 0x02, 369 Outer = 0x03, 370 Meta = 0x04, 371 Near = 0x05, 372 Far = 0x06 373 }; 374 375 enum class WindowsRTClassKind : uint8_t { 376 None = 0x00, 377 RefClass = 0x01, 378 ValueClass = 0x02, 379 Interface = 0x03 380 }; 381 382 /// Corresponds to CV_LVARFLAGS bitfield. 383 enum class LocalSymFlags : uint16_t { 384 None = 0, 385 IsParameter = 1 << 0, 386 IsAddressTaken = 1 << 1, 387 IsCompilerGenerated = 1 << 2, 388 IsAggregate = 1 << 3, 389 IsAggregated = 1 << 4, 390 IsAliased = 1 << 5, 391 IsAlias = 1 << 6, 392 IsReturnValue = 1 << 7, 393 IsOptimizedOut = 1 << 8, 394 IsEnregisteredGlobal = 1 << 9, 395 IsEnregisteredStatic = 1 << 10, 396 }; 397 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(LocalSymFlags) 398 399 /// Corresponds to the CV_PROCFLAGS bitfield. 400 enum class ProcSymFlags : uint8_t { 401 None = 0, 402 HasFP = 1 << 0, 403 HasIRET = 1 << 1, 404 HasFRET = 1 << 2, 405 IsNoReturn = 1 << 3, 406 IsUnreachable = 1 << 4, 407 HasCustomCallingConv = 1 << 5, 408 IsNoInline = 1 << 6, 409 HasOptimizedDebugInfo = 1 << 7, 410 }; 411 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ProcSymFlags) 412 413 /// Corresponds to COMPILESYM2::Flags bitfield. 414 enum class CompileSym2Flags : uint32_t { 415 EC = 1 << 8, 416 NoDbgInfo = 1 << 9, 417 LTCG = 1 << 10, 418 NoDataAlign = 1 << 11, 419 ManagedPresent = 1 << 12, 420 SecurityChecks = 1 << 13, 421 HotPatch = 1 << 14, 422 CVTCIL = 1 << 15, 423 MSILModule = 1 << 16, 424 }; 425 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(CompileSym2Flags) 426 427 /// Corresponds to COMPILESYM3::Flags bitfield. 428 enum class CompileSym3Flags : uint32_t { 429 EC = 1 << 8, 430 NoDbgInfo = 1 << 9, 431 LTCG = 1 << 10, 432 NoDataAlign = 1 << 11, 433 ManagedPresent = 1 << 12, 434 SecurityChecks = 1 << 13, 435 HotPatch = 1 << 14, 436 CVTCIL = 1 << 15, 437 MSILModule = 1 << 16, 438 Sdl = 1 << 17, 439 PGO = 1 << 18, 440 Exp = 1 << 19, 441 }; 442 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(CompileSym3Flags) 443 444 enum class ExportFlags : uint16_t { 445 IsConstant = 1 << 0, 446 IsData = 1 << 1, 447 IsPrivate = 1 << 2, 448 HasNoName = 1 << 3, 449 HasExplicitOrdinal = 1 << 4, 450 IsForwarder = 1 << 5 451 }; 452 CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ExportFlags) 453 454 // Corresponds to BinaryAnnotationOpcode enum. 455 enum class BinaryAnnotationsOpCode : uint32_t { 456 Invalid, 457 CodeOffset, 458 ChangeCodeOffsetBase, 459 ChangeCodeOffset, 460 ChangeCodeLength, 461 ChangeFile, 462 ChangeLineOffset, 463 ChangeLineEndDelta, 464 ChangeRangeKind, 465 ChangeColumnStart, 466 ChangeColumnEndDelta, 467 ChangeCodeOffsetAndLineOffset, 468 ChangeCodeLengthAndCodeOffset, 469 ChangeColumnEnd, 470 }; 471 472 // Corresponds to CV_cookietype_e enum. 473 enum class FrameCookieKind : uint8_t { 474 Copy, 475 XorStackPointer, 476 XorFramePointer, 477 XorR13, 478 }; 479 480 // Corresponds to CV_HREG_e enum. 481 enum class RegisterId : uint16_t { 482 Unknown = 0, 483 VFrame = 30006, 484 AL = 1, 485 CL = 2, 486 DL = 3, 487 BL = 4, 488 AH = 5, 489 CH = 6, 490 DH = 7, 491 BH = 8, 492 AX = 9, 493 CX = 10, 494 DX = 11, 495 BX = 12, 496 SP = 13, 497 BP = 14, 498 SI = 15, 499 DI = 16, 500 EAX = 17, 501 ECX = 18, 502 EDX = 19, 503 EBX = 20, 504 ESP = 21, 505 EBP = 22, 506 ESI = 23, 507 EDI = 24, 508 ES = 25, 509 CS = 26, 510 SS = 27, 511 DS = 28, 512 FS = 29, 513 GS = 30, 514 IP = 31, 515 RAX = 328, 516 RBX = 329, 517 RCX = 330, 518 RDX = 331, 519 RSI = 332, 520 RDI = 333, 521 RBP = 334, 522 RSP = 335, 523 R8 = 336, 524 R9 = 337, 525 R10 = 338, 526 R11 = 339, 527 R12 = 340, 528 R13 = 341, 529 R14 = 342, 530 R15 = 343, 531 }; 532 533 /// These values correspond to the THUNK_ORDINAL enumeration. 534 enum class ThunkOrdinal : uint8_t { 535 Standard, 536 ThisAdjustor, 537 Vcall, 538 Pcode, 539 UnknownLoad, 540 TrampIncremental, 541 BranchIsland 542 }; 543 544 enum class TrampolineType : uint16_t { TrampIncremental, BranchIsland }; 545 546 // These values correspond to the CV_SourceChksum_t enumeration. 547 enum class FileChecksumKind : uint8_t { None, MD5, SHA1, SHA256 }; 548 549 enum LineFlags : uint32_t { 550 HaveColumns = 1, // CV_LINES_HAVE_COLUMNS 551 }; 552 } 553 } 554 555 #endif 556