#ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEW_H
#define LLVM_DEBUGINFO_CODEVIEW_CODEVIEW_H
#include <cinttypes>
#include <type_traits>
#include "llvm/Support/Endian.h"
namespace llvm {
namespace codeview {
enum class TypeRecordKind : uint16_t {
#define TYPE_RECORD(lf_ename, value, name) name = value,
#include "CodeViewTypes.def"
};
enum TypeLeafKind : uint16_t {
#define CV_TYPE(name, val) name = val,
#include "CodeViewTypes.def"
};
enum class SymbolRecordKind : uint16_t {
#define SYMBOL_RECORD(lf_ename, value, name) name = value,
#include "CodeViewSymbols.def"
};
enum SymbolKind : uint16_t {
#define CV_SYMBOL(name, val) name = val,
#include "CodeViewSymbols.def"
};
#define CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(Class) \
inline Class operator|(Class a, Class b) { \
return static_cast<Class>( \
static_cast<std::underlying_type<Class>::type>(a) | \
static_cast<std::underlying_type<Class>::type>(b)); \
} \
inline Class operator&(Class a, Class b) { \
return static_cast<Class>( \
static_cast<std::underlying_type<Class>::type>(a) & \
static_cast<std::underlying_type<Class>::type>(b)); \
} \
inline Class operator~(Class a) { \
return static_cast<Class>( \
~static_cast<std::underlying_type<Class>::type>(a)); \
} \
inline Class &operator|=(Class &a, Class b) { \
a = a | b; \
return a; \
} \
inline Class &operator&=(Class &a, Class b) { \
a = a & b; \
return a; \
}
enum class CPUType : uint16_t {
Intel8080 = 0x0,
Intel8086 = 0x1,
Intel80286 = 0x2,
Intel80386 = 0x3,
Intel80486 = 0x4,
Pentium = 0x5,
PentiumPro = 0x6,
Pentium3 = 0x7,
MIPS = 0x10,
MIPS16 = 0x11,
MIPS32 = 0x12,
MIPS64 = 0x13,
MIPSI = 0x14,
MIPSII = 0x15,
MIPSIII = 0x16,
MIPSIV = 0x17,
MIPSV = 0x18,
M68000 = 0x20,
M68010 = 0x21,
M68020 = 0x22,
M68030 = 0x23,
M68040 = 0x24,
Alpha = 0x30,
Alpha21164 = 0x31,
Alpha21164A = 0x32,
Alpha21264 = 0x33,
Alpha21364 = 0x34,
PPC601 = 0x40,
PPC603 = 0x41,
PPC604 = 0x42,
PPC620 = 0x43,
PPCFP = 0x44,
PPCBE = 0x45,
SH3 = 0x50,
SH3E = 0x51,
SH3DSP = 0x52,
SH4 = 0x53,
SHMedia = 0x54,
ARM3 = 0x60,
ARM4 = 0x61,
ARM4T = 0x62,
ARM5 = 0x63,
ARM5T = 0x64,
ARM6 = 0x65,
ARM_XMAC = 0x66,
ARM_WMMX = 0x67,
ARM7 = 0x68,
Omni = 0x70,
Ia64 = 0x80,
Ia64_2 = 0x81,
CEE = 0x90,
AM33 = 0xa0,
M32R = 0xb0,
TriCore = 0xc0,
X64 = 0xd0,
EBC = 0xe0,
Thumb = 0xf0,
ARMNT = 0xf4,
ARM64 = 0xf6,
HybridX86ARM64 = 0xf7,
ARM64EC = 0xf8,
ARM64X = 0xf9,
D3D11_Shader = 0x100,
};
enum SourceLanguage : uint8_t {
C = 0x00,
Cpp = 0x01,
Fortran = 0x02,
Masm = 0x03,
Pascal = 0x04,
Basic = 0x05,
Cobol = 0x06,
Link = 0x07,
Cvtres = 0x08,
Cvtpgd = 0x09,
CSharp = 0x0a,
VB = 0x0b,
ILAsm = 0x0c,
Java = 0x0d,
JScript = 0x0e,
MSIL = 0x0f,
HLSL = 0x10,
Rust = 0x15,
D = 'D',
Swift = 'S',
};
enum class CallingConvention : uint8_t {
NearC = 0x00, FarC = 0x01, NearPascal = 0x02, FarPascal = 0x03, NearFast = 0x04, FarFast = 0x05, NearStdCall = 0x07, FarStdCall = 0x08, NearSysCall = 0x09, FarSysCall = 0x0a, ThisCall = 0x0b, MipsCall = 0x0c, Generic = 0x0d, AlphaCall = 0x0e, PpcCall = 0x0f, SHCall = 0x10, ArmCall = 0x11, AM33Call = 0x12, TriCall = 0x13, SH5Call = 0x14, M32RCall = 0x15, ClrCall = 0x16, Inline =
0x17, NearVector = 0x18 };
enum class ClassOptions : uint16_t {
None = 0x0000,
Packed = 0x0001,
HasConstructorOrDestructor = 0x0002,
HasOverloadedOperator = 0x0004,
Nested = 0x0008,
ContainsNestedClass = 0x0010,
HasOverloadedAssignmentOperator = 0x0020,
HasConversionOperator = 0x0040,
ForwardReference = 0x0080,
Scoped = 0x0100,
HasUniqueName = 0x0200,
Sealed = 0x0400,
Intrinsic = 0x2000
};
CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ClassOptions)
enum class FrameProcedureOptions : uint32_t {
None = 0x00000000,
HasAlloca = 0x00000001,
HasSetJmp = 0x00000002,
HasLongJmp = 0x00000004,
HasInlineAssembly = 0x00000008,
HasExceptionHandling = 0x00000010,
MarkedInline = 0x00000020,
HasStructuredExceptionHandling = 0x00000040,
Naked = 0x00000080,
SecurityChecks = 0x00000100,
AsynchronousExceptionHandling = 0x00000200,
NoStackOrderingForSecurityChecks = 0x00000400,
Inlined = 0x00000800,
StrictSecurityChecks = 0x00001000,
SafeBuffers = 0x00002000,
EncodedLocalBasePointerMask = 0x0000C000,
EncodedParamBasePointerMask = 0x00030000,
ProfileGuidedOptimization = 0x00040000,
ValidProfileCounts = 0x00080000,
OptimizedForSpeed = 0x00100000,
GuardCfg = 0x00200000,
GuardCfw = 0x00400000
};
CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(FrameProcedureOptions)
enum class FunctionOptions : uint8_t {
None = 0x00,
CxxReturnUdt = 0x01,
Constructor = 0x02,
ConstructorWithVirtualBases = 0x04
};
CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(FunctionOptions)
enum class HfaKind : uint8_t {
None = 0x00,
Float = 0x01,
Double = 0x02,
Other = 0x03
};
enum class MemberAccess : uint8_t {
None = 0,
Private = 1,
Protected = 2,
Public = 3
};
enum class MethodKind : uint8_t {
Vanilla = 0x00,
Virtual = 0x01,
Static = 0x02,
Friend = 0x03,
IntroducingVirtual = 0x04,
PureVirtual = 0x05,
PureIntroducingVirtual = 0x06
};
enum class MethodOptions : uint16_t {
None = 0x0000,
AccessMask = 0x0003,
MethodKindMask = 0x001c,
Pseudo = 0x0020,
NoInherit = 0x0040,
NoConstruct = 0x0080,
CompilerGenerated = 0x0100,
Sealed = 0x0200
};
CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(MethodOptions)
enum class LabelType : uint16_t {
Near = 0x0,
Far = 0x4,
};
enum class ModifierOptions : uint16_t {
None = 0x0000,
Const = 0x0001,
Volatile = 0x0002,
Unaligned = 0x0004
};
CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ModifierOptions)
enum : uint32_t { SubsectionIgnoreFlag = 0x80000000 };
enum class DebugSubsectionKind : uint32_t {
None = 0,
Symbols = 0xf1,
Lines = 0xf2,
StringTable = 0xf3,
FileChecksums = 0xf4,
FrameData = 0xf5,
InlineeLines = 0xf6,
CrossScopeImports = 0xf7,
CrossScopeExports = 0xf8,
ILLines = 0xf9,
FuncMDTokenMap = 0xfa,
TypeMDTokenMap = 0xfb,
MergedAssemblyInput = 0xfc,
CoffSymbolRVA = 0xfd,
XfgHashType = 0xff,
XfgHashVirtual = 0x100,
};
enum class PointerKind : uint8_t {
Near16 = 0x00, Far16 = 0x01, Huge16 = 0x02, BasedOnSegment = 0x03, BasedOnValue = 0x04, BasedOnSegmentValue = 0x05, BasedOnAddress = 0x06, BasedOnSegmentAddress = 0x07, BasedOnType = 0x08, BasedOnSelf = 0x09, Near32 = 0x0a, Far32 = 0x0b, Near64 = 0x0c };
enum class PointerMode : uint8_t {
Pointer = 0x00, LValueReference = 0x01, PointerToDataMember = 0x02, PointerToMemberFunction = 0x03, RValueReference = 0x04 };
enum class PointerOptions : uint32_t {
None = 0x00000000,
Flat32 = 0x00000100,
Volatile = 0x00000200,
Const = 0x00000400,
Unaligned = 0x00000800,
Restrict = 0x00001000,
WinRTSmartPointer = 0x00080000,
LValueRefThisPointer = 0x00100000,
RValueRefThisPointer = 0x00200000
};
CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(PointerOptions)
enum class PointerToMemberRepresentation : uint16_t {
Unknown = 0x00, SingleInheritanceData = 0x01, MultipleInheritanceData = 0x02, VirtualInheritanceData = 0x03, GeneralData = 0x04, SingleInheritanceFunction = 0x05, MultipleInheritanceFunction = 0x06, VirtualInheritanceFunction = 0x07, GeneralFunction = 0x08 };
enum class VFTableSlotKind : uint8_t {
Near16 = 0x00,
Far16 = 0x01,
This = 0x02,
Outer = 0x03,
Meta = 0x04,
Near = 0x05,
Far = 0x06
};
enum class WindowsRTClassKind : uint8_t {
None = 0x00,
RefClass = 0x01,
ValueClass = 0x02,
Interface = 0x03
};
enum class LocalSymFlags : uint16_t {
None = 0,
IsParameter = 1 << 0,
IsAddressTaken = 1 << 1,
IsCompilerGenerated = 1 << 2,
IsAggregate = 1 << 3,
IsAggregated = 1 << 4,
IsAliased = 1 << 5,
IsAlias = 1 << 6,
IsReturnValue = 1 << 7,
IsOptimizedOut = 1 << 8,
IsEnregisteredGlobal = 1 << 9,
IsEnregisteredStatic = 1 << 10,
};
CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(LocalSymFlags)
enum class PublicSymFlags : uint32_t {
None = 0,
Code = 1 << 0,
Function = 1 << 1,
Managed = 1 << 2,
MSIL = 1 << 3,
};
CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(PublicSymFlags)
enum class ProcSymFlags : uint8_t {
None = 0,
HasFP = 1 << 0,
HasIRET = 1 << 1,
HasFRET = 1 << 2,
IsNoReturn = 1 << 3,
IsUnreachable = 1 << 4,
HasCustomCallingConv = 1 << 5,
IsNoInline = 1 << 6,
HasOptimizedDebugInfo = 1 << 7,
};
CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ProcSymFlags)
enum class CompileSym2Flags : uint32_t {
None = 0,
SourceLanguageMask = 0xFF,
EC = 1 << 8,
NoDbgInfo = 1 << 9,
LTCG = 1 << 10,
NoDataAlign = 1 << 11,
ManagedPresent = 1 << 12,
SecurityChecks = 1 << 13,
HotPatch = 1 << 14,
CVTCIL = 1 << 15,
MSILModule = 1 << 16,
};
CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(CompileSym2Flags)
enum class CompileSym3Flags : uint32_t {
None = 0,
SourceLanguageMask = 0xFF,
EC = 1 << 8,
NoDbgInfo = 1 << 9,
LTCG = 1 << 10,
NoDataAlign = 1 << 11,
ManagedPresent = 1 << 12,
SecurityChecks = 1 << 13,
HotPatch = 1 << 14,
CVTCIL = 1 << 15,
MSILModule = 1 << 16,
Sdl = 1 << 17,
PGO = 1 << 18,
Exp = 1 << 19,
};
CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(CompileSym3Flags)
enum class ExportFlags : uint16_t {
None = 0,
IsConstant = 1 << 0,
IsData = 1 << 1,
IsPrivate = 1 << 2,
HasNoName = 1 << 3,
HasExplicitOrdinal = 1 << 4,
IsForwarder = 1 << 5
};
CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ExportFlags)
enum class BinaryAnnotationsOpCode : uint32_t {
Invalid,
CodeOffset,
ChangeCodeOffsetBase,
ChangeCodeOffset,
ChangeCodeLength,
ChangeFile,
ChangeLineOffset,
ChangeLineEndDelta,
ChangeRangeKind,
ChangeColumnStart,
ChangeColumnEndDelta,
ChangeCodeOffsetAndLineOffset,
ChangeCodeLengthAndCodeOffset,
ChangeColumnEnd,
};
enum class FrameCookieKind : uint8_t {
Copy,
XorStackPointer,
XorFramePointer,
XorR13,
};
enum class RegisterId : uint16_t {
#define CV_REGISTERS_ALL
#define CV_REGISTER(name, value) name = value,
#include "CodeViewRegisters.def"
#undef CV_REGISTER
#undef CV_REGISTERS_ALL
};
struct CPURegister {
CPURegister() = delete;
CPURegister(CPUType Cpu, codeview::RegisterId Reg) {
this->Cpu = Cpu;
this->Reg = Reg;
}
CPUType Cpu;
RegisterId Reg;
};
enum class EncodedFramePtrReg : uint8_t {
None = 0,
StackPtr = 1,
FramePtr = 2,
BasePtr = 3,
};
RegisterId decodeFramePtrReg(EncodedFramePtrReg EncodedReg, CPUType CPU);
EncodedFramePtrReg encodeFramePtrReg(RegisterId Reg, CPUType CPU);
enum class ThunkOrdinal : uint8_t {
Standard,
ThisAdjustor,
Vcall,
Pcode,
UnknownLoad,
TrampIncremental,
BranchIsland
};
enum class TrampolineType : uint16_t { TrampIncremental, BranchIsland };
enum class FileChecksumKind : uint8_t { None, MD5, SHA1, SHA256 };
enum LineFlags : uint16_t {
LF_None = 0,
LF_HaveColumns = 1, };
struct FrameData {
support::ulittle32_t RvaStart;
support::ulittle32_t CodeSize;
support::ulittle32_t LocalSize;
support::ulittle32_t ParamsSize;
support::ulittle32_t MaxStackSize;
support::ulittle32_t FrameFunc;
support::ulittle16_t PrologSize;
support::ulittle16_t SavedRegsSize;
support::ulittle32_t Flags;
enum : uint32_t {
HasSEH = 1 << 0,
HasEH = 1 << 1,
IsFunctionStart = 1 << 2,
};
};
struct CrossModuleExport {
support::ulittle32_t Local;
support::ulittle32_t Global;
};
struct CrossModuleImport {
support::ulittle32_t ModuleNameOffset;
support::ulittle32_t Count; };
enum class CodeViewContainer { ObjectFile, Pdb };
inline uint32_t alignOf(CodeViewContainer Container) {
if (Container == CodeViewContainer::ObjectFile)
return 1;
return 4;
}
}
}
#endif