#ifndef LLVM_READOBJ_CODEVIEW_H
#define LLVM_READOBJ_CODEVIEW_H
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/Support/Endian.h"
namespace llvm {
namespace codeview {
using llvm::support::little32_t;
using llvm::support::ulittle16_t;
using llvm::support::ulittle32_t;
struct FrameData {
ulittle32_t RvaStart;
ulittle32_t CodeSize;
ulittle32_t LocalSize;
ulittle32_t ParamsSize;
ulittle32_t MaxStackSize;
ulittle32_t FrameFunc;
ulittle16_t PrologSize;
ulittle16_t SavedRegsSize;
ulittle32_t Flags;
enum : uint32_t {
HasSEH = 1 << 0,
HasEH = 1 << 1,
IsFunctionStart = 1 << 2,
};
};
struct TypeRecordPrefix {
ulittle16_t Len; ulittle16_t Leaf; };
struct TypeServer2 {
char Signature[16]; ulittle32_t Age;
};
struct StringId {
TypeIndex id;
};
struct FuncId {
TypeIndex ParentScope;
TypeIndex FunctionType;
};
struct ClassType {
ulittle16_t MemberCount; ulittle16_t Properties; TypeIndex FieldList; TypeIndex DerivedFrom; TypeIndex VShape; };
struct UnionType {
ulittle16_t MemberCount; ulittle16_t Properties; TypeIndex FieldList; };
struct PointerType {
TypeIndex PointeeType;
ulittle32_t Attrs;
PointerKind getPtrKind() const { return PointerKind(Attrs & 0x1f); }
PointerMode getPtrMode() const { return PointerMode((Attrs >> 5) & 0x07); }
bool isFlat() const { return Attrs & (1 << 8); }
bool isVolatile() const { return Attrs & (1 << 9); }
bool isConst() const { return Attrs & (1 << 10); }
bool isUnaligned() const { return Attrs & (1 << 11); }
bool isPointerToDataMember() const {
return getPtrMode() == PointerMode::PointerToDataMember;
}
bool isPointerToMemberFunction() const {
return getPtrMode() == PointerMode::PointerToMemberFunction;
}
bool isPointerToMember() const {
return isPointerToMemberFunction() || isPointerToDataMember();
}
};
struct PointerToMemberTail {
TypeIndex ClassType;
ulittle16_t Representation; };
struct TypeModifier {
TypeIndex ModifiedType;
ulittle16_t Modifiers; };
struct VTableShape {
ulittle16_t VFEntryCount;
};
struct UDTSrcLine {
TypeIndex UDT; TypeIndex SourceFile; ulittle32_t LineNumber;
};
struct ArgList {
ulittle32_t NumArgs; };
struct BuildInfo {
ulittle16_t NumArgs; };
struct EnumType {
ulittle16_t NumEnumerators; ulittle16_t Properties;
TypeIndex UnderlyingType;
TypeIndex FieldListType;
};
struct ArrayType {
TypeIndex ElementType;
TypeIndex IndexType;
};
struct VFTableType {
TypeIndex CompleteClass; TypeIndex OverriddenVFTable; ulittle32_t VFPtrOffset; ulittle32_t NamesLen; };
struct MemberFuncId {
TypeIndex ClassType;
TypeIndex FunctionType;
};
struct ProcedureType {
TypeIndex ReturnType;
CallingConvention CallConv;
FunctionOptions Options;
ulittle16_t NumParameters;
TypeIndex ArgListType;
};
struct MemberFunctionType {
TypeIndex ReturnType;
TypeIndex ClassType;
TypeIndex ThisType;
CallingConvention CallConv;
FunctionOptions Options;
ulittle16_t NumParameters;
TypeIndex ArgListType;
little32_t ThisAdjustment;
};
struct MemberAttributes {
ulittle16_t Attrs;
MemberAccess getAccess() const {
return MemberAccess(unsigned(Attrs) & unsigned(MethodOptions::AccessMask));
}
MethodKind getMethodKind() const {
return MethodKind(
(unsigned(Attrs) & unsigned(MethodOptions::MethodKindMask)) >> 2);
}
MethodOptions getFlags() const {
return MethodOptions(
unsigned(Attrs) &
~unsigned(MethodOptions::AccessMask | MethodOptions::MethodKindMask));
}
bool isVirtual() const {
auto MP = getMethodKind();
return MP != MethodKind::Vanilla && MP != MethodKind::Friend &&
MP != MethodKind::Static;
}
bool isIntroducedVirtual() const {
auto MP = getMethodKind();
return MP == MethodKind::IntroducingVirtual ||
MP == MethodKind::PureIntroducingVirtual;
}
};
struct NestedType {
ulittle16_t Pad0; TypeIndex Type; };
struct OneMethod {
MemberAttributes Attrs;
TypeIndex Type;
MethodKind getMethodKind() const {
return Attrs.getMethodKind();
}
bool isVirtual() const { return Attrs.isVirtual(); }
bool isIntroducedVirtual() const { return Attrs.isIntroducedVirtual(); }
};
struct MethodListEntry {
MemberAttributes Attrs;
ulittle16_t Padding;
TypeIndex Type;
MethodKind getMethodKind() const {
return Attrs.getMethodKind();
}
bool isVirtual() const { return Attrs.isVirtual(); }
bool isIntroducedVirtual() const { return Attrs.isIntroducedVirtual(); }
};
struct OverloadedMethod {
ulittle16_t MethodCount; TypeIndex MethList; };
struct VirtualFunctionPointer {
ulittle16_t Pad0;
TypeIndex Type; };
struct DataMember {
MemberAttributes Attrs; TypeIndex Type;
};
struct StaticDataMember {
MemberAttributes Attrs; TypeIndex Type;
};
struct Enumerator {
MemberAttributes Attrs; };
struct BaseClass {
MemberAttributes Attrs; TypeIndex BaseType; };
struct VirtualBaseClass {
MemberAttributes Attrs; TypeIndex BaseType; TypeIndex VBPtrType; };
} }
#endif // LLVM_READOBJ_CODEVIEW_H