Index: llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h =================================================================== --- llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h +++ llvm/include/llvm/DebugInfo/CodeView/CodeViewRecordIO.h @@ -32,6 +32,7 @@ virtual void EmitBytes(StringRef Data) = 0; virtual void EmitIntValue(uint64_t Value, unsigned Size) = 0; virtual void EmitBinaryData(StringRef Data) = 0; + virtual void AddComment(const Twine &T) = 0; virtual ~CodeViewRecordStreamer() = default; }; @@ -59,7 +60,7 @@ Error beginRecord(Optional MaxLength); Error endRecord(); - Error mapInteger(TypeIndex &TypeInd); + Error mapInteger(TypeIndex &TypeInd, const char* Comment = nullptr); bool isStreaming() const { return (Streamer != nullptr) && (Reader == nullptr) && (Writer == nullptr); @@ -92,8 +93,9 @@ return Error::success(); } - template Error mapInteger(T &Value) { + template Error mapInteger(T &Value, const char* Comment = nullptr) { if (isStreaming()) { + emitComment(Comment); Streamer->EmitIntValue((int)Value, sizeof(T)); incrStreamedLen(sizeof(T)); return Error::success(); @@ -105,7 +107,7 @@ return Reader->readInteger(Value); } - template Error mapEnum(T &Value) { + template Error mapEnum(T &Value, const char* Comment = nullptr) { if (!isStreaming() && sizeof(Value) > maxFieldLength()) return make_error(cv_error_code::insufficient_buffer); @@ -115,7 +117,7 @@ if (isWriting() || isStreaming()) X = static_cast(Value); - if (auto EC = mapInteger(X)) + if (auto EC = mapInteger(X, Comment)) return EC; if (isReading()) @@ -124,19 +126,20 @@ return Error::success(); } - Error mapEncodedInteger(int64_t &Value); - Error mapEncodedInteger(uint64_t &Value); - Error mapEncodedInteger(APSInt &Value); - Error mapStringZ(StringRef &Value); - Error mapGuid(GUID &Guid); + Error mapEncodedInteger(int64_t &Value, const char* Comment = nullptr); + Error mapEncodedInteger(uint64_t &Value, const char* Comment = nullptr); + Error mapEncodedInteger(APSInt &Value, const char* Comment = nullptr); + Error mapStringZ(StringRef &Value, const char* Comment = nullptr); + Error mapGuid(GUID &Guid, const char* Comment = nullptr); - Error mapStringZVectorZ(std::vector &Value); + Error mapStringZVectorZ(std::vector &Value, const char* Comment = nullptr); template - Error mapVectorN(T &Items, const ElementMapper &Mapper) { + Error mapVectorN(T &Items, const ElementMapper &Mapper, const char* Comment = nullptr) { SizeType Size; if (isStreaming()) { Size = static_cast(Items.size()); + emitComment(Comment); Streamer->EmitIntValue(Size, sizeof(Size)); incrStreamedLen(sizeof(Size)); // add 1 for the delimiter @@ -168,7 +171,8 @@ } template - Error mapVectorTail(T &Items, const ElementMapper &Mapper) { + Error mapVectorTail(T &Items, const ElementMapper &Mapper, const char* Comment = nullptr) { + emitComment(Comment); if (isStreaming() || isWriting()) { for (auto &Item : Items) { if (auto EC = Mapper(*this, Item)) @@ -186,8 +190,8 @@ return Error::success(); } - Error mapByteVectorTail(ArrayRef &Bytes); - Error mapByteVectorTail(std::vector &Bytes); + Error mapByteVectorTail(ArrayRef &Bytes, const char* Comment = nullptr); + Error mapByteVectorTail(std::vector &Bytes, const char* Comment = nullptr); Error padToAlignment(uint32_t Align); Error skipPadding(); @@ -199,8 +203,8 @@ } private: - void emitEncodedSignedInteger(const int64_t &Value); - void emitEncodedUnsignedInteger(const uint64_t &Value); + void emitEncodedSignedInteger(const int64_t &Value, const char* Comment = nullptr); + void emitEncodedUnsignedInteger(const uint64_t &Value, const char* Comment = nullptr); Error writeEncodedSignedInteger(const int64_t &Value); Error writeEncodedUnsignedInteger(const uint64_t &Value); @@ -214,6 +218,13 @@ StreamedLen = 4; // The record prefix is 4 bytes long } + void emitComment(const char* Comment) { + if (isStreaming() && (Comment != nullptr)) { + Twine TComment(Comment); + Streamer->AddComment(TComment); + } + } + struct RecordLimit { uint32_t BeginOffset; Optional MaxLength; Index: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp =================================================================== --- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -108,6 +108,10 @@ void EmitBinaryData(StringRef Data) { OS->EmitBinaryData(Data); } + void AddComment(const Twine &T) { + OS->AddComment(T); + } + private: MCStreamer *OS = nullptr; }; Index: llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp =================================================================== --- llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp +++ llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp @@ -97,8 +97,9 @@ return Reader->skip(BytesToAdvance); } -Error CodeViewRecordIO::mapByteVectorTail(ArrayRef &Bytes) { +Error CodeViewRecordIO::mapByteVectorTail(ArrayRef &Bytes, const char* Comment) { if (isStreaming()) { + emitComment(Comment); Streamer->EmitBinaryData(toStringRef(Bytes)); incrStreamedLen(Bytes.size()); } else if (isWriting()) { @@ -111,9 +112,9 @@ return Error::success(); } -Error CodeViewRecordIO::mapByteVectorTail(std::vector &Bytes) { +Error CodeViewRecordIO::mapByteVectorTail(std::vector &Bytes, const char* Comment) { ArrayRef BytesRef(Bytes); - if (auto EC = mapByteVectorTail(BytesRef)) + if (auto EC = mapByteVectorTail(BytesRef, Comment)) return EC; if (!isWriting()) Bytes.assign(BytesRef.begin(), BytesRef.end()); @@ -121,8 +122,9 @@ return Error::success(); } -Error CodeViewRecordIO::mapInteger(TypeIndex &TypeInd) { +Error CodeViewRecordIO::mapInteger(TypeIndex &TypeInd, const char* Comment) { if (isStreaming()) { + emitComment(Comment); Streamer->EmitIntValue(TypeInd.getIndex(), sizeof(TypeInd.getIndex())); incrStreamedLen(sizeof(TypeInd.getIndex())); } else if (isWriting()) { @@ -137,12 +139,12 @@ return Error::success(); } -Error CodeViewRecordIO::mapEncodedInteger(int64_t &Value) { +Error CodeViewRecordIO::mapEncodedInteger(int64_t &Value, const char* Comment) { if (isStreaming()) { if (Value >= 0) - emitEncodedUnsignedInteger(static_cast(Value)); + emitEncodedUnsignedInteger(static_cast(Value), Comment); else - emitEncodedSignedInteger(Value); + emitEncodedSignedInteger(Value, Comment); } else if (isWriting()) { if (Value >= 0) { if (auto EC = writeEncodedUnsignedInteger(static_cast(Value))) @@ -161,9 +163,9 @@ return Error::success(); } -Error CodeViewRecordIO::mapEncodedInteger(uint64_t &Value) { +Error CodeViewRecordIO::mapEncodedInteger(uint64_t &Value, const char* Comment) { if (isStreaming()) - emitEncodedUnsignedInteger(Value); + emitEncodedUnsignedInteger(Value, Comment); else if (isWriting()) { if (auto EC = writeEncodedUnsignedInteger(Value)) return EC; @@ -176,12 +178,12 @@ return Error::success(); } -Error CodeViewRecordIO::mapEncodedInteger(APSInt &Value) { +Error CodeViewRecordIO::mapEncodedInteger(APSInt &Value, const char* Comment) { if (isStreaming()) { if (Value.isSigned()) - emitEncodedSignedInteger(Value.getSExtValue()); + emitEncodedSignedInteger(Value.getSExtValue(), Comment); else - emitEncodedUnsignedInteger(Value.getZExtValue()); + emitEncodedUnsignedInteger(Value.getZExtValue(), Comment); } else if (isWriting()) { if (Value.isSigned()) return writeEncodedSignedInteger(Value.getSExtValue()); @@ -191,9 +193,10 @@ return Error::success(); } -Error CodeViewRecordIO::mapStringZ(StringRef &Value) { +Error CodeViewRecordIO::mapStringZ(StringRef &Value, const char* Comment) { if (isStreaming()) { auto NullTerminatedString = StringRef(Value.data(), Value.size() + 1); + emitComment(Comment); Streamer->EmitBytes(NullTerminatedString); incrStreamedLen(NullTerminatedString.size()); } else if (isWriting()) { @@ -208,12 +211,13 @@ return Error::success(); } -Error CodeViewRecordIO::mapGuid(GUID &Guid) { +Error CodeViewRecordIO::mapGuid(GUID &Guid, const char* Comment) { constexpr uint32_t GuidSize = 16; if (isStreaming()) { StringRef GuidSR = StringRef((reinterpret_cast(&Guid)), GuidSize); + emitComment(Comment); Streamer->EmitBytes(GuidSR); incrStreamedLen(GuidSize); return Error::success(); @@ -234,9 +238,10 @@ return Error::success(); } -Error CodeViewRecordIO::mapStringZVectorZ(std::vector &Value) { +Error CodeViewRecordIO::mapStringZVectorZ(std::vector &Value, const char* Comment) { if (!isReading()) { + emitComment(Comment); for (auto V : Value) { if (auto EC = mapStringZ(V)) return EC; @@ -257,41 +262,49 @@ return Error::success(); } -void CodeViewRecordIO::emitEncodedSignedInteger(const int64_t &Value) { +void CodeViewRecordIO::emitEncodedSignedInteger(const int64_t &Value, const char* Comment) { assert(Value < 0 && "Encoded integer is not signed!"); if (Value >= std::numeric_limits::min()) { Streamer->EmitIntValue(LF_CHAR, 2); + emitComment(Comment); Streamer->EmitIntValue(Value, 1); incrStreamedLen(3); } else if (Value >= std::numeric_limits::min()) { Streamer->EmitIntValue(LF_SHORT, 2); + emitComment(Comment); Streamer->EmitIntValue(Value, 2); incrStreamedLen(4); } else if (Value >= std::numeric_limits::min()) { Streamer->EmitIntValue(LF_LONG, 2); + emitComment(Comment); Streamer->EmitIntValue(Value, 4); incrStreamedLen(6); } else { Streamer->EmitIntValue(LF_QUADWORD, 2); + emitComment(Comment); Streamer->EmitIntValue(Value, 4); incrStreamedLen(6); } } -void CodeViewRecordIO::emitEncodedUnsignedInteger(const uint64_t &Value) { +void CodeViewRecordIO::emitEncodedUnsignedInteger(const uint64_t &Value, const char* Comment) { if (Value < LF_NUMERIC) { + emitComment(Comment); Streamer->EmitIntValue(Value, 2); incrStreamedLen(2); } else if (Value <= std::numeric_limits::max()) { Streamer->EmitIntValue(LF_USHORT, 2); + emitComment(Comment); Streamer->EmitIntValue(Value, 2); incrStreamedLen(4); } else if (Value <= std::numeric_limits::max()) { Streamer->EmitIntValue(LF_ULONG, 2); + emitComment(Comment); Streamer->EmitIntValue(Value, 4); incrStreamedLen(6); } else { Streamer->EmitIntValue(LF_UQUADWORD, 2); + emitComment(Comment); Streamer->EmitIntValue(Value, 8); incrStreamedLen(6); } Index: llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp =================================================================== --- llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp +++ llvm/lib/DebugInfo/CodeView/TypeRecordMapping.cpp @@ -21,19 +21,19 @@ : IsFromOverloadList(IsFromOverloadList) {} Error operator()(CodeViewRecordIO &IO, OneMethodRecord &Method) const { - error(IO.mapInteger(Method.Attrs.Attrs)); + error(IO.mapInteger(Method.Attrs.Attrs, "NumAttributes")); if (IsFromOverloadList) { uint16_t Padding = 0; - error(IO.mapInteger(Padding)); + error(IO.mapInteger(Padding, "Padding")); } - error(IO.mapInteger(Method.Type)); + error(IO.mapInteger(Method.Type, "Type")); if (Method.isIntroducingVirtual()) { - error(IO.mapInteger(Method.VFTableOffset)); + error(IO.mapInteger(Method.VFTableOffset, "VFTableOffset")); } else if (IO.isReading()) Method.VFTableOffset = -1; if (!IsFromOverloadList) - error(IO.mapStringZ(Method.Name)); + error(IO.mapStringZ(Method.Name, "Name")); return Error::success(); } @@ -75,9 +75,9 @@ // Reading & Streaming mode come after writing mode is executed for each // record. Truncating large names are done during writing, so its not // necessary to do it while reading or streaming. - error(IO.mapStringZ(Name)); + error(IO.mapStringZ(Name, "Name")); if (HasUniqueName) - error(IO.mapStringZ(UniqueName)); + error(IO.mapStringZ(UniqueName, "LinkageName")); } return Error::success(); @@ -144,32 +144,32 @@ } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, ModifierRecord &Record) { - error(IO.mapInteger(Record.ModifiedType)); - error(IO.mapEnum(Record.Modifiers)); + error(IO.mapInteger(Record.ModifiedType, "ModifiedType")); + error(IO.mapEnum(Record.Modifiers, "Modifiers")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, ProcedureRecord &Record) { - error(IO.mapInteger(Record.ReturnType)); - error(IO.mapEnum(Record.CallConv)); - error(IO.mapEnum(Record.Options)); - error(IO.mapInteger(Record.ParameterCount)); - error(IO.mapInteger(Record.ArgumentList)); + error(IO.mapInteger(Record.ReturnType, "ReturnType")); + error(IO.mapEnum(Record.CallConv, "CallingConvention")); + error(IO.mapEnum(Record.Options, "FunctionOptions")); + error(IO.mapInteger(Record.ParameterCount, "NumParameters")); + error(IO.mapInteger(Record.ArgumentList, "ArgListType")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, MemberFunctionRecord &Record) { - error(IO.mapInteger(Record.ReturnType)); - error(IO.mapInteger(Record.ClassType)); - error(IO.mapInteger(Record.ThisType)); - error(IO.mapEnum(Record.CallConv)); - error(IO.mapEnum(Record.Options)); - error(IO.mapInteger(Record.ParameterCount)); - error(IO.mapInteger(Record.ArgumentList)); - error(IO.mapInteger(Record.ThisPointerAdjustment)); + error(IO.mapInteger(Record.ReturnType, "ReturnType")); + error(IO.mapInteger(Record.ClassType, "ClassType")); + error(IO.mapInteger(Record.ThisType, "ThisType")); + error(IO.mapEnum(Record.CallConv, "CallingConvention")); + error(IO.mapEnum(Record.Options, "FunctionOptions")); + error(IO.mapInteger(Record.ParameterCount, "NumParameters")); + error(IO.mapInteger(Record.ArgumentList, "ArgListType")); + error(IO.mapInteger(Record.ThisPointerAdjustment, "ThisAdjustment")); return Error::success(); } @@ -177,7 +177,8 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, ArgListRecord &Record) { error(IO.mapVectorN( Record.ArgIndices, - [](CodeViewRecordIO &IO, TypeIndex &N) { return IO.mapInteger(N); })); + [](CodeViewRecordIO &IO, TypeIndex &N) { return IO.mapInteger(N, "Argument"); }, + "NumArgs")); return Error::success(); } @@ -185,32 +186,33 @@ StringListRecord &Record) { error(IO.mapVectorN( Record.StringIndices, - [](CodeViewRecordIO &IO, TypeIndex &N) { return IO.mapInteger(N); })); + [](CodeViewRecordIO &IO, TypeIndex &N) { return IO.mapInteger(N, "Strings"); }, + "NumStrings")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, PointerRecord &Record) { - error(IO.mapInteger(Record.ReferentType)); - error(IO.mapInteger(Record.Attrs)); + error(IO.mapInteger(Record.ReferentType, "PointeeType")); + error(IO.mapInteger(Record.Attrs, "Attributes")); if (Record.isPointerToMember()) { if (IO.isReading()) Record.MemberInfo.emplace(); MemberPointerInfo &M = *Record.MemberInfo; - error(IO.mapInteger(M.ContainingType)); - error(IO.mapEnum(M.Representation)); + error(IO.mapInteger(M.ContainingType, "ClassType")); + error(IO.mapEnum(M.Representation, "Representation")); } return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, ArrayRecord &Record) { - error(IO.mapInteger(Record.ElementType)); - error(IO.mapInteger(Record.IndexType)); - error(IO.mapEncodedInteger(Record.Size)); - error(IO.mapStringZ(Record.Name)); + error(IO.mapInteger(Record.ElementType, "ElementType")); + error(IO.mapInteger(Record.IndexType, "IndexType")); + error(IO.mapEncodedInteger(Record.Size, "SizeOf")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } @@ -220,12 +222,12 @@ (CVR.kind() == TypeLeafKind::LF_CLASS) || (CVR.kind() == TypeLeafKind::LF_INTERFACE)); - error(IO.mapInteger(Record.MemberCount)); - error(IO.mapEnum(Record.Options)); - error(IO.mapInteger(Record.FieldList)); - error(IO.mapInteger(Record.DerivationList)); - error(IO.mapInteger(Record.VTableShape)); - error(IO.mapEncodedInteger(Record.Size)); + error(IO.mapInteger(Record.MemberCount, "MemberCount")); + error(IO.mapEnum(Record.Options, "Properties")); + error(IO.mapInteger(Record.FieldList, "FieldList")); + error(IO.mapInteger(Record.DerivationList, "DerivedFrom")); + error(IO.mapInteger(Record.VTableShape, "VShape")); + error(IO.mapEncodedInteger(Record.Size, "SizeOf")); error(mapNameAndUniqueName(IO, Record.Name, Record.UniqueName, Record.hasUniqueName())); @@ -233,10 +235,10 @@ } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, UnionRecord &Record) { - error(IO.mapInteger(Record.MemberCount)); - error(IO.mapEnum(Record.Options)); - error(IO.mapInteger(Record.FieldList)); - error(IO.mapEncodedInteger(Record.Size)); + error(IO.mapInteger(Record.MemberCount, "MemberCount")); + error(IO.mapEnum(Record.Options, "Properties")); + error(IO.mapInteger(Record.FieldList, "FieldList")); + error(IO.mapEncodedInteger(Record.Size, "SizeOf")); error(mapNameAndUniqueName(IO, Record.Name, Record.UniqueName, Record.hasUniqueName())); @@ -244,10 +246,10 @@ } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, EnumRecord &Record) { - error(IO.mapInteger(Record.MemberCount)); - error(IO.mapEnum(Record.Options)); - error(IO.mapInteger(Record.UnderlyingType)); - error(IO.mapInteger(Record.FieldList)); + error(IO.mapInteger(Record.MemberCount, "NumEnumerators")); + error(IO.mapEnum(Record.Options, "Properties")); + error(IO.mapInteger(Record.UnderlyingType, "UnderlyingType")); + error(IO.mapInteger(Record.FieldList, "FieldListType")); error(mapNameAndUniqueName(IO, Record.Name, Record.UniqueName, Record.hasUniqueName())); @@ -255,9 +257,9 @@ } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, BitFieldRecord &Record) { - error(IO.mapInteger(Record.Type)); - error(IO.mapInteger(Record.BitSize)); - error(IO.mapInteger(Record.BitOffset)); + error(IO.mapInteger(Record.Type, "Type")); + error(IO.mapInteger(Record.BitSize, "BitSize")); + error(IO.mapInteger(Record.BitOffset, "BitOffset")); return Error::success(); } @@ -268,7 +270,7 @@ if (!IO.isReading()) { ArrayRef Slots = Record.getSlots(); Size = Slots.size(); - error(IO.mapInteger(Size)); + error(IO.mapInteger(Size, "VFEntryCount")); for (size_t SlotIndex = 0; SlotIndex < Slots.size(); SlotIndex += 2) { uint8_t Byte = static_cast(Slots[SlotIndex]) << 4; @@ -292,61 +294,62 @@ } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, VFTableRecord &Record) { - error(IO.mapInteger(Record.CompleteClass)); - error(IO.mapInteger(Record.OverriddenVFTable)); - error(IO.mapInteger(Record.VFPtrOffset)); + error(IO.mapInteger(Record.CompleteClass, "CompleteClass")); + error(IO.mapInteger(Record.OverriddenVFTable, "OverriddenVFTable")); + error(IO.mapInteger(Record.VFPtrOffset, "VFPtrOffset")); uint32_t NamesLen = 0; if (!IO.isReading()) { for (auto Name : Record.MethodNames) NamesLen += Name.size() + 1; } - error(IO.mapInteger(NamesLen)); + error(IO.mapInteger(NamesLen, "")); error(IO.mapVectorTail( Record.MethodNames, - [](CodeViewRecordIO &IO, StringRef &S) { return IO.mapStringZ(S); })); + [](CodeViewRecordIO &IO, StringRef &S) { return IO.mapStringZ(S, "MethodName"); }, + "VFTableName")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, StringIdRecord &Record) { - error(IO.mapInteger(Record.Id)); - error(IO.mapStringZ(Record.String)); + error(IO.mapInteger(Record.Id, "Id")); + error(IO.mapStringZ(Record.String, "StringData")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, UdtSourceLineRecord &Record) { - error(IO.mapInteger(Record.UDT)); - error(IO.mapInteger(Record.SourceFile)); - error(IO.mapInteger(Record.LineNumber)); + error(IO.mapInteger(Record.UDT, "UDT")); + error(IO.mapInteger(Record.SourceFile, "SourceFile")); + error(IO.mapInteger(Record.LineNumber, "LineNumber")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, UdtModSourceLineRecord &Record) { - error(IO.mapInteger(Record.UDT)); - error(IO.mapInteger(Record.SourceFile)); - error(IO.mapInteger(Record.LineNumber)); - error(IO.mapInteger(Record.Module)); + error(IO.mapInteger(Record.UDT, "UDT")); + error(IO.mapInteger(Record.SourceFile, "SourceFile")); + error(IO.mapInteger(Record.LineNumber, "LineNumber")); + error(IO.mapInteger(Record.Module, "Module")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, FuncIdRecord &Record) { - error(IO.mapInteger(Record.ParentScope)); - error(IO.mapInteger(Record.FunctionType)); - error(IO.mapStringZ(Record.Name)); + error(IO.mapInteger(Record.ParentScope, "ParentScope")); + error(IO.mapInteger(Record.FunctionType, "FunctionType")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, MemberFuncIdRecord &Record) { - error(IO.mapInteger(Record.ClassType)); - error(IO.mapInteger(Record.FunctionType)); - error(IO.mapStringZ(Record.Name)); + error(IO.mapInteger(Record.ClassType, "ClassType")); + error(IO.mapInteger(Record.FunctionType, "FunctionType")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } @@ -355,7 +358,8 @@ BuildInfoRecord &Record) { error(IO.mapVectorN( Record.ArgIndices, - [](CodeViewRecordIO &IO, TypeIndex &N) { return IO.mapInteger(N); })); + [](CodeViewRecordIO &IO, TypeIndex &N) { return IO.mapInteger(N, "Argument"); }, + "NumArgs")); return Error::success(); } @@ -364,7 +368,7 @@ MethodOverloadListRecord &Record) { // TODO: Split the list into multiple records if it's longer than 64KB, using // a subrecord of TypeRecordKind::Index to chain the records together. - error(IO.mapVectorTail(Record.Methods, MapOneMethodRecord(true))); + error(IO.mapVectorTail(Record.Methods, MapOneMethodRecord(true), "Method")); return Error::success(); } @@ -378,22 +382,22 @@ Error TypeRecordMapping::visitKnownRecord(CVType &CVR, TypeServer2Record &Record) { - error(IO.mapGuid(Record.Guid)); - error(IO.mapInteger(Record.Age)); - error(IO.mapStringZ(Record.Name)); + error(IO.mapGuid(Record.Guid, "Guid")); + error(IO.mapInteger(Record.Age, "Age")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, LabelRecord &Record) { - error(IO.mapEnum(Record.Mode)); + error(IO.mapEnum(Record.Mode, "Mode")); return Error::success(); } Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, BaseClassRecord &Record) { - error(IO.mapInteger(Record.Attrs.Attrs)); - error(IO.mapInteger(Record.Type)); - error(IO.mapEncodedInteger(Record.Offset)); + error(IO.mapInteger(Record.Attrs.Attrs, "NumAttributes")); + error(IO.mapInteger(Record.Type, "BaseType")); + error(IO.mapEncodedInteger(Record.Offset, "BaseOffset")); return Error::success(); } @@ -403,27 +407,27 @@ error(IO.mapInteger(Record.Attrs.Attrs)); // FIXME: Handle full APInt such as __int128. - error(IO.mapEncodedInteger(Record.Value)); - error(IO.mapStringZ(Record.Name)); + error(IO.mapEncodedInteger(Record.Value, "EnumValue")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, DataMemberRecord &Record) { - error(IO.mapInteger(Record.Attrs.Attrs)); - error(IO.mapInteger(Record.Type)); - error(IO.mapEncodedInteger(Record.FieldOffset)); - error(IO.mapStringZ(Record.Name)); + error(IO.mapInteger(Record.Attrs.Attrs, "NumAttributes")); + error(IO.mapInteger(Record.Type, "Type")); + error(IO.mapEncodedInteger(Record.FieldOffset, "FieldOffset")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, OverloadedMethodRecord &Record) { - error(IO.mapInteger(Record.NumOverloads)); - error(IO.mapInteger(Record.MethodList)); - error(IO.mapStringZ(Record.Name)); + error(IO.mapInteger(Record.NumOverloads, "MethodCount")); + error(IO.mapInteger(Record.MethodList, "MethodListIndex")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } @@ -438,9 +442,9 @@ Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, NestedTypeRecord &Record) { uint16_t Padding = 0; - error(IO.mapInteger(Padding)); - error(IO.mapInteger(Record.Type)); - error(IO.mapStringZ(Record.Name)); + error(IO.mapInteger(Padding, "Padding")); + error(IO.mapInteger(Record.Type, "Type")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } @@ -448,9 +452,9 @@ Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, StaticDataMemberRecord &Record) { - error(IO.mapInteger(Record.Attrs.Attrs)); - error(IO.mapInteger(Record.Type)); - error(IO.mapStringZ(Record.Name)); + error(IO.mapInteger(Record.Attrs.Attrs, "NumAttributes")); + error(IO.mapInteger(Record.Type, "Type")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } @@ -458,11 +462,11 @@ Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, VirtualBaseClassRecord &Record) { - error(IO.mapInteger(Record.Attrs.Attrs)); - error(IO.mapInteger(Record.BaseType)); - error(IO.mapInteger(Record.VBPtrType)); - error(IO.mapEncodedInteger(Record.VBPtrOffset)); - error(IO.mapEncodedInteger(Record.VTableIndex)); + error(IO.mapInteger(Record.Attrs.Attrs, "NumAttributes")); + error(IO.mapInteger(Record.BaseType, "BaseType")); + error(IO.mapInteger(Record.VBPtrType, "VBPtrType")); + error(IO.mapEncodedInteger(Record.VBPtrOffset, "VBPtrOffset")); + error(IO.mapEncodedInteger(Record.VTableIndex, "VBTableIndex")); return Error::success(); } @@ -470,8 +474,8 @@ Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, VFPtrRecord &Record) { uint16_t Padding = 0; - error(IO.mapInteger(Padding)); - error(IO.mapInteger(Record.Type)); + error(IO.mapInteger(Padding, "Padding")); + error(IO.mapInteger(Record.Type, "Type")); return Error::success(); } @@ -479,23 +483,23 @@ Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR, ListContinuationRecord &Record) { uint16_t Padding = 0; - error(IO.mapInteger(Padding)); - error(IO.mapInteger(Record.ContinuationIndex)); + error(IO.mapInteger(Padding, "Padding")); + error(IO.mapInteger(Record.ContinuationIndex, "ContinuationIndex")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, PrecompRecord &Precomp) { - error(IO.mapInteger(Precomp.StartTypeIndex)); - error(IO.mapInteger(Precomp.TypesCount)); - error(IO.mapInteger(Precomp.Signature)); - error(IO.mapStringZ(Precomp.PrecompFilePath)); + error(IO.mapInteger(Precomp.StartTypeIndex, "StartIndex")); + error(IO.mapInteger(Precomp.TypesCount, "Count")); + error(IO.mapInteger(Precomp.Signature, "Signature")); + error(IO.mapStringZ(Precomp.PrecompFilePath, "PrecompFile")); return Error::success(); } Error TypeRecordMapping::visitKnownRecord(CVType &CVR, EndPrecompRecord &EndPrecomp) { - error(IO.mapInteger(EndPrecomp.Signature)); + error(IO.mapInteger(EndPrecomp.Signature, "Signature")); return Error::success(); } Index: llvm/test/DebugInfo/COFF/types-basic.ll =================================================================== --- llvm/test/DebugInfo/COFF/types-basic.ll +++ llvm/test/DebugInfo/COFF/types-basic.ll @@ -347,17 +347,15 @@ ; CHECK: ] ; CHECK: ] - - ; ASM: .section .debug$T,"dr" ; ASM: .p2align 2 ; ASM: .long 4 # Debug section magic ; ASM: .short 18 ; ASM: .short 4609 -; ASM: .long 3 -; ASM: .long 64 -; ASM: .long 65 -; ASM: .long 19 +; ASM: .long 3 # NumArgs +; ASM: .long 64 # Argument +; ASM: .long 65 # Argument +; ASM: .long 19 # Argument ; ASM: # ArgList (0x1000) { ; ASM: # TypeLeafKind: LF_ARGLIST (0x1201) ; ASM: # NumArgs: 3 @@ -369,11 +367,11 @@ ; ASM: # } ; ASM: .short 14 ; ASM: .short 4104 -; ASM: .long 3 -; ASM: .byte 0 -; ASM: .byte 0 -; ASM: .short 3 -; ASM: .long 4096 +; ASM: .long 3 # ReturnType +; ASM: .byte 0 # CallingConvention +; ASM: .byte 0 # FunctionOptions +; ASM: .short 3 # NumParameters +; ASM: .long 4096 # ArgListType ; ASM: # Procedure (0x1001) { ; ASM: # TypeLeafKind: LF_PROCEDURE (0x1008) ; ASM: # ReturnType: void (0x3) @@ -385,9 +383,9 @@ ; ASM: # } ; ASM: .short 14 ; ASM: .short 5633 -; ASM: .long 0 -; ASM: .long 4097 -; ASM: .asciz "f" +; ASM: .long 0 # ParentScope +; ASM: .long 4097 # FunctionType +; ASM: .asciz "f" # Name ; ASM: .byte 242 ; ASM: .byte 241 ; ASM: # FuncId (0x1002) { @@ -398,8 +396,8 @@ ; ASM: # } ; ASM: .short 10 ; ASM: .short 4097 -; ASM: .long 116 -; ASM: .short 1 +; ASM: .long 116 # ModifiedType +; ASM: .short 1 # Modifiers ; ASM: .byte 242 ; ASM: .byte 241 ; ASM: # Modifier (0x1003) { @@ -411,8 +409,8 @@ ; ASM: # } ; ASM: .short 10 ; ASM: .short 4098 -; ASM: .long 4099 -; ASM: .long 65548 +; ASM: .long 4099 # PointeeType +; ASM: .long 65548 # Attributes ; ASM: # Pointer (0x1004) { ; ASM: # TypeLeafKind: LF_POINTER (0x1002) ; ASM: # PointeeType: const int (0x1003) @@ -429,13 +427,13 @@ ; ASM: # } ; ASM: .short 22 ; ASM: .short 5381 -; ASM: .short 0 -; ASM: .short 128 -; ASM: .long 0 -; ASM: .long 0 -; ASM: .long 0 -; ASM: .short 0 -; ASM: .asciz "A" +; ASM: .short 0 # MemberCount +; ASM: .short 128 # Properties +; ASM: .long 0 # FieldList +; ASM: .long 0 # DerivedFrom +; ASM: .long 0 # VShape +; ASM: .short 0 # SizeOf +; ASM: .asciz "A" # Name ; ASM: # Struct (0x1005) { ; ASM: # TypeLeafKind: LF_STRUCTURE (0x1505) ; ASM: # MemberCount: 0 @@ -450,10 +448,10 @@ ; ASM: # } ; ASM: .short 18 ; ASM: .short 4098 -; ASM: .long 116 -; ASM: .long 32844 -; ASM: .long 4101 -; ASM: .short 4 +; ASM: .long 116 # PointeeType +; ASM: .long 32844 # Attributes +; ASM: .long 4101 # ClassType +; ASM: .short 4 # Representation ; ASM: .byte 242 ; ASM: .byte 241 ; ASM: # Pointer (0x1006) { @@ -474,8 +472,8 @@ ; ASM: # } ; ASM: .short 10 ; ASM: .short 4098 -; ASM: .long 4101 -; ASM: .long 66572 +; ASM: .long 4101 # PointeeType +; ASM: .long 66572 # Attributes ; ASM: # Pointer (0x1007) { ; ASM: # TypeLeafKind: LF_POINTER (0x1002) ; ASM: # PointeeType: A (0x1005) @@ -492,7 +490,7 @@ ; ASM: # } ; ASM: .short 6 ; ASM: .short 4609 -; ASM: .long 0 +; ASM: .long 0 # NumArgs ; ASM: # ArgList (0x1008) { ; ASM: # TypeLeafKind: LF_ARGLIST (0x1201) ; ASM: # NumArgs: 0 @@ -501,14 +499,14 @@ ; ASM: # } ; ASM: .short 26 ; ASM: .short 4105 -; ASM: .long 3 -; ASM: .long 4101 -; ASM: .long 4103 -; ASM: .byte 0 -; ASM: .byte 0 -; ASM: .short 0 -; ASM: .long 4104 -; ASM: .long 0 +; ASM: .long 3 # ReturnType +; ASM: .long 4101 # ClassType +; ASM: .long 4103 # ThisType +; ASM: .byte 0 # CallingConvention +; ASM: .byte 0 # FunctionOptions +; ASM: .short 0 # NumParameters +; ASM: .long 4104 # ArgListType +; ASM: .long 0 # ThisAdjustment ; ASM: # MemberFunction (0x1009) { ; ASM: # TypeLeafKind: LF_MFUNCTION (0x1009) ; ASM: # ReturnType: void (0x3) @@ -548,13 +546,13 @@ ; ASM: # } ; ASM: .short 22 ; ASM: .short 5381 -; ASM: .short 2 -; ASM: .short 0 -; ASM: .long 4106 -; ASM: .long 0 -; ASM: .long 0 -; ASM: .short 4 -; ASM: .asciz "A" +; ASM: .short 2 # MemberCount +; ASM: .short 0 # Properties +; ASM: .long 4106 # FieldList +; ASM: .long 0 # DerivedFrom +; ASM: .long 0 # VShape +; ASM: .short 4 # SizeOf +; ASM: .asciz "A" # Name ; ASM: # Struct (0x100B) { ; ASM: # TypeLeafKind: LF_STRUCTURE (0x1505) ; ASM: # MemberCount: 2 @@ -568,8 +566,8 @@ ; ASM: # } ; ASM: .short 30 ; ASM: .short 5637 -; ASM: .long 0 -; ASM: .asciz "D:\\src\\llvm\\build\\t.cpp" +; ASM: .long 0 # Id +; ASM: .asciz "D:\\src\\llvm\\build\\t.cpp" # StringData ; ASM: # StringId (0x100C) { ; ASM: # TypeLeafKind: LF_STRING_ID (0x1605) ; ASM: # Id: 0x0 @@ -577,9 +575,9 @@ ; ASM: # } ; ASM: .short 14 ; ASM: .short 5638 -; ASM: .long 4107 -; ASM: .long 4108 -; ASM: .long 1 +; ASM: .long 4107 # UDT +; ASM: .long 4108 # SourceFile +; ASM: .long 1 # LineNumber ; ASM: # UdtSourceLine (0x100D) { ; ASM: # TypeLeafKind: LF_UDT_SRC_LINE (0x1606) ; ASM: # UDT: A (0x100B) @@ -588,10 +586,10 @@ ; ASM: # } ; ASM: .short 18 ; ASM: .short 4098 -; ASM: .long 4105 -; ASM: .long 65644 -; ASM: .long 4101 -; ASM: .short 8 +; ASM: .long 4105 # PointeeType +; ASM: .long 65644 # Attributes +; ASM: .long 4101 # ClassType +; ASM: .short 8 # Representation ; ASM: .byte 242 ; ASM: .byte 241 ; ASM: # Pointer (0x100E) { @@ -612,8 +610,8 @@ ; ASM: # } ; ASM: .short 10 ; ASM: .short 4097 -; ASM: .long 3 -; ASM: .short 1 +; ASM: .long 3 # ModifiedType +; ASM: .short 1 # Modifiers ; ASM: .byte 242 ; ASM: .byte 241 ; ASM: # Modifier (0x100F) { @@ -625,8 +623,8 @@ ; ASM: # } ; ASM: .short 10 ; ASM: .short 4098 -; ASM: .long 4111 -; ASM: .long 65548 +; ASM: .long 4111 # PointeeType +; ASM: .long 65548 # Attributes ; ASM: # Pointer (0x1010) { ; ASM: # TypeLeafKind: LF_POINTER (0x1002) ; ASM: # PointeeType: const void (0x100F) @@ -643,11 +641,11 @@ ; ASM: # } ; ASM: .short 14 ; ASM: .short 4104 -; ASM: .long 3 -; ASM: .byte 0 -; ASM: .byte 0 -; ASM: .short 0 -; ASM: .long 4104 +; ASM: .long 3 # ReturnType +; ASM: .byte 0 # CallingConvention +; ASM: .byte 0 # FunctionOptions +; ASM: .short 0 # NumParameters +; ASM: .long 4104 # ArgListType ; ASM: # Procedure (0x1011) { ; ASM: # TypeLeafKind: LF_PROCEDURE (0x1008) ; ASM: # ReturnType: void (0x3) @@ -659,9 +657,9 @@ ; ASM: # } ; ASM: .short 22 ; ASM: .short 5633 -; ASM: .long 0 -; ASM: .long 4113 -; ASM: .asciz "CharTypes" +; ASM: .long 0 # ParentScope +; ASM: .long 4113 # FunctionType +; ASM: .asciz "CharTypes" # Name ; ASM: .byte 242 ; ASM: .byte 241 ; ASM: # FuncId (0x1012) { @@ -672,8 +670,8 @@ ; ASM: # } ; ASM: .short 26 ; ASM: .short 5637 -; ASM: .long 0 -; ASM: .asciz "D:\\src\\llvm\\build" +; ASM: .long 0 # Id +; ASM: .asciz "D:\\src\\llvm\\build" # StringData ; ASM: .byte 242 ; ASM: .byte 241 ; ASM: # StringId (0x1013) { @@ -683,8 +681,8 @@ ; ASM: # } ; ASM: .short 14 ; ASM: .short 5637 -; ASM: .long 0 -; ASM: .asciz "t.cpp" +; ASM: .long 0 # Id +; ASM: .asciz "t.cpp" # StringData ; ASM: .byte 242 ; ASM: .byte 241 ; ASM: # StringId (0x1014) { @@ -694,12 +692,12 @@ ; ASM: # } ; ASM: .short 26 ; ASM: .short 5635 -; ASM: .short 5 -; ASM: .long 4115 -; ASM: .long 0 -; ASM: .long 4116 -; ASM: .long 0 -; ASM: .long 0 +; ASM: .short 5 # NumArgs +; ASM: .long 4115 # Argument +; ASM: .long 0 # Argument +; ASM: .long 4116 # Argument +; ASM: .long 0 # Argument +; ASM: .long 0 # Argument ; ASM: .byte 242 ; ASM: .byte 241 ; ASM: # BuildInfo (0x1015) {