71 return ScalarTraits<StringRef>::input(S, V,
T.value);
74void ScalarTraits<TypeName>::output(
const TypeName &
T,
void *V,
76 ScalarTraits<StringRef>::output(
T.value, V, R);
79void ScalarEnumerationTraits<SymbolKind>::enumeration(IO &io,
82 for (
const auto &E : SymbolNames)
83 io.enumCase(
Value, E.Name.str().c_str(), E.
Value);
86void ScalarBitSetTraits<CompileSym2Flags>::bitset(IO &io,
89 for (
const auto &E : FlagNames) {
90 io.bitSetCase(Flags, E.Name.str().c_str(),
95void ScalarBitSetTraits<CompileSym3Flags>::bitset(IO &io,
98 for (
const auto &E : FlagNames) {
99 io.bitSetCase(Flags, E.Name.str().c_str(),
104void ScalarBitSetTraits<ExportFlags>::bitset(IO &io,
ExportFlags &Flags) {
106 for (
const auto &E : FlagNames) {
107 io.bitSetCase(Flags, E.Name.str().c_str(),
112void ScalarBitSetTraits<PublicSymFlags>::bitset(IO &io,
PublicSymFlags &Flags) {
114 for (
const auto &E : FlagNames) {
115 io.bitSetCase(Flags, E.Name.str().c_str(),
120void ScalarBitSetTraits<LocalSymFlags>::bitset(IO &io,
LocalSymFlags &Flags) {
122 for (
const auto &E : FlagNames) {
123 io.bitSetCase(Flags, E.Name.str().c_str(),
128void ScalarBitSetTraits<ProcSymFlags>::bitset(IO &io,
ProcSymFlags &Flags) {
130 for (
const auto &E : FlagNames) {
131 io.bitSetCase(Flags, E.Name.str().c_str(),
136void ScalarBitSetTraits<FrameProcedureOptions>::bitset(
139 for (
const auto &E : FlagNames) {
140 io.bitSetCase(Flags, E.Name.str().c_str(),
145void ScalarEnumerationTraits<CPUType>::enumeration(IO &io,
CPUType &Cpu) {
147 for (
const auto &E : CpuNames) {
148 io.enumCase(Cpu, E.Name.str().c_str(),
static_cast<CPUType>(E.Value));
152void ScalarEnumerationTraits<RegisterId>::enumeration(IO &io,
RegisterId &Reg) {
153 const auto *Header =
static_cast<COFF::header *
>(io.getContext());
154 assert(Header &&
"The IO context is not initialized");
156 std::optional<CPUType> CpuType;
159 switch (Header->Machine) {
161 CpuType = CPUType::Pentium3;
164 CpuType = CPUType::X64;
167 CpuType = CPUType::ARMNT;
172 CpuType = CPUType::ARM64;
179 for (
const auto &E : RegNames) {
180 io.enumCase(Reg, E.Name.str().c_str(),
static_cast<RegisterId>(E.Value));
182 io.enumFallback<Hex16>(
Reg);
185void ScalarEnumerationTraits<TrampolineType>::enumeration(
188 for (
const auto &E : TrampNames) {
189 io.enumCase(Tramp, E.Name.str().c_str(),
194void ScalarEnumerationTraits<ThunkOrdinal>::enumeration(IO &io,
197 for (
const auto &E : ThunkNames) {
198 io.enumCase(Ord, E.Name.str().c_str(),
static_cast<ThunkOrdinal>(E.Value));
202void ScalarEnumerationTraits<FrameCookieKind>::enumeration(
205 for (
const auto &E : ThunkNames) {
206 io.enumCase(FC, E.Name.str().c_str(),
211void ScalarEnumerationTraits<JumpTableEntrySize>::enumeration(
214 for (
const auto &E : ThunkNames) {
215 io.enumCase(FC, E.Name.str().c_str(),
224 io.mapRequired(
"OffsetStart",
Range.OffsetStart);
225 io.mapRequired(
"ISectStart",
Range.ISectStart);
226 io.mapRequired(
"Range",
Range.Range);
232 io.mapRequired(
"Range", Gap.
Range);
239namespace CodeViewYAML {
248 virtual void map(yaml::IO &io) = 0;
259 void map(yaml::IO &io)
override;
268 return SymbolDeserializer::deserializeAs<T>(CVS,
Symbol);
277 void map(yaml::IO &io)
override;
283 Prefix.RecordKind =
Kind;
284 Prefix.RecordLen = TotalLen - 2;
306 io.mapRequired(
"Data", Binary);
307 if (!io.outputting()) {
310 Binary.writeAsBinary(
OS);
311 Data.assign(Str.begin(), Str.end());
316 IO.mapRequired(
"Parent", Symbol.Parent);
317 IO.mapRequired(
"End", Symbol.End);
318 IO.mapRequired(
"Next", Symbol.Next);
319 IO.mapRequired(
"Off", Symbol.Offset);
320 IO.mapRequired(
"Seg", Symbol.Segment);
321 IO.mapRequired(
"Len", Symbol.Length);
322 IO.mapRequired(
"Ordinal", Symbol.Thunk);
326 IO.mapRequired(
"Type", Symbol.Type);
327 IO.mapRequired(
"Size", Symbol.Size);
328 IO.mapRequired(
"ThunkOff", Symbol.ThunkOffset);
329 IO.mapRequired(
"TargetOff", Symbol.TargetOffset);
330 IO.mapRequired(
"ThunkSection", Symbol.ThunkSection);
331 IO.mapRequired(
"TargetSection", Symbol.TargetSection);
335 IO.mapRequired(
"SectionNumber", Symbol.SectionNumber);
336 IO.mapRequired(
"Alignment", Symbol.Alignment);
337 IO.mapRequired(
"Rva", Symbol.Rva);
338 IO.mapRequired(
"Length", Symbol.Length);
339 IO.mapRequired(
"Characteristics", Symbol.Characteristics);
340 IO.mapRequired(
"Name", Symbol.Name);
344 IO.mapRequired(
"Size", Symbol.Size);
345 IO.mapRequired(
"Characteristics", Symbol.Characteristics);
346 IO.mapRequired(
"Offset", Symbol.Offset);
347 IO.mapRequired(
"Segment", Symbol.Segment);
348 IO.mapRequired(
"Name", Symbol.Name);
352 IO.mapRequired(
"Ordinal", Symbol.Ordinal);
353 IO.mapRequired(
"Flags", Symbol.Flags);
354 IO.mapRequired(
"Name", Symbol.Name);
358 IO.mapOptional(
"PtrParent", Symbol.Parent, 0U);
359 IO.mapOptional(
"PtrEnd", Symbol.End, 0U);
360 IO.mapOptional(
"PtrNext", Symbol.Next, 0U);
361 IO.mapRequired(
"CodeSize", Symbol.CodeSize);
362 IO.mapRequired(
"DbgStart", Symbol.DbgStart);
363 IO.mapRequired(
"DbgEnd", Symbol.DbgEnd);
364 IO.mapRequired(
"FunctionType", Symbol.FunctionType);
365 IO.mapOptional(
"Offset", Symbol.CodeOffset, 0U);
366 IO.mapOptional(
"Segment", Symbol.Segment,
uint16_t(0));
367 IO.mapRequired(
"Flags", Symbol.Flags);
368 IO.mapRequired(
"DisplayName", Symbol.Name);
372 IO.mapRequired(
"Type", Symbol.Index);
373 IO.mapRequired(
"Seg", Symbol.Register);
374 IO.mapRequired(
"Name", Symbol.Name);
378 IO.mapRequired(
"Flags", Symbol.Flags);
379 IO.mapOptional(
"Offset", Symbol.Offset, 0U);
380 IO.mapOptional(
"Segment", Symbol.Segment,
uint16_t(0));
381 IO.mapRequired(
"Name", Symbol.Name);
385 IO.mapRequired(
"SumName", Symbol.SumName);
386 IO.mapRequired(
"SymOffset", Symbol.SymOffset);
387 IO.mapRequired(
"Mod", Symbol.Module);
388 IO.mapRequired(
"Name", Symbol.Name);
392 IO.mapRequired(
"Entries", Symbol.Fields);
396 IO.mapOptional(
"PtrParent", Symbol.Parent, 0U);
397 IO.mapOptional(
"PtrEnd", Symbol.End, 0U);
398 IO.mapRequired(
"Inlinee", Symbol.Inlinee);
403 IO.mapRequired(
"Type", Symbol.Type);
404 IO.mapRequired(
"Flags", Symbol.Flags);
406 IO.mapRequired(
"VarName", Symbol.Name);
410 IO.mapRequired(
"Program", Symbol.Program);
411 IO.mapRequired(
"Range", Symbol.Range);
412 IO.mapRequired(
"Gaps", Symbol.Gaps);
416 IO.mapRequired(
"Program", Symbol.Program);
417 IO.mapRequired(
"OffsetInParent", Symbol.OffsetInParent);
418 IO.mapRequired(
"Range", Symbol.Range);
419 IO.mapRequired(
"Gaps", Symbol.Gaps);
423 IO.mapRequired(
"Register", Symbol.Hdr.Register);
424 IO.mapRequired(
"MayHaveNoName", Symbol.Hdr.MayHaveNoName);
425 IO.mapRequired(
"Range", Symbol.Range);
426 IO.mapRequired(
"Gaps", Symbol.Gaps);
430 IO.mapRequired(
"Offset", Symbol.Hdr.Offset);
431 IO.mapRequired(
"Range", Symbol.Range);
432 IO.mapRequired(
"Gaps", Symbol.Gaps);
436 IO.mapRequired(
"Register", Symbol.Hdr.Register);
437 IO.mapRequired(
"MayHaveNoName", Symbol.Hdr.MayHaveNoName);
438 IO.mapRequired(
"OffsetInParent", Symbol.Hdr.OffsetInParent);
439 IO.mapRequired(
"Range", Symbol.Range);
440 IO.mapRequired(
"Gaps", Symbol.Gaps);
445 IO.mapRequired(
"Register", Symbol.Offset);
449 IO.mapRequired(
"Register", Symbol.Hdr.Register);
450 IO.mapRequired(
"Flags", Symbol.Hdr.Flags);
451 IO.mapRequired(
"BasePointerOffset", Symbol.Hdr.BasePointerOffset);
452 IO.mapRequired(
"Range", Symbol.Range);
453 IO.mapRequired(
"Gaps", Symbol.Gaps);
457 IO.mapOptional(
"PtrParent", Symbol.Parent, 0U);
458 IO.mapOptional(
"PtrEnd", Symbol.End, 0U);
459 IO.mapRequired(
"CodeSize", Symbol.CodeSize);
460 IO.mapOptional(
"Offset", Symbol.CodeOffset, 0U);
461 IO.mapOptional(
"Segment", Symbol.Segment,
uint16_t(0));
462 IO.mapRequired(
"BlockName", Symbol.Name);
466 IO.mapOptional(
"Offset", Symbol.CodeOffset, 0U);
467 IO.mapOptional(
"Segment", Symbol.Segment,
uint16_t(0));
468 IO.mapRequired(
"Flags", Symbol.Flags);
469 IO.mapRequired(
"DisplayName", Symbol.Name);
473 IO.mapRequired(
"Signature", Symbol.Signature);
474 IO.mapRequired(
"ObjectName", Symbol.Name);
478 IO.mapRequired(
"Flags", Symbol.Flags);
479 IO.mapRequired(
"Machine", Symbol.Machine);
480 IO.mapRequired(
"FrontendMajor", Symbol.VersionFrontendMajor);
481 IO.mapRequired(
"FrontendMinor", Symbol.VersionFrontendMinor);
482 IO.mapRequired(
"FrontendBuild", Symbol.VersionFrontendBuild);
483 IO.mapRequired(
"BackendMajor", Symbol.VersionBackendMajor);
484 IO.mapRequired(
"BackendMinor", Symbol.VersionBackendMinor);
485 IO.mapRequired(
"BackendBuild", Symbol.VersionBackendBuild);
486 IO.mapRequired(
"Version", Symbol.Version);
490 IO.mapRequired(
"Flags", Symbol.Flags);
491 IO.mapRequired(
"Machine", Symbol.Machine);
492 IO.mapRequired(
"FrontendMajor", Symbol.VersionFrontendMajor);
493 IO.mapRequired(
"FrontendMinor", Symbol.VersionFrontendMinor);
494 IO.mapRequired(
"FrontendBuild", Symbol.VersionFrontendBuild);
495 IO.mapRequired(
"FrontendQFE", Symbol.VersionFrontendQFE);
496 IO.mapRequired(
"BackendMajor", Symbol.VersionBackendMajor);
497 IO.mapRequired(
"BackendMinor", Symbol.VersionBackendMinor);
498 IO.mapRequired(
"BackendBuild", Symbol.VersionBackendBuild);
499 IO.mapRequired(
"BackendQFE", Symbol.VersionBackendQFE);
500 IO.mapRequired(
"Version", Symbol.Version);
504 IO.mapRequired(
"TotalFrameBytes", Symbol.TotalFrameBytes);
505 IO.mapRequired(
"PaddingFrameBytes", Symbol.PaddingFrameBytes);
506 IO.mapRequired(
"OffsetToPadding", Symbol.OffsetToPadding);
507 IO.mapRequired(
"BytesOfCalleeSavedRegisters",
508 Symbol.BytesOfCalleeSavedRegisters);
509 IO.mapRequired(
"OffsetOfExceptionHandler", Symbol.OffsetOfExceptionHandler);
510 IO.mapRequired(
"SectionIdOfExceptionHandler",
511 Symbol.SectionIdOfExceptionHandler);
512 IO.mapRequired(
"Flags", Symbol.Flags);
516 IO.mapOptional(
"Offset", Symbol.CodeOffset, 0U);
517 IO.mapOptional(
"Segment", Symbol.Segment,
uint16_t(0));
518 IO.mapRequired(
"Type", Symbol.Type);
522 IO.mapRequired(
"Index", Symbol.Index);
523 IO.mapRequired(
"ModFilenameOffset", Symbol.ModFilenameOffset);
524 IO.mapRequired(
"Flags", Symbol.Flags);
525 IO.mapRequired(
"Name", Symbol.Name);
529 IO.mapOptional(
"Offset", Symbol.CodeOffset, 0U);
530 IO.mapOptional(
"Segment", Symbol.Segment,
uint16_t(0));
531 IO.mapRequired(
"CallInstructionSize", Symbol.CallInstructionSize);
532 IO.mapRequired(
"Type", Symbol.Type);
536 IO.mapRequired(
"Register", Symbol.Register);
537 IO.mapRequired(
"CookieKind", Symbol.CookieKind);
538 IO.mapRequired(
"Flags", Symbol.Flags);
542 IO.mapRequired(
"FuncID", Symbol.Indices);
546 IO.mapRequired(
"Type", Symbol.Type);
547 IO.mapRequired(
"UDTName", Symbol.Name);
551 IO.mapRequired(
"BuildId", Symbol.BuildId);
555 IO.mapRequired(
"Offset", Symbol.Offset);
556 IO.mapRequired(
"Type", Symbol.Type);
557 IO.mapRequired(
"VarName", Symbol.Name);
561 IO.mapRequired(
"Offset", Symbol.Offset);
562 IO.mapRequired(
"Type", Symbol.Type);
563 IO.mapRequired(
"Register", Symbol.Register);
564 IO.mapRequired(
"VarName", Symbol.Name);
568 IO.mapRequired(
"Type", Symbol.Type);
569 IO.mapRequired(
"Value", Symbol.Value);
570 IO.mapRequired(
"Name", Symbol.Name);
574 IO.mapRequired(
"Type", Symbol.Type);
575 IO.mapOptional(
"Offset", Symbol.DataOffset, 0U);
576 IO.mapOptional(
"Segment", Symbol.Segment,
uint16_t(0));
577 IO.mapRequired(
"DisplayName", Symbol.Name);
581 IO.mapRequired(
"Type", Symbol.Type);
582 IO.mapOptional(
"Offset", Symbol.DataOffset, 0U);
583 IO.mapOptional(
"Segment", Symbol.Segment,
uint16_t(0));
584 IO.mapRequired(
"DisplayName", Symbol.Name);
588 IO.mapRequired(
"Namespace", Symbol.Name);
592 IO.mapOptional(
"Offset", Symbol.CodeOffset, 0U);
593 IO.mapOptional(
"Segment", Symbol.Segment,
uint16_t(0));
594 IO.mapRequired(
"Strings", Symbol.Strings);
598 IO.mapRequired(
"BaseOffset", Symbol.BaseOffset);
599 IO.mapRequired(
"BaseSegment", Symbol.BaseSegment);
600 IO.mapRequired(
"SwitchType", Symbol.SwitchType);
601 IO.mapRequired(
"BranchOffset", Symbol.BranchOffset);
602 IO.mapRequired(
"TableOffset", Symbol.TableOffset);
603 IO.mapRequired(
"BranchSegment", Symbol.BranchSegment);
604 IO.mapRequired(
"TableSegment", Symbol.TableSegment);
605 IO.mapRequired(
"EntriesCount", Symbol.EntriesCount);
627template <
typename SymbolType>
632 auto Impl = std::make_shared<SymbolType>(Symbol.kind());
633 if (
auto EC = Impl->fromCodeViewSymbol(Symbol))
634 return std::move(
EC);
635 Result.Symbol = Impl;
641#define SYMBOL_RECORD(EnumName, EnumVal, ClassName) \
643 return fromCodeViewSymbolImpl<SymbolRecordImpl<ClassName>>(Symbol);
644#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, AliasName, ClassName) \
645 SYMBOL_RECORD(EnumName, EnumVal, ClassName)
646 switch (Symbol.kind()) {
647#include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
649 return fromCodeViewSymbolImpl<UnknownSymbolRecord>(Symbol);
651 return make_error<CodeViewError>(cv_error_code::corrupt_record);
654template <
typename ConcreteType>
657 if (!IO.outputting())
658 Obj.
Symbol = std::make_shared<ConcreteType>(Kind);
660 IO.mapRequired(Class, *Obj.
Symbol);
668 IO.mapRequired(
"Kind", Kind);
670#define SYMBOL_RECORD(EnumName, EnumVal, ClassName) \
672 mapSymbolRecordImpl<SymbolRecordImpl<ClassName>>(IO, #ClassName, Kind, \
675#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, AliasName, ClassName) \
676 SYMBOL_RECORD(EnumName, EnumVal, ClassName)
678#include "llvm/DebugInfo/CodeView/CodeViewSymbols.def"
680 mapSymbolRecordImpl<UnknownSymbolRecord>(IO,
"UnknownSym", Kind, Obj);
This file defines the BumpPtrAllocator interface.
static void mapSymbolRecordImpl(IO &IO, const char *Class, SymbolKind Kind, CodeViewYAML::SymbolRecord &Obj)
static Expected< CodeViewYAML::SymbolRecord > fromCodeViewSymbolImpl(CVSymbol Symbol)
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
#define LLVM_YAML_DECLARE_BITSET_TRAITS(Type)
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
#define LLVM_YAML_DECLARE_SCALAR_TRAITS(Type, MustQuote)
#define LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(type)
#define LLVM_YAML_STRONG_TYPEDEF(_base, _type)
#define LLVM_YAML_DECLARE_ENUM_TRAITS(Type)
An arbitrary precision integer that knows its signedness.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
Allocate memory in an ever growing pool, as if by bump-pointer.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
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.
Value(Type *Ty, unsigned scid)
CVRecord is a fat pointer (base + size pair) to a symbol or type record.
ArrayRef< uint8_t > RecordData
static CVSymbol writeOneSymbol(SymType &Sym, BumpPtrAllocator &Storage, CodeViewContainer Container)
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
Specialized YAMLIO scalar type for representing a binary blob.
@ IMAGE_FILE_MACHINE_ARM64
@ IMAGE_FILE_MACHINE_AMD64
@ IMAGE_FILE_MACHINE_ARM64EC
@ IMAGE_FILE_MACHINE_I386
@ IMAGE_FILE_MACHINE_ARM64X
@ IMAGE_FILE_MACHINE_ARMNT
Reg
All possible values of the reg field in the ModR/M byte.
ProcSymFlags
Corresponds to the CV_PROCFLAGS bitfield.
LocalSymFlags
Corresponds to CV_LVARFLAGS bitfield.
CompileSym2Flags
Corresponds to COMPILESYM2::Flags bitfield.
CPUType
These values correspond to the CV_CPU_TYPE_e enumeration, and are documented here: https://msdn....
CompileSym3Flags
Corresponds to COMPILESYM3::Flags bitfield.
ArrayRef< EnumEntry< uint32_t > > getCompileSym2FlagNames()
ArrayRef< EnumEntry< uint16_t > > getExportSymFlagNames()
ArrayRef< EnumEntry< uint16_t > > getJumpTableEntrySizeNames()
SymbolRecordKind
Distinguishes individual records in the Symbols subsection of a .debug$S section.
ArrayRef< EnumEntry< SymbolKind > > getSymbolTypeNames()
ThunkOrdinal
These values correspond to the THUNK_ORDINAL enumeration.
ArrayRef< EnumEntry< uint16_t > > getLocalFlagNames()
ArrayRef< EnumEntry< uint16_t > > getRegisterNames(CPUType Cpu)
ArrayRef< EnumEntry< uint8_t > > getThunkOrdinalNames()
ArrayRef< EnumEntry< uint8_t > > getProcSymFlagNames()
SymbolKind
Duplicate copy of the above enum, but using the official CV names.
ArrayRef< EnumEntry< unsigned > > getCPUTypeNames()
CVRecord< SymbolKind > CVSymbol
ArrayRef< EnumEntry< uint32_t > > getFrameProcSymFlagNames()
ArrayRef< EnumEntry< uint16_t > > getTrampolineNames()
PublicSymFlags
Corresponds to the CV_PUBSYMFLAGS bitfield.
ArrayRef< EnumEntry< uint32_t > > getPublicSymFlagNames()
ArrayRef< EnumEntry< uint32_t > > getCompileSym3FlagNames()
ArrayRef< EnumEntry< uint8_t > > getFrameCookieKindNames()
This is an optimization pass for GlobalISel generic memory operations.
codeview::CVSymbol toCodeViewSymbol(BumpPtrAllocator &Allocator, codeview::CodeViewContainer Container) const
std::shared_ptr< detail::SymbolRecordBase > Symbol
static Expected< SymbolRecord > fromCodeViewSymbol(codeview::CVSymbol Symbol)
SymbolRecordBase(codeview::SymbolKind K)
codeview::SymbolKind Kind
virtual void map(yaml::IO &io)=0
virtual codeview::CVSymbol toCodeViewSymbol(BumpPtrAllocator &Allocator, CodeViewContainer Container) const =0
virtual ~SymbolRecordBase()=default
virtual Error fromCodeViewSymbol(codeview::CVSymbol Type)=0
codeview::CVSymbol toCodeViewSymbol(BumpPtrAllocator &Allocator, CodeViewContainer Container) const override
void map(yaml::IO &io) override
Error fromCodeViewSymbol(codeview::CVSymbol CVS) override
SymbolRecordImpl(codeview::SymbolKind K)
std::vector< uint8_t > Data
Error fromCodeViewSymbol(CVSymbol CVS) override
void map(yaml::IO &io) override
UnknownSymbolRecord(codeview::SymbolKind K)
CVSymbol toCodeViewSymbol(BumpPtrAllocator &Allocator, CodeViewContainer Container) const override
static void mapping(IO &io, LocalVariableAddrGap &Gap)
static void mapping(IO &io, LocalVariableAddrRange &Range)
static void mapping(IO &io, SymbolRecordBase &Record)