#ifndef LLVM_DEBUGINFO_PDB_PDBTYPES_H
#define LLVM_DEBUGINFO_PDB_PDBTYPES_H
#include "llvm/ADT/APFloat.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
#include "llvm/DebugInfo/PDB/IPDBFrameData.h"
#include "llvm/DebugInfo/PDB/Native/RawTypes.h"
#include <cctype>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <functional>
namespace llvm {
namespace pdb {
typedef uint32_t SymIndexId;
class IPDBDataStream;
class IPDBInjectedSource;
class IPDBLineNumber;
class IPDBSectionContrib;
class IPDBSession;
class IPDBSourceFile;
class IPDBTable;
class PDBSymDumper;
class PDBSymbol;
class PDBSymbolExe;
class PDBSymbolCompiland;
class PDBSymbolCompilandDetails;
class PDBSymbolCompilandEnv;
class PDBSymbolFunc;
class PDBSymbolBlock;
class PDBSymbolData;
class PDBSymbolAnnotation;
class PDBSymbolLabel;
class PDBSymbolPublicSymbol;
class PDBSymbolTypeUDT;
class PDBSymbolTypeEnum;
class PDBSymbolTypeFunctionSig;
class PDBSymbolTypePointer;
class PDBSymbolTypeArray;
class PDBSymbolTypeBuiltin;
class PDBSymbolTypeTypedef;
class PDBSymbolTypeBaseClass;
class PDBSymbolTypeFriend;
class PDBSymbolTypeFunctionArg;
class PDBSymbolFuncDebugStart;
class PDBSymbolFuncDebugEnd;
class PDBSymbolUsingNamespace;
class PDBSymbolTypeVTableShape;
class PDBSymbolTypeVTable;
class PDBSymbolCustom;
class PDBSymbolThunk;
class PDBSymbolTypeCustom;
class PDBSymbolTypeManaged;
class PDBSymbolTypeDimension;
class PDBSymbolUnknown;
using IPDBEnumSymbols = IPDBEnumChildren<PDBSymbol>;
using IPDBEnumSourceFiles = IPDBEnumChildren<IPDBSourceFile>;
using IPDBEnumDataStreams = IPDBEnumChildren<IPDBDataStream>;
using IPDBEnumLineNumbers = IPDBEnumChildren<IPDBLineNumber>;
using IPDBEnumTables = IPDBEnumChildren<IPDBTable>;
using IPDBEnumInjectedSources = IPDBEnumChildren<IPDBInjectedSource>;
using IPDBEnumSectionContribs = IPDBEnumChildren<IPDBSectionContrib>;
using IPDBEnumFrameData = IPDBEnumChildren<IPDBFrameData>;
enum class PDB_ReaderType {
DIA = 0,
Native = 1,
};
enum class PDB_TableType {
TableInvalid = 0,
Symbols,
SourceFiles,
LineNumbers,
SectionContribs,
Segments,
InjectedSources,
FrameData,
InputAssemblyFiles,
Dbg
};
enum PDB_NameSearchFlags {
NS_Default = 0x0,
NS_CaseSensitive = 0x1,
NS_CaseInsensitive = 0x2,
NS_FileNameExtMatch = 0x4,
NS_Regex = 0x8,
NS_UndecoratedName = 0x10,
NS_CaseInFileNameExt = NS_CaseInsensitive | NS_FileNameExtMatch,
NS_CaseRegex = NS_Regex | NS_CaseSensitive,
NS_CaseInRex = NS_Regex | NS_CaseInsensitive
};
enum class PDB_Checksum { None = 0, MD5 = 1, SHA1 = 2, SHA256 = 3 };
using PDB_Cpu = codeview::CPUType;
enum class PDB_Machine {
Invalid = 0xffff,
Unknown = 0x0,
Am33 = 0x13,
Amd64 = 0x8664,
Arm = 0x1C0,
Arm64 = 0xaa64,
ArmNT = 0x1C4,
Ebc = 0xEBC,
x86 = 0x14C,
Ia64 = 0x200,
M32R = 0x9041,
Mips16 = 0x266,
MipsFpu = 0x366,
MipsFpu16 = 0x466,
PowerPC = 0x1F0,
PowerPCFP = 0x1F1,
R4000 = 0x166,
SH3 = 0x1A2,
SH3DSP = 0x1A3,
SH4 = 0x1A6,
SH5 = 0x1A8,
Thumb = 0x1C2,
WceMipsV2 = 0x169
};
struct PDB_SourceCompression {
enum : uint32_t {
None,
RunLengthEncoded,
Huffman,
LZ,
DotNet = 101,
};
};
using PDB_CallingConv = codeview::CallingConvention;
using PDB_Lang = codeview::SourceLanguage;
enum class PDB_DataKind {
Unknown,
Local,
StaticLocal,
Param,
ObjectPtr,
FileStatic,
Global,
Member,
StaticMember,
Constant
};
enum class PDB_SymType {
None,
Exe,
Compiland,
CompilandDetails,
CompilandEnv,
Function,
Block,
Data,
Annotation,
Label,
PublicSymbol,
UDT,
Enum,
FunctionSig,
PointerType,
ArrayType,
BuiltinType,
Typedef,
BaseClass,
Friend,
FunctionArg,
FuncDebugStart,
FuncDebugEnd,
UsingNamespace,
VTableShape,
VTable,
Custom,
Thunk,
CustomType,
ManagedType,
Dimension,
CallSite,
InlineSite,
BaseInterface,
VectorType,
MatrixType,
HLSLType,
Caller,
Callee,
Export,
HeapAllocationSite,
CoffGroup,
Inlinee,
Max
};
enum class PDB_LocType {
Null,
Static,
TLS,
RegRel,
ThisRel,
Enregistered,
BitField,
Slot,
IlRel,
MetaData,
Constant,
RegRelAliasIndir,
Max
};
enum class PDB_UdtType { Struct, Class, Union, Interface };
enum class PDB_StackFrameType : uint16_t {
FPO,
KernelTrap,
KernelTSS,
EBP,
FrameData,
Unknown = 0xffff
};
enum class PDB_MemoryType : uint16_t {
Code,
Data,
Stack,
HeapCode,
Any = 0xffff
};
enum class PDB_BuiltinType {
None = 0,
Void = 1,
Char = 2,
WCharT = 3,
Int = 6,
UInt = 7,
Float = 8,
BCD = 9,
Bool = 10,
Long = 13,
ULong = 14,
Currency = 25,
Date = 26,
Variant = 27,
Complex = 28,
Bitfield = 29,
BSTR = 30,
HResult = 31,
Char16 = 32,
Char32 = 33,
Char8 = 34,
};
enum PDB_UndnameFlags : uint32_t {
Undname_Complete = 0x0,
Undname_NoLeadingUnderscores = 0x1,
Undname_NoMsKeywords = 0x2,
Undname_NoFuncReturns = 0x4,
Undname_NoAllocModel = 0x8,
Undname_NoAllocLang = 0x10,
Undname_Reserved1 = 0x20,
Undname_Reserved2 = 0x40,
Undname_NoThisType = 0x60,
Undname_NoAccessSpec = 0x80,
Undname_NoThrowSig = 0x100,
Undname_NoMemberType = 0x200,
Undname_NoReturnUDTModel = 0x400,
Undname_32BitDecode = 0x800,
Undname_NameOnly = 0x1000,
Undname_TypeOnly = 0x2000,
Undname_HaveParams = 0x4000,
Undname_NoECSU = 0x8000,
Undname_NoIdentCharCheck = 0x10000,
Undname_NoPTR64 = 0x20000
};
enum class PDB_MemberAccess { Private = 1, Protected = 2, Public = 3 };
struct VersionInfo {
uint32_t Major;
uint32_t Minor;
uint32_t Build;
uint32_t QFE;
};
enum PDB_VariantType {
Empty,
Unknown,
Int8,
Int16,
Int32,
Int64,
Single,
Double,
UInt8,
UInt16,
UInt32,
UInt64,
Bool,
String
};
struct Variant {
Variant() = default;
explicit Variant(bool V) : Type(PDB_VariantType::Bool) { Value.Bool = V; }
explicit Variant(int8_t V) : Type(PDB_VariantType::Int8) { Value.Int8 = V; }
explicit Variant(int16_t V) : Type(PDB_VariantType::Int16) {
Value.Int16 = V;
}
explicit Variant(int32_t V) : Type(PDB_VariantType::Int32) {
Value.Int32 = V;
}
explicit Variant(int64_t V) : Type(PDB_VariantType::Int64) {
Value.Int64 = V;
}
explicit Variant(float V) : Type(PDB_VariantType::Single) {
Value.Single = V;
}
explicit Variant(double V) : Type(PDB_VariantType::Double) {
Value.Double = V;
}
explicit Variant(uint8_t V) : Type(PDB_VariantType::UInt8) {
Value.UInt8 = V;
}
explicit Variant(uint16_t V) : Type(PDB_VariantType::UInt16) {
Value.UInt16 = V;
}
explicit Variant(uint32_t V) : Type(PDB_VariantType::UInt32) {
Value.UInt32 = V;
}
explicit Variant(uint64_t V) : Type(PDB_VariantType::UInt64) {
Value.UInt64 = V;
}
Variant(const Variant &Other) {
*this = Other;
}
~Variant() {
if (Type == PDB_VariantType::String)
delete[] Value.String;
}
PDB_VariantType Type = PDB_VariantType::Empty;
union {
bool Bool;
int8_t Int8;
int16_t Int16;
int32_t Int32;
int64_t Int64;
float Single;
double Double;
uint8_t UInt8;
uint16_t UInt16;
uint32_t UInt32;
uint64_t UInt64;
char *String;
} Value;
bool isIntegralType() const {
switch (Type) {
case Bool:
case Int8:
case Int16:
case Int32:
case Int64:
case UInt8:
case UInt16:
case UInt32:
case UInt64:
return true;
default:
return false;
}
}
#define VARIANT_WIDTH(Enum, NumBits) \
case PDB_VariantType::Enum: \
return NumBits;
unsigned getBitWidth() const {
switch (Type) {
VARIANT_WIDTH(Bool, 1u)
VARIANT_WIDTH(Int8, 8u)
VARIANT_WIDTH(Int16, 16u)
VARIANT_WIDTH(Int32, 32u)
VARIANT_WIDTH(Int64, 64u)
VARIANT_WIDTH(Single, 32u)
VARIANT_WIDTH(Double, 64u)
VARIANT_WIDTH(UInt8, 8u)
VARIANT_WIDTH(UInt16, 16u)
VARIANT_WIDTH(UInt32, 32u)
VARIANT_WIDTH(UInt64, 64u)
default:
assert(false && "Variant::toAPSInt called on non-numeric type");
return 0u;
}
}
#undef VARIANT_WIDTH
#define VARIANT_APSINT(Enum, NumBits, IsUnsigned) \
case PDB_VariantType::Enum: \
return APSInt(APInt(NumBits, Value.Enum), IsUnsigned);
APSInt toAPSInt() const {
switch (Type) {
VARIANT_APSINT(Bool, 1u, true)
VARIANT_APSINT(Int8, 8u, false)
VARIANT_APSINT(Int16, 16u, false)
VARIANT_APSINT(Int32, 32u, false)
VARIANT_APSINT(Int64, 64u, false)
VARIANT_APSINT(UInt8, 8u, true)
VARIANT_APSINT(UInt16, 16u, true)
VARIANT_APSINT(UInt32, 32u, true)
VARIANT_APSINT(UInt64, 64u, true)
default:
assert(false && "Variant::toAPSInt called on non-integral type");
return APSInt();
}
}
#undef VARIANT_APSINT
APFloat toAPFloat() const {
switch (Type) {
case PDB_VariantType::Single:
case PDB_VariantType::UInt32:
case PDB_VariantType::Int32:
return APFloat(Value.Single);
case PDB_VariantType::Double:
case PDB_VariantType::UInt64:
case PDB_VariantType::Int64:
return APFloat(Value.Double);
default:
assert(false && "Variant::toAPFloat called on non-floating-point type");
return APFloat::getZero(APFloat::IEEEsingle());
}
}
#define VARIANT_EQUAL_CASE(Enum) \
case PDB_VariantType::Enum: \
return Value.Enum == Other.Value.Enum;
bool operator==(const Variant &Other) const {
if (Type != Other.Type)
return false;
switch (Type) {
VARIANT_EQUAL_CASE(Bool)
VARIANT_EQUAL_CASE(Int8)
VARIANT_EQUAL_CASE(Int16)
VARIANT_EQUAL_CASE(Int32)
VARIANT_EQUAL_CASE(Int64)
VARIANT_EQUAL_CASE(Single)
VARIANT_EQUAL_CASE(Double)
VARIANT_EQUAL_CASE(UInt8)
VARIANT_EQUAL_CASE(UInt16)
VARIANT_EQUAL_CASE(UInt32)
VARIANT_EQUAL_CASE(UInt64)
VARIANT_EQUAL_CASE(String)
default:
return true;
}
}
#undef VARIANT_EQUAL_CASE
bool operator!=(const Variant &Other) const { return !(*this == Other); }
Variant &operator=(const Variant &Other) {
if (this == &Other)
return *this;
if (Type == PDB_VariantType::String)
delete[] Value.String;
Type = Other.Type;
Value = Other.Value;
if (Other.Type == PDB_VariantType::String &&
Other.Value.String != nullptr) {
Value.String = new char[strlen(Other.Value.String) + 1];
::strcpy(Value.String, Other.Value.String);
}
return *this;
}
};
} }
namespace std {
template <> struct hash<llvm::pdb::PDB_SymType> {
using argument_type = llvm::pdb::PDB_SymType;
using result_type = std::size_t;
result_type operator()(const argument_type &Arg) const {
return std::hash<int>()(static_cast<int>(Arg));
}
};
}
#endif