LLVM: lib/ObjectYAML/CodeViewYAMLTypes.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
35#include
36#include
37#include
38#include
39
40using namespace llvm;
45
49
52
64
70
73
74namespace llvm {
77
88
106
116
126
139
140}
141}
142}
143
145 OS << G;
146}
147
149 if (Scalar.size() != 38)
150 return "GUID strings are 38 characters long";
151 if (Scalar.front() != '{' || Scalar.back() != '}')
152 return "GUID is not enclosed in {}";
156 if (A.size() != 5 || Scalar[8] != '-' || Scalar[13] != '-' ||
158 return "GUID sections are not properly delineated with dashes";
159 struct MSGuid {
164 };
165 MSGuid G = {};
170 return "GUID contains non hex digits";
171 G.Data4 = (D41 << 48) | D42;
172 ::memcpy(&S, &G, sizeof(GUID));
173 return "";
174}
175
179}
180
187}
188
191}
192
195 return "";
196}
197
200#define CV_TYPE(name, val) io.enumCase(Value, #name, name);
201#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
202#undef CV_TYPE
203}
204
223}
224
234}
235
263}
264
274 IO.enumCase(Kind, "BasedOnSegmentAddress",
281}
282
291}
292
298}
299
306}
307
316 IO.enumCase(Kind, "PureIntroducingVirtual",
318}
319
326}
327
331}
332
343}
344
351}
352
360}
361
380}
381
389}
390
394}
395
396namespace llvm {
399
404
412
423
427
433
437
441
447
454
458
459}
460}
461}
462
463namespace {
464
466public:
467 explicit MemberRecordConversionVisitor(std::vector &Records)
468 : Records(Records) {}
469
470#define TYPE_RECORD(EnumName, EnumVal, Name)
471#define MEMBER_RECORD(EnumName, EnumVal, Name) \
472 Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override { \
473 return visitKnownMemberImpl(Record); \
474 }
475#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
476#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
477#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
478private:
479 template Error visitKnownMemberImpl(T &Record) {
481 auto Impl = std::make_shared<MemberRecordImpl>(K);
482 Impl->Record = Record;
485 }
486
487 std::vector &Records;
488};
489
490}
491
493 MemberRecordConversionVisitor V(Members);
498}
499
504 for (const auto &Member : Members) {
505 Member.Member->writeTo(CRB);
506 }
509}
510
516}
517
518namespace llvm {
521
532
541
550
556
560
566
571
577
583
590
594
601
605
612
616
620
626
631
638
644
650
654
660
668
672
673}
674}
675}
676
677template
680
681 auto Impl = std::make_shared<LeafRecordImpl>(Type.kind());
682 if (auto EC = Impl->fromCodeViewRecord(Type))
683 return std::move(EC);
684 Result.Leaf = Impl;
685 return Result;
686}
687
689#define TYPE_RECORD(EnumName, EnumVal, ClassName) \
690 case EnumName: \
691 return fromCodeViewRecordImpl<ClassName##Record>(Type);
692#define TYPE_RECORD_ALIAS(EnumName, EnumVal, AliasName, ClassName) \
693 TYPE_RECORD(EnumName, EnumVal, ClassName)
694#define MEMBER_RECORD(EnumName, EnumVal, ClassName)
695#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, AliasName, ClassName)
696 switch (Type.kind()) {
697#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
698 default:
700 }
702}
703
706 return Leaf->toCodeViewRecord(Serializer);
707}
708
709namespace llvm {
710namespace yaml {
711
715
719
720}
721}
722
723template
727 Obj.Leaf = std::make_shared<LeafRecordImpl>(Kind);
728
729 if (Kind == LF_FIELDLIST)
730 Obj.Leaf->map(IO);
731 else
733}
734
735void MappingTraits::mapping(IO &IO, LeafRecord &Obj) {
740
741#define TYPE_RECORD(EnumName, EnumVal, ClassName) \
742 case EnumName: \
743 mapLeafRecordImpl<ClassName##Record>(IO, #ClassName, Kind, Obj); \
744 break;
745#define TYPE_RECORD_ALIAS(EnumName, EnumVal, AliasName, ClassName) \
746 TYPE_RECORD(EnumName, EnumVal, ClassName)
747#define MEMBER_RECORD(EnumName, EnumVal, ClassName)
748#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, AliasName, ClassName)
749 switch (Kind) {
750#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
752 }
753}
754
755template
759 Obj.Member = std::make_shared<MemberRecordImpl>(Kind);
760
762}
763
764void MappingTraits::mapping(IO &IO, MemberRecord &Obj) {
769
770#define MEMBER_RECORD(EnumName, EnumVal, ClassName) \
771 case EnumName: \
772 mapMemberRecordImpl<ClassName##Record>(IO, #ClassName, Kind, Obj); \
773 break;
774#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, AliasName, ClassName) \
775 MEMBER_RECORD(EnumName, EnumVal, ClassName)
776#define TYPE_RECORD(EnumName, EnumVal, ClassName)
777#define TYPE_RECORD_ALIAS(EnumName, EnumVal, AliasName, ClassName)
778 switch (Kind) {
779#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
781 }
782}
783
784std::vector
791
794 "Invalid .debug$T or .debug$P section!");
795
796 std::vector Result;
798 for (const auto &T : Types) {
800 Result.push_back(CVT);
801 }
802 return Result;
803}
804
810 for (const auto &Leaf : Leafs) {
811 CVType T = Leaf.Leaf->toCodeViewRecord(TS);
813 assert(T.length() % 4 == 0 && "Improper type record alignment!");
814 }
819 " section");
821 for (const auto &R : TS.records()) {
823 }
824 assert(Writer.bytesRemaining() == 0 && "Didn't write all type record bytes!");
826}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements the APSInt class, which is a simple class that represents an arbitrary sized int...
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static void mapLeafRecordImpl(IO &IO, const char *Class, TypeLeafKind Kind, LeafRecord &Obj)
Definition CodeViewYAMLTypes.cpp:724
static Expected< LeafRecord > fromCodeViewRecordImpl(CVType Type)
Definition CodeViewYAMLTypes.cpp:678
static void mapMemberRecordImpl(IO &IO, const char *Class, TypeLeafKind Kind, MemberRecord &Obj)
Definition CodeViewYAMLTypes.cpp:756
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
#define LLVM_YAML_DECLARE_BITSET_TRAITS(Type)
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
Utility for declaring that a std::vector of a particular type should be considered a YAML sequence.
#define LLVM_YAML_DECLARE_SCALAR_TRAITS(Type, MustQuote)
#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...
#define LLVM_YAML_DECLARE_MAPPING_TRAITS(Type)
#define LLVM_YAML_DECLARE_ENUM_TRAITS(Type)
LLVM_ABI void print(raw_ostream &OS, bool isSigned) const
An arbitrary precision integer that knows its signedness.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Provides read only access to a subclass of BinaryStream.
Error readInteger(T &Dest)
Read an integer of the specified endianness into Dest and update the stream's offset.
uint64_t bytesRemaining() const
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 ...
Provides write only access to a subclass of WritableBinaryStream.
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
uint64_t bytesRemaining() const
LLVM_ABI Error writeBytes(ArrayRef< uint8_t > Buffer)
Write the bytes specified in Buffer to the underlying stream.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Helper for check-and-exit error handling.
Tagged union holding either a T or a Error.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
TypeIndex insertRecord(ContinuationRecordBuilder &Builder)
ArrayRef< ArrayRef< uint8_t > > records() const
TypeIndex writeLeafType(T &Record)
LLVM_ABI void begin(ContinuationRecordKind RecordKind)
void writeMemberType(RecordType &Record)
PointerToMemberRepresentation Representation
static Error deserializeAs(CVType &CVT, T &Record)
void setIndex(uint32_t I)
uint32_t getIndex() const
This class implements an extremely fast bulk output stream that can only output to a stream.
void bitSetCase(T &Val, StringRef Str, const T ConstVal)
virtual bool outputting() const =0
void enumCase(T &Val, StringRef Str, const T ConstVal)
void mapOptional(StringRef Key, T &Val)
void mapRequired(StringRef Key, T &Val)
The Output class is used to generate a yaml document from in-memory structs and vectors.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI std::vector< LeafRecord > fromDebugT(ArrayRef< uint8_t > DebugTorP, StringRef SectionName)
Definition CodeViewYAMLTypes.cpp:785
LLVM_ABI ArrayRef< uint8_t > toDebugT(ArrayRef< LeafRecord >, BumpPtrAllocator &Alloc, StringRef SectionName)
Definition CodeViewYAMLTypes.cpp:805
PointerMode
Equivalent to CV_ptrmode_e.
@ PointerToMemberFunction
PointerOptions
Equivalent to misc lfPointerAttr bitfields.
MethodKind
Part of member attribute flags. (CV_methodprop_e)
CVRecord< TypeLeafKind > CVType
PointerKind
Equivalent to CV_ptrtype_e.
VarStreamArray< CVType > CVTypeArray
@ HasConstructorOrDestructor
@ HasOverloadedAssignmentOperator
PointerToMemberRepresentation
Equivalent to CV_pmtype_e.
@ MultipleInheritanceData
@ SingleInheritanceFunction
@ VirtualInheritanceFunction
@ MultipleInheritanceFunction
LLVM_ABI Error visitMemberRecordStream(ArrayRef< uint8_t > FieldList, TypeVisitorCallbacks &Callbacks)
CallingConvention
These values correspond to the CV_call_e enumeration, and are documented at the following locations: ...
MethodOptions
Equivalent to CV_fldattr_t bitfield.
@ ConstructorWithVirtualBases
MemberAccess
Source-level access specifier. (CV_access_e)
TypeLeafKind
Duplicate copy of the above enum, but using the official CV names.
TypeRecordKind
Distinguishes individual records in .debug$T or .debug$P section or PDB type stream.
ModifierOptions
Equivalent to CV_modifier_t.
LabelType
Equivalent to CV_LABEL_TYPE_e.
detail::packed_endian_specific_integral< uint32_t, llvm::endianness::little, unaligned > ulittle32_t
detail::packed_endian_specific_integral< uint64_t, llvm::endianness::big, unaligned > ubig64_t
detail::packed_endian_specific_integral< uint16_t, llvm::endianness::little, unaligned > ulittle16_t
This is an optimization pass for GlobalISel generic memory operations.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
bool to_integer(StringRef S, N &Num, unsigned Base=0)
Convert the string S to an integer of the specified type using the radix Base. If Base is 0,...
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
std::shared_ptr< detail::LeafRecordBase > Leaf
static LLVM_ABI Expected< LeafRecord > fromCodeViewRecord(codeview::CVType Type)
Definition CodeViewYAMLTypes.cpp:688
LLVM_ABI codeview::CVType toCodeViewRecord(codeview::AppendingTypeTableBuilder &Serializer) const
Definition CodeViewYAMLTypes.cpp:705
virtual CVType toCodeViewRecord(AppendingTypeTableBuilder &TS) const =0
virtual void map(yaml::IO &io)=0
LeafRecordBase(TypeLeafKind K)
Definition CodeViewYAMLTypes.cpp:81
virtual ~LeafRecordBase()=default
virtual Error fromCodeViewRecord(CVType Type)=0
TypeLeafKind Kind
Definition CodeViewYAMLTypes.cpp:79
CVType toCodeViewRecord(AppendingTypeTableBuilder &TS) const override
LeafRecordImpl(TypeLeafKind K)
Definition CodeViewYAMLTypes.cpp:108
Error fromCodeViewRecord(CVType Type) override
std::vector< MemberRecord > Members
Definition CodeViewYAMLTypes.cpp:114
T Record
Definition CodeViewYAMLTypes.cpp:104
Error fromCodeViewRecord(CVType Type) override
Definition CodeViewYAMLTypes.cpp:95
void map(yaml::IO &io) override
LeafRecordImpl(TypeLeafKind K)
Definition CodeViewYAMLTypes.cpp:90
CVType toCodeViewRecord(AppendingTypeTableBuilder &TS) const override
Definition CodeViewYAMLTypes.cpp:99
virtual void writeTo(ContinuationRecordBuilder &CRB)=0
virtual ~MemberRecordBase()=default
TypeLeafKind Kind
Definition CodeViewYAMLTypes.cpp:118
virtual void map(yaml::IO &io)=0
MemberRecordBase(TypeLeafKind K)
Definition CodeViewYAMLTypes.cpp:120
T Record
Definition CodeViewYAMLTypes.cpp:137
void map(yaml::IO &io) override
void writeTo(ContinuationRecordBuilder &CRB) override
Definition CodeViewYAMLTypes.cpp:133
MemberRecordImpl(TypeLeafKind K)
Definition CodeViewYAMLTypes.cpp:128
This represents the 'GUID' type from windows.h.
static void mapping(IO &io, LeafRecordBase &Record)
Definition CodeViewYAMLTypes.cpp:713
static void mapping(IO &io, MemberRecordBase &Record)
Definition CodeViewYAMLTypes.cpp:717
This class should be specialized by any type that needs to be converted to/from a YAML mapping.
This class should be specialized by any integer type that is a union of bit values and the YAML repre...
This class should be specialized by any integral type that converts to/from a YAML scalar where there...
This class should be specialized by type that requires custom conversion to/from a yaml scalar.