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