diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-06-26 20:32:52 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-06-26 20:32:52 +0000 | 
| commit | 08bbd35a80bf7765fe0d3043f9eb5a2f2786b649 (patch) | |
| tree | 80108f0f128657f8623f8f66ad9735b4d88e7b47 /include/llvm/DebugInfo/CodeView | |
| parent | 7c7aba6e5fef47a01a136be655b0a92cfd7090f6 (diff) | |
Notes
Diffstat (limited to 'include/llvm/DebugInfo/CodeView')
| -rw-r--r-- | include/llvm/DebugInfo/CodeView/CVRecord.h | 5 | ||||
| -rw-r--r-- | include/llvm/DebugInfo/CodeView/CodeView.h | 10 | ||||
| -rw-r--r-- | include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h | 12 | ||||
| -rw-r--r-- | include/llvm/DebugInfo/CodeView/EnumTables.h | 1 | ||||
| -rw-r--r-- | include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h | 41 | ||||
| -rw-r--r-- | include/llvm/DebugInfo/CodeView/SymbolRecord.h | 2 | ||||
| -rw-r--r-- | include/llvm/DebugInfo/CodeView/TypeDatabase.h | 84 | ||||
| -rw-r--r-- | include/llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h | 62 | ||||
| -rw-r--r-- | include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h | 6 | ||||
| -rw-r--r-- | include/llvm/DebugInfo/CodeView/TypeName.h | 22 | ||||
| -rw-r--r-- | include/llvm/DebugInfo/CodeView/TypeRecordMapping.h | 1 | ||||
| -rw-r--r-- | include/llvm/DebugInfo/CodeView/TypeSerializer.h | 1 | ||||
| -rw-r--r-- | include/llvm/DebugInfo/CodeView/TypeTableCollection.h | 11 | 
13 files changed, 86 insertions, 172 deletions
diff --git a/include/llvm/DebugInfo/CodeView/CVRecord.h b/include/llvm/DebugInfo/CodeView/CVRecord.h index 4c6bbedc6bbd..44040e04388a 100644 --- a/include/llvm/DebugInfo/CodeView/CVRecord.h +++ b/include/llvm/DebugInfo/CodeView/CVRecord.h @@ -27,9 +27,12 @@ namespace codeview {  template <typename Kind> class CVRecord {  public: -  CVRecord() = default; +  CVRecord() : Type(static_cast<Kind>(0)) {} +    CVRecord(Kind K, ArrayRef<uint8_t> Data) : Type(K), RecordData(Data) {} +  bool valid() const { return Type != static_cast<Kind>(0); } +    uint32_t length() const { return RecordData.size(); }    Kind kind() const { return Type; }    ArrayRef<uint8_t> data() const { return RecordData; } diff --git a/include/llvm/DebugInfo/CodeView/CodeView.h b/include/llvm/DebugInfo/CodeView/CodeView.h index 6820e26b754c..b7a7e33abadf 100644 --- a/include/llvm/DebugInfo/CodeView/CodeView.h +++ b/include/llvm/DebugInfo/CodeView/CodeView.h @@ -402,6 +402,16 @@ enum class LocalSymFlags : uint16_t {  };  CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(LocalSymFlags) +/// Corresponds to the CV_PUBSYMFLAGS bitfield. +enum class PublicSymFlags : uint32_t { +  None = 0, +  Code = 1 << 0, +  Function = 1 << 1, +  Managed = 1 << 2, +  MSIL = 1 << 3, +}; +CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(PublicSymFlags) +  /// Corresponds to the CV_PROCFLAGS bitfield.  enum class ProcSymFlags : uint8_t {    None = 0, diff --git a/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h b/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h index 694731742064..ee17b47d8e63 100644 --- a/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h +++ b/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h @@ -51,11 +51,23 @@ class DebugSubsectionRecordBuilder {  public:    DebugSubsectionRecordBuilder(std::shared_ptr<DebugSubsection> Subsection,                                 CodeViewContainer Container); + +  /// Use this to copy existing subsections directly from source to destination. +  /// For example, line table subsections in an object file only need to be +  /// relocated before being copied into the PDB. +  DebugSubsectionRecordBuilder(const DebugSubsectionRecord &Contents, +                               CodeViewContainer Container); +    uint32_t calculateSerializedLength();    Error commit(BinaryStreamWriter &Writer) const;  private: +  /// The subsection to build. Will be null if Contents is non-empty.    std::shared_ptr<DebugSubsection> Subsection; + +  /// The bytes of the subsection. Only non-empty if Subsection is null. +  DebugSubsectionRecord Contents; +    CodeViewContainer Container;  }; diff --git a/include/llvm/DebugInfo/CodeView/EnumTables.h b/include/llvm/DebugInfo/CodeView/EnumTables.h index 013e440613fc..5d54bb4cca84 100644 --- a/include/llvm/DebugInfo/CodeView/EnumTables.h +++ b/include/llvm/DebugInfo/CodeView/EnumTables.h @@ -22,6 +22,7 @@ namespace codeview {  ArrayRef<EnumEntry<SymbolKind>> getSymbolTypeNames();  ArrayRef<EnumEntry<TypeLeafKind>> getTypeLeafNames();  ArrayRef<EnumEntry<uint16_t>> getRegisterNames(); +ArrayRef<EnumEntry<uint32_t>> getPublicSymFlagNames();  ArrayRef<EnumEntry<uint8_t>> getProcSymFlagNames();  ArrayRef<EnumEntry<uint16_t>> getLocalFlagNames();  ArrayRef<EnumEntry<uint8_t>> getFrameCookieKindNames(); diff --git a/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h b/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h index 0d056e42b45f..8b1540abf903 100644 --- a/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h +++ b/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h @@ -11,18 +11,15 @@  #define LLVM_DEBUGINFO_CODEVIEW_LAZYRANDOMTYPECOLLECTION_H  #include "llvm/DebugInfo/CodeView/TypeCollection.h" -#include "llvm/DebugInfo/CodeView/TypeDatabase.h" -#include "llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h"  #include "llvm/DebugInfo/CodeView/TypeIndex.h"  #include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/Support/Allocator.h"  #include "llvm/Support/Error.h" +#include "llvm/Support/StringSaver.h"  namespace llvm {  namespace codeview { -class TypeDatabase; -class TypeVisitorCallbacks; -  /// \brief Provides amortized O(1) random access to a CodeView type stream.  /// Normally to access a type from a type stream, you must know its byte  /// offset into the type stream, because type records are variable-lengthed. @@ -47,6 +44,11 @@ class TypeVisitorCallbacks;  /// of O(N/M) and an amortized time of O(1).  class LazyRandomTypeCollection : public TypeCollection {    typedef FixedStreamArray<TypeIndexOffset> PartialOffsetArray; +  struct CacheEntry { +    CVType Type; +    uint32_t Offset; +    StringRef Name; +  };  public:    explicit LazyRandomTypeCollection(uint32_t RecordCountHint); @@ -56,8 +58,10 @@ public:                             PartialOffsetArray PartialOffsets);    LazyRandomTypeCollection(const CVTypeArray &Types, uint32_t RecordCountHint); -  void reset(ArrayRef<uint8_t> Data); -  void reset(StringRef Data); +  void reset(ArrayRef<uint8_t> Data, uint32_t RecordCountHint); +  void reset(StringRef Data, uint32_t RecordCountHint); + +  uint32_t getOffsetOfType(TypeIndex Index);    CVType getType(TypeIndex Index) override;    StringRef getTypeName(TypeIndex Index) override; @@ -68,27 +72,26 @@ public:    Optional<TypeIndex> getNext(TypeIndex Prev) override;  private: -  const TypeDatabase &database() const { return Database; }    Error ensureTypeExists(TypeIndex Index); +  void ensureCapacityFor(TypeIndex Index);    Error visitRangeForType(TypeIndex TI);    Error fullScanForType(TypeIndex TI); -  Error visitRange(TypeIndex Begin, uint32_t BeginOffset, TypeIndex End); -  Error visitOneRecord(TypeIndex TI, uint32_t Offset, CVType &Record); +  void visitRange(TypeIndex Begin, uint32_t BeginOffset, TypeIndex End); + +  /// Number of actual records. +  uint32_t Count = 0; -  /// Visited records get automatically added to the type database. -  TypeDatabase Database; +  /// The largest type index which we've visited. +  TypeIndex LargestTypeIndex = TypeIndex::None(); + +  BumpPtrAllocator Allocator; +  StringSaver NameStorage;    /// The type array to allow random access visitation of.    CVTypeArray Types; -  /// The database visitor which adds new records to the database. -  TypeDatabaseVisitor DatabaseVisitor; - -  /// A vector mapping type indices to type offset.  For every record that has -  /// been visited, contains the absolute offset of that record in the record -  /// array. -  std::vector<uint32_t> KnownOffsets; +  std::vector<CacheEntry> Records;    /// An array of index offsets for the given type stream, allowing log(N)    /// lookups of a type record by index.  Similar to KnownOffsets but only diff --git a/include/llvm/DebugInfo/CodeView/SymbolRecord.h b/include/llvm/DebugInfo/CodeView/SymbolRecord.h index 5f85ed28cb3a..1cf77fcdecbe 100644 --- a/include/llvm/DebugInfo/CodeView/SymbolRecord.h +++ b/include/llvm/DebugInfo/CodeView/SymbolRecord.h @@ -363,7 +363,7 @@ public:        : SymbolRecord(SymbolRecordKind::PublicSym32),          RecordOffset(RecordOffset) {} -  TypeIndex Index; +  PublicSymFlags Flags;    uint32_t Offset;    uint16_t Segment;    StringRef Name; diff --git a/include/llvm/DebugInfo/CodeView/TypeDatabase.h b/include/llvm/DebugInfo/CodeView/TypeDatabase.h deleted file mode 100644 index a743e7f70855..000000000000 --- a/include/llvm/DebugInfo/CodeView/TypeDatabase.h +++ /dev/null @@ -1,84 +0,0 @@ -//===- TypeDatabase.h - A collection of CodeView type records ---*- C++ -*-===// -// -//                     The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEDATABASE_H -#define LLVM_DEBUGINFO_CODEVIEW_TYPEDATABASE_H - -#include "llvm/ADT/BitVector.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/TypeCollection.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/Support/Allocator.h" -#include "llvm/Support/StringSaver.h" - -namespace llvm { -namespace codeview { -class TypeDatabase : public TypeCollection { -  friend class RandomAccessTypeVisitor; - -public: -  explicit TypeDatabase(uint32_t Capacity); - -  /// Records the name of a type, and reserves its type index. -  TypeIndex appendType(StringRef Name, const CVType &Data); - -  /// Records the name of a type, and reserves its type index. -  void recordType(StringRef Name, TypeIndex Index, const CVType &Data); - -  /// Saves the name in a StringSet and creates a stable StringRef. -  StringRef saveTypeName(StringRef TypeName); - -  StringRef getTypeName(TypeIndex Index) const; - -  const CVType &getTypeRecord(TypeIndex Index) const; -  CVType &getTypeRecord(TypeIndex Index); - -  bool contains(TypeIndex Index) const; -  uint32_t size() const; -  uint32_t capacity() const; -  bool empty() const; - -  CVType getType(TypeIndex Index) override; -  StringRef getTypeName(TypeIndex Index) override; -  bool contains(TypeIndex Index) override; -  uint32_t size() override; -  uint32_t capacity() override; - -  Optional<TypeIndex> getFirst() override; -  Optional<TypeIndex> getNext(TypeIndex Prev) override; - -  Optional<TypeIndex> largestTypeIndexLessThan(TypeIndex TI) const; - -private: -  TypeIndex getAppendIndex() const; - -  void grow(); -  void grow(TypeIndex Index); - -  BumpPtrAllocator Allocator; - -  uint32_t Count = 0; -  TypeIndex LargestTypeIndex; - -  /// All user defined type records in .debug$T live in here. Type indices -  /// greater than 0x1000 are user defined. Subtract 0x1000 from the index to -  /// index into this vector. -  SmallVector<StringRef, 10> CVUDTNames; -  SmallVector<CVType, 10> TypeRecords; - -  StringSaver TypeNameStorage; - -  BitVector ValidRecords; -}; -} -} - -#endif
\ No newline at end of file diff --git a/include/llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h b/include/llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h deleted file mode 100644 index 77dbc91a7d38..000000000000 --- a/include/llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h +++ /dev/null @@ -1,62 +0,0 @@ -//===-- TypeDatabaseVisitor.h -----------------------------------*- C++ -*-===// -// -//                     The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPEDATABASEVISITOR_H -#define LLVM_DEBUGINFO_CODEVIEW_TYPEDATABASEVISITOR_H - -#include "llvm/ADT/PointerUnion.h" - -#include "llvm/DebugInfo/CodeView/TypeDatabase.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" -#include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" - -namespace llvm { -namespace codeview { - -/// Dumper for CodeView type streams found in COFF object files and PDB files. -class TypeDatabaseVisitor : public TypeVisitorCallbacks { -public: -  explicit TypeDatabaseVisitor(TypeDatabase &TypeDB) : TypeDB(&TypeDB) {} - -  /// Paired begin/end actions for all types. Receives all record data, -  /// including the fixed-length record prefix. -  Error visitTypeBegin(CVType &Record) override; -  Error visitTypeBegin(CVType &Record, TypeIndex Index) override; -  Error visitTypeEnd(CVType &Record) override; -  Error visitMemberBegin(CVMemberRecord &Record) override; -  Error visitMemberEnd(CVMemberRecord &Record) override; - -#define TYPE_RECORD(EnumName, EnumVal, Name)                                   \ -  Error visitKnownRecord(CVType &CVR, Name##Record &Record) override; -#define MEMBER_RECORD(EnumName, EnumVal, Name)                                 \ -  Error visitKnownMember(CVMemberRecord &CVR, Name##Record &Record) override; -#define TYPE_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) -#include "llvm/DebugInfo/CodeView/CodeViewTypes.def" - -private: -  StringRef getTypeName(TypeIndex Index) const; -  StringRef saveTypeName(StringRef Name); - -  bool IsInFieldList = false; - -  /// Name of the current type. Only valid before visitTypeEnd. -  StringRef Name; -  /// Current type index.  Only valid before visitTypeEnd, and if we are -  /// visiting a random access type database. -  Optional<TypeIndex> CurrentTypeIndex; - -  TypeDatabase *TypeDB; -}; - -} // end namespace codeview -} // end namespace llvm - -#endif // LLVM_DEBUGINFO_CODEVIEW_TYPEDUMPER_H diff --git a/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h b/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h index 82ceb5038316..c393b42cd27c 100644 --- a/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h +++ b/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h @@ -11,6 +11,7 @@  #define LLVM_DEBUGINFO_CODEVIEW_TYPEINDEXDISCOVERY_H  #include "llvm/ADT/SmallVector.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h"  #include "llvm/DebugInfo/CodeView/TypeRecord.h"  #include "llvm/Support/Error.h" @@ -27,6 +28,11 @@ void discoverTypeIndices(ArrayRef<uint8_t> RecordData,                           SmallVectorImpl<TiReference> &Refs);  void discoverTypeIndices(const CVType &Type,                           SmallVectorImpl<TiReference> &Refs); + +/// Discover type indices in symbol records. Returns false if this is an unknown +/// record. +bool discoverTypeIndices(const CVSymbol &Symbol, +                         SmallVectorImpl<TiReference> &Refs);  }  } diff --git a/include/llvm/DebugInfo/CodeView/TypeName.h b/include/llvm/DebugInfo/CodeView/TypeName.h new file mode 100644 index 000000000000..a987b4afd283 --- /dev/null +++ b/include/llvm/DebugInfo/CodeView/TypeName.h @@ -0,0 +1,22 @@ +//===- TypeName.h --------------------------------------------- *- C++ --*-===// +// +//                     The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_DEBUGINFO_CODEVIEW_TYPENAME_H +#define LLVM_DEBUGINFO_CODEVIEW_TYPENAME_H + +#include "llvm/DebugInfo/CodeView/TypeCollection.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" + +namespace llvm { +namespace codeview { +std::string computeTypeName(TypeCollection &Types, TypeIndex Index); +} +} // namespace llvm + +#endif diff --git a/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h b/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h index 6156223b2560..cbe8d6066bb9 100644 --- a/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h +++ b/include/llvm/DebugInfo/CodeView/TypeRecordMapping.h @@ -25,6 +25,7 @@ public:    explicit TypeRecordMapping(BinaryStreamReader &Reader) : IO(Reader) {}    explicit TypeRecordMapping(BinaryStreamWriter &Writer) : IO(Writer) {} +  using TypeVisitorCallbacks::visitTypeBegin;    Error visitTypeBegin(CVType &Record) override;    Error visitTypeEnd(CVType &Record) override; diff --git a/include/llvm/DebugInfo/CodeView/TypeSerializer.h b/include/llvm/DebugInfo/CodeView/TypeSerializer.h index f785d4509547..988a2d4aa834 100644 --- a/include/llvm/DebugInfo/CodeView/TypeSerializer.h +++ b/include/llvm/DebugInfo/CodeView/TypeSerializer.h @@ -93,6 +93,7 @@ public:    TypeIndex insertRecord(const RemappedType &Record);    Expected<TypeIndex> visitTypeEndGetIndex(CVType &Record); +  using TypeVisitorCallbacks::visitTypeBegin;    Error visitTypeBegin(CVType &Record) override;    Error visitTypeEnd(CVType &Record) override;    Error visitMemberBegin(CVMemberRecord &Record) override; diff --git a/include/llvm/DebugInfo/CodeView/TypeTableCollection.h b/include/llvm/DebugInfo/CodeView/TypeTableCollection.h index 42b62ba2b6ce..80326a0ffd39 100644 --- a/include/llvm/DebugInfo/CodeView/TypeTableCollection.h +++ b/include/llvm/DebugInfo/CodeView/TypeTableCollection.h @@ -11,7 +11,9 @@  #define LLVM_DEBUGINFO_CODEVIEW_TYPETABLECOLLECTION_H  #include "llvm/DebugInfo/CodeView/TypeCollection.h" -#include "llvm/DebugInfo/CodeView/TypeDatabase.h" +#include "llvm/Support/StringSaver.h" + +#include <vector>  namespace llvm {  namespace codeview { @@ -30,11 +32,10 @@ public:    uint32_t capacity() override;  private: -  bool hasCapacityFor(TypeIndex Index) const; -  void ensureTypeExists(TypeIndex Index); - +  BumpPtrAllocator Allocator; +  StringSaver NameStorage; +  std::vector<StringRef> Names;    ArrayRef<ArrayRef<uint8_t>> Records; -  TypeDatabase Database;  };  }  }  | 
