]> granicus.if.org Git - llvm/commitdiff
[Codeview] Add a class for LF_UDT_MOD_SRC_LINE.
authorRui Ueyama <ruiu@google.com>
Wed, 15 Jun 2016 21:25:29 +0000 (21:25 +0000)
committerRui Ueyama <ruiu@google.com>
Wed, 15 Jun 2016 21:25:29 +0000 (21:25 +0000)
Differential Revision: http://reviews.llvm.org/D21406

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272843 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo/CodeView/TypeRecord.h
include/llvm/DebugInfo/CodeView/TypeRecords.def
include/llvm/DebugInfo/CodeView/TypeTableBuilder.h
lib/DebugInfo/CodeView/TypeDumper.cpp
lib/DebugInfo/CodeView/TypeRecord.cpp
lib/DebugInfo/CodeView/TypeTableBuilder.cpp
test/DebugInfo/PDB/pdbdump-headers.test

index 090922d79f149f84a9ddd1f3e0112bef1585bcb0..17f31e12db1b492e839edfa982701f3ab2739ec1 100644 (file)
@@ -767,6 +767,44 @@ private:
   uint32_t LineNumber;
 };
 
+// LF_UDT_MOD_SRC_LINE
+class UdtModSourceLineRecord : public TypeRecord {
+public:
+  UdtModSourceLineRecord(TypeIndex UDT, TypeIndex SourceFile,
+                         uint32_t LineNumber, uint16_t Module)
+      : TypeRecord(TypeRecordKind::UdtSourceLine), UDT(UDT),
+        SourceFile(SourceFile), LineNumber(LineNumber), Module(Module) {}
+
+  bool remapTypeIndices(ArrayRef<TypeIndex> IndexMap);
+
+  static ErrorOr<UdtModSourceLineRecord> deserialize(TypeRecordKind Kind,
+                                                     ArrayRef<uint8_t> &Data) {
+    const Layout *L = nullptr;
+    CV_DESERIALIZE(Data, L);
+
+    return UdtModSourceLineRecord(L->UDT, L->SourceFile, L->LineNumber,
+                                  L->Module);
+  }
+
+  TypeIndex getUDT() const { return UDT; }
+  TypeIndex getSourceFile() const { return SourceFile; }
+  uint32_t getLineNumber() const { return LineNumber; }
+  uint16_t getModule() const { return Module; }
+
+private:
+  struct Layout {
+    TypeIndex UDT;        // The user-defined type
+    TypeIndex SourceFile; // StringID containing the source filename
+    ulittle32_t LineNumber;
+    ulittle16_t Module; // Module that contributes this UDT definition
+  };
+
+  TypeIndex UDT;
+  TypeIndex SourceFile;
+  uint32_t LineNumber;
+  uint16_t Module;
+};
+
 // LF_BUILDINFO
 class BuildInfoRecord : public TypeRecord {
 public:
index e2824f1757e223e61983f8ec505711b60b4b9343..5f10b72c53016f5729bb63e84410f20639f18967 100644 (file)
@@ -81,6 +81,7 @@ TYPE_RECORD(LF_BUILDINFO, 0x1603, BuildInfo)
 TYPE_RECORD_ALIAS(LF_SUBSTR_LIST, 0x1604, StringList, ArgList)
 TYPE_RECORD(LF_STRING_ID, 0x1605, StringId)
 TYPE_RECORD(LF_UDT_SRC_LINE, 0x1606, UdtSourceLine)
+TYPE_RECORD(LF_UDT_MOD_SRC_LINE, 0x1607, UdtModSourceLine)
 
 TYPE_RECORD(LF_METHODLIST, 0x1206, MethodOverloadList)
 
@@ -194,10 +195,6 @@ CV_TYPE(LF_MODIFIER_EX, 0x1518)
 CV_TYPE(LF_VECTOR, 0x151b)
 CV_TYPE(LF_MATRIX, 0x151c)
 
-// ID leaf records. Subsequent leaf types may be referenced from .debug$S.
-
-CV_TYPE(LF_UDT_MOD_SRC_LINE, 0x1607)
-
 // Numeric leaf types. These are generally contained in other records, and not
 // encountered in the main type stream.
 
index e180390fccf297a964f86dc73a16cb30124dac75..5b2aa6186147029d733bbce0be0b3a34f5822524 100644 (file)
@@ -51,6 +51,7 @@ public:
   TypeIndex writeStringId(const StringIdRecord &Record);
   TypeIndex writeVFTable(const VFTableRecord &Record);
   TypeIndex writeUdtSourceLine(const UdtSourceLineRecord &Record);
+  TypeIndex writeUdtModSourceLine(const UdtModSourceLineRecord &Record);
   TypeIndex writeFuncId(const FuncIdRecord &Record);
   TypeIndex writeMemberFuncId(const MemberFuncIdRecord &Record);
   TypeIndex writeBuildInfo(const BuildInfoRecord &Record);
index 42cb0aa1fd23474fb3cb053dba4089682dbdc145..3aba50efb874c569d1c9dd40479356294e93e9b9 100644 (file)
@@ -514,6 +514,14 @@ void CVTypeDumperImpl::visitUdtSourceLine(TypeLeafKind Leaf,
   W.printNumber("LineNumber", Line.getLineNumber());
 }
 
+void CVTypeDumperImpl::visitUdtModSourceLine(TypeLeafKind Leaf,
+                                             UdtModSourceLineRecord &Line) {
+  printTypeIndex("UDT", Line.getUDT());
+  printTypeIndex("SourceFile", Line.getSourceFile());
+  W.printNumber("LineNumber", Line.getLineNumber());
+  W.printNumber("Module", Line.getModule());
+}
+
 void CVTypeDumperImpl::visitBuildInfo(TypeLeafKind Leaf,
                                       BuildInfoRecord &Args) {
   W.printNumber("NumArgs", static_cast<uint32_t>(Args.getArgs().size()));
index bce6ebc337e2d0f5af741ca1b8fbabb9b42475c7..cc09abcd988262bd1fe6909047b85f02ffa25e96 100644 (file)
@@ -491,6 +491,13 @@ bool UdtSourceLineRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
   return Success;
 }
 
+bool UdtModSourceLineRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
+  bool Success = true;
+  Success &= remapIndex(IndexMap, UDT);
+  Success &= remapIndex(IndexMap, SourceFile);
+  return Success;
+}
+
 bool BuildInfoRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
   bool Success = true;
   for (TypeIndex &Arg : ArgIndices)
