diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-06-16 21:03:24 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-06-16 21:03:24 +0000 | 
| commit | 7c7aba6e5fef47a01a136be655b0a92cfd7090f6 (patch) | |
| tree | 99ec531924f6078534b100ab9d7696abce848099 /include/llvm/DebugInfo | |
| parent | 7ab83427af0f77b59941ceba41d509d7d097b065 (diff) | |
Notes
Diffstat (limited to 'include/llvm/DebugInfo')
23 files changed, 214 insertions, 95 deletions
diff --git a/include/llvm/DebugInfo/CodeView/CodeView.h b/include/llvm/DebugInfo/CodeView/CodeView.h index 251c9d1ae62c..6820e26b754c 100644 --- a/include/llvm/DebugInfo/CodeView/CodeView.h +++ b/include/llvm/DebugInfo/CodeView/CodeView.h @@ -418,6 +418,8 @@ CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(ProcSymFlags)  /// Corresponds to COMPILESYM2::Flags bitfield.  enum class CompileSym2Flags : uint32_t { +  None = 0, +  SourceLanguageMask = 0xFF,    EC = 1 << 8,    NoDbgInfo = 1 << 9,    LTCG = 1 << 10, @@ -432,6 +434,8 @@ CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(CompileSym2Flags)  /// Corresponds to COMPILESYM3::Flags bitfield.  enum class CompileSym3Flags : uint32_t { +  None = 0, +  SourceLanguageMask = 0xFF,    EC = 1 << 8,    NoDbgInfo = 1 << 9,    LTCG = 1 << 10, @@ -448,6 +452,7 @@ enum class CompileSym3Flags : uint32_t {  CV_DEFINE_ENUM_CLASS_FLAGS_OPERATORS(CompileSym3Flags)  enum class ExportFlags : uint16_t { +  None = 0,    IsConstant = 1 << 0,    IsData = 1 << 1,    IsPrivate = 1 << 2, diff --git a/include/llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h b/include/llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h index 686b5c4f242e..1e329c7c3f14 100644 --- a/include/llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h +++ b/include/llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h @@ -49,6 +49,7 @@ public:    Error commit(BinaryStreamWriter &Writer) const override;    void addFrameData(const FrameData &Frame); +  void setFrames(ArrayRef<FrameData> Frames);  private:    std::vector<FrameData> Frames; diff --git a/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h b/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h index c9b062717baa..7484af663105 100644 --- a/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h +++ b/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h @@ -19,7 +19,7 @@  namespace llvm {  namespace codeview { -class DebugInlineeLinesSubsectionsRef; +class DebugInlineeLinesSubsectionRef;  class DebugChecksumsSubsection;  enum class InlineeLinesSignature : uint32_t { diff --git a/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h b/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h index 49a269d92e35..694731742064 100644 --- a/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h +++ b/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h @@ -49,13 +49,13 @@ private:  class DebugSubsectionRecordBuilder {  public: -  DebugSubsectionRecordBuilder(std::unique_ptr<DebugSubsection> Subsection, +  DebugSubsectionRecordBuilder(std::shared_ptr<DebugSubsection> Subsection,                                 CodeViewContainer Container);    uint32_t calculateSerializedLength();    Error commit(BinaryStreamWriter &Writer) const;  private: -  std::unique_ptr<DebugSubsection> Subsection; +  std::shared_ptr<DebugSubsection> Subsection;    CodeViewContainer Container;  }; @@ -64,6 +64,9 @@ private:  template <> struct VarStreamArrayExtractor<codeview::DebugSubsectionRecord> {    Error operator()(BinaryStreamRef Stream, uint32_t &Length,                     codeview::DebugSubsectionRecord &Info) { +    // FIXME: We need to pass the container type through to this function.  In +    // practice this isn't super important since the subsection header describes +    // its length and we can just skip it.  It's more important when writing.      if (auto EC = codeview::DebugSubsectionRecord::initialize(              Stream, Info, codeview::CodeViewContainer::Pdb))        return EC; diff --git a/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h b/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h index d4a3d9195a36..75f749dfa933 100644 --- a/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h +++ b/include/llvm/DebugInfo/CodeView/DebugSubsectionVisitor.h @@ -12,6 +12,7 @@  #include "llvm/DebugInfo/CodeView/CodeView.h"  #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h" +#include "llvm/DebugInfo/CodeView/StringsAndChecksums.h"  #include "llvm/Support/Error.h"  #include <cstdint> @@ -30,56 +31,7 @@ class DebugStringTableSubsectionRef;  class DebugSymbolRVASubsectionRef;  class DebugSymbolsSubsectionRef;  class DebugUnknownSubsectionRef; - -struct DebugSubsectionState { -public: -  // If no subsections are known about initially, we find as much as we can. -  DebugSubsectionState(); - -  // If only a string table subsection is given, we find a checksums subsection. -  explicit DebugSubsectionState(const DebugStringTableSubsectionRef &Strings); - -  // If both subsections are given, we don't need to find anything. -  DebugSubsectionState(const DebugStringTableSubsectionRef &Strings, -                       const DebugChecksumsSubsectionRef &Checksums); - -  template <typename T> void initialize(T &&FragmentRange) { -    for (const DebugSubsectionRecord &R : FragmentRange) { -      if (Strings && Checksums) -        return; -      if (R.kind() == DebugSubsectionKind::FileChecksums) { -        initializeChecksums(R); -        continue; -      } -      if (R.kind() == DebugSubsectionKind::StringTable && !Strings) { -        // While in practice we should never encounter a string table even -        // though the string table is already initialized, in theory it's -        // possible.  PDBs are supposed to have one global string table and -        // then this subsection should not appear.  Whereas object files are -        // supposed to have this subsection appear exactly once.  However, -        // for testing purposes it's nice to be able to test this subsection -        // independently of one format or the other, so for some tests we -        // manually construct a PDB that contains this subsection in addition -        // to a global string table. -        initializeStrings(R); -        continue; -      } -    } -  } - -  const DebugStringTableSubsectionRef &strings() const { return *Strings; } -  const DebugChecksumsSubsectionRef &checksums() const { return *Checksums; } - -private: -  void initializeStrings(const DebugSubsectionRecord &SR); -  void initializeChecksums(const DebugSubsectionRecord &FCR); - -  std::unique_ptr<DebugStringTableSubsectionRef> OwnedStrings; -  std::unique_ptr<DebugChecksumsSubsectionRef> OwnedChecksums; - -  const DebugStringTableSubsectionRef *Strings = nullptr; -  const DebugChecksumsSubsectionRef *Checksums = nullptr; -}; +class StringsAndChecksumsRef;  class DebugSubsectionVisitor {  public: @@ -89,38 +41,38 @@ public:      return Error::success();    }    virtual Error visitLines(DebugLinesSubsectionRef &Lines, -                           const DebugSubsectionState &State) = 0; +                           const StringsAndChecksumsRef &State) = 0;    virtual Error visitFileChecksums(DebugChecksumsSubsectionRef &Checksums, -                                   const DebugSubsectionState &State) = 0; +                                   const StringsAndChecksumsRef &State) = 0;    virtual Error visitInlineeLines(DebugInlineeLinesSubsectionRef &Inlinees, -                                  const DebugSubsectionState &State) = 0; +                                  const StringsAndChecksumsRef &State) = 0;    virtual Error    visitCrossModuleExports(DebugCrossModuleExportsSubsectionRef &CSE, -                          const DebugSubsectionState &State) = 0; +                          const StringsAndChecksumsRef &State) = 0;    virtual Error    visitCrossModuleImports(DebugCrossModuleImportsSubsectionRef &CSE, -                          const DebugSubsectionState &State) = 0; +                          const StringsAndChecksumsRef &State) = 0;    virtual Error visitStringTable(DebugStringTableSubsectionRef &ST, -                                 const DebugSubsectionState &State) = 0; +                                 const StringsAndChecksumsRef &State) = 0;    virtual Error visitSymbols(DebugSymbolsSubsectionRef &CSE, -                             const DebugSubsectionState &State) = 0; +                             const StringsAndChecksumsRef &State) = 0;    virtual Error visitFrameData(DebugFrameDataSubsectionRef &FD, -                               const DebugSubsectionState &State) = 0; +                               const StringsAndChecksumsRef &State) = 0;    virtual Error visitCOFFSymbolRVAs(DebugSymbolRVASubsectionRef &RVAs, -                                    const DebugSubsectionState &State) = 0; +                                    const StringsAndChecksumsRef &State) = 0;  };  Error visitDebugSubsection(const DebugSubsectionRecord &R,                             DebugSubsectionVisitor &V, -                           const DebugSubsectionState &State); +                           const StringsAndChecksumsRef &State);  namespace detail {  template <typename T>  Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V, -                            DebugSubsectionState &State) { +                            StringsAndChecksumsRef &State) {    State.initialize(std::forward<T>(FragmentRange));    for (const DebugSubsectionRecord &L : FragmentRange) { @@ -133,7 +85,7 @@ Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V,  template <typename T>  Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V) { -  DebugSubsectionState State; +  StringsAndChecksumsRef State;    return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V,                                         State);  } @@ -141,7 +93,7 @@ Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V) {  template <typename T>  Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V,                              const DebugStringTableSubsectionRef &Strings) { -  DebugSubsectionState State(Strings); +  StringsAndChecksumsRef State(Strings);    return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V,                                         State);  } @@ -150,7 +102,7 @@ template <typename T>  Error visitDebugSubsections(T &&FragmentRange, DebugSubsectionVisitor &V,                              const DebugStringTableSubsectionRef &Strings,                              const DebugChecksumsSubsectionRef &Checksums) { -  DebugSubsectionState State(Strings, Checksums); +  StringsAndChecksumsRef State(Strings, Checksums);    return detail::visitDebugSubsections(std::forward<T>(FragmentRange), V,                                         State);  } diff --git a/include/llvm/DebugInfo/CodeView/Formatters.h b/include/llvm/DebugInfo/CodeView/Formatters.h index 37a91098a8b6..1fbb0dd6f9b0 100644 --- a/include/llvm/DebugInfo/CodeView/Formatters.h +++ b/include/llvm/DebugInfo/CodeView/Formatters.h @@ -12,7 +12,10 @@  #include "llvm/ADT/ArrayRef.h"  #include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h"  #include "llvm/Support/FormatAdapters.h" +#include "llvm/Support/FormatProviders.h" +#include "llvm/Support/FormatVariadic.h"  namespace llvm {  namespace codeview { @@ -35,6 +38,20 @@ inline detail::GuidAdapter fmt_guid(ArrayRef<uint8_t> Item) {    return detail::GuidAdapter(Item);  }  } + +template <> struct format_provider<codeview::TypeIndex> { +public: +  static void format(const codeview::TypeIndex &V, llvm::raw_ostream &Stream, +                     StringRef Style) { +    if (V.isNoneType()) +      Stream << "<no type>"; +    else { +      Stream << formatv("{0:X+4}", V.getIndex()); +      if (V.isSimple()) +        Stream << " (" << codeview::TypeIndex::simpleTypeName(V) << ")"; +    } +  } +};  }  #endif diff --git a/include/llvm/DebugInfo/CodeView/StringsAndChecksums.h b/include/llvm/DebugInfo/CodeView/StringsAndChecksums.h new file mode 100644 index 000000000000..708b317164fc --- /dev/null +++ b/include/llvm/DebugInfo/CodeView/StringsAndChecksums.h @@ -0,0 +1,106 @@ +//===- StringsAndChecksums.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_STRINGS_AND_CHECKSUMS_H +#define LLVM_DEBUGINFO_CODEVIEW_STRINGS_AND_CHECKSUMS_H + +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h" + +#include <memory> + +namespace llvm { +namespace codeview { + +class DebugSubsectionRecord; +class DebugChecksumsSubsectionRef; +class DebugStringTableSubsectionRef; +class DebugChecksumsSubsection; +class DebugStringTableSubsection; + +class StringsAndChecksumsRef { +public: +  // If no subsections are known about initially, we find as much as we can. +  StringsAndChecksumsRef(); + +  // If only a string table subsection is given, we find a checksums subsection. +  explicit StringsAndChecksumsRef(const DebugStringTableSubsectionRef &Strings); + +  // If both subsections are given, we don't need to find anything. +  StringsAndChecksumsRef(const DebugStringTableSubsectionRef &Strings, +                         const DebugChecksumsSubsectionRef &Checksums); + +  void setChecksums(const DebugChecksumsSubsectionRef &CS); + +  template <typename T> void initialize(T &&FragmentRange) { +    for (const DebugSubsectionRecord &R : FragmentRange) { +      if (Strings && Checksums) +        return; +      if (R.kind() == DebugSubsectionKind::FileChecksums) { +        initializeChecksums(R); +        continue; +      } +      if (R.kind() == DebugSubsectionKind::StringTable && !Strings) { +        // While in practice we should never encounter a string table even +        // though the string table is already initialized, in theory it's +        // possible.  PDBs are supposed to have one global string table and +        // then this subsection should not appear.  Whereas object files are +        // supposed to have this subsection appear exactly once.  However, +        // for testing purposes it's nice to be able to test this subsection +        // independently of one format or the other, so for some tests we +        // manually construct a PDB that contains this subsection in addition +        // to a global string table. +        initializeStrings(R); +        continue; +      } +    } +  } + +  const DebugStringTableSubsectionRef &strings() const { return *Strings; } +  const DebugChecksumsSubsectionRef &checksums() const { return *Checksums; } + +  bool hasStrings() const { return Strings != nullptr; } +  bool hasChecksums() const { return Checksums != nullptr; } + +private: +  void initializeStrings(const DebugSubsectionRecord &SR); +  void initializeChecksums(const DebugSubsectionRecord &FCR); + +  std::unique_ptr<DebugStringTableSubsectionRef> OwnedStrings; +  std::unique_ptr<DebugChecksumsSubsectionRef> OwnedChecksums; + +  const DebugStringTableSubsectionRef *Strings = nullptr; +  const DebugChecksumsSubsectionRef *Checksums = nullptr; +}; + +class StringsAndChecksums { +public: +  using StringsPtr = std::shared_ptr<DebugStringTableSubsection>; +  using ChecksumsPtr = std::shared_ptr<DebugChecksumsSubsection>; +  // If no subsections are known about initially, we find as much as we can. +  StringsAndChecksums() {} + +  void setStrings(const StringsPtr &SP) { Strings = SP; } +  void setChecksums(const ChecksumsPtr &CP) { Checksums = CP; } + +  const StringsPtr &strings() const { return Strings; } +  const ChecksumsPtr &checksums() const { return Checksums; } + +  bool hasStrings() const { return Strings != nullptr; } +  bool hasChecksums() const { return Checksums != nullptr; } + +private: +  StringsPtr Strings; +  ChecksumsPtr Checksums; +}; + +} // namespace codeview +} // namespace llvm + +#endif diff --git a/include/llvm/DebugInfo/CodeView/SymbolRecord.h b/include/llvm/DebugInfo/CodeView/SymbolRecord.h index a3e4dff647bd..5f85ed28cb3a 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) {} -  uint32_t Index; +  TypeIndex Index;    uint32_t Offset;    uint16_t Segment;    StringRef Name; @@ -379,7 +379,7 @@ public:        : SymbolRecord(SymbolRecordKind::RegisterSym),          RecordOffset(RecordOffset) {} -  uint32_t Index; +  TypeIndex Index;    RegisterId Register;    StringRef Name; @@ -679,7 +679,7 @@ public:        : SymbolRecord(SymbolRecordKind::FileStaticSym),          RecordOffset(RecordOffset) {} -  uint32_t Index; +  TypeIndex Index;    uint32_t ModFilenameOffset;    LocalSymFlags Flags;    StringRef Name; @@ -814,7 +814,7 @@ public:    uint32_t CodeOffset;    uint16_t Register; -  uint8_t CookieKind; +  FrameCookieKind CookieKind;    uint8_t Flags;    uint32_t RecordOffset; @@ -871,7 +871,7 @@ public:    uint32_t Offset;    TypeIndex Type; -  uint16_t Register; +  RegisterId Register;    StringRef Name;    uint32_t RecordOffset; diff --git a/include/llvm/DebugInfo/CodeView/TypeIndex.h b/include/llvm/DebugInfo/CodeView/TypeIndex.h index 31eed7d3e877..10d51c2d6244 100644 --- a/include/llvm/DebugInfo/CodeView/TypeIndex.h +++ b/include/llvm/DebugInfo/CodeView/TypeIndex.h @@ -248,6 +248,8 @@ public:      return A.toArrayIndex() - B.toArrayIndex();    } +  static StringRef simpleTypeName(TypeIndex TI); +  private:    support::ulittle32_t Index;  }; diff --git a/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h b/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h index 72793e97b60d..3012b39dcc52 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h +++ b/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h @@ -50,6 +50,10 @@ public:      : AccelSection(AccelSection), StringSection(StringSection), Relocs(Relocs) {}    bool extract(); +  uint32_t getNumBuckets(); +  uint32_t getNumHashes(); +  uint32_t getSizeHdr(); +  uint32_t getHeaderDataLength();    void dump(raw_ostream &OS) const;  }; diff --git a/include/llvm/DebugInfo/DWARF/DWARFVerifier.h b/include/llvm/DebugInfo/DWARF/DWARFVerifier.h index b9f14be85926..9eb5c45faba8 100644 --- a/include/llvm/DebugInfo/DWARF/DWARFVerifier.h +++ b/include/llvm/DebugInfo/DWARF/DWARFVerifier.h @@ -20,6 +20,7 @@ struct DWARFAttribute;  class DWARFContext;  class DWARFDie;  class DWARFUnit; +class DWARFAcceleratorTable;  /// A class that verifies DWARF debug information given a DWARF Context.  class DWARFVerifier { @@ -29,8 +30,9 @@ class DWARFVerifier {    /// can verify each reference points to a valid DIE and not an offset that    /// lies between to valid DIEs.    std::map<uint64_t, std::set<uint32_t>> ReferenceToDIEOffsets; -  uint32_t NumDebugInfoErrors; -  uint32_t NumDebugLineErrors; +  uint32_t NumDebugInfoErrors = 0; +  uint32_t NumDebugLineErrors = 0; +  uint32_t NumAppleNamesErrors = 0;    /// Verifies the attribute's DWARF attribute and its value.    /// @@ -38,8 +40,8 @@ class DWARFVerifier {    /// - DW_AT_ranges values is a valid .debug_ranges offset    /// - DW_AT_stmt_list is a valid .debug_line offset    /// -  /// @param Die          The DWARF DIE that owns the attribute value -  /// @param AttrValue    The DWARF attribute value to check +  /// \param Die          The DWARF DIE that owns the attribute value +  /// \param AttrValue    The DWARF attribute value to check    void verifyDebugInfoAttribute(const DWARFDie &Die, DWARFAttribute &AttrValue);    /// Verifies the attribute's DWARF form. @@ -49,8 +51,8 @@ class DWARFVerifier {    /// - All DW_FORM_ref_addr values have valid .debug_info offsets    /// - All DW_FORM_strp values have valid .debug_str offsets    /// -  /// @param Die          The DWARF DIE that owns the attribute value -  /// @param AttrValue    The DWARF attribute value to check +  /// \param Die          The DWARF DIE that owns the attribute value +  /// \param AttrValue    The DWARF attribute value to check    void verifyDebugInfoForm(const DWARFDie &Die, DWARFAttribute &AttrValue);    /// Verifies the all valid references that were found when iterating through @@ -75,13 +77,13 @@ class DWARFVerifier {  public:    DWARFVerifier(raw_ostream &S, DWARFContext &D) -      : OS(S), DCtx(D), NumDebugInfoErrors(0), NumDebugLineErrors(0) {} +      : OS(S), DCtx(D) {}    /// Verify the information in the .debug_info section.    ///    /// Any errors are reported to the stream that was this object was    /// constructed with.    /// -  /// @return True if the .debug_info verifies successfully, false otherwise. +  /// \returns true if the .debug_info verifies successfully, false otherwise.    bool handleDebugInfo();    /// Verify the information in the .debug_line section. @@ -89,8 +91,16 @@ public:    /// Any errors are reported to the stream that was this object was    /// constructed with.    /// -  /// @return True if the .debug_line verifies successfully, false otherwise. +  /// \returns true if the .debug_line verifies successfully, false otherwise.    bool handleDebugLine(); + +  /// Verify the information in the .apple_names accelerator table. +  /// +  /// Any errors are reported to the stream that was this object was +  /// constructed with. +  /// +  /// \returns true if the .apple_names verifies successfully, false otherwise. +  bool handleAppleNames();  };  } // end namespace llvm diff --git a/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h b/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h index 2ff166b24e68..a89e26ae943c 100644 --- a/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h +++ b/include/llvm/DebugInfo/PDB/Native/DbiModuleDescriptorBuilder.h @@ -50,12 +50,14 @@ public:    void addSymbol(codeview::CVSymbol Symbol);    void -  addDebugSubsection(std::unique_ptr<codeview::DebugSubsection> Subsection); +  addDebugSubsection(std::shared_ptr<codeview::DebugSubsection> Subsection);    uint16_t getStreamIndex() const;    StringRef getModuleName() const { return ModuleName; }    StringRef getObjFileName() const { return ObjFileName; } +  unsigned getModuleIndex() const { return Layout.Mod; } +    ArrayRef<std::string> source_files() const {      return makeArrayRef(SourceFiles);    } diff --git a/include/llvm/DebugInfo/PDB/Native/DbiModuleList.h b/include/llvm/DebugInfo/PDB/Native/DbiModuleList.h index bcf1cff8f6e5..2885081628f6 100644 --- a/include/llvm/DebugInfo/PDB/Native/DbiModuleList.h +++ b/include/llvm/DebugInfo/PDB/Native/DbiModuleList.h @@ -12,6 +12,7 @@  #include "llvm/ADT/StringRef.h"  #include "llvm/ADT/iterator.h" +#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"  #include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h"  #include "llvm/Support/BinaryStreamArray.h"  #include "llvm/Support/BinaryStreamRef.h" @@ -21,6 +22,7 @@  #include <vector>  namespace llvm { +namespace codeview {}  namespace pdb {  class DbiModuleList; diff --git a/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h b/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h index e116f314ac0e..aeb2e2ab026a 100644 --- a/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h +++ b/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h @@ -49,7 +49,6 @@ public:    void setPdbDllRbld(uint16_t R);    void setFlags(uint16_t F);    void setMachineType(PDB_Machine M); -  void setSectionContribs(ArrayRef<SectionContrib> SecMap);    void setSectionMap(ArrayRef<SecMapEntry> SecMap);    // Add given bytes as a new stream. @@ -65,10 +64,8 @@ public:    Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef MsfBuffer); -  // A helper function to create Section Contributions from COFF input -  // section headers. -  static std::vector<SectionContrib> -  createSectionContribs(ArrayRef<llvm::object::coff_section> SecHdrs); +  void addSectionContrib(DbiModuleDescriptorBuilder *ModuleDbi, +                         const llvm::object::coff_section *SecHdr);    // A helper function to create a Section Map from a COFF section header.    static std::vector<SecMapEntry> @@ -112,7 +109,7 @@ private:    WritableBinaryStreamRef NamesBuffer;    MutableBinaryByteStream FileInfoBuffer; -  ArrayRef<SectionContrib> SectionContribs; +  std::vector<SectionContrib> SectionContribs;    ArrayRef<SecMapEntry> SectionMap;    llvm::SmallVector<DebugStream, (int)DbgHeaderType::Max> DbgStreams;  }; diff --git a/include/llvm/DebugInfo/PDB/Native/InfoStream.h b/include/llvm/DebugInfo/PDB/Native/InfoStream.h index 1c38c2b6194f..fc91fc7097bd 100644 --- a/include/llvm/DebugInfo/PDB/Native/InfoStream.h +++ b/include/llvm/DebugInfo/PDB/Native/InfoStream.h @@ -35,6 +35,7 @@ public:    uint32_t getStreamSize() const; +  bool containsIdStream() const;    PdbRaw_ImplVer getVersion() const;    uint32_t getSignature() const;    uint32_t getAge() const; diff --git a/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h b/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h index a8121978d882..c744696ae250 100644 --- a/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h +++ b/include/llvm/DebugInfo/PDB/Native/ModuleDebugStream.h @@ -31,6 +31,7 @@ class ModuleDebugStreamRef {  public:    ModuleDebugStreamRef(const DbiModuleDescriptor &Module,                         std::unique_ptr<msf::MappedBlockStream> Stream); +  ModuleDebugStreamRef(ModuleDebugStreamRef &&Other) = default;    ~ModuleDebugStreamRef();    Error reload(); @@ -40,6 +41,12 @@ public:    iterator_range<codeview::CVSymbolArray::Iterator>    symbols(bool *HadError) const; +  const codeview::CVSymbolArray &getSymbolArray() const { +    return SymbolsSubstream; +  } + +  ModuleDebugStreamRef &operator=(ModuleDebugStreamRef &&Other) = default; +    llvm::iterator_range<DebugSubsectionIterator> subsections() const;    bool hasDebugSubsections() const; @@ -54,7 +61,7 @@ private:    uint32_t Signature; -  std::unique_ptr<msf::MappedBlockStream> Stream; +  std::shared_ptr<msf::MappedBlockStream> Stream;    codeview::CVSymbolArray SymbolsSubstream;    BinaryStreamRef C11LinesSubstream; diff --git a/include/llvm/DebugInfo/PDB/Native/PDBFile.h b/include/llvm/DebugInfo/PDB/Native/PDBFile.h index 3bed67141c56..4d3c569c3cdf 100644 --- a/include/llvm/DebugInfo/PDB/Native/PDBFile.h +++ b/include/llvm/DebugInfo/PDB/Native/PDBFile.h @@ -108,6 +108,8 @@ public:    bool hasPDBTpiStream() const;    bool hasPDBStringTable(); +  uint32_t getPointerSize(); +  private:    Expected<std::unique_ptr<msf::MappedBlockStream>>    safelyCreateIndexedStream(const msf::MSFLayout &Layout, diff --git a/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h b/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h index 28a14d7356d2..86ef1136b41d 100644 --- a/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h +++ b/include/llvm/DebugInfo/PDB/Native/PDBStringTable.h @@ -45,7 +45,7 @@ public:    FixedStreamArray<support::ulittle32_t> name_ids() const; -  codeview::DebugStringTableSubsectionRef getStringTable() const; +  const codeview::DebugStringTableSubsectionRef &getStringTable() const;  private:    Error readHeader(BinaryStreamReader &Reader); diff --git a/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h b/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h index 0faa02dc4525..b57707ee7923 100644 --- a/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h +++ b/include/llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h @@ -41,10 +41,7 @@ public:    uint32_t calculateSerializedSize() const;    Error commit(BinaryStreamWriter &Writer) const; -  codeview::DebugStringTableSubsection &getStrings() { return Strings; } -  const codeview::DebugStringTableSubsection &getStrings() const { -    return Strings; -  } +  void setStrings(const codeview::DebugStringTableSubsection &Strings);  private:    uint32_t calculateHashTableSize() const; diff --git a/include/llvm/DebugInfo/PDB/Native/PublicsStream.h b/include/llvm/DebugInfo/PDB/Native/PublicsStream.h index 4a541edd6a7b..4570c80c76d7 100644 --- a/include/llvm/DebugInfo/PDB/Native/PublicsStream.h +++ b/include/llvm/DebugInfo/PDB/Native/PublicsStream.h @@ -35,6 +35,7 @@ public:    uint32_t getSymHash() const;    uint32_t getAddrMap() const;    uint32_t getNumBuckets() const { return NumBuckets; } +  Expected<const codeview::CVSymbolArray &> getSymbolArray() const;    iterator_range<codeview::CVSymbolArray::Iterator>    getSymbols(bool *HadError) const;    FixedStreamArray<support::ulittle32_t> getHashBuckets() const { diff --git a/include/llvm/DebugInfo/PDB/Native/RawConstants.h b/include/llvm/DebugInfo/PDB/Native/RawConstants.h index e1bd86b2870b..bb1d097b5123 100644 --- a/include/llvm/DebugInfo/PDB/Native/RawConstants.h +++ b/include/llvm/DebugInfo/PDB/Native/RawConstants.h @@ -98,15 +98,19 @@ enum class DbgHeaderType : uint16_t {  };  enum class OMFSegDescFlags : uint16_t { +  None = 0,    Read = 1 << 0,              // Segment is readable.    Write = 1 << 1,             // Segment is writable.    Execute = 1 << 2,           // Segment is executable.    AddressIs32Bit = 1 << 3,    // Descriptor describes a 32-bit linear address.    IsSelector = 1 << 8,        // Frame represents a selector.    IsAbsoluteAddress = 1 << 9, // Frame represents an absolute address. -  IsGroup = 1 << 10           // If set, descriptor represents a group. +  IsGroup = 1 << 10,          // If set, descriptor represents a group. +  LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ IsGroup)  }; +LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE(); +  } // end namespace pdb  } // end namespace llvm diff --git a/include/llvm/DebugInfo/PDB/Native/SymbolStream.h b/include/llvm/DebugInfo/PDB/Native/SymbolStream.h index 41d5e6ad64a0..17695f587849 100644 --- a/include/llvm/DebugInfo/PDB/Native/SymbolStream.h +++ b/include/llvm/DebugInfo/PDB/Native/SymbolStream.h @@ -27,6 +27,10 @@ public:    ~SymbolStream();    Error reload(); +  const codeview::CVSymbolArray &getSymbolArray() const { +    return SymbolRecords; +  } +    iterator_range<codeview::CVSymbolArray::Iterator>    getSymbols(bool *HadError) const; diff --git a/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h b/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h index 21cfa83e6af4..411720d6f56b 100644 --- a/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h +++ b/include/llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h @@ -58,6 +58,8 @@ public:    Error finalizeMsfLayout(); +  uint32_t getRecordCount() const { return TypeRecords.size(); } +    Error commit(const msf::MSFLayout &Layout, WritableBinaryStreamRef Buffer);    uint32_t calculateSerializedLength();  | 
