[llvm] r299388 - [codeview] Add support for label type records
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 3 14:25:20 PDT 2017
Author: rnk
Date: Mon Apr 3 16:25:20 2017
New Revision: 299388
URL: http://llvm.org/viewvc/llvm-project?rev=299388&view=rev
Log:
[codeview] Add support for label type records
MASM can produce these type records.
Added:
llvm/trunk/test/tools/llvm-readobj/Inputs/codeview-label.obj (with props)
llvm/trunk/test/tools/llvm-readobj/codeview-label.test
Modified:
llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h
llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h
llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecords.def
llvm/trunk/lib/DebugInfo/CodeView/TypeDatabaseVisitor.cpp
llvm/trunk/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp
llvm/trunk/lib/DebugInfo/CodeView/TypeRecordMapping.cpp
llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.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=299388&r1=299387&r2=299388&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h Mon Apr 3 16:25:20 2017
@@ -275,6 +275,12 @@ enum class MethodOptions : uint16_t {
};
CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(MethodOptions)
+/// Equivalent to CV_LABEL_TYPE_e.
+enum class LabelType : uint16_t {
+ Near = 0x0,
+ Far = 0x4,
+};
+
/// Equivalent to CV_modifier_t.
/// TODO: Add flag for _Atomic modifier
enum class ModifierOptions : uint16_t {
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h?rev=299388&r1=299387&r2=299388&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h Mon Apr 3 16:25:20 2017
@@ -199,6 +199,16 @@ public:
int32_t ThisPointerAdjustment;
};
+// LF_LABEL
+class LabelRecord : public TypeRecord {
+public:
+ explicit LabelRecord(TypeRecordKind Kind) : TypeRecord(Kind) {}
+
+ LabelRecord(LabelType Mode) : TypeRecord(TypeRecordKind::Label), Mode(Mode) {}
+
+ LabelType Mode;
+};
+
// LF_MFUNC_ID
class MemberFuncIdRecord : public TypeRecord {
public:
Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecords.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecords.def?rev=299388&r1=299387&r2=299388&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecords.def (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecords.def Mon Apr 3 16:25:20 2017
@@ -41,6 +41,7 @@ TYPE_RECORD(LF_POINTER, 0x1002, Pointer)
TYPE_RECORD(LF_MODIFIER, 0x1001, Modifier)
TYPE_RECORD(LF_PROCEDURE, 0x1008, Procedure)
TYPE_RECORD(LF_MFUNCTION, 0x1009, MemberFunction)
+TYPE_RECORD(LF_LABEL, 0x000e, Label)
TYPE_RECORD(LF_ARGLIST, 0x1201, ArgList)
TYPE_RECORD(LF_FIELDLIST, 0x1203, FieldList)
@@ -101,7 +102,6 @@ CV_TYPE(LF_MFUNCTION_16t, 0x0009)
CV_TYPE(LF_COBOL0_16t, 0x000b)
CV_TYPE(LF_COBOL1, 0x000c)
CV_TYPE(LF_BARRAY_16t, 0x000d)
-CV_TYPE(LF_LABEL, 0x000e)
CV_TYPE(LF_NULLLEAF, 0x000f) // LF_NULL
CV_TYPE(LF_NOTTRAN, 0x0010)
CV_TYPE(LF_DIMARRAY_16t, 0x0011)
Modified: llvm/trunk/lib/DebugInfo/CodeView/TypeDatabaseVisitor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeDatabaseVisitor.cpp?rev=299388&r1=299387&r2=299388&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/TypeDatabaseVisitor.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/TypeDatabaseVisitor.cpp Mon Apr 3 16:25:20 2017
@@ -299,6 +299,10 @@ Error TypeDatabaseVisitor::visitKnownRec
return Error::success();
}
+Error TypeDatabaseVisitor::visitKnownRecord(CVType &CVR, LabelRecord &R) {
+ return Error::success();
+}
+
Error TypeDatabaseVisitor::visitKnownMember(CVMemberRecord &CVR,
VFPtrRecord &VFP) {
return Error::success();
Modified: llvm/trunk/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp?rev=299388&r1=299387&r2=299388&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp Mon Apr 3 16:25:20 2017
@@ -146,6 +146,10 @@ static const EnumEntry<uint8_t> Function
ENUM_ENTRY(FunctionOptions, ConstructorWithVirtualBases),
};
+static const EnumEntry<uint16_t> LabelTypeEnum[] = {
+ ENUM_ENTRY(LabelType, Near), ENUM_ENTRY(LabelType, Far),
+};
+
#undef ENUM_ENTRY
static StringRef getLeafTypeName(TypeLeafKind LT) {
@@ -547,3 +551,8 @@ Error TypeDumpVisitor::visitKnownMember(
printTypeIndex("ContinuationIndex", Cont.getContinuationIndex());
return Error::success();
}
+
+Error TypeDumpVisitor::visitKnownRecord(CVType &CVR, LabelRecord &LR) {
+ W->printEnum("Mode", uint16_t(LR.Mode), makeArrayRef(LabelTypeEnum));
+ return Error::success();
+}
Modified: llvm/trunk/lib/DebugInfo/CodeView/TypeRecordMapping.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeRecordMapping.cpp?rev=299388&r1=299387&r2=299388&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/TypeRecordMapping.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/TypeRecordMapping.cpp Mon Apr 3 16:25:20 2017
@@ -380,6 +380,11 @@ Error TypeRecordMapping::visitKnownRecor
return Error::success();
}
+Error TypeRecordMapping::visitKnownRecord(CVType &CVR, LabelRecord &Record) {
+ error(IO.mapEnum(Record.Mode));
+ return Error::success();
+}
+
Error TypeRecordMapping::visitKnownMember(CVMemberRecord &CVR,
BaseClassRecord &Record) {
error(IO.mapInteger(Record.Attrs.Attrs));
Modified: llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp?rev=299388&r1=299387&r2=299388&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp Mon Apr 3 16:25:20 2017
@@ -301,6 +301,10 @@ Error TypeStreamMerger::visitKnownRecord
return writeRecord(R, true);
}
+Error TypeStreamMerger::visitKnownRecord(CVType &, LabelRecord &R) {
+ return writeRecord(R, true);
+}
+
Error TypeStreamMerger::visitKnownRecord(CVType &, VFTableRecord &R) {
bool Success = true;
Success &= remapIndex(R.CompleteClass);
Added: llvm/trunk/test/tools/llvm-readobj/Inputs/codeview-label.obj
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/Inputs/codeview-label.obj?rev=299388&view=auto
==============================================================================
Binary file - no diff available.
Propchange: llvm/trunk/test/tools/llvm-readobj/Inputs/codeview-label.obj
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: llvm/trunk/test/tools/llvm-readobj/codeview-label.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/codeview-label.test?rev=299388&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-readobj/codeview-label.test (added)
+++ llvm/trunk/test/tools/llvm-readobj/codeview-label.test Mon Apr 3 16:25:20 2017
@@ -0,0 +1,16 @@
+; RUN: llvm-readobj -codeview %S/Inputs/codeview-label.obj | FileCheck %s
+
+; CHECK-LABEL: Label (0x1000) {
+; CHECK-NEXT: TypeLeafKind: LF_LABEL (0xE)
+; CHECK-NEXT: Mode: Near (0x0)
+; CHECK-NEXT: }
+
+; To reproduce codeview-label.obj:
+; $ cat codeview-label.asm
+; .model flat, C
+; .code
+; public foo
+; foo:
+; ret
+; end
+; $ ml -c -Zi codeview-label.asm
Modified: llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.cpp?rev=299388&r1=299387&r2=299388&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.cpp (original)
+++ llvm/trunk/tools/llvm-pdbdump/YamlTypeDumper.cpp Mon Apr 3 16:25:20 2017
@@ -194,6 +194,13 @@ template <> struct ScalarEnumerationTrai
}
};
+template <> struct ScalarEnumerationTraits<LabelType> {
+ static void enumeration(IO &IO, LabelType &Value) {
+ IO.enumCase(Value, "Near", LabelType::Near);
+ IO.enumCase(Value, "Far", LabelType::Far);
+ }
+};
+
template <> struct ScalarBitSetTraits<PointerOptions> {
static void bitset(IO &IO, PointerOptions &Options) {
IO.bitSetCase(Options, "None", PointerOptions::None);
@@ -431,6 +438,10 @@ void MappingTraits<BuildInfoRecord>::map
IO.mapRequired("ArgIndices", Args.ArgIndices);
}
+void MappingTraits<LabelRecord>::mapping(IO &IO, LabelRecord &R) {
+ IO.mapRequired("Mode", R.Mode);
+}
+
void MappingTraits<NestedTypeRecord>::mapping(IO &IO,
NestedTypeRecord &Nested) {
IO.mapRequired("Type", Nested.Type);
More information about the llvm-commits
mailing list