index 13d1ae50069de83c55eef4196f7ff935abce010d..7ac9581db3f7860d0d68261639a5081687044d34 100644 (file)
@@ -226,7 +226,16 @@ TypeTableBuilder::writeUdtSourceLine(const UdtSourceLineRecord &Record) {
 }
 
 TypeIndex
-TypeTableBuilder::writeFuncId(const FuncIdRecord &Record) {
+TypeTableBuilder::writeUdtModSourceLine(const UdtModSourceLineRecord &Record) {
+  TypeRecordBuilder Builder(Record.getKind());
+  Builder.writeTypeIndex(Record.getUDT());
+  Builder.writeTypeIndex(Record.getSourceFile());
+  Builder.writeUInt32(Record.getLineNumber());
+  Builder.writeUInt16(Record.getModule());
+  return writeRecord(Builder);
+}
+
+TypeIndex TypeTableBuilder::writeFuncId(const FuncIdRecord &Record) {
   TypeRecordBuilder Builder(Record.getKind());
   Builder.writeTypeIndex(Record.getParentScope());
   Builder.writeTypeIndex(Record.getFunctionType());
index 2294da691824b67c3d3bf9a00f8bc6fafe272726..2539f00505e84f1104a1ba9fd6716a7ed1a94785 100644 (file)
 ; EMPTY-NEXT:     Record count: 15
 ; EMPTY-NEXT:     Records [
 ; EMPTY-NEXT:       {
-; EMPTY-NEXT:         UnknownLeaf (0x104B) {
+; EMPTY-NEXT:         UdtModSourceLine (0x104B) {
 ; EMPTY-NEXT:           TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
-; EMPTY-NEXT:           UnknownType {
-; EMPTY-NEXT:             Kind: LF_UDT_MOD_SRC_LINE (0x1607)
-; EMPTY-NEXT:             Length: 16
-; EMPTY-NEXT:           }
+; EMPTY-NEXT:           UDT: __vc_attributes::threadingAttribute (0x100B)
+; EMPTY-NEXT:           SourceFile: <unknown simple type> (0x1)
+; EMPTY-NEXT:           LineNumber: 481
+; EMPTY-NEXT:           Module: 1
 ; EMPTY-NEXT:         }
 ; EMPTY-NEXT:         Bytes (
 ; EMPTY-NEXT:           0000: 0B100000 01000000 E1010000 0100F2F1  |................|
 ; EMPTY-NEXT:         )
 ; EMPTY-NEXT:       }
 ; EMPTY-NEXT:       {
-; EMPTY-NEXT:         UnknownLeaf (0x104C) {
+; EMPTY-NEXT:         UdtModSourceLine (0x104C) {
 ; EMPTY-NEXT:           TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
-; EMPTY-NEXT:           UnknownType {
-; EMPTY-NEXT:             Kind: LF_UDT_MOD_SRC_LINE (0x1607)
-; EMPTY-NEXT:             Length: 16
-; EMPTY-NEXT:           }
+; EMPTY-NEXT:           UDT: __vc_attributes::event_receiverAttribute (0x1017)
+; EMPTY-NEXT:           SourceFile: <unknown simple type> (0x1)
+; EMPTY-NEXT:           LineNumber: 194
+; EMPTY-NEXT:           Module: 1
 ; EMPTY-NEXT:         }
 ; EMPTY-NEXT:         Bytes (
 ; EMPTY-NEXT:           0000: 17100000 01000000 C2000000 0100F2F1  |................|
 ; EMPTY-NEXT:         )
 ; EMPTY-NEXT:       }
 ; EMPTY-NEXT:       {
-; EMPTY-NEXT:         UnknownLeaf (0x104D) {
+; EMPTY-NEXT:         UdtModSourceLine (0x104D) {
 ; EMPTY-NEXT:           TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
-; EMPTY-NEXT:           UnknownType {
-; EMPTY-NEXT:             Kind: LF_UDT_MOD_SRC_LINE (0x1607)
-; EMPTY-NEXT:             Length: 16
-; EMPTY-NEXT:           }
+; EMPTY-NEXT:           UDT: __vc_attributes::aggregatableAttribute (0x1021)
+; EMPTY-NEXT:           SourceFile: <unknown simple type> (0x1)
+; EMPTY-NEXT:           LineNumber: 603
+; EMPTY-NEXT:           Module: 1
 ; EMPTY-NEXT:         }
 ; EMPTY-NEXT:         Bytes (
 ; EMPTY-NEXT:           0000: 21100000 01000000 5B020000 0100F2F1  |!.......[.......|
 ; EMPTY-NEXT:         )
 ; EMPTY-NEXT:       }
 ; EMPTY-NEXT:       {
-; EMPTY-NEXT:         UnknownLeaf (0x104E) {
+; EMPTY-NEXT:         UdtModSourceLine (0x104E) {
 ; EMPTY-NEXT:           TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
-; EMPTY-NEXT:           UnknownType {
-; EMPTY-NEXT:             Kind: LF_UDT_MOD_SRC_LINE (0x1607)
-; EMPTY-NEXT:             Length: 16
-; EMPTY-NEXT:           }
+; EMPTY-NEXT:           UDT: __vc_attributes::event_sourceAttribute (0x102C)
+; EMPTY-NEXT:           SourceFile: <unknown simple type> (0x1)
+; EMPTY-NEXT:           LineNumber: 1200
+; EMPTY-NEXT:           Module: 1
 ; EMPTY-NEXT:         }
 ; EMPTY-NEXT:         Bytes (
 ; EMPTY-NEXT:           0000: 2C100000 01000000 B0040000 0100F2F1  |,...............|
 ; EMPTY-NEXT:         )
 ; EMPTY-NEXT:       }
 ; EMPTY-NEXT:       {
-; EMPTY-NEXT:         UnknownLeaf (0x104F) {
+; EMPTY-NEXT:         UdtModSourceLine (0x104F) {
 ; EMPTY-NEXT:           TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
-; EMPTY-NEXT:           UnknownType {
-; EMPTY-NEXT:             Kind: LF_UDT_MOD_SRC_LINE (0x1607)
-; EMPTY-NEXT:             Length: 16
-; EMPTY-NEXT:           }
+; EMPTY-NEXT:           UDT: __vc_attributes::moduleAttribute (0x103A)
+; EMPTY-NEXT:           SourceFile: <unknown simple type> (0x1)
+; EMPTY-NEXT:           LineNumber: 540
+; EMPTY-NEXT:           Module: 1
 ; EMPTY-NEXT:         }
 ; EMPTY-NEXT:         Bytes (
 ; EMPTY-NEXT:           0000: 3A100000 01000000 1C020000 0100F2F1  |:...............|
 ; EMPTY-NEXT:         )
 ; EMPTY-NEXT:       }
 ; EMPTY-NEXT:       {
-; EMPTY-NEXT:         UnknownLeaf (0x1050) {
+; EMPTY-NEXT:         UdtModSourceLine (0x1050) {
 ; EMPTY-NEXT:           TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
-; EMPTY-NEXT:           UnknownType {
-; EMPTY-NEXT:             Kind: LF_UDT_MOD_SRC_LINE (0x1607)
-; EMPTY-NEXT:             Length: 16
-; EMPTY-NEXT:           }
+; EMPTY-NEXT:           UDT: __vc_attributes::helper_attributes::usageAttribute (0x1042)
+; EMPTY-NEXT:           SourceFile: <unknown simple type> (0x1)
+; EMPTY-NEXT:           LineNumber: 108
+; EMPTY-NEXT:           Module: 1
 ; EMPTY-NEXT:         }
 ; EMPTY-NEXT:         Bytes (
 ; EMPTY-NEXT:           0000: 42100000 01000000 6C000000 0100F2F1  |B.......l.......|
 ; ALL:   Record count: 15
 ; ALL:   Records [
 ; ALL:     {
-; ALL:       UnknownLeaf (0x104B) {
+; ALL:       UdtModSourceLine (0x104B) {
 ; ALL:         TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
-; ALL:         UnknownType {
-; ALL:           Kind: LF_UDT_MOD_SRC_LINE (0x1607)
-; ALL:           Length: 16
-; ALL:         }
+; ALL:         UDT: __vc_attributes::threadingAttribute (0x100B)
+; ALL:         SourceFile: <unknown simple type> (0x1)
+; ALL:         LineNumber: 481
+; ALL:         Module: 1
 ; ALL:       }
 ; ALL:     }
 ; ALL:     {
-; ALL:       UnknownLeaf (0x104C) {
+; ALL:       UdtModSourceLine (0x104C) {
 ; ALL:         TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
-; ALL:         UnknownType {
-; ALL:           Kind: LF_UDT_MOD_SRC_LINE (0x1607)
-; ALL:           Length: 16
-; ALL:         }
+; ALL:         UDT: __vc_attributes::event_receiverAttribute (0x1017)
+; ALL:         SourceFile: <unknown simple type> (0x1)
+; ALL:         LineNumber: 194
+; ALL:         Module: 1
 ; ALL:       }
 ; ALL:     }
 ; ALL:     {
-; ALL:       UnknownLeaf (0x104D) {
+; ALL:       UdtModSourceLine (0x104D) {
 ; ALL:         TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
-; ALL:         UnknownType {
-; ALL:           Kind: LF_UDT_MOD_SRC_LINE (0x1607)
-; ALL:           Length: 16
-; ALL:         }
+; ALL:         UDT: __vc_attributes::aggregatableAttribute (0x1021)
+; ALL:         SourceFile: <unknown simple type> (0x1)
+; ALL:         LineNumber: 603
+; ALL:         Module: 1
 ; ALL:       }
 ; ALL:     }
 ; ALL:     {
-; ALL:       UnknownLeaf (0x104E) {
+; ALL:       UdtModSourceLine (0x104E) {
 ; ALL:         TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
-; ALL:         UnknownType {
-; ALL:           Kind: LF_UDT_MOD_SRC_LINE (0x1607)
-; ALL:           Length: 16
-; ALL:         }
+; ALL:         UDT: __vc_attributes::event_sourceAttribute (0x102C)
+; ALL:         SourceFile: <unknown simple type> (0x1)
+; ALL:         LineNumber: 1200
+; ALL:         Module: 1
 ; ALL:       }
 ; ALL:     }
 ; ALL:     {
-; ALL:       UnknownLeaf (0x104F) {
+; ALL:       UdtModSourceLine (0x104F) {
 ; ALL:         TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
-; ALL:         UnknownType {
-; ALL:           Kind: LF_UDT_MOD_SRC_LINE (0x1607)
-; ALL:           Length: 16
-; ALL:         }
+; ALL:         UDT: __vc_attributes::moduleAttribute (0x103A)
+; ALL:         SourceFile: <unknown simple type> (0x1)
+; ALL:         LineNumber: 540
+; ALL:         Module: 1
 ; ALL:       }
 ; ALL:     }
 ; ALL:     {
-; ALL:       UnknownLeaf (0x1050) {
+; ALL:       UdtModSourceLine (0x1050) {
 ; ALL:         TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
-; ALL:         UnknownType {
-; ALL:           Kind: LF_UDT_MOD_SRC_LINE (0x1607)
-; ALL:           Length: 16
-; ALL:         }
+; ALL:         UDT: __vc_attributes::helper_attributes::usageAttribute (0x1042)
+; ALL:         SourceFile: <unknown simple type> (0x1)
+; ALL:         LineNumber: 108
+; ALL:         Module: 1
 ; ALL:       }
 ; ALL:     }
 ; ALL:     {
-; ALL:       UnknownLeaf (0x1051) {
+; ALL:       UdtModSourceLine (0x1051) {
 ; ALL:         TypeLeafKind: LF_UDT_MOD_SRC_LINE (0x1607)
-; ALL:         UnknownType {
-; ALL:           Kind: LF_UDT_MOD_SRC_LINE (0x1607)
-; ALL:           Length: 16
-; ALL:         }
+; ALL:         UDT: __vc_attributes::helper_attributes::v1_alttypeAttribute (0x104A)
+; ALL:         SourceFile: <unknown simple type> (0x1)
+; ALL:         LineNumber: 96
+; ALL:         Module: 1
 ; ALL:       }
 ; ALL:     }
 ; ALL:     {