[llvm] r290000 - Resubmit "[CodeView] Hook CodeViewRecordIO for reading/writing symbols."
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 16 17:01:35 PST 2016
I'm trying to submit a fix but there seem to be some issues with llvm svn
being down right now.
On Fri, Dec 16, 2016 at 4:45 PM Galina Kistanova <gkistanova at gmail.com>
wrote:
Hello Zachary,
This commit added warning to some builders:
SymbolSerializer.cpp.obj : warning LNK4221: This object file does not
define any previously undefined public symbols, so it will not be used by
any link operation that consumes this library
http://lab.llvm.org:8011/builders/lld-x86_64-win7/builds/2384
Please have a look at this?
Thanks
Galina
On Fri, Dec 16, 2016 at 2:48 PM, Zachary Turner via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
Author: zturner
Date: Fri Dec 16 16:48:14 2016
New Revision: 290000
URL: http://llvm.org/viewvc/llvm-project?rev=290000&view=rev
Log:
Resubmit "[CodeView] Hook CodeViewRecordIO for reading/writing symbols."
The original patch was broken due to some undefined behavior
as well as warnings that were triggering -Werror.
Added:
llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecordMapping.h
llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolSerializer.h
llvm/trunk/lib/DebugInfo/CodeView/SymbolRecordMapping.cpp
llvm/trunk/lib/DebugInfo/CodeView/SymbolSerializer.cpp
Modified:
llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h
llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h
llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h
llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h
llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt
llvm/trunk/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp
llvm/trunk/lib/DebugInfo/CodeView/SymbolDumper.cpp
llvm/trunk/lib/MC/MCCodeView.cpp
llvm/trunk/test/DebugInfo/PDB/pdb-yaml-symbols.test
llvm/trunk/test/DebugInfo/PDB/pdbdump-headers.test
llvm/trunk/tools/llvm-pdbdump/YamlSymbolDumper.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h
URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h?rev=290000&r1=289999&r2=290000&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h Fri Dec 16
16:48:14 2016
@@ -535,7 +535,7 @@ enum class ThunkOrdinal : uint8_t {
BranchIsland
};
-enum class TrampolineType { TrampIncremental, BranchIsland };
+enum class TrampolineType : uint16_t { TrampIncremental, BranchIsland };
// These values correspond to the CV_SourceChksum_t enumeration.
enum class FileChecksumKind : uint8_t { None, MD5, SHA1, SHA256 };
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h
URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h?rev=290000&r1=289999&r2=290000&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h Fri Dec
16 16:48:14 2016
@@ -46,6 +46,17 @@ public:
uint32_t maxFieldLength() const;
+ template <typename T> 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 <typename T> Error mapInteger(T &Value) {
if (isWriting())
return Writer->writeInteger(Value);
@@ -75,6 +86,8 @@ public:
Error mapStringZ(StringRef &Value);
Error mapGuid(StringRef &Guid);
+ Error mapStringZVectorZ(std::vector<StringRef> &Value);
+
template <typename SizeType, typename T, typename ElementMapper>
Error mapVectorN(T &Items, const ElementMapper &Mapper) {
SizeType Size;
@@ -121,6 +134,7 @@ public:
}
Error mapByteVectorTail(ArrayRef<uint8_t> &Bytes);
+ Error mapByteVectorTail(std::vector<uint8_t> &Bytes);
Error skipPadding();
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h
URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h?rev=290000&r1=289999&r2=290000&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h
(original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h Fri Dec
16 16:48:14 2016
@@ -12,6 +12,7 @@
#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"
@@ -22,41 +23,50 @@ namespace llvm {
namespace codeview {
class SymbolVisitorDelegate;
class SymbolDeserializer : public SymbolVisitorCallbacks {
+ struct MappingInfo {
+ explicit MappingInfo(ArrayRef<uint8_t> 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<MappingInfo>(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 defaultVisitKnownRecord(CVR, Record);
\
+ return visitKnownRecordImpl(CVR, Record);
\
}
#define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName)
#include "CVSymbolTypes.def"
-protected:
- template <typename T>
- Error deserializeRecord(msf::StreamReader &Reader, SymbolKind Kind,
- T &Record) const {
- uint32_t RecordOffset = Delegate ? Delegate->getRecordOffset(Reader) :
0;
- SymbolRecordKind RK = static_cast<SymbolRecordKind>(Kind);
- auto ExpectedRecord = T::deserialize(RK, RecordOffset, Reader);
- if (!ExpectedRecord)
- return ExpectedRecord.takeError();
- Record = std::move(*ExpectedRecord);
- return Error::success();
- }
-
private:
- template <typename T>
- Error defaultVisitKnownRecord(CVSymbol &CVR, T &Record) {
- msf::ByteStream S(CVR.content());
- msf::StreamReader SR(S);
- if (auto EC = deserializeRecord(SR, CVR.Type, Record))
+ template <typename T> Error visitKnownRecordImpl(CVSymbol &CVR, T
&Record) {
+
+ Record.RecordOffset =
+ Delegate ? Delegate->getRecordOffset(Mapping->Reader) : 0;
+ if (auto EC = Mapping->Mapping.visitKnownRecord(CVR, Record))
return EC;
return Error::success();
}
SymbolVisitorDelegate *Delegate;
+ std::unique_ptr<MappingInfo> Mapping;
};
}
}
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h
URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h?rev=290000&r1=289999&r2=290000&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h Fri Dec 16
16:48:14 2016
@@ -29,10 +29,6 @@
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) {}
@@ -47,181 +43,100 @@ private:
// S_GPROC32, S_LPROC32, S_GPROC32_ID, S_LPROC32_ID, S_LPROC32_DPC or
// S_LPROC32_DPC_ID
class ProcSym : public SymbolRecord {
-public:
- 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.
- };
+ static constexpr uint32_t RelocationOffset = 32;
+public:
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) {
- }
-
- static Expected<ProcSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- StringRef Name;
- CV_DESERIALIZE(Reader, H, Name);
-
- return ProcSym(Kind, RecordOffset, H, Name);
- }
+ ProcSym(SymbolRecordKind Kind, uint32_t RecordOffset)
+ : SymbolRecord(Kind), RecordOffset(RecordOffset) {}
uint32_t getRelocationOffset() const {
- return RecordOffset + offsetof(Hdr, CodeOffset);
+ return RecordOffset + RelocationOffset;
}
- uint32_t RecordOffset;
- Hdr Header;
+ 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;
+
+ uint32_t RecordOffset = 0;
};
// S_THUNK32
class Thunk32Sym : public SymbolRecord {
public:
- 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
- };
-
explicit Thunk32Sym(SymbolRecordKind Kind) : SymbolRecord(Kind) {}
- Thunk32Sym(SymbolRecordKind Kind, uint32_t RecordOffset, const Hdr *H,
- StringRef Name, ArrayRef<uint8_t> VariantData)
- : SymbolRecord(Kind), RecordOffset(RecordOffset), Header(*H),
Name(Name),
- VariantData(VariantData) {}
-
- static Expected<Thunk32Sym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- StringRef Name;
- ArrayRef<uint8_t> VariantData;
-
- CV_DESERIALIZE(Reader, H, Name, CV_ARRAY_FIELD_TAIL(VariantData));
-
- return Thunk32Sym(Kind, RecordOffset, H, Name, VariantData);
- }
+ Thunk32Sym(SymbolRecordKind Kind, uint32_t RecordOffset)
+ : SymbolRecord(Kind), RecordOffset(RecordOffset) {}
- uint32_t RecordOffset;
- Hdr Header;
+ uint32_t Parent;
+ uint32_t End;
+ uint32_t Next;
+ uint32_t Offset;
+ uint16_t Segment;
+ uint16_t Length;
+ ThunkOrdinal Thunk;
StringRef Name;
ArrayRef<uint8_t> VariantData;
+
+ uint32_t RecordOffset;
};
// S_TRAMPOLINE
class TrampolineSym : public SymbolRecord {
public:
- struct Hdr {
- ulittle16_t Type; // TrampolineType enum
- ulittle16_t Size;
- ulittle32_t ThunkOff;
- ulittle32_t TargetOff;
- ulittle16_t ThunkSection;
- ulittle16_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<TrampolineSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
-
- CV_DESERIALIZE(Reader, H);
+ TrampolineSym(SymbolRecordKind Kind, uint32_t RecordOffset)
+ : SymbolRecord(Kind), RecordOffset(RecordOffset) {}
- return TrampolineSym(Kind, RecordOffset, H);
- }
+ TrampolineType Type;
+ uint16_t Size;
+ uint32_t ThunkOffset;
+ uint32_t TargetOffset;
+ uint16_t ThunkSection;
+ uint16_t TargetSection;
uint32_t RecordOffset;
- Hdr Header;
};
// S_SECTION
class SectionSym : public SymbolRecord {
public:
- 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.
- };
-
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<SectionSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- StringRef Name;
-
- CV_DESERIALIZE(Reader, H, Name);
+ SectionSym(SymbolRecordKind Kind, uint32_t RecordOffset)
+ : SymbolRecord(Kind), RecordOffset(RecordOffset) {}
- return SectionSym(Kind, RecordOffset, H, Name);
- }
+ uint16_t SectionNumber;
+ uint8_t Alignment;
+ uint32_t Rva;
+ uint32_t Length;
+ uint32_t Characteristics;
+ StringRef Name;
uint32_t RecordOffset;
- Hdr Header;
- StringRef Name;
};
// S_COFFGROUP
class CoffGroupSym : public SymbolRecord {
public:
- struct Hdr {
- ulittle32_t Size;
- ulittle32_t Characteristics;
- ulittle32_t Offset;
- ulittle16_t Segment;
- // Name: The null-terminated name follows.
- };
-
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<CoffGroupSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- StringRef Name;
-
- CV_DESERIALIZE(Reader, H, Name);
+ CoffGroupSym(SymbolRecordKind Kind, uint32_t RecordOffset)
+ : SymbolRecord(Kind), RecordOffset(RecordOffset) {}
- return CoffGroupSym(Kind, RecordOffset, H, Name);
- }
+ uint32_t Size;
+ uint32_t Characteristics;
+ uint32_t Offset;
+ uint16_t Segment;
+ StringRef Name;
uint32_t RecordOffset;
- Hdr Header;
- StringRef Name;
};
class ScopeEndSym : public SymbolRecord {
@@ -230,40 +145,17 @@ public:
ScopeEndSym(SymbolRecordKind Kind, uint32_t RecordOffset)
: SymbolRecord(Kind), RecordOffset(RecordOffset) {}
- static Expected<ScopeEndSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- return ScopeEndSym(Kind, RecordOffset);
- }
uint32_t RecordOffset;
};
class CallerSym : public SymbolRecord {
public:
- struct Hdr {
- ulittle32_t Count;
- };
-
explicit CallerSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {}
- CallerSym(SymbolRecordKind Kind, uint32_t RecordOffset, const Hdr
*Header,
- ArrayRef<TypeIndex> Indices)
- : SymbolRecord(Kind), RecordOffset(RecordOffset), Header(*Header),
- Indices(Indices) {}
-
- static Expected<CallerSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *Header;
- ArrayRef<TypeIndex> Indices;
-
- CV_DESERIALIZE(Reader, Header, CV_ARRAY_FIELD_N(Indices,
Header->Count));
-
- return CallerSym(Kind, RecordOffset, Header, Indices);
- }
+ CallerSym(SymbolRecordKind Kind, uint32_t RecordOffset)
+ : SymbolRecord(Kind), RecordOffset(RecordOffset) {}
+ std::vector<TypeIndex> Indices;
uint32_t RecordOffset;
- Hdr Header;
- ArrayRef<TypeIndex> Indices;
};
struct BinaryAnnotationIterator {
@@ -447,404 +339,219 @@ 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, const Hdr *H,
- ArrayRef<uint8_t> Annotations)
+ InlineSiteSym(uint32_t RecordOffset)
: SymbolRecord(SymbolRecordKind::InlineSiteSym),
- RecordOffset(RecordOffset), Header(*H), Annotations(Annotations) {}
-
- static Expected<InlineSiteSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- ArrayRef<uint8_t> Annotations;
- CV_DESERIALIZE(Reader, H, CV_ARRAY_FIELD_TAIL(Annotations));
-
- return InlineSiteSym(RecordOffset, H, Annotations);
- }
+ RecordOffset(RecordOffset) {}
llvm::iterator_range<BinaryAnnotationIterator> annotations() const {
- return llvm::make_range(BinaryAnnotationIterator(Annotations),
+ return llvm::make_range(BinaryAnnotationIterator(AnnotationData),
BinaryAnnotationIterator());
}
- uint32_t RecordOffset;
- Hdr Header;
+ uint32_t Parent;
+ uint32_t End;
+ TypeIndex Inlinee;
+ std::vector<uint8_t> AnnotationData;
-private:
- ArrayRef<uint8_t> Annotations;
+ uint32_t RecordOffset;
};
// S_PUB32
class PublicSym32 : public SymbolRecord {
public:
- 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.
- };
-
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<PublicSym32> 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);
- }
+ explicit PublicSym32(uint32_t RecordOffset)
+ : SymbolRecord(SymbolRecordKind::PublicSym32),
+ RecordOffset(RecordOffset) {}
+
+ uint32_t Index;
+ uint32_t Offset;
+ uint16_t Segment;
+ StringRef Name;
uint32_t RecordOffset;
- Hdr Header;
- StringRef Name;
};
// S_REGISTER
class RegisterSym : public SymbolRecord {
public:
- struct Hdr {
- ulittle32_t Index; // Type index or Metadata token
- ulittle16_t Register; // RegisterId enumeration
- // Name: The null-terminated name follows.
- };
-
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<RegisterSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- StringRef Name;
- CV_DESERIALIZE(Reader, H, Name);
+ RegisterSym(uint32_t RecordOffset)
+ : SymbolRecord(SymbolRecordKind::RegisterSym),
+ RecordOffset(RecordOffset) {}
- return RegisterSym(RecordOffset, H, Name);
- }
+ uint32_t Index;
+ RegisterId Register;
+ StringRef 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) {}
- ProcRefSym(uint32_t RecordOffset, const Hdr *H, StringRef Name)
- : SymbolRecord(SymbolRecordKind::ProcRefSym),
RecordOffset(RecordOffset),
- Header(*H), Name(Name) {}
-
- static Expected<ProcRefSym> 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);
+ explicit ProcRefSym(uint32_t RecordOffset)
+ : SymbolRecord(SymbolRecordKind::ProcRefSym),
RecordOffset(RecordOffset) {
}
- uint32_t RecordOffset;
- Hdr Header;
+ uint32_t SumName;
+ uint32_t SymOffset;
+ uint16_t Module;
StringRef Name;
+
+ uint32_t RecordOffset;
};
// S_LOCAL
class LocalSym : public SymbolRecord {
public:
- struct Hdr {
- TypeIndex Type;
- ulittle16_t Flags; // LocalSymFlags enum
- // Name: The null-terminated name follows.
- };
-
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<LocalSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- StringRef Name;
- CV_DESERIALIZE(Reader, H, Name);
+ explicit LocalSym(uint32_t RecordOffset)
+ : SymbolRecord(SymbolRecordKind::LocalSym),
RecordOffset(RecordOffset) {}
- return LocalSym(RecordOffset, H, Name);
- }
+ TypeIndex Type;
+ LocalSymFlags Flags;
+ StringRef Name;
uint32_t RecordOffset;
- Hdr Header;
- StringRef Name;
};
struct LocalVariableAddrRange {
- ulittle32_t OffsetStart;
- ulittle16_t ISectStart;
- ulittle16_t Range;
+ uint32_t OffsetStart;
+ uint16_t ISectStart;
+ uint16_t Range;
};
struct LocalVariableAddrGap {
- ulittle16_t GapStartOffset;
- ulittle16_t Range;
+ uint16_t GapStartOffset;
+ uint16_t Range;
};
enum : uint16_t { MaxDefRange = 0xf000 };
// S_DEFRANGE
class DefRangeSym : public SymbolRecord {
-public:
- struct Hdr {
- ulittle32_t Program;
- LocalVariableAddrRange Range;
- // LocalVariableAddrGap Gaps[];
- };
+ static constexpr uint32_t RelocationOffset = 8;
+public:
explicit DefRangeSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {}
- DefRangeSym(uint32_t RecordOffset, const Hdr *H,
- ArrayRef<LocalVariableAddrGap> Gaps)
- : SymbolRecord(SymbolRecordKind::DefRangeSym),
RecordOffset(RecordOffset),
- Header(*H), Gaps(Gaps) {}
-
- static Expected<DefRangeSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- ArrayRef<LocalVariableAddrGap> Gaps;
- CV_DESERIALIZE(Reader, H, CV_ARRAY_FIELD_TAIL(Gaps));
-
- return DefRangeSym(RecordOffset, H, Gaps);
- }
+ explicit DefRangeSym(uint32_t RecordOffset)
+ : SymbolRecord(SymbolRecordKind::DefRangeSym),
+ RecordOffset(RecordOffset) {}
uint32_t getRelocationOffset() const {
- return RecordOffset + offsetof(Hdr, Range);
+ return RecordOffset + RelocationOffset;
}
+ uint32_t Program;
+ LocalVariableAddrRange Range;
+ std::vector<LocalVariableAddrGap> Gaps;
+
uint32_t RecordOffset;
- Hdr Header;
- ArrayRef<LocalVariableAddrGap> Gaps;
};
// S_DEFRANGE_SUBFIELD
class DefRangeSubfieldSym : public SymbolRecord {
+ static constexpr uint32_t RelocationOffset = 12;
+
public:
- struct Hdr {
- ulittle32_t Program;
- ulittle16_t OffsetInParent;
- LocalVariableAddrRange Range;
- // LocalVariableAddrGap Gaps[];
- };
explicit DefRangeSubfieldSym(SymbolRecordKind Kind) : SymbolRecord(Kind)
{}
- DefRangeSubfieldSym(uint32_t RecordOffset, const Hdr *H,
- ArrayRef<LocalVariableAddrGap> Gaps)
+ DefRangeSubfieldSym(uint32_t RecordOffset)
: SymbolRecord(SymbolRecordKind::DefRangeSubfieldSym),
- RecordOffset(RecordOffset), Header(*H), Gaps(Gaps) {}
-
- static Expected<DefRangeSubfieldSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader
&Reader) {
- const Hdr *H = nullptr;
- ArrayRef<LocalVariableAddrGap> Gaps;
- CV_DESERIALIZE(Reader, H, CV_ARRAY_FIELD_TAIL(Gaps));
-
- return DefRangeSubfieldSym(RecordOffset, H, Gaps);
- }
+ RecordOffset(RecordOffset) {}
uint32_t getRelocationOffset() const {
- return RecordOffset + offsetof(Hdr, Range);
+ return RecordOffset + RelocationOffset;
}
+ uint32_t Program;
+ uint16_t OffsetInParent;
+ LocalVariableAddrRange Range;
+ std::vector<LocalVariableAddrGap> Gaps;
+
uint32_t RecordOffset;
- Hdr Header;
- ArrayRef<LocalVariableAddrGap> Gaps;
};
// S_DEFRANGE_REGISTER
class DefRangeRegisterSym : public SymbolRecord {
public:
- struct Hdr {
+ struct Header {
ulittle16_t Register;
ulittle16_t MayHaveNoName;
- LocalVariableAddrRange Range;
- // LocalVariableAddrGap Gaps[];
};
-
explicit DefRangeRegisterSym(SymbolRecordKind Kind) : SymbolRecord(Kind)
{}
- DefRangeRegisterSym(uint32_t RecordOffset, const Hdr *H,
- ArrayRef<LocalVariableAddrGap> Gaps)
+ DefRangeRegisterSym(uint32_t RecordOffset)
: SymbolRecord(SymbolRecordKind::DefRangeRegisterSym),
- RecordOffset(RecordOffset), Header(*H), Gaps(Gaps) {}
+ RecordOffset(RecordOffset) {}
- DefRangeRegisterSym(uint16_t Register, uint16_t MayHaveNoName,
- ArrayRef<LocalVariableAddrGap> Gaps)
- : SymbolRecord(SymbolRecordKind::DefRangeRegisterSym),
RecordOffset(0),
- Gaps(Gaps) {
- Header.Register = Register;
- Header.MayHaveNoName = MayHaveNoName;
- Header.Range = {};
- }
-
- static Expected<DefRangeRegisterSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader
&Reader) {
- const Hdr *H = nullptr;
- ArrayRef<LocalVariableAddrGap> Gaps;
- CV_DESERIALIZE(Reader, H, CV_ARRAY_FIELD_TAIL(Gaps));
+ uint32_t getRelocationOffset() const { return RecordOffset +
sizeof(Header); }
- return DefRangeRegisterSym(RecordOffset, H, Gaps);
- }
-
- uint32_t getRelocationOffset() const {
- return RecordOffset + offsetof(Hdr, Range);
- }
+ Header Hdr;
+ LocalVariableAddrRange Range;
+ std::vector<LocalVariableAddrGap> Gaps;
uint32_t RecordOffset;
- Hdr Header;
- ArrayRef<LocalVariableAddrGap> Gaps;
};
// S_DEFRANGE_SUBFIELD_REGISTER
class DefRangeSubfieldRegisterSym : public SymbolRecord {
public:
- struct Hdr {
- ulittle16_t Register; // Register to which the variable is relative
+ struct Header {
+ ulittle16_t Register;
ulittle16_t MayHaveNoName;
ulittle32_t OffsetInParent;
- LocalVariableAddrRange Range;
- // LocalVariableAddrGap Gaps[];
};
-
explicit DefRangeSubfieldRegisterSym(SymbolRecordKind Kind)
: SymbolRecord(Kind) {}
- DefRangeSubfieldRegisterSym(uint32_t RecordOffset, const Hdr *H,
- ArrayRef<LocalVariableAddrGap> Gaps)
+ DefRangeSubfieldRegisterSym(uint32_t RecordOffset)
: SymbolRecord(SymbolRecordKind::DefRangeSubfieldRegisterSym),
- RecordOffset(RecordOffset), Header(*H), Gaps(Gaps) {}
+ RecordOffset(RecordOffset) {}
- DefRangeSubfieldRegisterSym(uint16_t Register, uint16_t MayHaveNoName,
- uint32_t OffsetInParent,
- ArrayRef<LocalVariableAddrGap> Gaps)
- : SymbolRecord(SymbolRecordKind::DefRangeSubfieldRegisterSym),
- RecordOffset(0), Gaps(Gaps) {
- Header.Register = Register;
- Header.MayHaveNoName = MayHaveNoName;
- Header.OffsetInParent = OffsetInParent;
- Header.Range = {};
- }
-
- static Expected<DefRangeSubfieldRegisterSym>
- deserialize(SymbolRecordKind Kind, uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- ArrayRef<LocalVariableAddrGap> Gaps;
- CV_DESERIALIZE(Reader, H, CV_ARRAY_FIELD_TAIL(Gaps));
-
- return DefRangeSubfieldRegisterSym(RecordOffset, H, Gaps);
- }
+ uint32_t getRelocationOffset() const { return RecordOffset +
sizeof(Header); }
- uint32_t getRelocationOffset() const {
- return RecordOffset + offsetof(Hdr, Range);
- }
+ Header Hdr;
+ LocalVariableAddrRange Range;
+ std::vector<LocalVariableAddrGap> Gaps;
uint32_t RecordOffset;
- Hdr Header;
- ArrayRef<LocalVariableAddrGap> 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[];
- };
+ static constexpr uint32_t RelocationOffset = 8;
+public:
explicit DefRangeFramePointerRelSym(SymbolRecordKind Kind)
: SymbolRecord(Kind) {}
- DefRangeFramePointerRelSym(uint32_t RecordOffset, const Hdr *H,
- ArrayRef<LocalVariableAddrGap> Gaps)
+ DefRangeFramePointerRelSym(uint32_t RecordOffset)
: SymbolRecord(SymbolRecordKind::DefRangeFramePointerRelSym),
- RecordOffset(RecordOffset), Header(*H), Gaps(Gaps) {}
-
- static Expected<DefRangeFramePointerRelSym>
- deserialize(SymbolRecordKind Kind, uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- ArrayRef<LocalVariableAddrGap> Gaps;
- CV_DESERIALIZE(Reader, H, CV_ARRAY_FIELD_TAIL(Gaps));
-
- return DefRangeFramePointerRelSym(RecordOffset, H, Gaps);
- }
+ RecordOffset(RecordOffset) {}
uint32_t getRelocationOffset() const {
- return RecordOffset + offsetof(Hdr, Range);
+ return RecordOffset + RelocationOffset;
}
+ int32_t Offset;
+ LocalVariableAddrRange Range;
+ std::vector<LocalVariableAddrGap> Gaps;
+
uint32_t RecordOffset;
- Hdr Header;
- ArrayRef<LocalVariableAddrGap> Gaps;
};
// S_DEFRANGE_REGISTER_REL
class DefRangeRegisterRelSym : public SymbolRecord {
public:
- struct Hdr {
- ulittle16_t BaseRegister;
+ struct Header {
+ ulittle16_t Register;
ulittle16_t Flags;
little32_t BasePointerOffset;
- LocalVariableAddrRange Range;
- // LocalVariableAddrGap Gaps[];
};
-
explicit DefRangeRegisterRelSym(SymbolRecordKind Kind) :
SymbolRecord(Kind) {}
- DefRangeRegisterRelSym(uint32_t RecordOffset, const Hdr *H,
- ArrayRef<LocalVariableAddrGap> Gaps)
+ explicit DefRangeRegisterRelSym(uint32_t RecordOffset)
: SymbolRecord(SymbolRecordKind::DefRangeRegisterRelSym),
- RecordOffset(RecordOffset), Header(*H), Gaps(Gaps) {}
-
- DefRangeRegisterRelSym(uint16_t BaseRegister, uint16_t Flags,
- int32_t BasePointerOffset,
- ArrayRef<LocalVariableAddrGap> Gaps)
- : SymbolRecord(SymbolRecordKind::DefRangeRegisterRelSym),
RecordOffset(0),
- Gaps(Gaps) {
- Header.BaseRegister = BaseRegister;
- Header.Flags = Flags;
- Header.BasePointerOffset = BasePointerOffset;
- Header.Range = {};
- }
-
- static Expected<DefRangeRegisterRelSym>
- deserialize(SymbolRecordKind Kind, uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- ArrayRef<LocalVariableAddrGap> Gaps;
- CV_DESERIALIZE(Reader, H, CV_ARRAY_FIELD_TAIL(Gaps));
-
- return DefRangeRegisterRelSym(RecordOffset, H, Gaps);
- }
+ RecordOffset(RecordOffset) {}
// The flags implement this notional bitfield:
// uint16_t IsSubfield : 1;
@@ -855,642 +562,379 @@ public:
OffsetInParentShift = 4,
};
- bool hasSpilledUDTMember() const { return Header.Flags & IsSubfieldFlag;
}
- uint16_t offsetInParent() const { return Header.Flags >>
OffsetInParentShift; }
+ bool hasSpilledUDTMember() const { return Hdr.Flags & IsSubfieldFlag; }
+ uint16_t offsetInParent() const { return Hdr.Flags >>
OffsetInParentShift; }
- uint32_t getRelocationOffset() const {
- return RecordOffset + offsetof(Hdr, Range);
- }
+ uint32_t getRelocationOffset() const { return RecordOffset +
sizeof(Header); }
+
+ Header Hdr;
+ LocalVariableAddrRange Range;
+ std::vector<LocalVariableAddrGap> Gaps;
uint32_t RecordOffset;
- Hdr Header;
- ArrayRef<LocalVariableAddrGap> 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) {}
- DefRangeFramePointerRelFullScopeSym(uint32_t RecordOffset, const Hdr *H)
+ explicit DefRangeFramePointerRelFullScopeSym(uint32_t RecordOffset)
:
SymbolRecord(SymbolRecordKind::DefRangeFramePointerRelFullScopeSym),
- RecordOffset(RecordOffset), Header(*H) {}
+ RecordOffset(RecordOffset) {}
- static Expected<DefRangeFramePointerRelFullScopeSym>
- deserialize(SymbolRecordKind Kind, uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- CV_DESERIALIZE(Reader, H);
-
- return DefRangeFramePointerRelFullScopeSym(RecordOffset, H);
- }
+ int32_t Offset;
uint32_t RecordOffset;
- Hdr Header;
};
// S_BLOCK32
class BlockSym : public SymbolRecord {
-public:
- struct Hdr {
- ulittle32_t PtrParent;
- ulittle32_t PtrEnd;
- ulittle32_t CodeSize;
- ulittle32_t CodeOffset;
- ulittle16_t Segment;
- // Name: The null-terminated name follows.
- };
+ static constexpr uint32_t RelocationOffset = 16;
+public:
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<BlockSym> 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);
- }
+ explicit BlockSym(uint32_t RecordOffset)
+ : SymbolRecord(SymbolRecordKind::BlockSym),
RecordOffset(RecordOffset) {}
uint32_t getRelocationOffset() const {
- return RecordOffset + offsetof(Hdr, CodeOffset);
+ return RecordOffset + RelocationOffset;
}
- uint32_t RecordOffset;
- Hdr Header;
+ uint32_t Parent;
+ uint32_t End;
+ uint32_t CodeSize;
+ uint32_t CodeOffset;
+ uint16_t Segment;
StringRef Name;
+
+ uint32_t RecordOffset;
};
// S_LABEL32
class LabelSym : public SymbolRecord {
-public:
- struct Hdr {
- ulittle32_t CodeOffset;
- ulittle16_t Segment;
- uint8_t Flags; // CV_PROCFLAGS
- // Name: The null-terminated name follows.
- };
+ static constexpr uint32_t RelocationOffset = 4;
+public:
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<LabelSym> 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);
- }
+ explicit LabelSym(uint32_t RecordOffset)
+ : SymbolRecord(SymbolRecordKind::LabelSym),
RecordOffset(RecordOffset) {}
uint32_t getRelocationOffset() const {
- return RecordOffset + offsetof(Hdr, CodeOffset);
+ return RecordOffset + RelocationOffset;
}
- uint32_t RecordOffset;
- Hdr Header;
+ uint32_t CodeOffset;
+ uint16_t Segment;
+ ProcSymFlags Flags;
StringRef Name;
+
+ uint32_t RecordOffset;
};
// 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, const Hdr *H, StringRef Name)
- : SymbolRecord(SymbolRecordKind::ObjNameSym),
RecordOffset(RecordOffset),
- Header(*H), Name(Name) {}
-
- static Expected<ObjNameSym> 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);
+ ObjNameSym(uint32_t RecordOffset)
+ : SymbolRecord(SymbolRecordKind::ObjNameSym),
RecordOffset(RecordOffset) {
}
- uint32_t RecordOffset;
- Hdr Header;
+ uint32_t Signature;
StringRef Name;
+
+ uint32_t RecordOffset;
};
// S_ENVBLOCK
class EnvBlockSym : public SymbolRecord {
public:
- struct Hdr {
- uint8_t Reserved;
- // Sequence of zero terminated strings.
- };
-
explicit EnvBlockSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {}
- EnvBlockSym(uint32_t RecordOffset, const Hdr *H,
- const std::vector<StringRef> &Fields)
- : SymbolRecord(SymbolRecordKind::EnvBlockSym),
RecordOffset(RecordOffset),
- Header(*H), Fields(Fields) {}
-
- static Expected<EnvBlockSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- std::vector<StringRef> Fields;
- CV_DESERIALIZE(Reader, H, CV_STRING_ARRAY_NULL_TERM(Fields));
+ EnvBlockSym(uint32_t RecordOffset)
+ : SymbolRecord(SymbolRecordKind::EnvBlockSym),
+ RecordOffset(RecordOffset) {}
- return EnvBlockSym(RecordOffset, H, Fields);
- }
+ std::vector<StringRef> Fields;
uint32_t RecordOffset;
- Hdr Header;
- std::vector<StringRef> Fields;
};
// S_EXPORT
class ExportSym : public SymbolRecord {
public:
- struct Hdr {
- ulittle16_t Ordinal;
- ulittle16_t Flags; // ExportFlags
- // Name: The null-terminated name follows.
- };
-
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<ExportSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- StringRef Name;
- CV_DESERIALIZE(Reader, H, Name);
+ ExportSym(uint32_t RecordOffset)
+ : SymbolRecord(SymbolRecordKind::ExportSym),
RecordOffset(RecordOffset) {}
- return ExportSym(RecordOffset, H, Name);
- }
+ uint16_t Ordinal;
+ ExportFlags Flags;
+ StringRef Name;
uint32_t RecordOffset;
- Hdr Header;
- StringRef Name;
};
// S_FILESTATIC
class FileStaticSym : public SymbolRecord {
public:
- 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.
- };
-
explicit FileStaticSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {}
- FileStaticSym(uint32_t RecordOffset, const Hdr *H, StringRef Name)
+ FileStaticSym(uint32_t RecordOffset)
: SymbolRecord(SymbolRecordKind::FileStaticSym),
- RecordOffset(RecordOffset), Header(*H), Name(Name) {}
-
- static Expected<FileStaticSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- StringRef Name;
- CV_DESERIALIZE(Reader, H, Name);
+ RecordOffset(RecordOffset) {}
- return FileStaticSym(RecordOffset, H, Name);
- }
+ uint32_t Index;
+ uint32_t ModFilenameOffset;
+ LocalSymFlags Flags;
+ StringRef 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, const Hdr *H, StringRef Version)
- : SymbolRecord(SymbolRecordKind::Compile2Sym),
RecordOffset(RecordOffset),
- Header(*H), Version(Version) {}
-
- static Expected<Compile2Sym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- StringRef Version;
- CV_DESERIALIZE(Reader, H, Version);
+ Compile2Sym(uint32_t RecordOffset)
+ : SymbolRecord(SymbolRecordKind::Compile2Sym),
+ RecordOffset(RecordOffset) {}
+
+ 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<StringRef> ExtraStrings;
- return Compile2Sym(RecordOffset, H, Version);
- }
+ uint8_t getLanguage() const { return static_cast<uint32_t>(Flags) &
0xFF; }
+ uint32_t getFlags() const { return static_cast<uint32_t>(Flags) & ~0xFF;
}
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, const Hdr *H, StringRef Version)
- : SymbolRecord(SymbolRecordKind::Compile3Sym),
RecordOffset(RecordOffset),
- Header(*H), Version(Version) {}
-
- static Expected<Compile3Sym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- StringRef Version;
- CV_DESERIALIZE(Reader, H, Version);
+ Compile3Sym(uint32_t RecordOffset)
+ : SymbolRecord(SymbolRecordKind::Compile3Sym),
+ RecordOffset(RecordOffset) {}
+
+ 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;
- return Compile3Sym(RecordOffset, H, Version);
- }
+ uint8_t getLanguage() const { return static_cast<uint32_t>(Flags) &
0xFF; }
+ uint32_t getFlags() const { return static_cast<uint32_t>(Flags) & ~0xFF;
}
uint32_t RecordOffset;
- Hdr Header;
- StringRef Version;
};
// S_FRAMEPROC
class FrameProcSym : public SymbolRecord {
public:
- struct Hdr {
- ulittle32_t TotalFrameBytes;
- ulittle32_t PaddingFrameBytes;
- ulittle32_t OffsetToPadding;
- ulittle32_t BytesOfCalleeSavedRegisters;
- ulittle32_t OffsetOfExceptionHandler;
- ulittle16_t SectionIdOfExceptionHandler;
- ulittle32_t Flags;
- };
-
explicit FrameProcSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {}
- FrameProcSym(uint32_t RecordOffset, const Hdr *H)
+ explicit FrameProcSym(uint32_t RecordOffset)
: SymbolRecord(SymbolRecordKind::FrameProcSym),
- RecordOffset(RecordOffset), Header(*H) {}
-
- static Expected<FrameProcSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- CV_DESERIALIZE(Reader, H);
+ RecordOffset(RecordOffset) {}
- return FrameProcSym(RecordOffset, H);
- }
+ uint32_t TotalFrameBytes;
+ uint32_t PaddingFrameBytes;
+ uint32_t OffsetToPadding;
+ uint32_t BytesOfCalleeSavedRegisters;
+ uint32_t OffsetOfExceptionHandler;
+ uint16_t SectionIdOfExceptionHandler;
+ FrameProcedureOptions Flags;
uint32_t RecordOffset;
- Hdr Header;
};
// S_CALLSITEINFO
class CallSiteInfoSym : public SymbolRecord {
-public:
- struct Hdr {
- ulittle32_t CodeOffset;
- ulittle16_t Segment;
- ulittle16_t Reserved;
- TypeIndex Type;
- };
+ static constexpr uint32_t RelocationOffset = 4;
+public:
explicit CallSiteInfoSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {}
- CallSiteInfoSym(uint32_t RecordOffset, const Hdr *H)
- : SymbolRecord(SymbolRecordKind::CallSiteInfoSym),
- RecordOffset(RecordOffset), Header(*H) {}
-
- static Expected<CallSiteInfoSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- CV_DESERIALIZE(Reader, H);
-
- return CallSiteInfoSym(RecordOffset, H);
- }
+ explicit CallSiteInfoSym(uint32_t RecordOffset)
+ : SymbolRecord(SymbolRecordKind::CallSiteInfoSym) {}
uint32_t getRelocationOffset() const {
- return RecordOffset + offsetof(Hdr, CodeOffset);
+ return RecordOffset + RelocationOffset;
}
+ uint32_t CodeOffset;
+ uint16_t Segment;
+ TypeIndex Type;
+
uint32_t RecordOffset;
- Hdr Header;
};
// S_HEAPALLOCSITE
class HeapAllocationSiteSym : public SymbolRecord {
-public:
- struct Hdr {
- ulittle32_t CodeOffset;
- ulittle16_t Segment;
- ulittle16_t CallInstructionSize;
- TypeIndex Type;
- };
+ static constexpr uint32_t RelocationOffset = 4;
+public:
explicit HeapAllocationSiteSym(SymbolRecordKind Kind) :
SymbolRecord(Kind) {}
- HeapAllocationSiteSym(uint32_t RecordOffset, const Hdr *H)
+ explicit HeapAllocationSiteSym(uint32_t RecordOffset)
: SymbolRecord(SymbolRecordKind::HeapAllocationSiteSym),
- RecordOffset(RecordOffset), Header(*H) {}
-
- static Expected<HeapAllocationSiteSym>
- deserialize(SymbolRecordKind Kind, uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- CV_DESERIALIZE(Reader, H);
-
- return HeapAllocationSiteSym(RecordOffset, H);
- }
+ RecordOffset(RecordOffset) {}
uint32_t getRelocationOffset() const {
- return RecordOffset + offsetof(Hdr, CodeOffset);
+ return RecordOffset + RelocationOffset;
}
+ uint32_t CodeOffset;
+ uint16_t Segment;
+ uint16_t CallInstructionSize;
+ TypeIndex Type;
+
uint32_t RecordOffset;
- Hdr Header;
};
// S_FRAMECOOKIE
class FrameCookieSym : public SymbolRecord {
-public:
- struct Hdr {
- ulittle32_t CodeOffset;
- ulittle16_t Register;
- uint8_t CookieKind;
- uint8_t Flags;
- };
+ static constexpr uint32_t RelocationOffset = 4;
+public:
explicit FrameCookieSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {}
- FrameCookieSym(uint32_t RecordOffset, const Hdr *H)
- : SymbolRecord(SymbolRecordKind::FrameCookieSym),
- RecordOffset(RecordOffset), Header(*H) {}
-
- static Expected<FrameCookieSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- CV_DESERIALIZE(Reader, H);
-
- return FrameCookieSym(RecordOffset, H);
- }
+ explicit FrameCookieSym(uint32_t RecordOffset)
+ : SymbolRecord(SymbolRecordKind::FrameCookieSym) {}
uint32_t getRelocationOffset() const {
- return RecordOffset + offsetof(Hdr, CodeOffset);
+ return RecordOffset + RelocationOffset;
}
+ uint32_t CodeOffset;
+ uint16_t Register;
+ uint8_t CookieKind;
+ uint8_t Flags;
+
uint32_t RecordOffset;
- Hdr Header;
};
// S_UDT, S_COBOLUDT
class UDTSym : public SymbolRecord {
public:
- struct Hdr {
- TypeIndex Type; // Type of the UDT
- // Name: The null-terminated name follows.
- };
-
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<UDTSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- StringRef Name;
- CV_DESERIALIZE(Reader, H, Name);
+ explicit UDTSym(uint32_t RecordOffset)
+ : SymbolRecord(SymbolRecordKind::UDTSym) {}
- return UDTSym(RecordOffset, H, Name);
- }
+ TypeIndex Type;
+ StringRef Name;
uint32_t RecordOffset;
- Hdr Header;
- StringRef Name;
};
// S_BUILDINFO
class BuildInfoSym : public SymbolRecord {
public:
- struct Hdr {
- ulittle32_t BuildId;
- };
-
explicit BuildInfoSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {}
- BuildInfoSym(uint32_t RecordOffset, const Hdr *H)
+ BuildInfoSym(uint32_t RecordOffset)
: SymbolRecord(SymbolRecordKind::BuildInfoSym),
- RecordOffset(RecordOffset), Header(*H) {}
+ RecordOffset(RecordOffset) {}
- static Expected<BuildInfoSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- CV_DESERIALIZE(Reader, H);
-
- return BuildInfoSym(RecordOffset, H);
- }
+ uint32_t BuildId;
uint32_t RecordOffset;
- Hdr Header;
};
// S_BPREL32
class BPRelativeSym : public SymbolRecord {
public:
- struct Hdr {
- little32_t Offset; // Offset from the base pointer register
- TypeIndex Type; // Type of the variable
- // Name: The null-terminated name follows.
- };
-
explicit BPRelativeSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {}
- BPRelativeSym(uint32_t RecordOffset, const Hdr *H, StringRef Name)
+ explicit BPRelativeSym(uint32_t RecordOffset)
: SymbolRecord(SymbolRecordKind::BPRelativeSym),
- RecordOffset(RecordOffset), Header(*H), Name(Name) {}
-
- static Expected<BPRelativeSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- StringRef Name;
- CV_DESERIALIZE(Reader, H, Name);
+ RecordOffset(RecordOffset) {}
- return BPRelativeSym(RecordOffset, H, Name);
- }
+ int32_t Offset;
+ TypeIndex Type;
+ StringRef Name;
uint32_t RecordOffset;
- Hdr Header;
- StringRef Name;
};
// S_REGREL32
class RegRelativeSym : public SymbolRecord {
public:
- 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.
- };
-
explicit RegRelativeSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {}
- RegRelativeSym(uint32_t RecordOffset, const Hdr *H, StringRef Name)
+ explicit RegRelativeSym(uint32_t RecordOffset)
: SymbolRecord(SymbolRecordKind::RegRelativeSym),
- RecordOffset(RecordOffset), Header(*H), Name(Name) {}
-
- static Expected<RegRelativeSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- StringRef Name;
- CV_DESERIALIZE(Reader, H, Name);
+ RecordOffset(RecordOffset) {}
- return RegRelativeSym(RecordOffset, H, Name);
- }
+ uint32_t Offset;
+ TypeIndex Type;
+ uint16_t Register;
+ StringRef Name;
uint32_t RecordOffset;
- Hdr Header;
- StringRef Name;
};
// S_CONSTANT, S_MANCONSTANT
class ConstantSym : public SymbolRecord {
public:
- struct Hdr {
- TypeIndex Type;
- // Value: The value of the constant.
- // Name: The null-terminated name follows.
- };
-
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<ConstantSym> deserialize(SymbolRecordKind Kind,
- uint32_t RecordOffset,
- msf::StreamReader &Reader) {
- const Hdr *H = nullptr;
- APSInt Value;
- StringRef Name;
- CV_DESERIALIZE(Reader, H, Value, Name);
+ ConstantSym(uint32_t RecordOffset)
+ : SymbolRecord(SymbolRecordKind::ConstantSym),
+ RecordOffset(RecordOffset) {}
- return ConstantSym(RecordOffset, H, Value, Name);
- }
-
- uint32_t RecordOffset;
- Hdr Header;
+ TypeIndex Type;
APSInt Value;
StringRef Name;
+
+ uint32_t RecordOffset;
};
// S_LDATA32, S_GDATA32, S_LMANDATA, S_GMANDATA
class DataSym : public SymbolRecord {
-public:
- struct Hdr {
- TypeIndex Type;
- ulittle32_t DataOffset;
- ulittle16_t Segment;
- // Name: The null-terminated name follows.
- };
+ static constexpr uint32_t RelocationOffset = 8;
+public:
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<DataSym> 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);
- }
+ DataSym(uint32_t RecordOffset)
+ : SymbolRecord(SymbolRecordKind::DataSym),
RecordOffset(RecordOffset) {}
uint32_t getRelocationOffset() const {
- return RecordOffset + offsetof(Hdr, DataOffset);
+ return RecordOffset + RelocationOffset;
}
- uint32_t RecordOffset;
- Hdr Header;
+ TypeIndex Type;
+ uint32_t DataOffset;
+ uint16_t Segment;
StringRef Name;
+
+ uint32_t RecordOffset;
};
// S_LTHREAD32, S_GTHREAD32
class ThreadLocalDataSym : public SymbolRecord {
-public:
- struct Hdr {
- TypeIndex Type;
- ulittle32_t DataOffset;
- ulittle16_t Segment;
- // Name: The null-terminated name follows.
- };
+ static constexpr uint32_t RelocationOffset = 8;
+public:
explicit ThreadLocalDataSym(SymbolRecordKind Kind) : SymbolRecord(Kind)
{}
- ThreadLocalDataSym(uint32_t RecordOffset, const Hdr *H, StringRef Name)
+ explicit ThreadLocalDataSym(uint32_t Record
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161217/a29b62d1/attachment.html>
More information about the llvm-commits
mailing list