[llvm] r270637 - [codeview] Add support for new types and symbols.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Tue May 24 17:12:48 PDT 2016


Author: zturner
Date: Tue May 24 19:12:48 2016
New Revision: 270637

URL: http://llvm.org/viewvc/llvm-project?rev=270637&view=rev
Log:
[codeview] Add support for new types and symbols.

This patch adds support for:

S_EXPORT
LF_BITFIELD

With this patch, I have run through a couple of gigabytes of PDB
files and cannot find a type or symbol that we do not understand.

Modified:
    llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h
    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/TypeDumper.cpp
    llvm/trunk/lib/DebugInfo/CodeView/TypeRecord.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h?rev=270637&r1=270636&r2=270637&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/CVTypeVisitor.h Tue May 24 19:12:48 2016
@@ -58,7 +58,7 @@ public:
     DerivedThis->visitTypeBegin(Record.Type, RecordData);
     switch (Record.Type) {
     default:
-      DerivedThis->visitUnknownType(Record.Type);
+      DerivedThis->visitUnknownType(Record.Type, RecordData);
       break;
     case LF_FIELDLIST:
       DerivedThis->visitFieldList(Record.Type, LeafData);
@@ -90,7 +90,7 @@ public:
   }
 
   /// Action to take on unknown types. By default, they are ignored.
-  void visitUnknownType(TypeLeafKind Leaf) {}
+  void visitUnknownType(TypeLeafKind Leaf, ArrayRef<uint8_t> RecordData) {}
 
   /// Paired begin/end actions for all types. Receives all record data,
   /// including the fixed-length record prefix.

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=270637&r1=270636&r2=270637&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/CodeView.h Tue May 24 19:12:48 2016
@@ -23,7 +23,6 @@ enum class TypeRecordKind : uint16_t {
 #include "TypeRecords.def"
   // FIXME: Add serialization support
   FieldList = 0x1203,
-  BitField = 0x1205,
 };
 
 /// Duplicate copy of the above enum, but using the official CV names. Useful

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=270637&r1=270636&r2=270637&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h Tue May 24 19:12:48 2016
@@ -705,17 +705,36 @@ private:
   TypeIndex UnderlyingType;
 };
 
+// LF_BITFIELD
 class BitFieldRecord : public TypeRecord {
 public:
   BitFieldRecord(TypeIndex Type, uint8_t BitSize, uint8_t BitOffset)
       : TypeRecord(TypeRecordKind::BitField), Type(Type), BitSize(BitSize),
         BitOffset(BitOffset) {}
 
+  /// Rewrite member type indices with IndexMap. Returns false if a type index
+  /// is not in the map.
+  bool remapTypeIndices(ArrayRef<TypeIndex> IndexMap);
+
+  static ErrorOr<BitFieldRecord> deserialize(TypeRecordKind Kind,
+                                             ArrayRef<uint8_t> &Data) {
+    const Layout *L = nullptr;
+    CV_DESERIALIZE(Data, L);
+
+    return BitFieldRecord(L->Type, L->BitSize, L->BitOffset);
+  }
+
   TypeIndex getType() const { return Type; }
   uint8_t getBitOffset() const { return BitOffset; }
   uint8_t getBitSize() const { return BitSize; }
 
 private:
+  struct Layout {
+    TypeIndex Type;
+    uint8_t BitSize;
+    uint8_t BitOffset;
+  };
+
   TypeIndex Type;
   uint8_t BitSize;
   uint8_t BitOffset;

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=270637&r1=270636&r2=270637&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecords.def (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecords.def Tue May 24 19:12:48 2016
@@ -53,6 +53,8 @@ TYPE_RECORD(LF_TYPESERVER2, 0x1515, Type
 TYPE_RECORD(LF_VFTABLE, 0x151d, VFTable)
 TYPE_RECORD(LF_VTSHAPE, 0x000a, VFTableShape)
 
+TYPE_RECORD(LF_BITFIELD, 0x1205, BitField)
+
 // Member type records. These are generally not length prefixed, and appear
 // inside of a field list record.
 MEMBER_RECORD(LF_BCLASS, 0x1400, BaseClass)
@@ -156,7 +158,6 @@ CV_TYPE(LF_SKIP, 0x1200)
 CV_TYPE(LF_DEFARG_ST, 0x1202)
 CV_TYPE(LF_FIELDLIST, 0x1203)
 CV_TYPE(LF_DERIVED, 0x1204)
-CV_TYPE(LF_BITFIELD, 0x1205)
 CV_TYPE(LF_DIMCONU, 0x1207)
 CV_TYPE(LF_DIMCONLU, 0x1208)
 CV_TYPE(LF_DIMVARU, 0x1209)

Modified: llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp?rev=270637&r1=270636&r2=270637&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp Tue May 24 19:12:48 2016
@@ -209,6 +209,7 @@ public:
 #include "llvm/DebugInfo/CodeView/TypeRecords.def"
 
   void visitUnknownMember(TypeLeafKind Leaf);
+  void visitUnknownType(TypeLeafKind Leaf, ArrayRef<uint8_t> LeafData);
 
   void visitTypeBegin(TypeLeafKind Leaf, ArrayRef<uint8_t> LeafData);
   void visitTypeEnd(TypeLeafKind Leaf, ArrayRef<uint8_t> LeafData);
@@ -493,6 +494,13 @@ void CVTypeDumperImpl::visitModifier(Typ
   Name = CVTD.saveName(TypeName);
 }
 
+void CVTypeDumperImpl::visitBitField(TypeLeafKind Leaf,
+                                     BitFieldRecord &BitField) {
+  printTypeIndex("Type", BitField.getType());
+  W.printNumber("BitSize", BitField.getBitSize());
+  W.printNumber("BitOffset", BitField.getBitOffset());
+}
+
 void CVTypeDumperImpl::visitVFTableShape(TypeLeafKind Leaf,
                                          VFTableShapeRecord &Shape) {
   W.printNumber("VFEntryCount", Shape.getEntryCount());
@@ -538,6 +546,13 @@ void CVTypeDumperImpl::visitUnknownMembe
   W.printHex("UnknownMember", unsigned(Leaf));
 }
 
+void CVTypeDumperImpl::visitUnknownType(TypeLeafKind Leaf,
+                                        ArrayRef<uint8_t> RecordData) {
+  DictScope S(W, "UnknownType");
+  W.printEnum("Kind", uint16_t(Leaf), makeArrayRef(LeafTypeNames));
+  W.printNumber("Length", uint32_t(RecordData.size()));
+}
+
 void CVTypeDumperImpl::visitNestedType(TypeLeafKind Leaf,
                                        NestedTypeRecord &Nested) {
   DictScope S(W, "NestedType");

Modified: llvm/trunk/lib/DebugInfo/CodeView/TypeRecord.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeRecord.cpp?rev=270637&r1=270636&r2=270637&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/TypeRecord.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/TypeRecord.cpp Tue May 24 19:12:48 2016
@@ -105,6 +105,10 @@ bool EnumRecord::remapTypeIndices(ArrayR
   return Success;
 }
 
+bool BitFieldRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
+  return remapIndex(IndexMap, Type);
+}
+
 bool VFTableShapeRecord::remapTypeIndices(ArrayRef<TypeIndex> IndexMap) {
   return true;
 }




More information about the llvm-commits mailing list