41 using namespace llvm::codeview;
42 using namespace llvm::CodeViewYAML;
43 using namespace llvm::CodeViewYAML::detail;
44 using namespace llvm::yaml;
75 namespace CodeViewYAML {
96 return TypeDeserializer::deserializeAs<T>(
Type,
Record);
149 if (Scalar.
size() != 38)
150 return "GUID strings are 38 characters long";
151 if (Scalar[0] !=
'{' || Scalar[37] !=
'}')
152 return "GUID is not enclosed in {}";
153 if (Scalar[9] !=
'-' || Scalar[14] !=
'-' || Scalar[19] !=
'-' ||
155 return "GUID sections are not properly delineated with dashes";
157 uint8_t *OutBuffer = S.
Guid;
158 for (
auto Iter = Scalar.
begin(); Iter != Scalar.
end();) {
159 if (*Iter ==
'-' || *Iter ==
'{' || *Iter ==
'}') {
165 *OutBuffer++ = Value;
195 #define CV_TYPE(name, val) io.enumCase(Value, #name, name);
196 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
203 IO.
enumCase(Value,
"SingleInheritanceData",
205 IO.
enumCase(Value,
"MultipleInheritanceData",
207 IO.
enumCase(Value,
"VirtualInheritanceData",
210 IO.
enumCase(Value,
"SingleInheritanceFunction",
212 IO.
enumCase(Value,
"MultipleInheritanceFunction",
214 IO.
enumCase(Value,
"VirtualInheritanceFunction",
216 IO.
enumCase(Value,
"GeneralFunction",
268 IO.
enumCase(Kind,
"BasedOnSegmentAddress",
282 IO.
enumCase(Mode,
"PointerToMemberFunction",
310 IO.
enumCase(Kind,
"PureIntroducingVirtual",
352 IO.
bitSetCase(Options,
"ConstructorWithVirtualBases",
358 IO.
bitSetCase(Options,
"HasConstructorOrDestructor",
360 IO.
bitSetCase(Options,
"HasOverloadedOperator",
365 IO.
bitSetCase(Options,
"HasOverloadedAssignmentOperator",
367 IO.
bitSetCase(Options,
"HasConversionOperator",
391 namespace CodeViewYAML {
461 explicit MemberRecordConversionVisitor(std::vector<MemberRecord> &Records)
462 : Records(Records) {}
464 #define TYPE_RECORD(EnumName, EnumVal, Name)
465 #define MEMBER_RECORD(EnumName, EnumVal, Name) \
466 Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
467 return visitKnownMemberImpl(Record); \
469 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
470 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
471 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
473 template <
typename T>
Error visitKnownMemberImpl(
T &
Record) {
475 auto Impl = std::make_shared<MemberRecordImpl<T>>(K);
476 Impl->Record = Record;
481 std::vector<MemberRecord> &Records;
487 MemberRecordConversionVisitor V(Members);
495 for (
const auto &Member : Members) {
496 Member.Member->writeTo(FLRB);
510 namespace CodeViewYAML {
519 IO.
mapRequired(
"DerivationList", Record.DerivationList);
534 IO.
mapRequired(
"NumEnumerators", Record.MemberCount);
539 IO.
mapRequired(
"UnderlyingType", Record.UnderlyingType);
565 IO.
mapRequired(
"FunctionType", Record.FunctionType);
587 IO.
mapRequired(
"CompleteClass", Record.CompleteClass);
588 IO.
mapRequired(
"OverriddenVFTable", Record.OverriddenVFTable);
602 IO.
mapRequired(
"NumOverloads", Record.NumOverloads);
650 IO.
mapRequired(
"ContinuationIndex", Record.ContinuationIndex);
657 template <
typename T>
661 auto Impl = std::make_shared<LeafRecordImpl<T>>(Type.
kind());
662 if (
auto EC = Impl->fromCodeViewRecord(Type))
663 return std::move(
EC);
669 #define TYPE_RECORD(EnumName, EnumVal, ClassName) \
671 return fromCodeViewRecordImpl<ClassName##Record>(Type);
672 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, AliasName, ClassName) \
673 TYPE_RECORD(EnumName, EnumVal, ClassName)
674 #define MEMBER_RECORD(EnumName, EnumVal, ClassName)
675 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, AliasName, ClassName)
676 switch (Type.
kind()) {
677 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
686 return Leaf->toCodeViewRecord(TTB);
690 return Leaf->toCodeViewRecord(TTB);
707 template <
typename ConcreteType>
713 if (Kind == LF_FIELDLIST)
722 Kind = Obj.
Leaf->Kind;
725 #define TYPE_RECORD(EnumName, EnumVal, ClassName) \
727 mapLeafRecordImpl<ClassName##Record>(IO, #ClassName, Kind, Obj); \
729 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, AliasName, ClassName) \
730 TYPE_RECORD(EnumName, EnumVal, ClassName)
731 #define MEMBER_RECORD(EnumName, EnumVal, ClassName)
732 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, AliasName, ClassName)
734 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
739 template <
typename ConcreteType>
754 #define MEMBER_RECORD(EnumName, EnumVal, ClassName) \
756 mapMemberRecordImpl<ClassName##Record>(IO, #ClassName, Kind, Obj); \
758 #define MEMBER_RECORD_ALIAS(EnumName, EnumVal, AliasName, ClassName) \
759 MEMBER_RECORD(EnumName, EnumVal, ClassName)
760 #define TYPE_RECORD(EnumName, EnumVal, ClassName)
761 #define TYPE_RECORD_ALIAS(EnumName, EnumVal, AliasName, ClassName)
763 #include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
768 std::vector<LeafRecord>
778 std::vector<LeafRecord> Result;
780 for (
const auto &
T : Types) {
781 auto CVT = Err(LeafRecord::fromCodeViewRecord(
T));
782 Result.push_back(CVT);
791 for (
const auto &Leaf : Leafs) {
792 CVType T = Leaf.toCodeViewRecord(TTB);
794 assert(T.
length() % 4 == 0 &&
"Improper type record alignment!");
799 ExitOnError Err(
"Error writing type record to .debug$T section");
801 for (
const auto &R : TTB.
records()) {
PointerKind
Equivalent to CV_ptrtype_e.
void bitSetCase(T &Val, const char *Str, const T ConstVal)
Error writeBytes(ArrayRef< uint8_t > Buffer)
Write the bytes specified in Buffer to the underlying stream.
virtual void map(yaml::IO &io)=0
TypeIndex writeKnownType(T &Record)
void mapOptional(const char *Key, T &Val)
Error readInteger(T &Dest)
Read an integer of the specified endianness into Dest and update the stream's offset.
TypeLeafKind
Duplicate copy of the above enum, but using the official CV names.
void print(raw_ostream &OS, bool isSigned) const
Helper for check-and-exit error handling.
Error visitMemberRecordStream(ArrayRef< uint8_t > FieldList, TypeVisitorCallbacks &Callbacks)
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
Utility for declaring that a std::vector of a particular type should be considered a YAML sequence...
LeafRecordImpl(TypeLeafKind K)
void writeTo(FieldListRecordBuilder &FLRB) override
CVRecord< TypeLeafKind > CVType
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
#define LLVM_YAML_DECLARE_ENUM_TRAITS(Type)
ArrayRef< uint8_t > toDebugT(ArrayRef< LeafRecord >, BumpPtrAllocator &Alloc)
void setIndex(uint32_t I)
virtual void map(yaml::IO &io)=0
This represents the 'GUID' type from windows.h.
Tagged union holding either a T or a Error.
This class should be specialized by any type that needs to be converted to/from a YAML mapping...
ModifierOptions
Equivalent to CV_modifier_t.
LabelType
Equivalent to CV_LABEL_TYPE_e.
Error fromCodeViewRecord(CVType Type) override
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
MethodKind
Part of member attribute flags. (CV_methodprop_e)
uint32_t getIndex() const
std::vector< LeafRecord > fromDebugT(ArrayRef< uint8_t > DebugT)
TypeRecordKind
Distinguishes individual records in .debug$T section or PDB type stream.
static void mapping(IO &io, LeafRecordBase &Record)
void enumCase(T &Val, const char *Str, const T ConstVal)
Function Alias Analysis false
uint32_t bytesRemaining() const
The instances of the Type class are immutable: once they are created, they are never changed...
Allocate memory in an ever growing pool, as if by bump-pointer.
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, size_t Alignment)
Allocate space at the specified alignment.
static Expected< LeafRecord > fromCodeViewRecordImpl(CVType Type)
Provides write only access to a subclass of WritableBinaryStream.
MemberRecordImpl(TypeLeafKind K)
Error writeInteger(T Value)
Write the the integer Value to the underlying stream in the specified endianness. ...
The Output class is used to generate a yaml document from in-memory structs and vectors.
static void mapMemberRecordImpl(IO &IO, const char *Class, TypeLeafKind Kind, MemberRecord &Obj)
static const char *const Magic
PointerOptions
Equivalent to misc lfPointerAttr bitfields.
static ErrorSuccess success()
Create a success value.
LeafRecordBase(TypeLeafKind K)
#define LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(type)
Utility for declaring that a std::vector of a particular type should be considered a YAML flow sequen...
std::vector< MemberRecord > Members
This class should be specialized by any integral type that converts to/from a YAML scalar where there...
ArrayRef< uint8_t > content() const
This class should be specialized by type that requires custom conversion to/from a yaml scalar...
static void mapping(IO &io, MemberRecordBase &Record)
LeafRecordImpl(TypeLeafKind K)
PointerMode
Equivalent to CV_ptrmode_e.
std::shared_ptr< detail::MemberRecordBase > Member
#define LLVM_YAML_DECLARE_SCALAR_TRAITS(Type, MustQuote)
#define LLVM_YAML_DECLARE_BITSET_TRAITS(Type)
MethodOptions
Equivalent to CV_fldattr_t bitfield.
static void mapLeafRecordImpl(IO &IO, const char *Class, TypeLeafKind Kind, LeafRecord &Obj)
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
llvm_unreachable("Unknown RegBank!")
void writeMemberType(T &Record)
CVType toCodeViewRecord(TypeTableBuilder &TTB) const override
uint32_t bytesRemaining() const
PointerToMemberRepresentation
Equivalent to CV_pmtype_e.
virtual bool outputting()=0
This class should be specialized by any integer type that is a union of bit values and the YAML repre...
MemberAccess
Source-level access specifier. (CV_access_e)
#define LLVM_YAML_DECLARE_MAPPING_TRAITS(Type)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
static unsigned hexDigitValue(char C)
Interpret the given character C as a hexadecimal digit and return its value.
Lightweight error class with error context and mandatory checking.
CallingConvention
These values correspond to the CV_call_e enumeration, and are documented at the following locations: ...
MemberRecordBase(TypeLeafKind K)
This class implements an extremely fast bulk output stream that can only output to a stream...
Provides read only access to a subclass of BinaryStream.
StringRef - Represent a constant reference to a string, i.e.
ArrayRef< ArrayRef< uint8_t > > records() const
void mapRequired(const char *Key, T &Val)
std::shared_ptr< detail::LeafRecordBase > Leaf
Error readArray(ArrayRef< T > &Array, uint32_t NumElements)
Get a reference to a NumElements element array of objects of type T from the underlying stream as if ...
PointerToMemberRepresentation Representation