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 Twine &Comment = ""); 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 Twine &Comment = "") { 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 Twine &Comment = "") { 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,22 @@ 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 Twine &Comment = ""); + Error mapEncodedInteger(uint64_t &Value, const Twine &Comment = ""); + Error mapEncodedInteger(APSInt &Value, const Twine &Comment = ""); + Error mapStringZ(StringRef &Value, const Twine &Comment = ""); + Error mapGuid(GUID &Guid, const Twine &Comment = ""); - Error mapStringZVectorZ(std::vector &Value); + Error mapStringZVectorZ(std::vector &Value, + const Twine &Comment = ""); template - Error mapVectorN(T &Items, const ElementMapper &Mapper) { + Error mapVectorN(T &Items, const ElementMapper &Mapper, + const Twine &Comment = "") { 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 +173,9 @@ } template - Error mapVectorTail(T &Items, const ElementMapper &Mapper) { + Error mapVectorTail(T &Items, const ElementMapper &Mapper, + const Twine &Comment = "") { + emitComment(Comment); if (isStreaming() || isWriting()) { for (auto &Item : Items) { if (auto EC = Mapper(*this, Item)) @@ -186,8 +193,9 @@ return Error::success(); } - Error mapByteVectorTail(ArrayRef &Bytes); - Error mapByteVectorTail(std::vector &Bytes); + Error mapByteVectorTail(ArrayRef &Bytes, const Twine &Comment = ""); + Error mapByteVectorTail(std::vector &Bytes, + const Twine &Comment = ""); Error padToAlignment(uint32_t Align); Error skipPadding(); @@ -199,8 +207,10 @@ } private: - void emitEncodedSignedInteger(const int64_t &Value); - void emitEncodedUnsignedInteger(const uint64_t &Value); + void emitEncodedSignedInteger(const int64_t &Value, + const Twine &Comment = ""); + void emitEncodedUnsignedInteger(const uint64_t &Value, + const Twine &Comment = ""); Error writeEncodedSignedInteger(const int64_t &Value); Error writeEncodedUnsignedInteger(const uint64_t &Value); @@ -214,6 +224,13 @@ StreamedLen = 4; // The record prefix is 4 bytes long } + void emitComment(const Twine &Comment) { + if (isStreaming()) { + 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,8 @@ void EmitBinaryData(StringRef Data) { OS->EmitBinaryData(Data); } + void AddComment(const Twine &T) { OS->AddComment(T); } + private: MCStreamer *OS = nullptr; }; @@ -615,6 +617,13 @@ OS.EmitBytes(NullTerminatedString); } +static StringRef getTypeLeafName(TypeLeafKind TypeKind) { + for (const EnumEntry &EE : getTypeLeafNames()) + if (EE.Value == TypeKind) + return EE.Name; + return ""; +} + void CodeViewDebug::emitTypeInformation() { if (TypeTable.empty()) return; @@ -659,8 +668,12 @@ auto RecordLen = Record.length(); auto RecordKind = Record.kind(); - OS.EmitIntValue(RecordLen - 2, 2); - OS.EmitIntValue(RecordKind, sizeof(RecordKind)); + if (OS.isVerboseAsm()) + CVMCOS.AddComment("Record length"); + CVMCOS.EmitIntValue(RecordLen - 2, 2); + if (OS.isVerboseAsm()) + CVMCOS.AddComment("Record kind: " + getTypeLeafName(RecordKind)); + CVMCOS.EmitIntValue(RecordKind, sizeof(RecordKind)); Error E = codeview::visitTypeRecord(Record, *B, Pipeline); Index: llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp =================================================================== --- llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp +++ llvm/lib/DebugInfo/CodeView/CodeViewRecordIO.cpp @@ -97,8 +97,10 @@ return Reader->skip(BytesToAdvance); } -Error CodeViewRecordIO::mapByteVectorTail(ArrayRef &Bytes) { +Error CodeViewRecordIO::mapByteVectorTail(ArrayRef &Bytes, + const Twine &Comment) { if (isStreaming()) { + emitComment(Comment); Streamer->EmitBinaryData(toStringRef(Bytes)); incrStreamedLen(Bytes.size()); } else if (isWriting()) { @@ -111,9 +113,10 @@ return Error::success(); } -Error CodeViewRecordIO::mapByteVectorTail(std::vector &Bytes) { +Error CodeViewRecordIO::mapByteVectorTail(std::vector &Bytes, + const Twine &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 +124,9 @@ return Error::success(); } -Error CodeViewRecordIO::mapInteger(TypeIndex &TypeInd) { +Error CodeViewRecordIO::mapInteger(TypeIndex &TypeInd, const Twine &Comment) { if (isStreaming()) { + emitComment(Comment); Streamer->EmitIntValue(TypeInd.getIndex(), sizeof(TypeInd.getIndex())); incrStreamedLen(sizeof(TypeInd.getIndex())); } else if (isWriting()) { @@ -137,12 +141,13 @@ return Error::success(); } -Error CodeViewRecordIO::mapEncodedInteger(int64_t &Value) { +Error CodeViewRecordIO::mapEncodedInteger(int64_t &Value, + const Twine &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 +166,10 @@ return Error::success(); } -Error CodeViewRecordIO::mapEncodedInteger(uint64_t &Value) { +Error CodeViewRecordIO::mapEncodedInteger(uint64_t &Value, + const Twine &Comment) { if (isStreaming()) - emitEncodedUnsignedInteger(Value); + emitEncodedUnsignedInteger(Value, Comment); else if (isWriting()) { if (auto EC = writeEncodedUnsignedInteger(Value)) return EC; @@ -176,12 +182,12 @@ return Error::success(); } -Error CodeViewRecordIO::mapEncodedInteger(APSInt &Value) { +Error CodeViewRecordIO::mapEncodedInteger(APSInt &Value, const Twine &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 +197,10 @@ return Error::success(); } -Error CodeViewRecordIO::mapStringZ(StringRef &Value) { +Error CodeViewRecordIO::mapStringZ(StringRef &Value, const Twine &Comment) { if (isStreaming()) { auto NullTerminatedString = StringRef(Value.data(), Value.size() + 1); + emitComment(Comment); Streamer->EmitBytes(NullTerminatedString); incrStreamedLen(NullTerminatedString.size()); } else if (isWriting()) { @@ -208,12 +215,13 @@ return Error::success(); } -Error CodeViewRecordIO::mapGuid(GUID &Guid) { +Error CodeViewRecordIO::mapGuid(GUID &Guid, const Twine &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 +242,11 @@ return Error::success(); } -Error CodeViewRecordIO::mapStringZVectorZ(std::vector &Value) { +Error CodeViewRecordIO::mapStringZVectorZ(std::vector &Value, + const Twine &Comment) { if (!isReading()) { + emitComment(Comment); for (auto V : Value) { if (auto EC = mapStringZ(V)) return EC; @@ -257,41 +267,51 @@ return Error::success(); } -void CodeViewRecordIO::emitEncodedSignedInteger(const int64_t &Value) { +void CodeViewRecordIO::emitEncodedSignedInteger(const int64_t &Value, + const Twine &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 Twine &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, "AccessSpecifier")); 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,10 @@ 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 +188,35 @@ 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 +226,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 +239,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 +250,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 +261,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 +274,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 +298,64 @@ } 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 +364,10 @@ 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 +376,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 +390,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, "AccessSpecifier")); + error(IO.mapInteger(Record.Type, "BaseType")); + error(IO.mapEncodedInteger(Record.Offset, "BaseOffset")); return Error::success(); } @@ -403,27 +415,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, "AccessSpecifier")); + 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 +450,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 +460,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, "AccessSpecifier")); + error(IO.mapInteger(Record.Type, "Type")); + error(IO.mapStringZ(Record.Name, "Name")); return Error::success(); } @@ -458,11 +470,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, "AccessSpecifier")); + 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 +482,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 +491,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: .short 18 # Record length +; ASM: .short 4609 # Record kind: LF_ARGLIST +; 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 @@ -367,13 +365,13 @@ ; ASM: # ArgType: __int64 (0x13) ; ASM: # ] ; ASM: # } -; ASM: .short 14 -; ASM: .short 4104 -; ASM: .long 3 -; ASM: .byte 0 -; ASM: .byte 0 -; ASM: .short 3 -; ASM: .long 4096 +; ASM: .short 14 # Record length +; ASM: .short 4104 # Record kind: LF_PROCEDURE +; 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) @@ -383,11 +381,11 @@ ; ASM: # NumParameters: 3 ; ASM: # ArgListType: (float, double, __int64) (0x1000) ; ASM: # } -; ASM: .short 14 -; ASM: .short 5633 -; ASM: .long 0 -; ASM: .long 4097 -; ASM: .asciz "f" +; ASM: .short 14 # Record length +; ASM: .short 5633 # Record kind: LF_FUNC_ID +; ASM: .long 0 # ParentScope +; ASM: .long 4097 # FunctionType +; ASM: .asciz "f" # Name ; ASM: .byte 242 ; ASM: .byte 241 ; ASM: # FuncId (0x1002) { @@ -396,10 +394,10 @@ ; ASM: # FunctionType: void (float, double, __int64) (0x1001) ; ASM: # Name: f ; ASM: # } -; ASM: .short 10 -; ASM: .short 4097 -; ASM: .long 116 -; ASM: .short 1 +; ASM: .short 10 # Record length +; ASM: .short 4097 # Record kind: LF_MODIFIER +; ASM: .long 116 # ModifiedType +; ASM: .short 1 # Modifiers ; ASM: .byte 242 ; ASM: .byte 241 ; ASM: # Modifier (0x1003) { @@ -409,10 +407,10 @@ ; ASM: # Const (0x1) ; ASM: # ] ; ASM: # } -; ASM: .short 10 -; ASM: .short 4098 -; ASM: .long 4099 -; ASM: .long 65548 +; ASM: .short 10 # Record length +; ASM: .short 4098 # Record kind: LF_POINTER +; ASM: .long 4099 # PointeeType +; ASM: .long 65548 # Attributes ; ASM: # Pointer (0x1004) { ; ASM: # TypeLeafKind: LF_POINTER (0x1002) ; ASM: # PointeeType: const int (0x1003) @@ -427,15 +425,15 @@ ; ASM: # IsThisPtr&&: 0 ; ASM: # SizeOf: 8 ; 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 22 # Record length +; ASM: .short 5381 # Record kind: LF_STRUCTURE +; 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 @@ -448,12 +446,12 @@ ; ASM: # SizeOf: 0 ; ASM: # Name: A ; ASM: # } -; ASM: .short 18 -; ASM: .short 4098 -; ASM: .long 116 -; ASM: .long 32844 -; ASM: .long 4101 -; ASM: .short 4 +; ASM: .short 18 # Record length +; ASM: .short 4098 # Record kind: LF_POINTER +; 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) { @@ -472,10 +470,10 @@ ; ASM: # ClassType: A (0x1005) ; ASM: # Representation: GeneralData (0x4) ; ASM: # } -; ASM: .short 10 -; ASM: .short 4098 -; ASM: .long 4101 -; ASM: .long 66572 +; ASM: .short 10 # Record length +; ASM: .short 4098 # Record kind: LF_POINTER +; ASM: .long 4101 # PointeeType +; ASM: .long 66572 # Attributes ; ASM: # Pointer (0x1007) { ; ASM: # TypeLeafKind: LF_POINTER (0x1002) ; ASM: # PointeeType: A (0x1005) @@ -490,25 +488,25 @@ ; ASM: # IsThisPtr&&: 0 ; ASM: # SizeOf: 8 ; ASM: # } -; ASM: .short 6 -; ASM: .short 4609 -; ASM: .long 0 +; ASM: .short 6 # Record length +; ASM: .short 4609 # Record kind: LF_ARGLIST +; ASM: .long 0 # NumArgs ; ASM: # ArgList (0x1008) { ; ASM: # TypeLeafKind: LF_ARGLIST (0x1201) ; ASM: # NumArgs: 0 ; ASM: # Arguments [ ; ASM: # ] ; 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: .short 26 # Record length +; ASM: .short 4105 # Record kind: LF_MFUNCTION +; 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) @@ -521,8 +519,8 @@ ; ASM: # ArgListType: () (0x1008) ; ASM: # ThisAdjustment: 0 ; ASM: # } -; ASM: .short 30 -; ASM: .short 4611 +; ASM: .short 30 # Record length +; ASM: .short 4611 # Record kind: LF_FIELDLIST ; ASM: .byte 0x0d, 0x15, 0x03, 0x00 ; ASM: .byte 0x74, 0x00, 0x00, 0x00 ; ASM: .byte 0x00, 0x00, 0x61, 0x00 @@ -546,15 +544,15 @@ ; ASM: # Name: A::f ; ASM: # } ; 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 22 # Record length +; ASM: .short 5381 # Record kind: LF_STRUCTURE +; 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 @@ -566,32 +564,32 @@ ; ASM: # SizeOf: 4 ; ASM: # Name: A ; ASM: # } -; ASM: .short 30 -; ASM: .short 5637 -; ASM: .long 0 -; ASM: .asciz "D:\\src\\llvm\\build\\t.cpp" +; ASM: .short 30 # Record length +; ASM: .short 5637 # Record kind: LF_STRING_ID +; 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 ; ASM: # StringData: D:\src\llvm\build\t.cpp ; ASM: # } -; ASM: .short 14 -; ASM: .short 5638 -; ASM: .long 4107 -; ASM: .long 4108 -; ASM: .long 1 +; ASM: .short 14 # Record length +; ASM: .short 5638 # Record kind: LF_UDT_SRC_LINE +; 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) ; ASM: # SourceFile: D:\src\llvm\build\t.cpp (0x100C) ; ASM: # LineNumber: 1 ; ASM: # } -; ASM: .short 18 -; ASM: .short 4098 -; ASM: .long 4105 -; ASM: .long 65644 -; ASM: .long 4101 -; ASM: .short 8 +; ASM: .short 18 # Record length +; ASM: .short 4098 # Record kind: LF_POINTER +; 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) { @@ -610,10 +608,10 @@ ; ASM: # ClassType: A (0x1005) ; ASM: # Representation: GeneralFunction (0x8) ; ASM: # } -; ASM: .short 10 -; ASM: .short 4097 -; ASM: .long 3 -; ASM: .short 1 +; ASM: .short 10 # Record length +; ASM: .short 4097 # Record kind: LF_MODIFIER +; ASM: .long 3 # ModifiedType +; ASM: .short 1 # Modifiers ; ASM: .byte 242 ; ASM: .byte 241 ; ASM: # Modifier (0x100F) { @@ -623,10 +621,10 @@ ; ASM: # Const (0x1) ; ASM: # ] ; ASM: # } -; ASM: .short 10 -; ASM: .short 4098 -; ASM: .long 4111 -; ASM: .long 65548 +; ASM: .short 10 # Record length +; ASM: .short 4098 # Record kind: LF_POINTER +; ASM: .long 4111 # PointeeType +; ASM: .long 65548 # Attributes ; ASM: # Pointer (0x1010) { ; ASM: # TypeLeafKind: LF_POINTER (0x1002) ; ASM: # PointeeType: const void (0x100F) @@ -641,13 +639,13 @@ ; ASM: # IsThisPtr&&: 0 ; ASM: # SizeOf: 8 ; ASM: # } -; ASM: .short 14 -; ASM: .short 4104 -; ASM: .long 3 -; ASM: .byte 0 -; ASM: .byte 0 -; ASM: .short 0 -; ASM: .long 4104 +; ASM: .short 14 # Record length +; ASM: .short 4104 # Record kind: LF_PROCEDURE +; 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) @@ -657,11 +655,11 @@ ; ASM: # NumParameters: 0 ; ASM: # ArgListType: () (0x1008) ; ASM: # } -; ASM: .short 22 -; ASM: .short 5633 -; ASM: .long 0 -; ASM: .long 4113 -; ASM: .asciz "CharTypes" +; ASM: .short 22 # Record length +; ASM: .short 5633 # Record kind: LF_FUNC_ID +; ASM: .long 0 # ParentScope +; ASM: .long 4113 # FunctionType +; ASM: .asciz "CharTypes" # Name ; ASM: .byte 242 ; ASM: .byte 241 ; ASM: # FuncId (0x1012) { @@ -670,10 +668,10 @@ ; ASM: # FunctionType: void () (0x1011) ; ASM: # Name: CharTypes ; ASM: # } -; ASM: .short 26 -; ASM: .short 5637 -; ASM: .long 0 -; ASM: .asciz "D:\\src\\llvm\\build" +; ASM: .short 26 # Record length +; ASM: .short 5637 # Record kind: LF_STRING_ID +; ASM: .long 0 # Id +; ASM: .asciz "D:\\src\\llvm\\build" # StringData ; ASM: .byte 242 ; ASM: .byte 241 ; ASM: # StringId (0x1013) { @@ -681,10 +679,10 @@ ; ASM: # Id: 0x0 ; ASM: # StringData: D:\src\llvm\build ; ASM: # } -; ASM: .short 14 -; ASM: .short 5637 -; ASM: .long 0 -; ASM: .asciz "t.cpp" +; ASM: .short 14 # Record length +; ASM: .short 5637 # Record kind: LF_STRING_ID +; ASM: .long 0 # Id +; ASM: .asciz "t.cpp" # StringData ; ASM: .byte 242 ; ASM: .byte 241 ; ASM: # StringId (0x1014) { @@ -692,14 +690,14 @@ ; ASM: # Id: 0x0 ; ASM: # StringData: t.cpp ; 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 26 # Record length +; ASM: .short 5635 # Record kind: LF_BUILDINFO +; 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) {