From d0fffd1d1405823e4dc1a4ad16e007e3bdd4bf69 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Fri, 16 Dec 2016 19:25:23 +0000 Subject: [PATCH] Revert "[CodeView] Hook CodeViewRecordIO for reading/writing symbols." This reverts commit r289978, which is failing due to some rebase/merge issues. llvm-svn: 289981 --- .../llvm/DebugInfo/CodeView/CodeView.h | 2 +- .../DebugInfo/CodeView/CodeViewRecordIO.h | 14 - .../DebugInfo/CodeView/SymbolDeserializer.h | 48 +- .../llvm/DebugInfo/CodeView/SymbolRecord.h | 1212 ++++++++++++----- .../DebugInfo/CodeView/SymbolRecordMapping.h | 44 - .../DebugInfo/CodeView/SymbolSerializer.h | 96 -- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 30 +- llvm/lib/DebugInfo/CodeView/CMakeLists.txt | 2 - .../DebugInfo/CodeView/CodeViewRecordIO.cpp | 31 - llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp | 276 ++-- .../CodeView/SymbolRecordMapping.cpp | 464 ------- .../DebugInfo/CodeView/SymbolSerializer.cpp | 1 - llvm/lib/MC/MCCodeView.cpp | 4 +- llvm/test/DebugInfo/PDB/pdb-yaml-symbols.test | 19 +- llvm/test/DebugInfo/PDB/pdbdump-headers.test | 10 + llvm/tools/llvm-pdbdump/YamlSymbolDumper.cpp | 300 ++-- 16 files changed, 1201 insertions(+), 1352 deletions(-) delete mode 100644 llvm/include/llvm/DebugInfo/CodeView/SymbolRecordMapping.h delete mode 100644 llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h delete mode 100644 llvm/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp delete mode 100644 llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp diff --git a/llvm/include/llvm/DebugInfo/CodeView/CodeView.h b/llvm/include/llvm/DebugInfo/CodeView/CodeView.h index e21cfa3d030a..06ea42e08691 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/CodeView.h +++ b/llvm/include/llvm/DebugInfo/CodeView/CodeView.h @@ -535,7 +535,7 @@ enum class ThunkOrdinal : uint8_t { BranchIsland }; -enum class TrampolineType : uint16_t { TrampIncremental, BranchIsland }; +enum class TrampolineType { TrampIncremental, BranchIsland }; // These values correspond to the CV_SourceChksum_t enumeration. enum class FileChecksumKind : uint8_t { None, MD5, SHA1, SHA256 }; diff --git a/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h b/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h index 5a036b9d5b6c..6c95f63db952 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h +++ b/llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h @@ -46,17 +46,6 @@ public: uint32_t maxFieldLength() const; - template Error mapObject(T &Value) { - if (isWriting()) - return Writer->writeObject(Value); - - const T *ValuePtr; - if (auto EC = Reader->readObject(ValuePtr)) - return EC; - Value = *ValuePtr; - return Error::success(); - } - template Error mapInteger(T &Value) { if (isWriting()) return Writer->writeInteger(Value); @@ -86,8 +75,6 @@ public: Error mapStringZ(StringRef &Value); Error mapGuid(StringRef &Guid); - Error mapStringZVectorZ(std::vector &Value); - template Error mapVectorN(T &Items, const ElementMapper &Mapper) { SizeType Size; @@ -134,7 +121,6 @@ public: } Error mapByteVectorTail(ArrayRef &Bytes); - Error mapByteVectorTail(std::vector &Bytes); Error skipPadding(); diff --git a/llvm/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h b/llvm/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h index 13c2bb14ecf5..3ccc2db073c4 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h +++ b/llvm/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h @@ -12,7 +12,6 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/CodeView/SymbolRecordMapping.h" #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h" #include "llvm/DebugInfo/CodeView/SymbolVisitorDelegate.h" #include "llvm/DebugInfo/MSF/ByteStream.h" @@ -23,50 +22,41 @@ namespace llvm { namespace codeview { class SymbolVisitorDelegate; class SymbolDeserializer : public SymbolVisitorCallbacks { - struct MappingInfo { - explicit MappingInfo(ArrayRef RecordData) - : Stream(RecordData), Reader(Stream), Mapping(Reader) {} - - msf::ByteStream Stream; - msf::StreamReader Reader; - SymbolRecordMapping Mapping; - }; - public: explicit SymbolDeserializer(SymbolVisitorDelegate *Delegate) : Delegate(Delegate) {} - Error visitSymbolBegin(CVSymbol &Record) override { - assert(!Mapping && "Already in a symbol mapping!"); - Mapping = llvm::make_unique(Record.content()); - return Mapping->Mapping.visitSymbolBegin(Record); - } - Error visitSymbolEnd(CVSymbol &Record) override { - assert(Mapping && "Not in a symbol mapping!"); - auto EC = Mapping->Mapping.visitSymbolEnd(Record); - Mapping.reset(); - return EC; - } - #define SYMBOL_RECORD(EnumName, EnumVal, Name) \ Error visitKnownRecord(CVSymbol &CVR, Name &Record) override { \ - return visitKnownRecordImpl(CVR, Record); \ + return defaultVisitKnownRecord(CVR, Record); \ } #define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) #include "CVSymbolTypes.def" -private: - template Error visitKnownRecordImpl(CVSymbol &CVR, T &Record) { +protected: + template + Error deserializeRecord(msf::StreamReader &Reader, SymbolKind Kind, + T &Record) const { + uint32_t RecordOffset = Delegate ? Delegate->getRecordOffset(Reader) : 0; + SymbolRecordKind RK = static_cast(Kind); + auto ExpectedRecord = T::deserialize(RK, RecordOffset, Reader); + if (!ExpectedRecord) + return ExpectedRecord.takeError(); + Record = std::move(*ExpectedRecord); + return Error::success(); + } - Record.RecordOffset = - Delegate ? Delegate->getRecordOffset(Mapping->Reader) : 0; - if (auto EC = Mapping->Mapping.visitKnownRecord(CVR, Record)) +private: + template + Error defaultVisitKnownRecord(CVSymbol &CVR, T &Record) { + msf::ByteStream S(CVR.content()); + msf::StreamReader SR(S); + if (auto EC = deserializeRecord(SR, CVR.Type, Record)) return EC; return Error::success(); } SymbolVisitorDelegate *Delegate; - std::unique_ptr Mapping; }; } } diff --git a/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h b/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h index 0ebb6644fbb4..1e0973d5ccee 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h +++ b/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h @@ -29,6 +29,10 @@ namespace llvm { namespace codeview { +using support::ulittle16_t; +using support::ulittle32_t; +using support::little32_t; + class SymbolRecord { protected: explicit SymbolRecord(SymbolRecordKind Kind) : Kind(Kind) {} @@ -44,97 +48,180 @@ private: // S_LPROC32_DPC_ID class ProcSym : public SymbolRecord { public: - explicit ProcSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - ProcSym(SymbolRecordKind Kind, uint32_t RecordOffset) - : SymbolRecord(Kind), RecordOffset(RecordOffset), Name(Name) {} + struct Hdr { + ulittle32_t PtrParent; + ulittle32_t PtrEnd; + ulittle32_t PtrNext; + ulittle32_t CodeSize; + ulittle32_t DbgStart; + ulittle32_t DbgEnd; + TypeIndex FunctionType; + ulittle32_t CodeOffset; + ulittle16_t Segment; + uint8_t Flags; // ProcSymFlags enum + // Name: The null-terminated name follows. + }; - uint32_t getRelocationOffset() const { - return RecordOffset + offsetof(ProcSym, CodeOffset); + explicit ProcSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + ProcSym(SymbolRecordKind Kind, uint32_t RecordOffset, const Hdr *H, + StringRef Name) + : SymbolRecord(Kind), RecordOffset(RecordOffset), Header(*H), Name(Name) { } - uint32_t Parent = 0; - uint32_t End = 0; - uint32_t Next = 0; - uint32_t CodeSize = 0; - uint32_t DbgStart = 0; - uint32_t DbgEnd = 0; - TypeIndex FunctionType; - uint32_t CodeOffset = 0; - uint16_t Segment = 0; - ProcSymFlags Flags = ProcSymFlags::None; - StringRef Name; + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Name; + CV_DESERIALIZE(Reader, H, Name); - uint32_t RecordOffset = 0; + return ProcSym(Kind, RecordOffset, H, Name); + } + + uint32_t getRelocationOffset() const { + return RecordOffset + offsetof(Hdr, CodeOffset); + } + + uint32_t RecordOffset; + Hdr Header; + StringRef Name; }; // S_THUNK32 class Thunk32Sym : public SymbolRecord { public: - explicit Thunk32Sym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - Thunk32Sym(SymbolRecordKind Kind, uint32_t RecordOffset) - : SymbolRecord(Kind), RecordOffset(RecordOffset) {} + struct Hdr { + ulittle32_t Parent; + ulittle32_t End; + ulittle32_t Next; + ulittle32_t Off; + ulittle16_t Seg; + ulittle16_t Len; + uint8_t Ord; // ThunkOrdinal enumeration + // Name: The null-terminated name follows. + // Variant portion of thunk + }; - uint32_t Parent; - uint32_t End; - uint32_t Next; - uint32_t Offset; - uint16_t Segment; - uint16_t Length; - ThunkOrdinal Thunk; - StringRef Name; - ArrayRef VariantData; + explicit Thunk32Sym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + Thunk32Sym(SymbolRecordKind Kind, uint32_t RecordOffset, const Hdr *H, + StringRef Name, ArrayRef VariantData) + : SymbolRecord(Kind), RecordOffset(RecordOffset), Header(*H), Name(Name), + VariantData(VariantData) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Name; + ArrayRef VariantData; + + CV_DESERIALIZE(Reader, H, Name, CV_ARRAY_FIELD_TAIL(VariantData)); + + return Thunk32Sym(Kind, RecordOffset, H, Name, VariantData); + } uint32_t RecordOffset; + Hdr Header; + StringRef Name; + ArrayRef VariantData; }; // S_TRAMPOLINE class TrampolineSym : public SymbolRecord { public: - explicit TrampolineSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - TrampolineSym(SymbolRecordKind Kind, uint32_t RecordOffset) - : SymbolRecord(Kind), RecordOffset(RecordOffset) {} + struct Hdr { + ulittle16_t Type; // TrampolineType enum + ulittle16_t Size; + ulittle32_t ThunkOff; + ulittle32_t TargetOff; + ulittle16_t ThunkSection; + ulittle16_t TargetSection; + }; - TrampolineType Type; - uint16_t Size; - uint32_t ThunkOffset; - uint32_t TargetOffset; - uint16_t ThunkSection; - uint16_t TargetSection; + explicit TrampolineSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + TrampolineSym(SymbolRecordKind Kind, uint32_t RecordOffset, const Hdr *H) + : SymbolRecord(Kind), RecordOffset(RecordOffset), Header(*H) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + + CV_DESERIALIZE(Reader, H); + + return TrampolineSym(Kind, RecordOffset, H); + } uint32_t RecordOffset; + Hdr Header; }; // S_SECTION class SectionSym : public SymbolRecord { public: - explicit SectionSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - SectionSym(SymbolRecordKind Kind, uint32_t RecordOffset) - : SymbolRecord(Kind), RecordOffset(RecordOffset) {} + struct Hdr { + ulittle16_t SectionNumber; + uint8_t Alignment; + uint8_t Reserved; // Must be 0 + ulittle32_t Rva; + ulittle32_t Length; + ulittle32_t Characteristics; + // Name: The null-terminated name follows. + }; - uint16_t SectionNumber; - uint8_t Alignment; - uint32_t Rva; - uint32_t Length; - uint32_t Characteristics; - StringRef Name; + explicit SectionSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + SectionSym(SymbolRecordKind Kind, uint32_t RecordOffset, const Hdr *H, + StringRef Name) + : SymbolRecord(Kind), RecordOffset(RecordOffset), Header(*H), Name(Name) { + } + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Name; + + CV_DESERIALIZE(Reader, H, Name); + + return SectionSym(Kind, RecordOffset, H, Name); + } uint32_t RecordOffset; + Hdr Header; + StringRef Name; }; // S_COFFGROUP class CoffGroupSym : public SymbolRecord { public: - explicit CoffGroupSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - CoffGroupSym(SymbolRecordKind Kind, uint32_t RecordOffset) - : SymbolRecord(Kind), RecordOffset(RecordOffset) {} + struct Hdr { + ulittle32_t Size; + ulittle32_t Characteristics; + ulittle32_t Offset; + ulittle16_t Segment; + // Name: The null-terminated name follows. + }; - uint32_t Size; - uint32_t Characteristics; - uint32_t Offset; - uint16_t Segment; - StringRef Name; + explicit CoffGroupSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + CoffGroupSym(SymbolRecordKind Kind, uint32_t RecordOffset, const Hdr *H, + StringRef Name) + : SymbolRecord(Kind), RecordOffset(RecordOffset), Header(*H), Name(Name) { + } + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Name; + + CV_DESERIALIZE(Reader, H, Name); + + return CoffGroupSym(Kind, RecordOffset, H, Name); + } uint32_t RecordOffset; + Hdr Header; + StringRef Name; }; class ScopeEndSym : public SymbolRecord { @@ -143,17 +230,40 @@ public: ScopeEndSym(SymbolRecordKind Kind, uint32_t RecordOffset) : SymbolRecord(Kind), RecordOffset(RecordOffset) {} + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + return ScopeEndSym(Kind, RecordOffset); + } uint32_t RecordOffset; }; class CallerSym : public SymbolRecord { public: - explicit CallerSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - CallerSym(SymbolRecordKind Kind, uint32_t RecordOffset) - : SymbolRecord(Kind), RecordOffset(RecordOffset) {} + struct Hdr { + ulittle32_t Count; + }; + + explicit CallerSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + CallerSym(SymbolRecordKind Kind, uint32_t RecordOffset, const Hdr *Header, + ArrayRef Indices) + : SymbolRecord(Kind), RecordOffset(RecordOffset), Header(*Header), + Indices(Indices) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *Header; + ArrayRef Indices; + + CV_DESERIALIZE(Reader, Header, CV_ARRAY_FIELD_N(Indices, Header->Count)); + + return CallerSym(Kind, RecordOffset, Header, Indices); + } - std::vector Indices; uint32_t RecordOffset; + Hdr Header; + ArrayRef Indices; }; struct BinaryAnnotationIterator { @@ -337,94 +447,168 @@ private: // S_INLINESITE class InlineSiteSym : public SymbolRecord { public: + struct Hdr { + ulittle32_t PtrParent; + ulittle32_t PtrEnd; + TypeIndex Inlinee; + // BinaryAnnotations + }; + explicit InlineSiteSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - InlineSiteSym(uint32_t RecordOffset) + InlineSiteSym(uint32_t RecordOffset, const Hdr *H, + ArrayRef Annotations) : SymbolRecord(SymbolRecordKind::InlineSiteSym), - RecordOffset(RecordOffset) {} + RecordOffset(RecordOffset), Header(*H), Annotations(Annotations) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + ArrayRef Annotations; + CV_DESERIALIZE(Reader, H, CV_ARRAY_FIELD_TAIL(Annotations)); + + return InlineSiteSym(RecordOffset, H, Annotations); + } llvm::iterator_range annotations() const { - return llvm::make_range(BinaryAnnotationIterator(AnnotationData), + return llvm::make_range(BinaryAnnotationIterator(Annotations), BinaryAnnotationIterator()); } - uint32_t Parent; - uint32_t End; - TypeIndex Inlinee; - std::vector AnnotationData; - uint32_t RecordOffset; + Hdr Header; + +private: + ArrayRef Annotations; }; // S_PUB32 class PublicSym32 : public SymbolRecord { public: - explicit PublicSym32(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit PublicSym32(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::PublicSym32), - RecordOffset(RecordOffset) {} + struct Hdr { + ulittle32_t Index; // Type index, or Metadata token if a managed symbol + ulittle32_t Off; + ulittle16_t Seg; + // Name: The null-terminated name follows. + }; - uint32_t Index; - uint32_t Offset; - uint16_t Segment; - StringRef Name; + explicit PublicSym32(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + PublicSym32(uint32_t RecordOffset, const Hdr *H, StringRef Name) + : SymbolRecord(SymbolRecordKind::PublicSym32), RecordOffset(RecordOffset), + Header(*H), Name(Name) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Name; + CV_DESERIALIZE(Reader, H, Name); + + return PublicSym32(RecordOffset, H, Name); + } uint32_t RecordOffset; + Hdr Header; + StringRef Name; }; // S_REGISTER class RegisterSym : public SymbolRecord { public: - explicit RegisterSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - RegisterSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::RegisterSym), - RecordOffset(RecordOffset) {} + struct Hdr { + ulittle32_t Index; // Type index or Metadata token + ulittle16_t Register; // RegisterId enumeration + // Name: The null-terminated name follows. + }; - uint32_t Index; - RegisterId Register; - StringRef Name; + explicit RegisterSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + RegisterSym(uint32_t RecordOffset, const Hdr *H, StringRef Name) + : SymbolRecord(SymbolRecordKind::RegisterSym), RecordOffset(RecordOffset), + Header(*H), Name(Name) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Name; + CV_DESERIALIZE(Reader, H, Name); + + return RegisterSym(RecordOffset, H, Name); + } uint32_t RecordOffset; + Hdr Header; + StringRef Name; }; // S_PROCREF, S_LPROCREF class ProcRefSym : public SymbolRecord { public: + struct Hdr { + ulittle32_t SumName; // SUC of the name (?) + ulittle32_t SymOffset; // Offset of actual symbol in $$Symbols + ulittle16_t Mod; // Module containing the actual symbol + // Name: The null-terminated name follows. + }; + explicit ProcRefSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit ProcRefSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::ProcRefSym), RecordOffset(RecordOffset) { + ProcRefSym(uint32_t RecordOffset, const Hdr *H, StringRef Name) + : SymbolRecord(SymbolRecordKind::ProcRefSym), RecordOffset(RecordOffset), + Header(*H), Name(Name) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Name; + CV_DESERIALIZE(Reader, H, Name); + + return ProcRefSym(RecordOffset, H, Name); } - uint32_t SumName; - uint32_t SymOffset; - uint16_t Module; - StringRef Name; - uint32_t RecordOffset; + Hdr Header; + StringRef Name; }; // S_LOCAL class LocalSym : public SymbolRecord { public: - explicit LocalSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit LocalSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::LocalSym), RecordOffset(RecordOffset) {} + struct Hdr { + TypeIndex Type; + ulittle16_t Flags; // LocalSymFlags enum + // Name: The null-terminated name follows. + }; - TypeIndex Type; - LocalSymFlags Flags; - StringRef Name; + explicit LocalSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + LocalSym(uint32_t RecordOffset, const Hdr *H, StringRef Name) + : SymbolRecord(SymbolRecordKind::LocalSym), RecordOffset(RecordOffset), + Header(*H), Name(Name) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Name; + CV_DESERIALIZE(Reader, H, Name); + + return LocalSym(RecordOffset, H, Name); + } uint32_t RecordOffset; + Hdr Header; + StringRef Name; }; struct LocalVariableAddrRange { - uint32_t OffsetStart; - uint16_t ISectStart; - uint16_t Range; + ulittle32_t OffsetStart; + ulittle16_t ISectStart; + ulittle16_t Range; }; struct LocalVariableAddrGap { - uint16_t GapStartOffset; - uint16_t Range; + ulittle16_t GapStartOffset; + ulittle16_t Range; }; enum : uint16_t { MaxDefRange = 0xf000 }; @@ -432,118 +616,235 @@ enum : uint16_t { MaxDefRange = 0xf000 }; // S_DEFRANGE class DefRangeSym : public SymbolRecord { public: - explicit DefRangeSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit DefRangeSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::DefRangeSym), - RecordOffset(RecordOffset) {} + struct Hdr { + ulittle32_t Program; + LocalVariableAddrRange Range; + // LocalVariableAddrGap Gaps[]; + }; - uint32_t getRelocationOffset() const { - return RecordOffset + offsetof(DefRangeSym, Range); + explicit DefRangeSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + DefRangeSym(uint32_t RecordOffset, const Hdr *H, + ArrayRef Gaps) + : SymbolRecord(SymbolRecordKind::DefRangeSym), RecordOffset(RecordOffset), + Header(*H), Gaps(Gaps) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + ArrayRef Gaps; + CV_DESERIALIZE(Reader, H, CV_ARRAY_FIELD_TAIL(Gaps)); + + return DefRangeSym(RecordOffset, H, Gaps); } - uint32_t Program; - LocalVariableAddrRange Range; - std::vector Gaps; + uint32_t getRelocationOffset() const { + return RecordOffset + offsetof(Hdr, Range); + } uint32_t RecordOffset; + Hdr Header; + ArrayRef Gaps; }; // S_DEFRANGE_SUBFIELD class DefRangeSubfieldSym : public SymbolRecord { public: + struct Hdr { + ulittle32_t Program; + ulittle16_t OffsetInParent; + LocalVariableAddrRange Range; + // LocalVariableAddrGap Gaps[]; + }; explicit DefRangeSubfieldSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - DefRangeSubfieldSym(uint32_t RecordOffset) + DefRangeSubfieldSym(uint32_t RecordOffset, const Hdr *H, + ArrayRef Gaps) : SymbolRecord(SymbolRecordKind::DefRangeSubfieldSym), - RecordOffset(RecordOffset) {} + RecordOffset(RecordOffset), Header(*H), Gaps(Gaps) {} - uint32_t getRelocationOffset() const { - return RecordOffset + offsetof(DefRangeSubfieldSym, Range); + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + ArrayRef Gaps; + CV_DESERIALIZE(Reader, H, CV_ARRAY_FIELD_TAIL(Gaps)); + + return DefRangeSubfieldSym(RecordOffset, H, Gaps); } - uint32_t Program; - uint16_t OffsetInParent; - LocalVariableAddrRange Range; - std::vector Gaps; + uint32_t getRelocationOffset() const { + return RecordOffset + offsetof(Hdr, Range); + } uint32_t RecordOffset; + Hdr Header; + ArrayRef Gaps; }; // S_DEFRANGE_REGISTER class DefRangeRegisterSym : public SymbolRecord { public: - struct Header { + struct Hdr { ulittle16_t Register; ulittle16_t MayHaveNoName; + LocalVariableAddrRange Range; + // LocalVariableAddrGap Gaps[]; }; + explicit DefRangeRegisterSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - DefRangeRegisterSym(uint32_t RecordOffset) + DefRangeRegisterSym(uint32_t RecordOffset, const Hdr *H, + ArrayRef Gaps) : SymbolRecord(SymbolRecordKind::DefRangeRegisterSym), - RecordOffset(RecordOffset) {} + RecordOffset(RecordOffset), Header(*H), Gaps(Gaps) {} - uint32_t getRelocationOffset() const { return RecordOffset + sizeof(Header); } + DefRangeRegisterSym(uint16_t Register, uint16_t MayHaveNoName, + ArrayRef Gaps) + : SymbolRecord(SymbolRecordKind::DefRangeRegisterSym), RecordOffset(0), + Gaps(Gaps) { + Header.Register = Register; + Header.MayHaveNoName = MayHaveNoName; + Header.Range = {}; + } - Header Hdr; - LocalVariableAddrRange Range; - std::vector Gaps; + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + ArrayRef Gaps; + CV_DESERIALIZE(Reader, H, CV_ARRAY_FIELD_TAIL(Gaps)); + + return DefRangeRegisterSym(RecordOffset, H, Gaps); + } + + uint32_t getRelocationOffset() const { + return RecordOffset + offsetof(Hdr, Range); + } uint32_t RecordOffset; + Hdr Header; + ArrayRef Gaps; }; // S_DEFRANGE_SUBFIELD_REGISTER class DefRangeSubfieldRegisterSym : public SymbolRecord { public: - struct Header { - ulittle16_t Register; + struct Hdr { + ulittle16_t Register; // Register to which the variable is relative ulittle16_t MayHaveNoName; ulittle32_t OffsetInParent; + LocalVariableAddrRange Range; + // LocalVariableAddrGap Gaps[]; }; + explicit DefRangeSubfieldRegisterSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - DefRangeSubfieldRegisterSym(uint32_t RecordOffset) + DefRangeSubfieldRegisterSym(uint32_t RecordOffset, const Hdr *H, + ArrayRef Gaps) : SymbolRecord(SymbolRecordKind::DefRangeSubfieldRegisterSym), - RecordOffset(RecordOffset) {} + RecordOffset(RecordOffset), Header(*H), Gaps(Gaps) {} - uint32_t getRelocationOffset() const { return RecordOffset + sizeof(Header); } + DefRangeSubfieldRegisterSym(uint16_t Register, uint16_t MayHaveNoName, + uint32_t OffsetInParent, + ArrayRef Gaps) + : SymbolRecord(SymbolRecordKind::DefRangeSubfieldRegisterSym), + RecordOffset(0), Gaps(Gaps) { + Header.Register = Register; + Header.MayHaveNoName = MayHaveNoName; + Header.OffsetInParent = OffsetInParent; + Header.Range = {}; + } - Header Hdr; - LocalVariableAddrRange Range; - std::vector Gaps; + static Expected + deserialize(SymbolRecordKind Kind, uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + ArrayRef Gaps; + CV_DESERIALIZE(Reader, H, CV_ARRAY_FIELD_TAIL(Gaps)); + + return DefRangeSubfieldRegisterSym(RecordOffset, H, Gaps); + } + + uint32_t getRelocationOffset() const { + return RecordOffset + offsetof(Hdr, Range); + } uint32_t RecordOffset; + Hdr Header; + ArrayRef Gaps; }; // S_DEFRANGE_FRAMEPOINTER_REL class DefRangeFramePointerRelSym : public SymbolRecord { public: + struct Hdr { + little32_t Offset; // Offset from the frame pointer register + LocalVariableAddrRange Range; + // LocalVariableAddrGap Gaps[]; + }; + explicit DefRangeFramePointerRelSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - DefRangeFramePointerRelSym(uint32_t RecordOffset) + DefRangeFramePointerRelSym(uint32_t RecordOffset, const Hdr *H, + ArrayRef Gaps) : SymbolRecord(SymbolRecordKind::DefRangeFramePointerRelSym), - RecordOffset(RecordOffset) {} + RecordOffset(RecordOffset), Header(*H), Gaps(Gaps) {} - uint32_t getRelocationOffset() const { - return RecordOffset + offsetof(DefRangeFramePointerRelSym, Range); + static Expected + deserialize(SymbolRecordKind Kind, uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + ArrayRef Gaps; + CV_DESERIALIZE(Reader, H, CV_ARRAY_FIELD_TAIL(Gaps)); + + return DefRangeFramePointerRelSym(RecordOffset, H, Gaps); } - int32_t Offset; - LocalVariableAddrRange Range; - std::vector Gaps; + uint32_t getRelocationOffset() const { + return RecordOffset + offsetof(Hdr, Range); + } uint32_t RecordOffset; + Hdr Header; + ArrayRef Gaps; }; // S_DEFRANGE_REGISTER_REL class DefRangeRegisterRelSym : public SymbolRecord { public: - struct Header { - ulittle16_t Register; + struct Hdr { + ulittle16_t BaseRegister; ulittle16_t Flags; little32_t BasePointerOffset; + LocalVariableAddrRange Range; + // LocalVariableAddrGap Gaps[]; }; + explicit DefRangeRegisterRelSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit DefRangeRegisterRelSym(uint32_t RecordOffset) + DefRangeRegisterRelSym(uint32_t RecordOffset, const Hdr *H, + ArrayRef Gaps) : SymbolRecord(SymbolRecordKind::DefRangeRegisterRelSym), - RecordOffset(RecordOffset) {} + RecordOffset(RecordOffset), Header(*H), Gaps(Gaps) {} + + DefRangeRegisterRelSym(uint16_t BaseRegister, uint16_t Flags, + int32_t BasePointerOffset, + ArrayRef Gaps) + : SymbolRecord(SymbolRecordKind::DefRangeRegisterRelSym), RecordOffset(0), + Gaps(Gaps) { + Header.BaseRegister = BaseRegister; + Header.Flags = Flags; + Header.BasePointerOffset = BasePointerOffset; + Header.Range = {}; + } + + static Expected + deserialize(SymbolRecordKind Kind, uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + ArrayRef Gaps; + CV_DESERIALIZE(Reader, H, CV_ARRAY_FIELD_TAIL(Gaps)); + + return DefRangeRegisterRelSym(RecordOffset, H, Gaps); + } // The flags implement this notional bitfield: // uint16_t IsSubfield : 1; @@ -554,365 +855,642 @@ public: OffsetInParentShift = 4, }; - bool hasSpilledUDTMember() const { return Hdr.Flags & IsSubfieldFlag; } - uint16_t offsetInParent() const { return Hdr.Flags >> OffsetInParentShift; } + bool hasSpilledUDTMember() const { return Header.Flags & IsSubfieldFlag; } + uint16_t offsetInParent() const { return Header.Flags >> OffsetInParentShift; } - uint32_t getRelocationOffset() const { return RecordOffset + sizeof(Header); } - - Header Hdr; - LocalVariableAddrRange Range; - std::vector Gaps; + uint32_t getRelocationOffset() const { + return RecordOffset + offsetof(Hdr, Range); + } uint32_t RecordOffset; + Hdr Header; + ArrayRef Gaps; }; // S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE class DefRangeFramePointerRelFullScopeSym : public SymbolRecord { public: + struct Hdr { + little32_t Offset; // Offset from the frame pointer register + }; + explicit DefRangeFramePointerRelFullScopeSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit DefRangeFramePointerRelFullScopeSym(uint32_t RecordOffset) + DefRangeFramePointerRelFullScopeSym(uint32_t RecordOffset, const Hdr *H) : SymbolRecord(SymbolRecordKind::DefRangeFramePointerRelFullScopeSym), - RecordOffset(RecordOffset) {} + RecordOffset(RecordOffset), Header(*H) {} - int32_t Offset; + static Expected + deserialize(SymbolRecordKind Kind, uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + CV_DESERIALIZE(Reader, H); + + return DefRangeFramePointerRelFullScopeSym(RecordOffset, H); + } uint32_t RecordOffset; + Hdr Header; }; // S_BLOCK32 class BlockSym : public SymbolRecord { public: - explicit BlockSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit BlockSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::BlockSym), RecordOffset(RecordOffset) {} + struct Hdr { + ulittle32_t PtrParent; + ulittle32_t PtrEnd; + ulittle32_t CodeSize; + ulittle32_t CodeOffset; + ulittle16_t Segment; + // Name: The null-terminated name follows. + }; - uint32_t getRelocationOffset() const { - return RecordOffset + offsetof(BlockSym, CodeOffset); + explicit BlockSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + BlockSym(uint32_t RecordOffset, const Hdr *H, StringRef Name) + : SymbolRecord(SymbolRecordKind::BlockSym), RecordOffset(RecordOffset), + Header(*H), Name(Name) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Name; + CV_DESERIALIZE(Reader, H, Name); + + return BlockSym(RecordOffset, H, Name); } - uint32_t Parent; - uint32_t End; - uint32_t CodeSize; - uint32_t CodeOffset; - uint16_t Segment; - StringRef Name; + uint32_t getRelocationOffset() const { + return RecordOffset + offsetof(Hdr, CodeOffset); + } uint32_t RecordOffset; + Hdr Header; + StringRef Name; }; // S_LABEL32 class LabelSym : public SymbolRecord { public: - explicit LabelSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit LabelSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::LabelSym), RecordOffset(RecordOffset) {} + struct Hdr { + ulittle32_t CodeOffset; + ulittle16_t Segment; + uint8_t Flags; // CV_PROCFLAGS + // Name: The null-terminated name follows. + }; - uint32_t getRelocationOffset() const { - return RecordOffset + offsetof(LabelSym, CodeOffset); + explicit LabelSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + LabelSym(uint32_t RecordOffset, const Hdr *H, StringRef Name) + : SymbolRecord(SymbolRecordKind::LabelSym), RecordOffset(RecordOffset), + Header(*H), Name(Name) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Name; + CV_DESERIALIZE(Reader, H, Name); + + return LabelSym(RecordOffset, H, Name); } - uint32_t CodeOffset; - uint16_t Segment; - ProcSymFlags Flags; - StringRef Name; + uint32_t getRelocationOffset() const { + return RecordOffset + offsetof(Hdr, CodeOffset); + } uint32_t RecordOffset; + Hdr Header; + StringRef Name; }; // S_OBJNAME class ObjNameSym : public SymbolRecord { public: + struct Hdr { + ulittle32_t Signature; + // Name: The null-terminated name follows. + }; + explicit ObjNameSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - ObjNameSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::ObjNameSym), RecordOffset(RecordOffset) { + ObjNameSym(uint32_t RecordOffset, const Hdr *H, StringRef Name) + : SymbolRecord(SymbolRecordKind::ObjNameSym), RecordOffset(RecordOffset), + Header(*H), Name(Name) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Name; + CV_DESERIALIZE(Reader, H, Name); + + return ObjNameSym(RecordOffset, H, Name); } - uint32_t Signature; - StringRef Name; - uint32_t RecordOffset; + Hdr Header; + StringRef Name; }; // S_ENVBLOCK class EnvBlockSym : public SymbolRecord { public: - explicit EnvBlockSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - EnvBlockSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::EnvBlockSym), - RecordOffset(RecordOffset) {} + struct Hdr { + uint8_t Reserved; + // Sequence of zero terminated strings. + }; - std::vector Fields; + explicit EnvBlockSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + EnvBlockSym(uint32_t RecordOffset, const Hdr *H, + const std::vector &Fields) + : SymbolRecord(SymbolRecordKind::EnvBlockSym), RecordOffset(RecordOffset), + Header(*H), Fields(Fields) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + std::vector Fields; + CV_DESERIALIZE(Reader, H, CV_STRING_ARRAY_NULL_TERM(Fields)); + + return EnvBlockSym(RecordOffset, H, Fields); + } uint32_t RecordOffset; + Hdr Header; + std::vector Fields; }; // S_EXPORT class ExportSym : public SymbolRecord { public: - explicit ExportSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - ExportSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::ExportSym), RecordOffset(RecordOffset) {} + struct Hdr { + ulittle16_t Ordinal; + ulittle16_t Flags; // ExportFlags + // Name: The null-terminated name follows. + }; - uint16_t Ordinal; - ExportFlags Flags; - StringRef Name; + explicit ExportSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + ExportSym(uint32_t RecordOffset, const Hdr *H, StringRef Name) + : SymbolRecord(SymbolRecordKind::ExportSym), RecordOffset(RecordOffset), + Header(*H), Name(Name) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Name; + CV_DESERIALIZE(Reader, H, Name); + + return ExportSym(RecordOffset, H, Name); + } uint32_t RecordOffset; + Hdr Header; + StringRef Name; }; // S_FILESTATIC class FileStaticSym : public SymbolRecord { public: - explicit FileStaticSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - FileStaticSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::FileStaticSym), - RecordOffset(RecordOffset) {} + struct Hdr { + ulittle32_t Index; // Type Index + ulittle32_t ModFilenameOffset; // Index of mod filename in string table + ulittle16_t Flags; // LocalSymFlags enum + // Name: The null-terminated name follows. + }; - uint32_t Index; - uint32_t ModFilenameOffset; - LocalSymFlags Flags; - StringRef Name; + explicit FileStaticSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + FileStaticSym(uint32_t RecordOffset, const Hdr *H, StringRef Name) + : SymbolRecord(SymbolRecordKind::FileStaticSym), + RecordOffset(RecordOffset), Header(*H), Name(Name) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Name; + CV_DESERIALIZE(Reader, H, Name); + + return FileStaticSym(RecordOffset, H, Name); + } uint32_t RecordOffset; + Hdr Header; + StringRef Name; }; // S_COMPILE2 class Compile2Sym : public SymbolRecord { public: + struct Hdr { + ulittle32_t flags; // CompileSym2Flags enum + uint8_t getLanguage() const { return flags & 0xFF; } + unsigned short Machine; // CPUType enum + unsigned short VersionFrontendMajor; + unsigned short VersionFrontendMinor; + unsigned short VersionFrontendBuild; + unsigned short VersionBackendMajor; + unsigned short VersionBackendMinor; + unsigned short VersionBackendBuild; + // Version: The null-terminated version string follows. + // Optional block of zero terminated strings terminated with a double zero. + }; + explicit Compile2Sym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - Compile2Sym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::Compile2Sym), - RecordOffset(RecordOffset) {} + Compile2Sym(uint32_t RecordOffset, const Hdr *H, StringRef Version) + : SymbolRecord(SymbolRecordKind::Compile2Sym), RecordOffset(RecordOffset), + Header(*H), Version(Version) {} - CompileSym2Flags Flags; - CPUType Machine; - uint16_t VersionFrontendMajor; - uint16_t VersionFrontendMinor; - uint16_t VersionFrontendBuild; - uint16_t VersionBackendMajor; - uint16_t VersionBackendMinor; - uint16_t VersionBackendBuild; - StringRef Version; - std::vector ExtraStrings; + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Version; + CV_DESERIALIZE(Reader, H, Version); - uint8_t getLanguage() const { return static_cast(Flags) & 0xFF; } - uint32_t getFlags() const { return static_cast(Flags) & ~0xFF; } + return Compile2Sym(RecordOffset, H, Version); + } uint32_t RecordOffset; + Hdr Header; + StringRef Version; }; // S_COMPILE3 class Compile3Sym : public SymbolRecord { public: + struct Hdr { + ulittle32_t flags; // CompileSym3Flags enum + uint8_t getLanguage() const { return flags & 0xff; } + ulittle16_t Machine; // CPUType enum + ulittle16_t VersionFrontendMajor; + ulittle16_t VersionFrontendMinor; + ulittle16_t VersionFrontendBuild; + ulittle16_t VersionFrontendQFE; + ulittle16_t VersionBackendMajor; + ulittle16_t VersionBackendMinor; + ulittle16_t VersionBackendBuild; + ulittle16_t VersionBackendQFE; + // VersionString: The null-terminated version string follows. + }; + explicit Compile3Sym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - Compile3Sym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::Compile3Sym), - RecordOffset(RecordOffset) {} + Compile3Sym(uint32_t RecordOffset, const Hdr *H, StringRef Version) + : SymbolRecord(SymbolRecordKind::Compile3Sym), RecordOffset(RecordOffset), + Header(*H), Version(Version) {} - CompileSym3Flags Flags; - CPUType Machine; - uint16_t VersionFrontendMajor; - uint16_t VersionFrontendMinor; - uint16_t VersionFrontendBuild; - uint16_t VersionFrontendQFE; - uint16_t VersionBackendMajor; - uint16_t VersionBackendMinor; - uint16_t VersionBackendBuild; - uint16_t VersionBackendQFE; - StringRef Version; + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Version; + CV_DESERIALIZE(Reader, H, Version); - uint8_t getLanguage() const { return static_cast(Flags) & 0xFF; } - uint32_t getFlags() const { return static_cast(Flags) & ~0xFF; } + return Compile3Sym(RecordOffset, H, Version); + } uint32_t RecordOffset; + Hdr Header; + StringRef Version; }; // S_FRAMEPROC class FrameProcSym : public SymbolRecord { public: - explicit FrameProcSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit FrameProcSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::FrameProcSym), - RecordOffset(RecordOffset) {} + struct Hdr { + ulittle32_t TotalFrameBytes; + ulittle32_t PaddingFrameBytes; + ulittle32_t OffsetToPadding; + ulittle32_t BytesOfCalleeSavedRegisters; + ulittle32_t OffsetOfExceptionHandler; + ulittle16_t SectionIdOfExceptionHandler; + ulittle32_t Flags; + }; - uint32_t TotalFrameBytes; - uint32_t PaddingFrameBytes; - uint32_t OffsetToPadding; - uint32_t BytesOfCalleeSavedRegisters; - uint32_t OffsetOfExceptionHandler; - uint16_t SectionIdOfExceptionHandler; - FrameProcedureOptions Flags; + explicit FrameProcSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + FrameProcSym(uint32_t RecordOffset, const Hdr *H) + : SymbolRecord(SymbolRecordKind::FrameProcSym), + RecordOffset(RecordOffset), Header(*H) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + CV_DESERIALIZE(Reader, H); + + return FrameProcSym(RecordOffset, H); + } uint32_t RecordOffset; + Hdr Header; }; // S_CALLSITEINFO class CallSiteInfoSym : public SymbolRecord { public: - explicit CallSiteInfoSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit CallSiteInfoSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::CallSiteInfoSym) {} + struct Hdr { + ulittle32_t CodeOffset; + ulittle16_t Segment; + ulittle16_t Reserved; + TypeIndex Type; + }; - uint32_t getRelocationOffset() const { - return RecordOffset + offsetof(CallSiteInfoSym, CodeOffset); + explicit CallSiteInfoSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + CallSiteInfoSym(uint32_t RecordOffset, const Hdr *H) + : SymbolRecord(SymbolRecordKind::CallSiteInfoSym), + RecordOffset(RecordOffset), Header(*H) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + CV_DESERIALIZE(Reader, H); + + return CallSiteInfoSym(RecordOffset, H); } - uint32_t CodeOffset; - uint16_t Segment; - TypeIndex Type; + uint32_t getRelocationOffset() const { + return RecordOffset + offsetof(Hdr, CodeOffset); + } uint32_t RecordOffset; + Hdr Header; }; // S_HEAPALLOCSITE class HeapAllocationSiteSym : public SymbolRecord { public: - explicit HeapAllocationSiteSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit HeapAllocationSiteSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::HeapAllocationSiteSym), - RecordOffset(RecordOffset) {} + struct Hdr { + ulittle32_t CodeOffset; + ulittle16_t Segment; + ulittle16_t CallInstructionSize; + TypeIndex Type; + }; - uint32_t getRelocationOffset() const { - return RecordOffset + offsetof(HeapAllocationSiteSym, CodeOffset); + explicit HeapAllocationSiteSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + HeapAllocationSiteSym(uint32_t RecordOffset, const Hdr *H) + : SymbolRecord(SymbolRecordKind::HeapAllocationSiteSym), + RecordOffset(RecordOffset), Header(*H) {} + + static Expected + deserialize(SymbolRecordKind Kind, uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + CV_DESERIALIZE(Reader, H); + + return HeapAllocationSiteSym(RecordOffset, H); } - uint32_t CodeOffset; - uint16_t Segment; - uint16_t CallInstructionSize; - TypeIndex Type; + uint32_t getRelocationOffset() const { + return RecordOffset + offsetof(Hdr, CodeOffset); + } uint32_t RecordOffset; + Hdr Header; }; // S_FRAMECOOKIE class FrameCookieSym : public SymbolRecord { public: - explicit FrameCookieSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit FrameCookieSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::FrameCookieSym) {} + struct Hdr { + ulittle32_t CodeOffset; + ulittle16_t Register; + uint8_t CookieKind; + uint8_t Flags; + }; - uint32_t getRelocationOffset() const { - return RecordOffset + offsetof(FrameCookieSym, CodeOffset); + explicit FrameCookieSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + FrameCookieSym(uint32_t RecordOffset, const Hdr *H) + : SymbolRecord(SymbolRecordKind::FrameCookieSym), + RecordOffset(RecordOffset), Header(*H) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + CV_DESERIALIZE(Reader, H); + + return FrameCookieSym(RecordOffset, H); } - uint32_t CodeOffset; - uint16_t Register; - uint8_t CookieKind; - uint8_t Flags; + uint32_t getRelocationOffset() const { + return RecordOffset + offsetof(Hdr, CodeOffset); + } uint32_t RecordOffset; + Hdr Header; }; // S_UDT, S_COBOLUDT class UDTSym : public SymbolRecord { public: - explicit UDTSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit UDTSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::UDTSym) {} + struct Hdr { + TypeIndex Type; // Type of the UDT + // Name: The null-terminated name follows. + }; - TypeIndex Type; - StringRef Name; + explicit UDTSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + UDTSym(uint32_t RecordOffset, const Hdr *H, StringRef Name) + : SymbolRecord(SymbolRecordKind::UDTSym), RecordOffset(RecordOffset), + Header(*H), Name(Name) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Name; + CV_DESERIALIZE(Reader, H, Name); + + return UDTSym(RecordOffset, H, Name); + } uint32_t RecordOffset; + Hdr Header; + StringRef Name; }; // S_BUILDINFO class BuildInfoSym : public SymbolRecord { public: - explicit BuildInfoSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - BuildInfoSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::BuildInfoSym), - RecordOffset(RecordOffset) {} + struct Hdr { + ulittle32_t BuildId; + }; - uint32_t BuildId; + explicit BuildInfoSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + BuildInfoSym(uint32_t RecordOffset, const Hdr *H) + : SymbolRecord(SymbolRecordKind::BuildInfoSym), + RecordOffset(RecordOffset), Header(*H) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + CV_DESERIALIZE(Reader, H); + + return BuildInfoSym(RecordOffset, H); + } uint32_t RecordOffset; + Hdr Header; }; // S_BPREL32 class BPRelativeSym : public SymbolRecord { public: - explicit BPRelativeSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit BPRelativeSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::BPRelativeSym), - RecordOffset(RecordOffset) {} + struct Hdr { + little32_t Offset; // Offset from the base pointer register + TypeIndex Type; // Type of the variable + // Name: The null-terminated name follows. + }; - int32_t Offset; - TypeIndex Type; - StringRef Name; + explicit BPRelativeSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + BPRelativeSym(uint32_t RecordOffset, const Hdr *H, StringRef Name) + : SymbolRecord(SymbolRecordKind::BPRelativeSym), + RecordOffset(RecordOffset), Header(*H), Name(Name) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Name; + CV_DESERIALIZE(Reader, H, Name); + + return BPRelativeSym(RecordOffset, H, Name); + } uint32_t RecordOffset; + Hdr Header; + StringRef Name; }; // S_REGREL32 class RegRelativeSym : public SymbolRecord { public: - explicit RegRelativeSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit RegRelativeSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::RegRelativeSym), - RecordOffset(RecordOffset) {} + struct Hdr { + ulittle32_t Offset; // Offset from the register + TypeIndex Type; // Type of the variable + ulittle16_t Register; // Register to which the variable is relative + // Name: The null-terminated name follows. + }; - uint32_t Offset; - TypeIndex Type; - uint16_t Register; - StringRef Name; + explicit RegRelativeSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + RegRelativeSym(uint32_t RecordOffset, const Hdr *H, StringRef Name) + : SymbolRecord(SymbolRecordKind::RegRelativeSym), + RecordOffset(RecordOffset), Header(*H), Name(Name) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Name; + CV_DESERIALIZE(Reader, H, Name); + + return RegRelativeSym(RecordOffset, H, Name); + } uint32_t RecordOffset; + Hdr Header; + StringRef Name; }; // S_CONSTANT, S_MANCONSTANT class ConstantSym : public SymbolRecord { public: - explicit ConstantSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - ConstantSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::ConstantSym), - RecordOffset(RecordOffset) {} + struct Hdr { + TypeIndex Type; + // Value: The value of the constant. + // Name: The null-terminated name follows. + }; - TypeIndex Type; - APSInt Value; - StringRef Name; + explicit ConstantSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + ConstantSym(uint32_t RecordOffset, const Hdr *H, const APSInt &Value, + StringRef Name) + : SymbolRecord(SymbolRecordKind::ConstantSym), RecordOffset(RecordOffset), + Header(*H), Value(Value), Name(Name) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + APSInt Value; + StringRef Name; + CV_DESERIALIZE(Reader, H, Value, Name); + + return ConstantSym(RecordOffset, H, Value, Name); + } uint32_t RecordOffset; + Hdr Header; + APSInt Value; + StringRef Name; }; // S_LDATA32, S_GDATA32, S_LMANDATA, S_GMANDATA class DataSym : public SymbolRecord { public: - explicit DataSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - DataSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::DataSym), RecordOffset(RecordOffset) {} + struct Hdr { + TypeIndex Type; + ulittle32_t DataOffset; + ulittle16_t Segment; + // Name: The null-terminated name follows. + }; - uint32_t getRelocationOffset() const { - return RecordOffset + offsetof(DataSym, DataOffset); + explicit DataSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + DataSym(uint32_t RecordOffset, const Hdr *H, StringRef Name) + : SymbolRecord(SymbolRecordKind::DataSym), RecordOffset(RecordOffset), + Header(*H), Name(Name) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Name; + CV_DESERIALIZE(Reader, H, Name); + + return DataSym(RecordOffset, H, Name); } - TypeIndex Type; - uint32_t DataOffset; - uint16_t Segment; - StringRef Name; + uint32_t getRelocationOffset() const { + return RecordOffset + offsetof(Hdr, DataOffset); + } uint32_t RecordOffset; + Hdr Header; + StringRef Name; }; // S_LTHREAD32, S_GTHREAD32 class ThreadLocalDataSym : public SymbolRecord { public: - explicit ThreadLocalDataSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} - explicit ThreadLocalDataSym(uint32_t RecordOffset) - : SymbolRecord(SymbolRecordKind::ThreadLocalDataSym), - RecordOffset(RecordOffset) {} + struct Hdr { + TypeIndex Type; + ulittle32_t DataOffset; + ulittle16_t Segment; + // Name: The null-terminated name follows. + }; - uint32_t getRelocationOffset() const { - return RecordOffset + offsetof(ThreadLocalDataSym, DataOffset); + explicit ThreadLocalDataSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} + ThreadLocalDataSym(uint32_t RecordOffset, const Hdr *H, StringRef Name) + : SymbolRecord(SymbolRecordKind::ThreadLocalDataSym), + RecordOffset(RecordOffset), Header(*H), Name(Name) {} + + static Expected deserialize(SymbolRecordKind Kind, + uint32_t RecordOffset, + msf::StreamReader &Reader) { + const Hdr *H = nullptr; + StringRef Name; + CV_DESERIALIZE(Reader, H, Name); + + return ThreadLocalDataSym(RecordOffset, H, Name); } - TypeIndex Type; - uint32_t DataOffset; - uint16_t Segment; - StringRef Name; + uint32_t getRelocationOffset() const { + return RecordOffset + offsetof(Hdr, DataOffset); + } uint32_t RecordOffset; + Hdr Header; + StringRef Name; }; typedef CVRecord CVSymbol; diff --git a/llvm/include/llvm/DebugInfo/CodeView/SymbolRecordMapping.h b/llvm/include/llvm/DebugInfo/CodeView/SymbolRecordMapping.h deleted file mode 100644 index 1bd14ed1347a..000000000000 --- a/llvm/include/llvm/DebugInfo/CodeView/SymbolRecordMapping.h +++ /dev/null @@ -1,44 +0,0 @@ -//===- SymbolRecordMapping.h ------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORDMAPPING_H -#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLRECORDMAPPING_H - -#include "llvm/DebugInfo/CodeView/CodeViewRecordIO.h" -#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h" - -namespace llvm { -namespace msf { -class StreamReader; -class StreamWriter; -} - -namespace codeview { -class SymbolRecordMapping : public SymbolVisitorCallbacks { -public: - explicit SymbolRecordMapping(msf::StreamReader &Reader) : IO(Reader) {} - explicit SymbolRecordMapping(msf::StreamWriter &Writer) : IO(Writer) {} - - Error visitSymbolBegin(CVSymbol &Record) override; - Error visitSymbolEnd(CVSymbol &Record) override; - -#define SYMBOL_RECORD(EnumName, EnumVal, Name) \ - Error visitKnownRecord(CVSymbol &CVR, Name &Record) override; -#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#include "CVSymbolTypes.def" - -private: - Optional Kind; - - CodeViewRecordIO IO; -}; -} -} - -#endif diff --git a/llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h b/llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h deleted file mode 100644 index 55f00f635e37..000000000000 --- a/llvm/include/llvm/DebugInfo/CodeView/SymbolSerializer.h +++ /dev/null @@ -1,96 +0,0 @@ -//===- symbolSerializer.h ---------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLSERIALIZER_H -#define LLVM_DEBUGINFO_CODEVIEW_SYMBOLSERIALIZER_H - -#include "llvm/DebugInfo/CodeView/SymbolRecordMapping.h" -#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h" -#include "llvm/DebugInfo/Msf/ByteStream.h" -#include "llvm/DebugInfo/Msf/StreamWriter.h" - -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/ADT/iterator_range.h" -#include "llvm/Support/Allocator.h" -#include "llvm/Support/Error.h" - -namespace llvm { -namespace codeview { - -class SymbolSerializer : public SymbolVisitorCallbacks { - uint32_t RecordStart = 0; - msf::StreamWriter &Writer; - SymbolRecordMapping Mapping; - Optional CurrentSymbol; - - Error writeRecordPrefix(SymbolKind Kind) { - RecordPrefix Prefix; - Prefix.RecordKind = Kind; - Prefix.RecordLen = 0; - if (auto EC = Writer.writeObject(Prefix)) - return EC; - return Error::success(); - } - -public: - explicit SymbolSerializer(msf::StreamWriter &Writer) - : Writer(Writer), Mapping(Writer) {} - - virtual Error visitSymbolBegin(CVSymbol &Record) override { - assert(!CurrentSymbol.hasValue() && "Already in a symbol mapping!"); - - RecordStart = Writer.getOffset(); - if (auto EC = writeRecordPrefix(Record.kind())) - return EC; - - CurrentSymbol = Record.kind(); - if (auto EC = Mapping.visitSymbolBegin(Record)) - return EC; - - return Error::success(); - } - - virtual Error visitSymbolEnd(CVSymbol &Record) override { - assert(CurrentSymbol.hasValue() && "Not in a symbol mapping!"); - - if (auto EC = Mapping.visitSymbolEnd(Record)) - return EC; - - uint32_t RecordEnd = Writer.getOffset(); - Writer.setOffset(RecordStart); - uint16_t Length = RecordEnd - Writer.getOffset() - 2; - if (auto EC = Writer.writeInteger(Length)) - return EC; - - Writer.setOffset(RecordEnd); - CurrentSymbol.reset(); - - return Error::success(); - } - -#define SYMBOL_RECORD(EnumName, EnumVal, Name) \ - virtual Error visitKnownRecord(CVSymbol &CVR, Name &Record) override { \ - return visitKnownRecordImpl(CVR, Record); \ - } -#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#include "CVSymbolTypes.def" - -private: - template - Error visitKnownRecordImpl(CVSymbol &CVR, RecordKind &Record) { - return Mapping.visitKnownRecord(CVR, Record); - } -}; -} -} - -#endif diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index 3d0ae1a93992..3f5ef1a52ffb 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -2072,39 +2072,35 @@ void CodeViewDebug::emitLocalVariable(const LocalVariable &Var) { (DefRange.StructOffset << DefRangeRegisterRelSym::OffsetInParentShift); } - DefRangeRegisterRelSym Sym(S_DEFRANGE_REGISTER_REL); - Sym.Hdr.Register = DefRange.CVRegister; - Sym.Hdr.Flags = RegRelFlags; - Sym.Hdr.BasePointerOffset = DefRange.DataOffset; + DefRangeRegisterRelSym Sym(DefRange.CVRegister, RegRelFlags, + DefRange.DataOffset, None); ulittle16_t SymKind = ulittle16_t(S_DEFRANGE_REGISTER_REL); BytePrefix += StringRef(reinterpret_cast(&SymKind), sizeof(SymKind)); BytePrefix += - StringRef(reinterpret_cast(&Sym.Hdr), sizeof(Sym.Hdr)); + StringRef(reinterpret_cast(&Sym.Header), + sizeof(Sym.Header) - sizeof(LocalVariableAddrRange)); } else { assert(DefRange.DataOffset == 0 && "unexpected offset into register"); if (DefRange.IsSubfield) { // Unclear what matters here. - DefRangeSubfieldRegisterSym Sym(S_DEFRANGE_SUBFIELD_REGISTER); - Sym.Hdr.Register = DefRange.CVRegister; - Sym.Hdr.MayHaveNoName = 0; - Sym.Hdr.OffsetInParent = DefRange.StructOffset; - + DefRangeSubfieldRegisterSym Sym(DefRange.CVRegister, 0, + DefRange.StructOffset, None); ulittle16_t SymKind = ulittle16_t(S_DEFRANGE_SUBFIELD_REGISTER); BytePrefix += StringRef(reinterpret_cast(&SymKind), sizeof(SymKind)); - BytePrefix += StringRef(reinterpret_cast(&Sym.Hdr), - sizeof(Sym.Hdr)); + BytePrefix += + StringRef(reinterpret_cast(&Sym.Header), + sizeof(Sym.Header) - sizeof(LocalVariableAddrRange)); } else { // Unclear what matters here. - DefRangeRegisterSym Sym(S_DEFRANGE_REGISTER); - Sym.Hdr.Register = DefRange.CVRegister; - Sym.Hdr.MayHaveNoName = 0; + DefRangeRegisterSym Sym(DefRange.CVRegister, 0, None); ulittle16_t SymKind = ulittle16_t(S_DEFRANGE_REGISTER); BytePrefix += StringRef(reinterpret_cast(&SymKind), sizeof(SymKind)); - BytePrefix += StringRef(reinterpret_cast(&Sym.Hdr), - sizeof(Sym.Hdr)); + BytePrefix += + StringRef(reinterpret_cast(&Sym.Header), + sizeof(Sym.Header) - sizeof(LocalVariableAddrRange)); } } OS.EmitCVDefRangeDirective(DefRange.Ranges, BytePrefix); diff --git a/llvm/lib/DebugInfo/CodeView/CMakeLists.txt b/llvm/lib/DebugInfo/CodeView/CMakeLists.txt index be22b9f0d50e..12675c3c6316 100644 --- a/llvm/lib/DebugInfo/CodeView/CMakeLists.txt +++ b/llvm/lib/DebugInfo/CodeView/CMakeLists.txt @@ -8,9 +8,7 @@ add_llvm_library(LLVMDebugInfoCodeView ModuleSubstream.cpp ModuleSubstreamVisitor.cpp RecordSerialization.cpp - SymbolRecordMapping.cpp SymbolDumper.cpp - SymbolSerializer.cpp TypeDumper.cpp TypeRecord.cpp TypeRecordMapping.cpp diff --git a/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp b/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp index 9bd85cf9dc68..19facaec9f07 100644 --- a/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp +++ b/llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp @@ -75,16 +75,6 @@ Error CodeViewRecordIO::mapByteVectorTail(ArrayRef &Bytes) { return Error::success(); } -Error CodeViewRecordIO::mapByteVectorTail(std::vector &Bytes) { - ArrayRef BytesRef(Bytes); - if (auto EC = mapByteVectorTail(BytesRef)) - return EC; - if (!isWriting()) - Bytes.assign(BytesRef.begin(), BytesRef.end()); - - return Error::success(); -} - Error CodeViewRecordIO::mapInteger(TypeIndex &TypeInd) { if (isWriting()) { if (auto EC = Writer->writeInteger(TypeInd.getIndex())) @@ -170,27 +160,6 @@ Error CodeViewRecordIO::mapGuid(StringRef &Guid) { return Error::success(); } -Error CodeViewRecordIO::mapStringZVectorZ(std::vector &Value) { - if (isWriting()) { - for (auto V : Value) { - if (auto EC = mapStringZ(V)) - return EC; - } - if (auto EC = Writer->writeInteger(uint8_t(0))) - return EC; - } else { - StringRef S; - if (auto EC = mapStringZ(S)) - return EC; - while (!S.empty()) { - Value.push_back(S); - if (auto EC = mapStringZ(S)) - return EC; - }; - } - return Error::success(); -} - Error CodeViewRecordIO::writeEncodedSignedInteger(const int64_t &Value) { assert(Value < 0 && "Encoded integer is not signed!"); if (Value >= std::numeric_limits::min()) { diff --git a/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp b/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp index 326e1f5add65..19a2552ff7f3 100644 --- a/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp +++ b/llvm/lib/DebugInfo/CodeView/SymbolDumper.cpp @@ -94,14 +94,14 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, BlockSym &Block) { DictScope S(W, "BlockStart"); StringRef LinkageName; - W.printHex("PtrParent", Block.Parent); - W.printHex("PtrEnd", Block.End); - W.printHex("CodeSize", Block.CodeSize); + W.printHex("PtrParent", Block.Header.PtrParent); + W.printHex("PtrEnd", Block.Header.PtrEnd); + W.printHex("CodeSize", Block.Header.CodeSize); if (ObjDelegate) { ObjDelegate->printRelocatedField("CodeOffset", Block.getRelocationOffset(), - Block.CodeOffset, &LinkageName); + Block.Header.CodeOffset, &LinkageName); } - W.printHex("Segment", Block.Segment); + W.printHex("Segment", Block.Header.Segment); W.printString("BlockName", Block.Name); W.printString("LinkageName", LinkageName); return Error::success(); @@ -109,35 +109,36 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, BlockSym &Block) { Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, Thunk32Sym &Thunk) { DictScope S(W, "Thunk32"); - W.printNumber("Parent", Thunk.Parent); - W.printNumber("End", Thunk.End); - W.printNumber("Next", Thunk.Next); - W.printNumber("Off", Thunk.Offset); - W.printNumber("Seg", Thunk.Segment); - W.printNumber("Len", Thunk.Length); - W.printEnum("Ordinal", uint8_t(Thunk.Thunk), getThunkOrdinalNames()); + W.printNumber("Parent", Thunk.Header.Parent); + W.printNumber("End", Thunk.Header.End); + W.printNumber("Next", Thunk.Header.Next); + W.printNumber("Off", Thunk.Header.Off); + W.printNumber("Seg", Thunk.Header.Seg); + W.printNumber("Len", Thunk.Header.Len); + W.printEnum("Ordinal", Thunk.Header.Ord, getThunkOrdinalNames()); return Error::success(); } Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, TrampolineSym &Tramp) { DictScope S(W, "Trampoline"); - W.printEnum("Type", uint16_t(Tramp.Type), getTrampolineNames()); - W.printNumber("Size", Tramp.Size); - W.printNumber("ThunkOff", Tramp.ThunkOffset); - W.printNumber("TargetOff", Tramp.TargetOffset); - W.printNumber("ThunkSection", Tramp.ThunkSection); - W.printNumber("TargetSection", Tramp.TargetSection); + W.printEnum("Type", Tramp.Header.Type, getTrampolineNames()); + W.printNumber("Size", Tramp.Header.Size); + W.printNumber("ThunkOff", Tramp.Header.ThunkOff); + W.printNumber("TargetOff", Tramp.Header.TargetOff); + W.printNumber("ThunkSection", Tramp.Header.ThunkSection); + W.printNumber("TargetSection", Tramp.Header.TargetSection); return Error::success(); } Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, SectionSym &Section) { DictScope S(W, "Section"); - W.printNumber("SectionNumber", Section.SectionNumber); - W.printNumber("Alignment", Section.Alignment); - W.printNumber("Rva", Section.Rva); - W.printNumber("Length", Section.Length); - W.printFlags("Characteristics", Section.Characteristics, + W.printNumber("SectionNumber", Section.Header.SectionNumber); + W.printNumber("Alignment", Section.Header.Alignment); + W.printNumber("Reserved", Section.Header.Reserved); + W.printNumber("Rva", Section.Header.Rva); + W.printNumber("Length", Section.Header.Length); + W.printFlags("Characteristics", Section.Header.Characteristics, getImageSectionCharacteristicNames(), COFF::SectionCharacteristics(0x00F00000)); @@ -148,12 +149,12 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, SectionSym &Section) { Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, CoffGroupSym &CoffGroup) { DictScope S(W, "COFF Group"); - W.printNumber("Size", CoffGroup.Size); - W.printFlags("Characteristics", CoffGroup.Characteristics, + W.printNumber("Size", CoffGroup.Header.Size); + W.printFlags("Characteristics", CoffGroup.Header.Characteristics, getImageSectionCharacteristicNames(), COFF::SectionCharacteristics(0x00F00000)); - W.printNumber("Offset", CoffGroup.Offset); - W.printNumber("Segment", CoffGroup.Segment); + W.printNumber("Offset", CoffGroup.Header.Offset); + W.printNumber("Segment", CoffGroup.Header.Segment); W.printString("Name", CoffGroup.Name); return Error::success(); } @@ -162,8 +163,8 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, BPRelativeSym &BPRel) { DictScope S(W, "BPRelativeSym"); - W.printNumber("Offset", BPRel.Offset); - CVTD.printTypeIndex("Type", BPRel.Type); + W.printNumber("Offset", BPRel.Header.Offset); + CVTD.printTypeIndex("Type", BPRel.Header.Type); W.printString("VarName", BPRel.Name); return Error::success(); } @@ -172,7 +173,7 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, BuildInfoSym &BuildInfo) { DictScope S(W, "BuildInfo"); - W.printNumber("BuildId", BuildInfo.BuildId); + W.printNumber("BuildId", BuildInfo.Header.BuildId); return Error::success(); } @@ -182,12 +183,13 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, StringRef LinkageName; if (ObjDelegate) { - ObjDelegate->printRelocatedField("CodeOffset", - CallSiteInfo.getRelocationOffset(), - CallSiteInfo.CodeOffset, &LinkageName); + ObjDelegate->printRelocatedField( + "CodeOffset", CallSiteInfo.getRelocationOffset(), + CallSiteInfo.Header.CodeOffset, &LinkageName); } - W.printHex("Segment", CallSiteInfo.Segment); - CVTD.printTypeIndex("Type", CallSiteInfo.Type); + W.printHex("Segment", CallSiteInfo.Header.Segment); + W.printHex("Reserved", CallSiteInfo.Header.Reserved); + CVTD.printTypeIndex("Type", CallSiteInfo.Header.Type); if (!LinkageName.empty()) W.printString("LinkageName", LinkageName); return Error::success(); @@ -197,6 +199,7 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, EnvBlockSym &EnvBlock) { DictScope S(W, "EnvBlock"); + W.printNumber("Reserved", EnvBlock.Header.Reserved); ListScope L(W, "Entries"); for (auto Entry : EnvBlock.Fields) { W.printString(Entry); @@ -207,17 +210,17 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, FileStaticSym &FileStatic) { DictScope S(W, "FileStatic"); - W.printNumber("Index", FileStatic.Index); - W.printNumber("ModFilenameOffset", FileStatic.ModFilenameOffset); - W.printFlags("Flags", uint16_t(FileStatic.Flags), getLocalFlagNames()); + W.printNumber("Index", FileStatic.Header.Index); + W.printNumber("ModFilenameOffset", FileStatic.Header.ModFilenameOffset); + W.printFlags("Flags", uint16_t(FileStatic.Header.Flags), getLocalFlagNames()); W.printString("Name", FileStatic.Name); return Error::success(); } Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ExportSym &Export) { DictScope S(W, "Export"); - W.printNumber("Ordinal", Export.Ordinal); - W.printFlags("Flags", uint16_t(Export.Flags), getExportSymFlagNames()); + W.printNumber("Ordinal", Export.Header.Ordinal); + W.printFlags("Flags", Export.Header.Flags, getExportSymFlagNames()); W.printString("Name", Export.Name); return Error::success(); } @@ -226,20 +229,24 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, Compile2Sym &Compile2) { DictScope S(W, "CompilerFlags2"); - W.printEnum("Language", Compile2.getLanguage(), getSourceLanguageNames()); - W.printFlags("Flags", Compile2.getFlags(), getCompileSym2FlagNames()); - W.printEnum("Machine", unsigned(Compile2.Machine), getCPUTypeNames()); + W.printEnum("Language", Compile2.Header.getLanguage(), + getSourceLanguageNames()); + W.printFlags("Flags", Compile2.Header.flags & ~0xff, + getCompileSym2FlagNames()); + W.printEnum("Machine", unsigned(Compile2.Header.Machine), getCPUTypeNames()); std::string FrontendVersion; { raw_string_ostream Out(FrontendVersion); - Out << Compile2.VersionFrontendMajor << '.' << Compile2.VersionFrontendMinor - << '.' << Compile2.VersionFrontendBuild; + Out << Compile2.Header.VersionFrontendMajor << '.' + << Compile2.Header.VersionFrontendMinor << '.' + << Compile2.Header.VersionFrontendBuild; } std::string BackendVersion; { raw_string_ostream Out(BackendVersion); - Out << Compile2.VersionBackendMajor << '.' << Compile2.VersionBackendMinor - << '.' << Compile2.VersionBackendBuild; + Out << Compile2.Header.VersionBackendMajor << '.' + << Compile2.Header.VersionBackendMinor << '.' + << Compile2.Header.VersionBackendBuild; } W.printString("FrontendVersion", FrontendVersion); W.printString("BackendVersion", BackendVersion); @@ -251,22 +258,26 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, Compile3Sym &Compile3) { DictScope S(W, "CompilerFlags3"); - W.printEnum("Language", Compile3.getLanguage(), getSourceLanguageNames()); - W.printFlags("Flags", Compile3.getFlags(), getCompileSym3FlagNames()); - W.printEnum("Machine", unsigned(Compile3.Machine), getCPUTypeNames()); + W.printEnum("Language", Compile3.Header.getLanguage(), + getSourceLanguageNames()); + W.printFlags("Flags", Compile3.Header.flags & ~0xff, + getCompileSym3FlagNames()); + W.printEnum("Machine", unsigned(Compile3.Header.Machine), getCPUTypeNames()); std::string FrontendVersion; { raw_string_ostream Out(FrontendVersion); - Out << Compile3.VersionFrontendMajor << '.' << Compile3.VersionFrontendMinor - << '.' << Compile3.VersionFrontendBuild << '.' - << Compile3.VersionFrontendQFE; + Out << Compile3.Header.VersionFrontendMajor << '.' + << Compile3.Header.VersionFrontendMinor << '.' + << Compile3.Header.VersionFrontendBuild << '.' + << Compile3.Header.VersionFrontendQFE; } std::string BackendVersion; { raw_string_ostream Out(BackendVersion); - Out << Compile3.VersionBackendMajor << '.' << Compile3.VersionBackendMinor - << '.' << Compile3.VersionBackendBuild << '.' - << Compile3.VersionBackendQFE; + Out << Compile3.Header.VersionBackendMajor << '.' + << Compile3.Header.VersionBackendMinor << '.' + << Compile3.Header.VersionBackendBuild << '.' + << Compile3.Header.VersionBackendQFE; } W.printString("FrontendVersion", FrontendVersion); W.printString("BackendVersion", BackendVersion); @@ -278,7 +289,7 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ConstantSym &Constant) { DictScope S(W, "Constant"); - CVTD.printTypeIndex("Type", Constant.Type); + CVTD.printTypeIndex("Type", Constant.Header.Type); W.printNumber("Value", Constant.Value); W.printString("Name", Constant.Name); return Error::success(); @@ -291,9 +302,9 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, DataSym &Data) { StringRef LinkageName; if (ObjDelegate) { ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(), - Data.DataOffset, &LinkageName); + Data.Header.DataOffset, &LinkageName); } - CVTD.printTypeIndex("Type", Data.Type); + CVTD.printTypeIndex("Type", Data.Header.Type); W.printString("DisplayName", Data.Name); if (!LinkageName.empty()) W.printString("LinkageName", LinkageName); @@ -304,7 +315,7 @@ Error CVSymbolDumperImpl::visitKnownRecord( CVSymbol &CVR, DefRangeFramePointerRelFullScopeSym &DefRangeFramePointerRelFullScope) { DictScope S(W, "DefRangeFramePointerRelFullScope"); - W.printNumber("Offset", DefRangeFramePointerRelFullScope.Offset); + W.printNumber("Offset", DefRangeFramePointerRelFullScope.Header.Offset); return Error::success(); } @@ -312,8 +323,8 @@ Error CVSymbolDumperImpl::visitKnownRecord( CVSymbol &CVR, DefRangeFramePointerRelSym &DefRangeFramePointerRel) { DictScope S(W, "DefRangeFramePointerRel"); - W.printNumber("Offset", DefRangeFramePointerRel.Offset); - printLocalVariableAddrRange(DefRangeFramePointerRel.Range, + W.printNumber("Offset", DefRangeFramePointerRel.Header.Offset); + printLocalVariableAddrRange(DefRangeFramePointerRel.Header.Range, DefRangeFramePointerRel.getRelocationOffset()); printLocalVariableAddrGap(DefRangeFramePointerRel.Gaps); return Error::success(); @@ -323,12 +334,13 @@ Error CVSymbolDumperImpl::visitKnownRecord( CVSymbol &CVR, DefRangeRegisterRelSym &DefRangeRegisterRel) { DictScope S(W, "DefRangeRegisterRel"); - W.printNumber("BaseRegister", DefRangeRegisterRel.Hdr.Register); + W.printNumber("BaseRegister", DefRangeRegisterRel.Header.BaseRegister); W.printBoolean("HasSpilledUDTMember", DefRangeRegisterRel.hasSpilledUDTMember()); W.printNumber("OffsetInParent", DefRangeRegisterRel.offsetInParent()); - W.printNumber("BasePointerOffset", DefRangeRegisterRel.Hdr.BasePointerOffset); - printLocalVariableAddrRange(DefRangeRegisterRel.Range, + W.printNumber("BasePointerOffset", + DefRangeRegisterRel.Header.BasePointerOffset); + printLocalVariableAddrRange(DefRangeRegisterRel.Header.Range, DefRangeRegisterRel.getRelocationOffset()); printLocalVariableAddrGap(DefRangeRegisterRel.Gaps); return Error::success(); @@ -338,9 +350,9 @@ Error CVSymbolDumperImpl::visitKnownRecord( CVSymbol &CVR, DefRangeRegisterSym &DefRangeRegister) { DictScope S(W, "DefRangeRegister"); - W.printNumber("Register", DefRangeRegister.Hdr.Register); - W.printNumber("MayHaveNoName", DefRangeRegister.Hdr.MayHaveNoName); - printLocalVariableAddrRange(DefRangeRegister.Range, + W.printNumber("Register", DefRangeRegister.Header.Register); + W.printNumber("MayHaveNoName", DefRangeRegister.Header.MayHaveNoName); + printLocalVariableAddrRange(DefRangeRegister.Header.Range, DefRangeRegister.getRelocationOffset()); printLocalVariableAddrGap(DefRangeRegister.Gaps); return Error::success(); @@ -350,10 +362,11 @@ Error CVSymbolDumperImpl::visitKnownRecord( CVSymbol &CVR, DefRangeSubfieldRegisterSym &DefRangeSubfieldRegister) { DictScope S(W, "DefRangeSubfieldRegister"); - W.printNumber("Register", DefRangeSubfieldRegister.Hdr.Register); - W.printNumber("MayHaveNoName", DefRangeSubfieldRegister.Hdr.MayHaveNoName); - W.printNumber("OffsetInParent", DefRangeSubfieldRegister.Hdr.OffsetInParent); - printLocalVariableAddrRange(DefRangeSubfieldRegister.Range, + W.printNumber("Register", DefRangeSubfieldRegister.Header.Register); + W.printNumber("MayHaveNoName", DefRangeSubfieldRegister.Header.MayHaveNoName); + W.printNumber("OffsetInParent", + DefRangeSubfieldRegister.Header.OffsetInParent); + printLocalVariableAddrRange(DefRangeSubfieldRegister.Header.Range, DefRangeSubfieldRegister.getRelocationOffset()); printLocalVariableAddrGap(DefRangeSubfieldRegister.Gaps); return Error::success(); @@ -365,7 +378,7 @@ Error CVSymbolDumperImpl::visitKnownRecord( if (ObjDelegate) { StringRef StringTable = ObjDelegate->getStringTable(); - auto ProgramStringTableOffset = DefRangeSubfield.Program; + auto ProgramStringTableOffset = DefRangeSubfield.Header.Program; if (ProgramStringTableOffset >= StringTable.size()) return llvm::make_error( "String table offset outside of bounds of String Table!"); @@ -373,8 +386,8 @@ Error CVSymbolDumperImpl::visitKnownRecord( StringTable.drop_front(ProgramStringTableOffset).split('\0').first; W.printString("Program", Program); } - W.printNumber("OffsetInParent", DefRangeSubfield.OffsetInParent); - printLocalVariableAddrRange(DefRangeSubfield.Range, + W.printNumber("OffsetInParent", DefRangeSubfield.Header.OffsetInParent); + printLocalVariableAddrRange(DefRangeSubfield.Header.Range, DefRangeSubfield.getRelocationOffset()); printLocalVariableAddrGap(DefRangeSubfield.Gaps); return Error::success(); @@ -386,7 +399,7 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, if (ObjDelegate) { StringRef StringTable = ObjDelegate->getStringTable(); - auto ProgramStringTableOffset = DefRange.Program; + auto ProgramStringTableOffset = DefRange.Header.Program; if (ProgramStringTableOffset >= StringTable.size()) return llvm::make_error( "String table offset outside of bounds of String Table!"); @@ -394,7 +407,8 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, StringTable.drop_front(ProgramStringTableOffset).split('\0').first; W.printString("Program", Program); } - printLocalVariableAddrRange(DefRange.Range, DefRange.getRelocationOffset()); + printLocalVariableAddrRange(DefRange.Header.Range, + DefRange.getRelocationOffset()); printLocalVariableAddrGap(DefRange.Gaps); return Error::success(); } @@ -405,14 +419,14 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, StringRef LinkageName; if (ObjDelegate) { - ObjDelegate->printRelocatedField("CodeOffset", - FrameCookie.getRelocationOffset(), - FrameCookie.CodeOffset, &LinkageName); + ObjDelegate->printRelocatedField( + "CodeOffset", FrameCookie.getRelocationOffset(), + FrameCookie.Header.CodeOffset, &LinkageName); } - W.printHex("Register", FrameCookie.Register); - W.printEnum("CookieKind", uint16_t(FrameCookie.CookieKind), + W.printHex("Register", FrameCookie.Header.Register); + W.printEnum("CookieKind", uint16_t(FrameCookie.Header.CookieKind), getFrameCookieKindNames()); - W.printHex("Flags", FrameCookie.Flags); + W.printHex("Flags", FrameCookie.Header.Flags); return Error::success(); } @@ -420,16 +434,16 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, FrameProcSym &FrameProc) { DictScope S(W, "FrameProc"); - W.printHex("TotalFrameBytes", FrameProc.TotalFrameBytes); - W.printHex("PaddingFrameBytes", FrameProc.PaddingFrameBytes); - W.printHex("OffsetToPadding", FrameProc.OffsetToPadding); + W.printHex("TotalFrameBytes", FrameProc.Header.TotalFrameBytes); + W.printHex("PaddingFrameBytes", FrameProc.Header.PaddingFrameBytes); + W.printHex("OffsetToPadding", FrameProc.Header.OffsetToPadding); W.printHex("BytesOfCalleeSavedRegisters", - FrameProc.BytesOfCalleeSavedRegisters); - W.printHex("OffsetOfExceptionHandler", FrameProc.OffsetOfExceptionHandler); + FrameProc.Header.BytesOfCalleeSavedRegisters); + W.printHex("OffsetOfExceptionHandler", + FrameProc.Header.OffsetOfExceptionHandler); W.printHex("SectionIdOfExceptionHandler", - FrameProc.SectionIdOfExceptionHandler); - W.printFlags("Flags", static_cast(FrameProc.Flags), - getFrameProcSymFlagNames()); + FrameProc.Header.SectionIdOfExceptionHandler); + W.printFlags("Flags", FrameProc.Header.Flags, getFrameProcSymFlagNames()); return Error::success(); } @@ -439,13 +453,13 @@ Error CVSymbolDumperImpl::visitKnownRecord( StringRef LinkageName; if (ObjDelegate) { - ObjDelegate->printRelocatedField("CodeOffset", - HeapAllocSite.getRelocationOffset(), - HeapAllocSite.CodeOffset, &LinkageName); + ObjDelegate->printRelocatedField( + "CodeOffset", HeapAllocSite.getRelocationOffset(), + HeapAllocSite.Header.CodeOffset, &LinkageName); } - W.printHex("Segment", HeapAllocSite.Segment); - W.printHex("CallInstructionSize", HeapAllocSite.CallInstructionSize); - CVTD.printTypeIndex("Type", HeapAllocSite.Type); + W.printHex("Segment", HeapAllocSite.Header.Segment); + W.printHex("CallInstructionSize", HeapAllocSite.Header.CallInstructionSize); + CVTD.printTypeIndex("Type", HeapAllocSite.Header.Type); if (!LinkageName.empty()) W.printString("LinkageName", LinkageName); return Error::success(); @@ -455,9 +469,9 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, InlineSiteSym &InlineSite) { DictScope S(W, "InlineSite"); - W.printHex("PtrParent", InlineSite.Parent); - W.printHex("PtrEnd", InlineSite.End); - CVTD.printTypeIndex("Inlinee", InlineSite.Inlinee); + W.printHex("PtrParent", InlineSite.Header.PtrParent); + W.printHex("PtrEnd", InlineSite.Header.PtrEnd); + CVTD.printTypeIndex("Inlinee", InlineSite.Header.Inlinee); ListScope BinaryAnnotations(W, "BinaryAnnotations"); for (auto &Annotation : InlineSite.annotations()) { @@ -511,26 +525,26 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, RegisterSym &Register) { DictScope S(W, "RegisterSym"); - W.printNumber("Type", Register.Index); - W.printEnum("Seg", uint16_t(Register.Register), getRegisterNames()); + W.printNumber("Type", Register.Header.Index); + W.printEnum("Seg", uint16_t(Register.Header.Register), getRegisterNames()); W.printString("Name", Register.Name); return Error::success(); } Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, PublicSym32 &Public) { DictScope S(W, "PublicSym"); - W.printNumber("Type", Public.Index); - W.printNumber("Seg", Public.Segment); - W.printNumber("Off", Public.Offset); + W.printNumber("Type", Public.Header.Index); + W.printNumber("Seg", Public.Header.Seg); + W.printNumber("Off", Public.Header.Off); W.printString("Name", Public.Name); return Error::success(); } Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ProcRefSym &ProcRef) { DictScope S(W, "ProcRef"); - W.printNumber("SumName", ProcRef.SumName); - W.printNumber("SymOffset", ProcRef.SymOffset); - W.printNumber("Mod", ProcRef.Module); + W.printNumber("SumName", ProcRef.Header.SumName); + W.printNumber("SymOffset", ProcRef.Header.SymOffset); + W.printNumber("Mod", ProcRef.Header.Mod); W.printString("Name", ProcRef.Name); return Error::success(); } @@ -541,11 +555,11 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LabelSym &Label) { StringRef LinkageName; if (ObjDelegate) { ObjDelegate->printRelocatedField("CodeOffset", Label.getRelocationOffset(), - Label.CodeOffset, &LinkageName); + Label.Header.CodeOffset, &LinkageName); } - W.printHex("Segment", Label.Segment); - W.printHex("Flags", uint8_t(Label.Flags)); - W.printFlags("Flags", uint8_t(Label.Flags), getProcSymFlagNames()); + W.printHex("Segment", Label.Header.Segment); + W.printHex("Flags", Label.Header.Flags); + W.printFlags("Flags", Label.Header.Flags, getProcSymFlagNames()); W.printString("DisplayName", Label.Name); if (!LinkageName.empty()) W.printString("LinkageName", LinkageName); @@ -555,8 +569,8 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LabelSym &Label) { Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LocalSym &Local) { DictScope S(W, "Local"); - CVTD.printTypeIndex("Type", Local.Type); - W.printFlags("Flags", uint16_t(Local.Flags), getLocalFlagNames()); + CVTD.printTypeIndex("Type", Local.Header.Type); + W.printFlags("Flags", uint16_t(Local.Header.Flags), getLocalFlagNames()); W.printString("VarName", Local.Name); return Error::success(); } @@ -564,7 +578,7 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, LocalSym &Local) { Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ObjNameSym &ObjName) { DictScope S(W, "ObjectName"); - W.printHex("Signature", ObjName.Signature); + W.printHex("Signature", ObjName.Header.Signature); W.printString("ObjectName", ObjName.Name); return Error::success(); } @@ -580,19 +594,19 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, ProcSym &Proc) { StringRef LinkageName; W.printEnum("Kind", uint16_t(CVR.kind()), getSymbolTypeNames()); - W.printHex("PtrParent", Proc.Parent); - W.printHex("PtrEnd", Proc.End); - W.printHex("PtrNext", Proc.Next); - W.printHex("CodeSize", Proc.CodeSize); - W.printHex("DbgStart", Proc.DbgStart); - W.printHex("DbgEnd", Proc.DbgEnd); - CVTD.printTypeIndex("FunctionType", Proc.FunctionType); + W.printHex("PtrParent", Proc.Header.PtrParent); + W.printHex("PtrEnd", Proc.Header.PtrEnd); + W.printHex("PtrNext", Proc.Header.PtrNext); + W.printHex("CodeSize", Proc.Header.CodeSize); + W.printHex("DbgStart", Proc.Header.DbgStart); + W.printHex("DbgEnd", Proc.Header.DbgEnd); + CVTD.printTypeIndex("FunctionType", Proc.Header.FunctionType); if (ObjDelegate) { ObjDelegate->printRelocatedField("CodeOffset", Proc.getRelocationOffset(), - Proc.CodeOffset, &LinkageName); + Proc.Header.CodeOffset, &LinkageName); } - W.printHex("Segment", Proc.Segment); - W.printFlags("Flags", static_cast(Proc.Flags), + W.printHex("Segment", Proc.Header.Segment); + W.printFlags("Flags", static_cast(Proc.Header.Flags), getProcSymFlagNames()); W.printString("DisplayName", Proc.Name); if (!LinkageName.empty()) @@ -624,9 +638,9 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, RegRelativeSym &RegRel) { DictScope S(W, "RegRelativeSym"); - W.printHex("Offset", RegRel.Offset); - CVTD.printTypeIndex("Type", RegRel.Type); - W.printHex("Register", RegRel.Register); + W.printHex("Offset", RegRel.Header.Offset); + CVTD.printTypeIndex("Type", RegRel.Header.Type); + W.printHex("Register", RegRel.Header.Register); W.printString("VarName", RegRel.Name); return Error::success(); } @@ -638,9 +652,9 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, StringRef LinkageName; if (ObjDelegate) { ObjDelegate->printRelocatedField("DataOffset", Data.getRelocationOffset(), - Data.DataOffset, &LinkageName); + Data.Header.DataOffset, &LinkageName); } - CVTD.printTypeIndex("Type", Data.Type); + CVTD.printTypeIndex("Type", Data.Header.Type); W.printString("DisplayName", Data.Name); if (!LinkageName.empty()) W.printString("LinkageName", LinkageName); @@ -649,7 +663,7 @@ Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, Error CVSymbolDumperImpl::visitKnownRecord(CVSymbol &CVR, UDTSym &UDT) { DictScope S(W, "UDT"); - CVTD.printTypeIndex("Type", UDT.Type); + CVTD.printTypeIndex("Type", UDT.Header.Type); W.printString("UDTName", UDT.Name); return Error::success(); } diff --git a/llvm/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp b/llvm/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp deleted file mode 100644 index bb1731465495..000000000000 --- a/llvm/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp +++ /dev/null @@ -1,464 +0,0 @@ -//===- SymbolRecordMapping.cpp -----------------------------------*- C++-*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "llvm/DebugInfo/CodeView/SymbolRecordMapping.h" - -using namespace llvm; -using namespace llvm::codeview; - -#define error(X) \ - if (auto EC = X) \ - return EC; - -namespace { -struct MapGap { - Error operator()(CodeViewRecordIO &IO, LocalVariableAddrGap &Gap) const { - error(IO.mapInteger(Gap.GapStartOffset)); - error(IO.mapInteger(Gap.Range)); - return Error::success(); - } -}; -} - -static Error mapLocalVariableAddrRange(CodeViewRecordIO &IO, - LocalVariableAddrRange &Range) { - error(IO.mapInteger(Range.OffsetStart)); - error(IO.mapInteger(Range.ISectStart)); - error(IO.mapInteger(Range.Range)); - return Error::success(); -} - -Error SymbolRecordMapping::visitSymbolBegin(CVSymbol &Record) { - error(IO.beginRecord(MaxRecordLength - sizeof(RecordPrefix))); - return Error::success(); -} - -Error SymbolRecordMapping::visitSymbolEnd(CVSymbol &Record) { - error(IO.endRecord()); - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, BlockSym &Block) { - - error(IO.mapInteger(Block.Parent)); - error(IO.mapInteger(Block.End)); - error(IO.mapInteger(Block.CodeSize)); - error(IO.mapInteger(Block.CodeOffset)); - error(IO.mapInteger(Block.Segment)); - error(IO.mapStringZ(Block.Name)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, Thunk32Sym &Thunk) { - - error(IO.mapInteger(Thunk.Parent)); - error(IO.mapInteger(Thunk.End)); - error(IO.mapInteger(Thunk.Next)); - error(IO.mapInteger(Thunk.Offset)); - error(IO.mapInteger(Thunk.Segment)); - error(IO.mapInteger(Thunk.Length)); - error(IO.mapEnum(Thunk.Thunk)); - error(IO.mapStringZ(Thunk.Name)); - error(IO.mapByteVectorTail(Thunk.VariantData)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - TrampolineSym &Tramp) { - - error(IO.mapEnum(Tramp.Type)); - error(IO.mapInteger(Tramp.Size)); - error(IO.mapInteger(Tramp.ThunkOffset)); - error(IO.mapInteger(Tramp.TargetOffset)); - error(IO.mapInteger(Tramp.ThunkSection)); - error(IO.mapInteger(Tramp.TargetSection)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - SectionSym &Section) { - uint8_t Padding = 0; - - error(IO.mapInteger(Section.SectionNumber)); - error(IO.mapInteger(Section.Alignment)); - error(IO.mapInteger(Padding)); - error(IO.mapInteger(Section.Rva)); - error(IO.mapInteger(Section.Length)); - error(IO.mapInteger(Section.Characteristics)); - error(IO.mapStringZ(Section.Name)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - CoffGroupSym &CoffGroup) { - - error(IO.mapInteger(CoffGroup.Size)); - error(IO.mapInteger(CoffGroup.Characteristics)); - error(IO.mapInteger(CoffGroup.Offset)); - error(IO.mapInteger(CoffGroup.Segment)); - error(IO.mapStringZ(CoffGroup.Name)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - BPRelativeSym &BPRel) { - - error(IO.mapInteger(BPRel.Offset)); - error(IO.mapInteger(BPRel.Type)); - error(IO.mapStringZ(BPRel.Name)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - BuildInfoSym &BuildInfo) { - - error(IO.mapInteger(BuildInfo.BuildId)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - CallSiteInfoSym &CallSiteInfo) { - uint16_t Padding = 0; - - error(IO.mapInteger(CallSiteInfo.CodeOffset)); - error(IO.mapInteger(CallSiteInfo.Segment)); - error(IO.mapInteger(Padding)); - error(IO.mapInteger(CallSiteInfo.Type)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - EnvBlockSym &EnvBlock) { - - uint8_t Reserved = 0; - error(IO.mapInteger(Reserved)); - error(IO.mapStringZVectorZ(EnvBlock.Fields)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - FileStaticSym &FileStatic) { - - error(IO.mapInteger(FileStatic.Index)); - error(IO.mapInteger(FileStatic.ModFilenameOffset)); - error(IO.mapEnum(FileStatic.Flags)); - error(IO.mapStringZ(FileStatic.Name)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, ExportSym &Export) { - - error(IO.mapInteger(Export.Ordinal)); - error(IO.mapEnum(Export.Flags)); - error(IO.mapStringZ(Export.Name)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - Compile2Sym &Compile2) { - - error(IO.mapEnum(Compile2.Flags)); - error(IO.mapEnum(Compile2.Machine)); - error(IO.mapInteger(Compile2.VersionFrontendMajor)); - error(IO.mapInteger(Compile2.VersionFrontendMinor)); - error(IO.mapInteger(Compile2.VersionFrontendBuild)); - error(IO.mapInteger(Compile2.VersionBackendMajor)); - error(IO.mapInteger(Compile2.VersionBackendMinor)); - error(IO.mapInteger(Compile2.VersionBackendBuild)); - error(IO.mapStringZ(Compile2.Version)); - error(IO.mapStringZVectorZ(Compile2.ExtraStrings)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - Compile3Sym &Compile3) { - - error(IO.mapEnum(Compile3.Flags)); - error(IO.mapEnum(Compile3.Machine)); - error(IO.mapInteger(Compile3.VersionFrontendMajor)); - error(IO.mapInteger(Compile3.VersionFrontendMinor)); - error(IO.mapInteger(Compile3.VersionFrontendBuild)); - error(IO.mapInteger(Compile3.VersionFrontendQFE)); - error(IO.mapInteger(Compile3.VersionBackendMajor)); - error(IO.mapInteger(Compile3.VersionBackendMinor)); - error(IO.mapInteger(Compile3.VersionBackendBuild)); - error(IO.mapInteger(Compile3.VersionBackendQFE)); - error(IO.mapStringZ(Compile3.Version)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - ConstantSym &Constant) { - - error(IO.mapInteger(Constant.Type)); - error(IO.mapEncodedInteger(Constant.Value)); - error(IO.mapStringZ(Constant.Name)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, DataSym &Data) { - - error(IO.mapInteger(Data.Type)); - error(IO.mapInteger(Data.DataOffset)); - error(IO.mapInteger(Data.Segment)); - error(IO.mapStringZ(Data.Name)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord( - CVSymbol &CVR, DefRangeFramePointerRelSym &DefRangeFramePointerRel) { - - error(IO.mapInteger(DefRangeFramePointerRel.Offset)); - error(mapLocalVariableAddrRange(IO, DefRangeFramePointerRel.Range)); - error(IO.mapVectorTail(DefRangeFramePointerRel.Gaps, MapGap())); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord( - CVSymbol &CVR, - DefRangeFramePointerRelFullScopeSym &DefRangeFramePointerRelFullScope) { - - error(IO.mapInteger(DefRangeFramePointerRelFullScope.Offset)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord( - CVSymbol &CVR, DefRangeRegisterRelSym &DefRangeRegisterRel) { - - error(IO.mapObject(DefRangeRegisterRel.Hdr.Register)); - error(IO.mapObject(DefRangeRegisterRel.Hdr.Flags)); - error(IO.mapObject(DefRangeRegisterRel.Hdr.BasePointerOffset)); - error(mapLocalVariableAddrRange(IO, DefRangeRegisterRel.Range)); - error(IO.mapVectorTail(DefRangeRegisterRel.Gaps, MapGap())); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord( - CVSymbol &CVR, DefRangeRegisterSym &DefRangeRegister) { - - error(IO.mapObject(DefRangeRegister.Hdr.Register)); - error(IO.mapObject(DefRangeRegister.Hdr.MayHaveNoName)); - error(mapLocalVariableAddrRange(IO, DefRangeRegister.Range)); - error(IO.mapVectorTail(DefRangeRegister.Gaps, MapGap())); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord( - CVSymbol &CVR, DefRangeSubfieldRegisterSym &DefRangeSubfieldRegister) { - - error(IO.mapObject(DefRangeSubfieldRegister.Hdr.Register)); - error(IO.mapObject(DefRangeSubfieldRegister.Hdr.MayHaveNoName)); - error(IO.mapObject(DefRangeSubfieldRegister.Hdr.OffsetInParent)); - error(mapLocalVariableAddrRange(IO, DefRangeSubfieldRegister.Range)); - error(IO.mapVectorTail(DefRangeSubfieldRegister.Gaps, MapGap())); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord( - CVSymbol &CVR, DefRangeSubfieldSym &DefRangeSubfield) { - - error(IO.mapInteger(DefRangeSubfield.Program)); - error(IO.mapInteger(DefRangeSubfield.OffsetInParent)); - error(mapLocalVariableAddrRange(IO, DefRangeSubfield.Range)); - error(IO.mapVectorTail(DefRangeSubfield.Gaps, MapGap())); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - DefRangeSym &DefRange) { - - error(IO.mapInteger(DefRange.Program)); - error(mapLocalVariableAddrRange(IO, DefRange.Range)); - error(IO.mapVectorTail(DefRange.Gaps, MapGap())); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - FrameCookieSym &FrameCookie) { - - error(IO.mapInteger(FrameCookie.CodeOffset)); - error(IO.mapInteger(FrameCookie.Register)); - error(IO.mapInteger(FrameCookie.CookieKind)); - error(IO.mapInteger(FrameCookie.Flags)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - FrameProcSym &FrameProc) { - error(IO.mapInteger(FrameProc.TotalFrameBytes)); - error(IO.mapInteger(FrameProc.PaddingFrameBytes)); - error(IO.mapInteger(FrameProc.OffsetToPadding)); - error(IO.mapInteger(FrameProc.BytesOfCalleeSavedRegisters)); - error(IO.mapInteger(FrameProc.OffsetOfExceptionHandler)); - error(IO.mapInteger(FrameProc.SectionIdOfExceptionHandler)); - error(IO.mapEnum(FrameProc.Flags)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord( - CVSymbol &CVR, HeapAllocationSiteSym &HeapAllocSite) { - - error(IO.mapInteger(HeapAllocSite.CodeOffset)); - error(IO.mapInteger(HeapAllocSite.Segment)); - error(IO.mapInteger(HeapAllocSite.CallInstructionSize)); - error(IO.mapInteger(HeapAllocSite.Type)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - InlineSiteSym &InlineSite) { - - error(IO.mapInteger(InlineSite.Parent)); - error(IO.mapInteger(InlineSite.End)); - error(IO.mapInteger(InlineSite.Inlinee)); - error(IO.mapByteVectorTail(InlineSite.AnnotationData)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - RegisterSym &Register) { - - error(IO.mapInteger(Register.Index)); - error(IO.mapEnum(Register.Register)); - error(IO.mapStringZ(Register.Name)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - PublicSym32 &Public) { - - error(IO.mapInteger(Public.Index)); - error(IO.mapInteger(Public.Offset)); - error(IO.mapInteger(Public.Segment)); - error(IO.mapStringZ(Public.Name)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - ProcRefSym &ProcRef) { - - error(IO.mapInteger(ProcRef.SumName)); - error(IO.mapInteger(ProcRef.SymOffset)); - error(IO.mapInteger(ProcRef.Module)); - error(IO.mapStringZ(ProcRef.Name)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, LabelSym &Label) { - - error(IO.mapInteger(Label.CodeOffset)); - error(IO.mapInteger(Label.Segment)); - error(IO.mapEnum(Label.Flags)); - error(IO.mapStringZ(Label.Name)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, LocalSym &Local) { - error(IO.mapInteger(Local.Type)); - error(IO.mapEnum(Local.Flags)); - error(IO.mapStringZ(Local.Name)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - ObjNameSym &ObjName) { - - error(IO.mapInteger(ObjName.Signature)); - error(IO.mapStringZ(ObjName.Name)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, ProcSym &Proc) { - error(IO.mapInteger(Proc.Parent)); - error(IO.mapInteger(Proc.End)); - error(IO.mapInteger(Proc.Next)); - error(IO.mapInteger(Proc.CodeSize)); - error(IO.mapInteger(Proc.DbgStart)); - error(IO.mapInteger(Proc.DbgEnd)); - error(IO.mapInteger(Proc.FunctionType)); - error(IO.mapInteger(Proc.CodeOffset)); - error(IO.mapInteger(Proc.Segment)); - error(IO.mapEnum(Proc.Flags)); - error(IO.mapStringZ(Proc.Name)); - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - ScopeEndSym &ScopeEnd) { - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, CallerSym &Caller) { - error(IO.mapVectorN( - Caller.Indices, - [](CodeViewRecordIO &IO, TypeIndex &N) { return IO.mapInteger(N); })); - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - RegRelativeSym &RegRel) { - - error(IO.mapInteger(RegRel.Offset)); - error(IO.mapInteger(RegRel.Type)); - error(IO.mapInteger(RegRel.Register)); - error(IO.mapStringZ(RegRel.Name)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, - ThreadLocalDataSym &Data) { - - error(IO.mapInteger(Data.Type)); - error(IO.mapInteger(Data.DataOffset)); - error(IO.mapInteger(Data.Segment)); - error(IO.mapStringZ(Data.Name)); - - return Error::success(); -} - -Error SymbolRecordMapping::visitKnownRecord(CVSymbol &CVR, UDTSym &UDT) { - - error(IO.mapInteger(UDT.Type)); - error(IO.mapStringZ(UDT.Name)); - - return Error::success(); -} diff --git a/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp b/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp deleted file mode 100644 index 323838aad5f5..000000000000 --- a/llvm/lib/DebugInfo/CodeView/SymbolSerializer.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "llvm/DebugInfo/CodeView/SymbolSerializer.h" \ No newline at end of file diff --git a/llvm/lib/MC/MCCodeView.cpp b/llvm/lib/MC/MCCodeView.cpp index 22bdba1ca2be..ac1acc08b0c4 100644 --- a/llvm/lib/MC/MCCodeView.cpp +++ b/llvm/lib/MC/MCCodeView.cpp @@ -361,9 +361,7 @@ void CodeViewContext::encodeInlineLineTable(MCAsmLayout &Layout, // Exit early if our line table would produce an oversized InlineSiteSym // record. Account for the ChangeCodeLength annotation emitted after the // loop ends. - constexpr uint32_t InlineSiteSize = 12; - constexpr uint32_t AnnotationSize = 8; - size_t MaxBufferSize = MaxRecordLength - InlineSiteSize - AnnotationSize; + size_t MaxBufferSize = MaxRecordLength - sizeof(InlineSiteSym::Hdr) - 8; if (Buffer.size() >= MaxBufferSize) break; diff --git a/llvm/test/DebugInfo/PDB/pdb-yaml-symbols.test b/llvm/test/DebugInfo/PDB/pdb-yaml-symbols.test index e3cdcb6ababb..9b6872d5ecaf 100644 --- a/llvm/test/DebugInfo/PDB/pdb-yaml-symbols.test +++ b/llvm/test/DebugInfo/PDB/pdb-yaml-symbols.test @@ -35,8 +35,8 @@ YAML: Signature: 0 YAML: ObjectName: 'd:\src\llvm\test\DebugInfo\PDB\Inputs\empty.obj' YAML: - Kind: S_COMPILE3 YAML: Compile3Sym: -YAML: Flags: [ SecurityChecks ] -YAML: Machine: Pentium3 +YAML: Flags: 8193 +YAML: Machine: 7 YAML: FrontendMajor: 18 YAML: FrontendMinor: 0 YAML: FrontendBuild: 31101 @@ -56,7 +56,7 @@ YAML: DbgStart: 3 YAML: DbgEnd: 8 YAML: FunctionType: 4097 YAML: Segment: 1 -YAML: Flags: [ HasFP ] +YAML: Flags: 1 YAML: DisplayName: main YAML: - Kind: S_FRAMEPROC YAML: FrameProcSym: @@ -66,7 +66,7 @@ YAML: OffsetToPadding: 0 YAML: BytesOfCalleeSavedRegisters: 0 YAML: OffsetOfExceptionHandler: 0 YAML: SectionIdOfExceptionHandler: 0 -YAML: Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ] +YAML: Flags: 1212928 YAML: - Kind: S_END YAML: ScopeEndSym: YAML: - Kind: S_BUILDINFO @@ -83,8 +83,8 @@ YAML: Signature: 0 YAML: ObjectName: '* Linker *' YAML: - Kind: S_COMPILE3 YAML: Compile3Sym: -YAML: Flags: [ ] -YAML: Machine: Intel80386 +YAML: Flags: 7 +YAML: Machine: 3 YAML: FrontendMajor: 0 YAML: FrontendMinor: 0 YAML: FrontendBuild: 0 @@ -96,6 +96,7 @@ YAML: BackendQFE: 0 YAML: Version: 'Microsoft (R) LINK' YAML: - Kind: S_ENVBLOCK YAML: EnvBlockSym: +YAML: Reserved: 0 YAML: Entries: YAML: - cwd YAML: - 'd:\src\llvm\test\DebugInfo\PDB\Inputs' @@ -105,7 +106,7 @@ YAML: - pdb YAML: - 'd:\src\llvm\test\DebugInfo\PDB\Inputs\empty.pdb' YAML: - Kind: S_TRAMPOLINE YAML: TrampolineSym: -YAML: Type: TrampIncremental +YAML: Type: 0 YAML: Size: 5 YAML: ThunkOff: 5 YAML: TargetOff: 16 @@ -115,6 +116,7 @@ YAML: - Kind: S_SECTION YAML: SectionSym: YAML: SectionNumber: 1 YAML: Alignment: 12 +YAML: Reserved: 0 YAML: Rva: 4096 YAML: Length: 4122 YAML: Characteristics: 1610612768 @@ -130,6 +132,7 @@ YAML: - Kind: S_SECTION YAML: SectionSym: YAML: SectionNumber: 2 YAML: Alignment: 12 +YAML: Reserved: 0 YAML: Rva: 12288 YAML: Length: 690 YAML: Characteristics: 1073741888 @@ -159,6 +162,7 @@ YAML: - Kind: S_SECTION YAML: SectionSym: YAML: SectionNumber: 3 YAML: Alignment: 12 +YAML: Reserved: 0 YAML: Rva: 16384 YAML: Length: 4 YAML: Characteristics: 3221225536 @@ -174,6 +178,7 @@ YAML: - Kind: S_SECTION YAML: SectionSym: YAML: SectionNumber: 4 YAML: Alignment: 12 +YAML: Reserved: 0 YAML: Rva: 20480 YAML: Length: 8 YAML: Characteristics: 1107296320 diff --git a/llvm/test/DebugInfo/PDB/pdbdump-headers.test b/llvm/test/DebugInfo/PDB/pdbdump-headers.test index edbaedb6b526..adcab2c0deb0 100644 --- a/llvm/test/DebugInfo/PDB/pdbdump-headers.test +++ b/llvm/test/DebugInfo/PDB/pdbdump-headers.test @@ -417,6 +417,7 @@ ; EMPTY-NEXT: } ; EMPTY-NEXT: { ; EMPTY-NEXT: EnvBlock { +; EMPTY-NEXT: Reserved: 0 ; EMPTY-NEXT: Entries [ ; EMPTY-NEXT: cwd ; EMPTY-NEXT: d:\src\llvm\test\DebugInfo\PDB\Inputs @@ -457,6 +458,7 @@ ; EMPTY-NEXT: Section { ; EMPTY-NEXT: SectionNumber: 1 ; EMPTY-NEXT: Alignment: 12 +; EMPTY-NEXT: Reserved: 0 ; EMPTY-NEXT: Rva: 4096 ; EMPTY-NEXT: Length: 4122 ; EMPTY-NEXT: Characteristics [ (0x60000020) @@ -492,6 +494,7 @@ ; EMPTY-NEXT: Section { ; EMPTY-NEXT: SectionNumber: 2 ; EMPTY-NEXT: Alignment: 12 +; EMPTY-NEXT: Reserved: 0 ; EMPTY-NEXT: Rva: 12288 ; EMPTY-NEXT: Length: 690 ; EMPTY-NEXT: Characteristics [ (0x40000040) @@ -557,6 +560,7 @@ ; EMPTY-NEXT: Section { ; EMPTY-NEXT: SectionNumber: 3 ; EMPTY-NEXT: Alignment: 12 +; EMPTY-NEXT: Reserved: 0 ; EMPTY-NEXT: Rva: 16384 ; EMPTY-NEXT: Length: 4 ; EMPTY-NEXT: Characteristics [ (0xC0000040) @@ -592,6 +596,7 @@ ; EMPTY-NEXT: Section { ; EMPTY-NEXT: SectionNumber: 4 ; EMPTY-NEXT: Alignment: 12 +; EMPTY-NEXT: Reserved: 0 ; EMPTY-NEXT: Rva: 20480 ; EMPTY-NEXT: Length: 8 ; EMPTY-NEXT: Characteristics [ (0x42000040) @@ -1250,6 +1255,7 @@ ; ALL: } ; ALL: { ; ALL: EnvBlock { +; ALL: Reserved: 0 ; ALL: Entries [ ; ALL: cwd ; ALL: d:\src\llvm\test\DebugInfo\PDB\Inputs @@ -1274,6 +1280,7 @@ ; ALL: Section { ; ALL: SectionNumber: 1 ; ALL: Alignment: 12 +; ALL: Reserved: 0 ; ALL: Rva: 4096 ; ALL: Length: 4122 ; ALL: Characteristics [ (0x60000020) @@ -1301,6 +1308,7 @@ ; ALL: Section { ; ALL: SectionNumber: 2 ; ALL: Alignment: 12 +; ALL: Reserved: 0 ; ALL: Rva: 12288 ; ALL: Length: 690 ; ALL: Characteristics [ (0x40000040) @@ -1350,6 +1358,7 @@ ; ALL: Section { ; ALL: SectionNumber: 3 ; ALL: Alignment: 12 +; ALL: Reserved: 0 ; ALL: Rva: 16384 ; ALL: Length: 4 ; ALL: Characteristics [ (0xC0000040) @@ -1377,6 +1386,7 @@ ; ALL: Section { ; ALL: SectionNumber: 4 ; ALL: Alignment: 12 +; ALL: Reserved: 0 ; ALL: Rva: 20480 ; ALL: Length: 8 ; ALL: Characteristics [ (0x42000040) diff --git a/llvm/tools/llvm-pdbdump/YamlSymbolDumper.cpp b/llvm/tools/llvm-pdbdump/YamlSymbolDumper.cpp index 210260a03b5f..c2df26f7cd29 100644 --- a/llvm/tools/llvm-pdbdump/YamlSymbolDumper.cpp +++ b/llvm/tools/llvm-pdbdump/YamlSymbolDumper.cpp @@ -38,197 +38,105 @@ void ScalarEnumerationTraits::enumeration(IO &io, io.enumCase(Value, E.Name.str().c_str(), E.Value); } -template <> struct ScalarBitSetTraits { - static void bitset(IO &io, CompileSym2Flags &Flags) { - auto FlagNames = getCompileSym2FlagNames(); - for (const auto &E : FlagNames) { - io.bitSetCase(Flags, E.Name.str().c_str(), - static_cast(E.Value)); - } - } -}; - -template <> struct ScalarBitSetTraits { - static void bitset(IO &io, CompileSym3Flags &Flags) { - auto FlagNames = getCompileSym3FlagNames(); - for (const auto &E : FlagNames) { - io.bitSetCase(Flags, E.Name.str().c_str(), - static_cast(E.Value)); - } - } -}; - -template <> struct ScalarBitSetTraits { - static void bitset(IO &io, ExportFlags &Flags) { - auto FlagNames = getExportSymFlagNames(); - for (const auto &E : FlagNames) { - io.bitSetCase(Flags, E.Name.str().c_str(), - static_cast(E.Value)); - } - } -}; - -template <> struct ScalarBitSetTraits { - static void bitset(IO &io, LocalSymFlags &Flags) { - auto FlagNames = getLocalFlagNames(); - for (const auto &E : FlagNames) { - io.bitSetCase(Flags, E.Name.str().c_str(), - static_cast(E.Value)); - } - } -}; - -template <> struct ScalarBitSetTraits { - static void bitset(IO &io, ProcSymFlags &Flags) { - auto FlagNames = getProcSymFlagNames(); - for (const auto &E : FlagNames) { - io.bitSetCase(Flags, E.Name.str().c_str(), - static_cast(E.Value)); - } - } -}; - -template <> struct ScalarBitSetTraits { - static void bitset(IO &io, FrameProcedureOptions &Flags) { - auto FlagNames = getFrameProcSymFlagNames(); - for (const auto &E : FlagNames) { - io.bitSetCase(Flags, E.Name.str().c_str(), - static_cast(E.Value)); - } - } -}; - -template <> struct ScalarEnumerationTraits { - static void enumeration(IO &io, CPUType &Cpu) { - auto CpuNames = getCPUTypeNames(); - for (const auto &E : CpuNames) { - io.enumCase(Cpu, E.Name.str().c_str(), static_cast(E.Value)); - } - } -}; - -template <> struct ScalarEnumerationTraits { - static void enumeration(IO &io, RegisterId &Reg) { - auto RegNames = getRegisterNames(); - for (const auto &E : RegNames) { - io.enumCase(Reg, E.Name.str().c_str(), static_cast(E.Value)); - } - } -}; - -template <> struct ScalarEnumerationTraits { - static void enumeration(IO &io, TrampolineType &Tramp) { - auto TrampNames = getTrampolineNames(); - for (const auto &E : TrampNames) { - io.enumCase(Tramp, E.Name.str().c_str(), - static_cast(E.Value)); - } - } -}; - template <> struct ScalarEnumerationTraits { - static void enumeration(IO &io, ThunkOrdinal &Ord) { - auto ThunkNames = getThunkOrdinalNames(); - for (const auto &E : ThunkNames) { - io.enumCase(Ord, E.Name.str().c_str(), - static_cast(E.Value)); - } - } + void enumeration(IO &io, ThunkOrdinal Ord) {} }; void MappingTraits::mapping(IO &IO, ScopeEndSym &Obj) {} void MappingTraits::mapping(IO &IO, Thunk32Sym &Thunk) { - IO.mapRequired("Parent", Thunk.Parent); - IO.mapRequired("End", Thunk.End); - IO.mapRequired("Next", Thunk.Next); - IO.mapRequired("Off", Thunk.Offset); - IO.mapRequired("Seg", Thunk.Segment); - IO.mapRequired("Len", Thunk.Length); - IO.mapRequired("Ordinal", Thunk.Thunk); + IO.mapRequired("Parent", Thunk.Header.Parent); + IO.mapRequired("End", Thunk.Header.End); + IO.mapRequired("Next", Thunk.Header.Next); + IO.mapRequired("Off", Thunk.Header.Off); + IO.mapRequired("Seg", Thunk.Header.Seg); + IO.mapRequired("Len", Thunk.Header.Len); + IO.mapRequired("Ordinal", Thunk.Header.Ord); } void MappingTraits::mapping(IO &IO, TrampolineSym &Tramp) { - IO.mapRequired("Type", Tramp.Type); - IO.mapRequired("Size", Tramp.Size); - IO.mapRequired("ThunkOff", Tramp.ThunkOffset); - IO.mapRequired("TargetOff", Tramp.TargetOffset); - IO.mapRequired("ThunkSection", Tramp.ThunkSection); - IO.mapRequired("TargetSection", Tramp.TargetSection); + IO.mapRequired("Type", Tramp.Header.Type); + IO.mapRequired("Size", Tramp.Header.Size); + IO.mapRequired("ThunkOff", Tramp.Header.ThunkOff); + IO.mapRequired("TargetOff", Tramp.Header.TargetOff); + IO.mapRequired("ThunkSection", Tramp.Header.ThunkSection); + IO.mapRequired("TargetSection", Tramp.Header.TargetSection); } void MappingTraits::mapping(IO &IO, SectionSym &Section) { - IO.mapRequired("SectionNumber", Section.SectionNumber); - IO.mapRequired("Alignment", Section.Alignment); - IO.mapRequired("Rva", Section.Rva); - IO.mapRequired("Length", Section.Length); - IO.mapRequired("Characteristics", Section.Characteristics); + IO.mapRequired("SectionNumber", Section.Header.SectionNumber); + IO.mapRequired("Alignment", Section.Header.Alignment); + IO.mapRequired("Reserved", Section.Header.Reserved); + IO.mapRequired("Rva", Section.Header.Rva); + IO.mapRequired("Length", Section.Header.Length); + IO.mapRequired("Characteristics", Section.Header.Characteristics); IO.mapRequired("Name", Section.Name); } void MappingTraits::mapping(IO &IO, CoffGroupSym &CoffGroup) { - IO.mapRequired("Size", CoffGroup.Size); - IO.mapRequired("Characteristics", CoffGroup.Characteristics); - IO.mapRequired("Offset", CoffGroup.Offset); - IO.mapRequired("Segment", CoffGroup.Segment); + IO.mapRequired("Size", CoffGroup.Header.Size); + IO.mapRequired("Characteristics", CoffGroup.Header.Characteristics); + IO.mapRequired("Offset", CoffGroup.Header.Offset); + IO.mapRequired("Segment", CoffGroup.Header.Segment); IO.mapRequired("Name", CoffGroup.Name); } void MappingTraits::mapping(IO &IO, ExportSym &Export) { - IO.mapRequired("Ordinal", Export.Ordinal); - IO.mapRequired("Flags", Export.Flags); + IO.mapRequired("Ordinal", Export.Header.Ordinal); + IO.mapRequired("Flags", Export.Header.Flags); IO.mapRequired("Name", Export.Name); } void MappingTraits::mapping(IO &IO, ProcSym &Proc) { // TODO: Print the linkage name - IO.mapRequired("PtrParent", Proc.Parent); - IO.mapRequired("PtrEnd", Proc.End); - IO.mapRequired("PtrNext", Proc.Next); - IO.mapRequired("CodeSize", Proc.CodeSize); - IO.mapRequired("DbgStart", Proc.DbgStart); - IO.mapRequired("DbgEnd", Proc.DbgEnd); - IO.mapRequired("FunctionType", Proc.FunctionType); - IO.mapRequired("Segment", Proc.Segment); - IO.mapRequired("Flags", Proc.Flags); + IO.mapRequired("PtrParent", Proc.Header.PtrParent); + IO.mapRequired("PtrEnd", Proc.Header.PtrEnd); + IO.mapRequired("PtrNext", Proc.Header.PtrNext); + IO.mapRequired("CodeSize", Proc.Header.CodeSize); + IO.mapRequired("DbgStart", Proc.Header.DbgStart); + IO.mapRequired("DbgEnd", Proc.Header.DbgEnd); + IO.mapRequired("FunctionType", Proc.Header.FunctionType); + IO.mapRequired("Segment", Proc.Header.Segment); + IO.mapRequired("Flags", Proc.Header.Flags); IO.mapRequired("DisplayName", Proc.Name); } void MappingTraits::mapping(IO &IO, RegisterSym &Register) { - IO.mapRequired("Type", Register.Index); - IO.mapRequired("Seg", Register.Register); + IO.mapRequired("Type", Register.Header.Index); + IO.mapRequired("Seg", Register.Header.Register); IO.mapRequired("Name", Register.Name); } void MappingTraits::mapping(IO &IO, PublicSym32 &Public) { - IO.mapRequired("Type", Public.Index); - IO.mapRequired("Seg", Public.Segment); - IO.mapRequired("Off", Public.Offset); + IO.mapRequired("Type", Public.Header.Index); + IO.mapRequired("Seg", Public.Header.Seg); + IO.mapRequired("Off", Public.Header.Off); IO.mapRequired("Name", Public.Name); } void MappingTraits::mapping(IO &IO, ProcRefSym &ProcRef) { - IO.mapRequired("SumName", ProcRef.SumName); - IO.mapRequired("SymOffset", ProcRef.SymOffset); - IO.mapRequired("Mod", ProcRef.Module); + IO.mapRequired("SumName", ProcRef.Header.SumName); + IO.mapRequired("SymOffset", ProcRef.Header.SymOffset); + IO.mapRequired("Mod", ProcRef.Header.Mod); IO.mapRequired("Name", ProcRef.Name); } void MappingTraits::mapping(IO &IO, EnvBlockSym &EnvBlock) { + IO.mapRequired("Reserved", EnvBlock.Header.Reserved); IO.mapRequired("Entries", EnvBlock.Fields); } void MappingTraits::mapping(IO &IO, InlineSiteSym &InlineSite) { - IO.mapRequired("PtrParent", InlineSite.Parent); - IO.mapRequired("PtrEnd", InlineSite.End); - IO.mapRequired("Inlinee", InlineSite.Inlinee); + IO.mapRequired("PtrParent", InlineSite.Header.PtrParent); + IO.mapRequired("PtrEnd", InlineSite.Header.PtrEnd); + IO.mapRequired("Inlinee", InlineSite.Header.Inlinee); // TODO: The binary annotations } void MappingTraits::mapping(IO &IO, LocalSym &Local) { - IO.mapRequired("Type", Local.Type); - IO.mapRequired("Flags", Local.Flags); + IO.mapRequired("Type", Local.Header.Type); + IO.mapRequired("Flags", Local.Header.Flags); IO.mapRequired("VarName", Local.Name); } @@ -268,93 +176,95 @@ void MappingTraits::mapping( void MappingTraits::mapping(IO &IO, BlockSym &Block) { // TODO: Print the linkage name - IO.mapRequired("PtrParent", Block.Parent); - IO.mapRequired("PtrEnd", Block.End); - IO.mapRequired("CodeSize", Block.CodeSize); - IO.mapRequired("Segment", Block.Segment); + IO.mapRequired("PtrParent", Block.Header.PtrParent); + IO.mapRequired("PtrEnd", Block.Header.PtrEnd); + IO.mapRequired("CodeSize", Block.Header.CodeSize); + IO.mapRequired("Segment", Block.Header.Segment); IO.mapRequired("BlockName", Block.Name); } void MappingTraits::mapping(IO &IO, LabelSym &Label) { // TODO: Print the linkage name - IO.mapRequired("Segment", Label.Segment); - IO.mapRequired("Flags", Label.Flags); - IO.mapRequired("Flags", Label.Flags); + IO.mapRequired("Segment", Label.Header.Segment); + IO.mapRequired("Flags", Label.Header.Flags); + IO.mapRequired("Flags", Label.Header.Flags); IO.mapRequired("DisplayName", Label.Name); } void MappingTraits::mapping(IO &IO, ObjNameSym &ObjName) { - IO.mapRequired("Signature", ObjName.Signature); + IO.mapRequired("Signature", ObjName.Header.Signature); IO.mapRequired("ObjectName", ObjName.Name); } void MappingTraits::mapping(IO &IO, Compile2Sym &Compile2) { - IO.mapRequired("Flags", Compile2.Flags); - IO.mapRequired("Machine", Compile2.Machine); - IO.mapRequired("FrontendMajor", Compile2.VersionFrontendMajor); - IO.mapRequired("FrontendMinor", Compile2.VersionFrontendMinor); - IO.mapRequired("FrontendBuild", Compile2.VersionFrontendBuild); - IO.mapRequired("BackendMajor", Compile2.VersionBackendMajor); - IO.mapRequired("BackendMinor", Compile2.VersionBackendMinor); - IO.mapRequired("BackendBuild", Compile2.VersionBackendBuild); + IO.mapRequired("Flags", Compile2.Header.flags); + IO.mapRequired("Machine", Compile2.Header.Machine); + IO.mapRequired("FrontendMajor", Compile2.Header.VersionFrontendMajor); + IO.mapRequired("FrontendMinor", Compile2.Header.VersionFrontendMinor); + IO.mapRequired("FrontendBuild", Compile2.Header.VersionFrontendBuild); + IO.mapRequired("BackendMajor", Compile2.Header.VersionBackendMajor); + IO.mapRequired("BackendMinor", Compile2.Header.VersionBackendMinor); + IO.mapRequired("BackendBuild", Compile2.Header.VersionBackendBuild); IO.mapRequired("Version", Compile2.Version); } void MappingTraits::mapping(IO &IO, Compile3Sym &Compile3) { - IO.mapRequired("Flags", Compile3.Flags); - IO.mapRequired("Machine", Compile3.Machine); - IO.mapRequired("FrontendMajor", Compile3.VersionFrontendMajor); - IO.mapRequired("FrontendMinor", Compile3.VersionFrontendMinor); - IO.mapRequired("FrontendBuild", Compile3.VersionFrontendBuild); - IO.mapRequired("FrontendQFE", Compile3.VersionFrontendQFE); - IO.mapRequired("BackendMajor", Compile3.VersionBackendMajor); - IO.mapRequired("BackendMinor", Compile3.VersionBackendMinor); - IO.mapRequired("BackendBuild", Compile3.VersionBackendBuild); - IO.mapRequired("BackendQFE", Compile3.VersionBackendQFE); + IO.mapRequired("Flags", Compile3.Header.flags); + IO.mapRequired("Machine", Compile3.Header.Machine); + IO.mapRequired("FrontendMajor", Compile3.Header.VersionFrontendMajor); + IO.mapRequired("FrontendMinor", Compile3.Header.VersionFrontendMinor); + IO.mapRequired("FrontendBuild", Compile3.Header.VersionFrontendBuild); + IO.mapRequired("FrontendQFE", Compile3.Header.VersionFrontendQFE); + IO.mapRequired("BackendMajor", Compile3.Header.VersionBackendMajor); + IO.mapRequired("BackendMinor", Compile3.Header.VersionBackendMinor); + IO.mapRequired("BackendBuild", Compile3.Header.VersionBackendBuild); + IO.mapRequired("BackendQFE", Compile3.Header.VersionBackendQFE); IO.mapRequired("Version", Compile3.Version); } void MappingTraits::mapping(IO &IO, FrameProcSym &FrameProc) { - IO.mapRequired("TotalFrameBytes", FrameProc.TotalFrameBytes); - IO.mapRequired("PaddingFrameBytes", FrameProc.PaddingFrameBytes); - IO.mapRequired("OffsetToPadding", FrameProc.OffsetToPadding); + IO.mapRequired("TotalFrameBytes", FrameProc.Header.TotalFrameBytes); + IO.mapRequired("PaddingFrameBytes", FrameProc.Header.PaddingFrameBytes); + IO.mapRequired("OffsetToPadding", FrameProc.Header.OffsetToPadding); IO.mapRequired("BytesOfCalleeSavedRegisters", - FrameProc.BytesOfCalleeSavedRegisters); + FrameProc.Header.BytesOfCalleeSavedRegisters); IO.mapRequired("OffsetOfExceptionHandler", - FrameProc.OffsetOfExceptionHandler); + FrameProc.Header.OffsetOfExceptionHandler); IO.mapRequired("SectionIdOfExceptionHandler", - FrameProc.SectionIdOfExceptionHandler); - IO.mapRequired("Flags", FrameProc.Flags); + FrameProc.Header.SectionIdOfExceptionHandler); + IO.mapRequired("Flags", FrameProc.Header.Flags); } void MappingTraits::mapping(IO &IO, CallSiteInfoSym &CallSiteInfo) { // TODO: Map Linkage Name - IO.mapRequired("Segment", CallSiteInfo.Segment); - IO.mapRequired("Type", CallSiteInfo.Type); + IO.mapRequired("Segment", CallSiteInfo.Header.Segment); + IO.mapRequired("Reserved", CallSiteInfo.Header.Reserved); + IO.mapRequired("Type", CallSiteInfo.Header.Type); } void MappingTraits::mapping(IO &IO, FileStaticSym &FileStatic) { - IO.mapRequired("Index", FileStatic.Index); - IO.mapRequired("ModFilenameOffset", FileStatic.ModFilenameOffset); - IO.mapRequired("Flags", FileStatic.Flags); + IO.mapRequired("Index", FileStatic.Header.Index); + IO.mapRequired("ModFilenameOffset", FileStatic.Header.ModFilenameOffset); + IO.mapRequired("Flags", FileStatic.Header.Flags); IO.mapRequired("Name", FileStatic.Name); } void MappingTraits::mapping( IO &IO, HeapAllocationSiteSym &HeapAllocSite) { // TODO: Map Linkage Name - IO.mapRequired("Segment", HeapAllocSite.Segment); - IO.mapRequired("CallInstructionSize", HeapAllocSite.CallInstructionSize); - IO.mapRequired("Type", HeapAllocSite.Type); + IO.mapRequired("Segment", HeapAllocSite.Header.Segment); + IO.mapRequired("CallInstructionSize", + HeapAllocSite.Header.CallInstructionSize); + IO.mapRequired("Type", HeapAllocSite.Header.Type); } void MappingTraits::mapping(IO &IO, FrameCookieSym &FrameCookie) { // TODO: Map Linkage Name - IO.mapRequired("Register", FrameCookie.Register); - IO.mapRequired("CookieKind", FrameCookie.CookieKind); - IO.mapRequired("Flags", FrameCookie.Flags); + IO.mapRequired("Register", FrameCookie.Header.Register); + IO.mapRequired("CookieKind", FrameCookie.Header.CookieKind); + IO.mapRequired("Flags", FrameCookie.Header.Flags); } void MappingTraits::mapping(IO &IO, CallerSym &Caller) { @@ -364,43 +274,43 @@ void MappingTraits::mapping(IO &IO, CallerSym &Caller) { } void MappingTraits::mapping(IO &IO, UDTSym &UDT) { - IO.mapRequired("Type", UDT.Type); + IO.mapRequired("Type", UDT.Header.Type); IO.mapRequired("UDTName", UDT.Name); } void MappingTraits::mapping(IO &IO, BuildInfoSym &BuildInfo) { - IO.mapRequired("BuildId", BuildInfo.BuildId); + IO.mapRequired("BuildId", BuildInfo.Header.BuildId); } void MappingTraits::mapping(IO &IO, BPRelativeSym &BPRel) { - IO.mapRequired("Offset", BPRel.Offset); - IO.mapRequired("Type", BPRel.Type); + IO.mapRequired("Offset", BPRel.Header.Offset); + IO.mapRequired("Type", BPRel.Header.Type); IO.mapRequired("VarName", BPRel.Name); } void MappingTraits::mapping(IO &IO, RegRelativeSym &RegRel) { - IO.mapRequired("Offset", RegRel.Offset); - IO.mapRequired("Type", RegRel.Type); - IO.mapRequired("Register", RegRel.Register); + IO.mapRequired("Offset", RegRel.Header.Offset); + IO.mapRequired("Type", RegRel.Header.Type); + IO.mapRequired("Register", RegRel.Header.Register); IO.mapRequired("VarName", RegRel.Name); } void MappingTraits::mapping(IO &IO, ConstantSym &Constant) { - IO.mapRequired("Type", Constant.Type); + IO.mapRequired("Type", Constant.Header.Type); IO.mapRequired("Value", Constant.Value); IO.mapRequired("Name", Constant.Name); } void MappingTraits::mapping(IO &IO, DataSym &Data) { // TODO: Map linkage name - IO.mapRequired("Type", Data.Type); + IO.mapRequired("Type", Data.Header.Type); IO.mapRequired("DisplayName", Data.Name); } void MappingTraits::mapping(IO &IO, ThreadLocalDataSym &Data) { // TODO: Map linkage name - IO.mapRequired("Type", Data.Type); + IO.mapRequired("Type", Data.Header.Type); IO.mapRequired("DisplayName", Data.Name); } }