diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-07-01 13:22:02 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-07-01 13:22:02 +0000 |
commit | 9df3605dea17e84f8183581f6103bd0c79e2a606 (patch) | |
tree | 70a2f36ce9eb9bb213603cd7f2f120af53fc176f /include/llvm/DebugInfo/CodeView | |
parent | 08bbd35a80bf7765fe0d3043f9eb5a2f2786b649 (diff) |
Diffstat (limited to 'include/llvm/DebugInfo/CodeView')
22 files changed, 253 insertions, 159 deletions
diff --git a/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h b/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h index b2d3f5ea34a84..7c8cd121751a2 100644 --- a/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h +++ b/include/llvm/DebugInfo/CodeView/CVSymbolVisitor.h @@ -25,7 +25,9 @@ public: CVSymbolVisitor(SymbolVisitorCallbacks &Callbacks); Error visitSymbolRecord(CVSymbol &Record); + Error visitSymbolRecord(CVSymbol &Record, uint32_t Offset); Error visitSymbolStream(const CVSymbolArray &Symbols); + Error visitSymbolStream(const CVSymbolArray &Symbols, uint32_t InitialOffset); private: SymbolVisitorCallbacks &Callbacks; diff --git a/include/llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h b/include/llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h index 9fc90f13d3473..78b284563afd9 100644 --- a/include/llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h +++ b/include/llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h @@ -12,13 +12,19 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/DebugSubsection.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/BinaryStreamArray.h" #include "llvm/Support/BinaryStreamReader.h" -#include "llvm/Support/Endian.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <vector> namespace llvm { + namespace codeview { class DebugStringTableSubsection; @@ -28,24 +34,22 @@ struct FileChecksumEntry { FileChecksumKind Kind; // The type of checksum. ArrayRef<uint8_t> Checksum; // The bytes of the checksum. }; -} -} -namespace llvm { +} // end namespace codeview + template <> struct VarStreamArrayExtractor<codeview::FileChecksumEntry> { public: - typedef void ContextType; + using ContextType = void; Error operator()(BinaryStreamRef Stream, uint32_t &Len, codeview::FileChecksumEntry &Item); }; -} -namespace llvm { namespace codeview { + class DebugChecksumsSubsectionRef final : public DebugSubsectionRef { - typedef VarStreamArray<codeview::FileChecksumEntry> FileChecksumArray; - typedef FileChecksumArray::Iterator Iterator; + using FileChecksumArray = VarStreamArray<codeview::FileChecksumEntry>; + using Iterator = FileChecksumArray::Iterator; public: DebugChecksumsSubsectionRef() @@ -89,10 +93,12 @@ private: DenseMap<uint32_t, uint32_t> OffsetMap; uint32_t SerializedSize = 0; - llvm::BumpPtrAllocator Storage; + BumpPtrAllocator Storage; std::vector<FileChecksumEntry> Checksums; }; -} -} -#endif +} // end namespace codeview + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCHECKSUMSSUBSECTION_H diff --git a/include/llvm/DebugInfo/CodeView/DebugCrossExSubsection.h b/include/llvm/DebugInfo/CodeView/DebugCrossExSubsection.h index f755b23422c77..2f9e9814d998d 100644 --- a/include/llvm/DebugInfo/CodeView/DebugCrossExSubsection.h +++ b/include/llvm/DebugInfo/CodeView/DebugCrossExSubsection.h @@ -10,18 +10,21 @@ #ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSEXSUBSECTION_H #define LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSEXSUBSECTION_H +#include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/DebugSubsection.h" #include "llvm/Support/BinaryStreamArray.h" #include "llvm/Support/BinaryStreamReader.h" -#include "llvm/Support/Endian.h" - +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Error.h" +#include <cstdint> #include <map> namespace llvm { namespace codeview { + class DebugCrossModuleExportsSubsectionRef final : public DebugSubsectionRef { - typedef FixedStreamArray<CrossModuleExport> ReferenceArray; - typedef ReferenceArray::Iterator Iterator; + using ReferenceArray = FixedStreamArray<CrossModuleExport>; + using Iterator = ReferenceArray::Iterator; public: DebugCrossModuleExportsSubsectionRef() @@ -58,7 +61,8 @@ public: private: std::map<uint32_t, uint32_t> Mappings; }; -} -} -#endif +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSEXSUBSECTION_H diff --git a/include/llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h b/include/llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h index ea3a9a43d50b3..8be7ef265c82e 100644 --- a/include/llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h +++ b/include/llvm/DebugInfo/CodeView/DebugCrossImpSubsection.h @@ -11,38 +11,43 @@ #define LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/DebugSubsection.h" #include "llvm/Support/BinaryStreamArray.h" #include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/BinaryStreamRef.h" #include "llvm/Support/Endian.h" +#include "llvm/Support/Error.h" +#include <cstdint> +#include <vector> namespace llvm { + namespace codeview { struct CrossModuleImportItem { const CrossModuleImport *Header = nullptr; - llvm::FixedStreamArray<support::ulittle32_t> Imports; + FixedStreamArray<support::ulittle32_t> Imports; }; -} -} -namespace llvm { +} // end namespace codeview + template <> struct VarStreamArrayExtractor<codeview::CrossModuleImportItem> { public: - typedef void ContextType; + using ContextType = void; Error operator()(BinaryStreamRef Stream, uint32_t &Len, codeview::CrossModuleImportItem &Item); }; -} -namespace llvm { namespace codeview { + class DebugStringTableSubsection; class DebugCrossModuleImportsSubsectionRef final : public DebugSubsectionRef { - typedef VarStreamArray<CrossModuleImportItem> ReferenceArray; - typedef ReferenceArray::Iterator Iterator; + using ReferenceArray = VarStreamArray<CrossModuleImportItem>; + using Iterator = ReferenceArray::Iterator; public: DebugCrossModuleImportsSubsectionRef() @@ -82,7 +87,9 @@ private: DebugStringTableSubsection &Strings; StringMap<std::vector<support::ulittle32_t>> Mappings; }; -} -} -#endif +} // end namespace codeview + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCROSSIMPSUBSECTION_H diff --git a/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h b/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h index 7484af6631051..b88c0eae1de28 100644 --- a/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h +++ b/include/llvm/DebugInfo/CodeView/DebugInlineeLinesSubsection.h @@ -7,19 +7,26 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_CODEVIEW_BUGINLINEELINESSUBSECTION_H -#define LLVM_DEBUGINFO_CODEVIEW_BUGINLINEELINESSUBSECTION_H +#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGINLINEELINESSUBSECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_DEBUGINLINEELINESSUBSECTION_H +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/DebugSubsection.h" #include "llvm/DebugInfo/CodeView/Line.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" #include "llvm/Support/BinaryStreamArray.h" #include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" +#include <cstdint> +#include <vector> namespace llvm { + namespace codeview { -class DebugInlineeLinesSubsectionRef; class DebugChecksumsSubsection; enum class InlineeLinesSignature : uint32_t { @@ -40,18 +47,21 @@ struct InlineeSourceLine { const InlineeSourceLineHeader *Header; FixedStreamArray<support::ulittle32_t> ExtraFiles; }; -} + +} // end namespace codeview template <> struct VarStreamArrayExtractor<codeview::InlineeSourceLine> { Error operator()(BinaryStreamRef Stream, uint32_t &Len, codeview::InlineeSourceLine &Item); + bool HasExtraFiles = false; }; namespace codeview { + class DebugInlineeLinesSubsectionRef final : public DebugSubsectionRef { - typedef VarStreamArray<InlineeSourceLine> LinesArray; - typedef LinesArray::Iterator Iterator; + using LinesArray = VarStreamArray<InlineeSourceLine>; + using Iterator = LinesArray::Iterator; public: DebugInlineeLinesSubsectionRef(); @@ -99,13 +109,13 @@ public: private: DebugChecksumsSubsection &Checksums; - bool HasExtraFiles = false; uint32_t ExtraFileCount = 0; - std::vector<Entry> Entries; }; -} -} -#endif +} // end namespace codeview + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGINLINEELINESSUBSECTION_H diff --git a/include/llvm/DebugInfo/CodeView/DebugLinesSubsection.h b/include/llvm/DebugInfo/CodeView/DebugLinesSubsection.h index f1feb1336cc53..53044b6c3dc8b 100644 --- a/include/llvm/DebugInfo/CodeView/DebugLinesSubsection.h +++ b/include/llvm/DebugInfo/CodeView/DebugLinesSubsection.h @@ -1,4 +1,4 @@ -//===- DebugLinesSubsection.h --------------------------------*- C++ -*-===// +//===- DebugLinesSubsection.h -----------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,14 +7,20 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGLINEFRAGMENT_H -#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGLINEFRAGMENT_H +#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGLINESSUBSECTION_H +#define LLVM_DEBUGINFO_CODEVIEW_DEBUGLINESSUBSECTION_H +#include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/DebugSubsection.h" #include "llvm/DebugInfo/CodeView/Line.h" #include "llvm/Support/BinaryStreamArray.h" #include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/BinaryStreamRef.h" +#include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" +#include <cstdint> +#include <vector> namespace llvm { namespace codeview { @@ -72,8 +78,9 @@ public: class DebugLinesSubsectionRef final : public DebugSubsectionRef { friend class LineColumnExtractor; - typedef VarStreamArray<LineColumnEntry, LineColumnExtractor> LineInfoArray; - typedef LineInfoArray::Iterator Iterator; + + using LineInfoArray = VarStreamArray<LineColumnEntry, LineColumnExtractor>; + using Iterator = LineInfoArray::Iterator; public: DebugLinesSubsectionRef(); @@ -130,14 +137,14 @@ public: private: DebugChecksumsSubsection &Checksums; - uint32_t RelocOffset = 0; uint16_t RelocSegment = 0; uint32_t CodeSize = 0; LineFlags Flags = LF_None; std::vector<Block> Blocks; }; -} -} -#endif +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGLINESSUBSECTION_H diff --git a/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h b/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h index be0a2344965b1..7f0f10e4fbfa2 100644 --- a/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h +++ b/include/llvm/DebugInfo/CodeView/DebugStringTableSubsection.h @@ -12,17 +12,15 @@ #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/DebugSubsection.h" #include "llvm/Support/BinaryStreamRef.h" #include "llvm/Support/Error.h" - -#include <stdint.h> +#include <cstdint> namespace llvm { class BinaryStreamReader; -class BinaryStreamRef; -class BinaryStreamWriter; namespace codeview { @@ -83,7 +81,9 @@ private: StringMap<uint32_t> Strings; uint32_t StringSize = 1; }; -} -} -#endif +} // end namespace codeview + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H diff --git a/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h b/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h index ee17b47d8e631..fc0cf0d1d90ec 100644 --- a/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h +++ b/include/llvm/DebugInfo/CodeView/DebugSubsectionRecord.h @@ -1,4 +1,4 @@ -//===- DebugSubsection.h ------------------------------------*- C++ -*-===// +//===- DebugSubsectionRecord.h ----------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,17 +7,22 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTRECORD_H -#define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTRECORD_H +#ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONRECORD_H +#define LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONRECORD_H #include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/Support/BinaryStreamArray.h" #include "llvm/Support/BinaryStreamRef.h" -#include "llvm/Support/BinaryStreamWriter.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" +#include "llvm/Support/MathExtras.h" +#include <cstdint> +#include <memory> namespace llvm { + +class BinaryStreamWriter; + namespace codeview { class DebugSubsection; @@ -42,8 +47,8 @@ public: BinaryStreamRef getRecordData() const; private: - CodeViewContainer Container; - DebugSubsectionKind Kind; + CodeViewContainer Container = CodeViewContainer::ObjectFile; + DebugSubsectionKind Kind = DebugSubsectionKind::None; BinaryStreamRef Data; }; @@ -71,7 +76,7 @@ private: CodeViewContainer Container; }; -} // namespace codeview +} // end namespace codeview template <> struct VarStreamArrayExtractor<codeview::DebugSubsectionRecord> { Error operator()(BinaryStreamRef Stream, uint32_t &Length, @@ -88,8 +93,11 @@ template <> struct VarStreamArrayExtractor<codeview::DebugSubsectionRecord> { }; namespace codeview { -typedef VarStreamArray<DebugSubsectionRecord> DebugSubsectionArray; -} -} // namespace llvm -#endif // LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFRAGMENTRECORD_H +using DebugSubsectionArray = VarStreamArray<DebugSubsectionRecord>; + +} // end namespace codeview + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGSUBSECTIONRECORD_H diff --git a/include/llvm/DebugInfo/CodeView/DebugSymbolRVASubsection.h b/include/llvm/DebugInfo/CodeView/DebugSymbolRVASubsection.h index ad58a293cb09a..a4c04b55eb4c2 100644 --- a/include/llvm/DebugInfo/CodeView/DebugSymbolRVASubsection.h +++ b/include/llvm/DebugInfo/CodeView/DebugSymbolRVASubsection.h @@ -10,17 +10,23 @@ #ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSYMBOLRVASUBSECTION_H #define LLVM_DEBUGINFO_CODEVIEW_DEBUGSYMBOLRVASUBSECTION_H +#include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/DebugSubsection.h" #include "llvm/Support/BinaryStreamArray.h" -#include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" +#include <cstdint> +#include <vector> namespace llvm { + +class BinaryStreamReader; + namespace codeview { class DebugSymbolRVASubsectionRef final : public DebugSubsectionRef { public: - typedef FixedStreamArray<support::ulittle32_t> ArrayType; + using ArrayType = FixedStreamArray<support::ulittle32_t>; DebugSymbolRVASubsectionRef(); @@ -53,7 +59,9 @@ public: private: std::vector<support::ulittle32_t> RVAs; }; -} // namespace codeview -} // namespace llvm -#endif +} // end namespace codeview + +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGSYMBOLRVASUBSECTION_H diff --git a/include/llvm/DebugInfo/CodeView/EnumTables.h b/include/llvm/DebugInfo/CodeView/EnumTables.h index 5d54bb4cca841..ee0f0f7c6023a 100644 --- a/include/llvm/DebugInfo/CodeView/EnumTables.h +++ b/include/llvm/DebugInfo/CodeView/EnumTables.h @@ -1,4 +1,4 @@ -//===- EnumTables.h Enum to string conversion tables ------------*- C++ -*-===// +//===- EnumTables.h - Enum to string conversion tables ----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,11 +14,11 @@ #include "llvm/BinaryFormat/COFF.h" #include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/Support/ScopedPrinter.h" - -#include <stdint.h> +#include <cstdint> namespace llvm { namespace codeview { + ArrayRef<EnumEntry<SymbolKind>> getSymbolTypeNames(); ArrayRef<EnumEntry<TypeLeafKind>> getTypeLeafNames(); ArrayRef<EnumEntry<uint16_t>> getRegisterNames(); @@ -38,7 +38,8 @@ ArrayRef<EnumEntry<uint8_t>> getThunkOrdinalNames(); ArrayRef<EnumEntry<uint16_t>> getTrampolineNames(); ArrayRef<EnumEntry<COFF::SectionCharacteristics>> getImageSectionCharacteristicNames(); -} // namespace codeview -} // namespace llvm + +} // end namespace codeview +} // end namespace llvm #endif // LLVM_DEBUGINFO_CODEVIEW_ENUMTABLES_H diff --git a/include/llvm/DebugInfo/CodeView/Formatters.h b/include/llvm/DebugInfo/CodeView/Formatters.h index 1fbb0dd6f9b00..0842c1e373dbd 100644 --- a/include/llvm/DebugInfo/CodeView/Formatters.h +++ b/include/llvm/DebugInfo/CodeView/Formatters.h @@ -14,21 +14,27 @@ #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" +#include "llvm/Support/raw_ostream.h" +#include <cstdint> namespace llvm { + namespace codeview { + namespace detail { -class GuidAdapter final : public llvm::FormatAdapter<ArrayRef<uint8_t>> { + +class GuidAdapter final : public FormatAdapter<ArrayRef<uint8_t>> { ArrayRef<uint8_t> Guid; public: explicit GuidAdapter(ArrayRef<uint8_t> Guid); explicit GuidAdapter(StringRef Guid); - void format(llvm::raw_ostream &Stream, StringRef Style); + + void format(raw_ostream &Stream, StringRef Style) override ; }; -} + +} // end namespace detail inline detail::GuidAdapter fmt_guid(StringRef Item) { return detail::GuidAdapter(Item); @@ -37,11 +43,12 @@ inline detail::GuidAdapter fmt_guid(StringRef Item) { inline detail::GuidAdapter fmt_guid(ArrayRef<uint8_t> Item) { return detail::GuidAdapter(Item); } -} + +} // end namespace codeview template <> struct format_provider<codeview::TypeIndex> { public: - static void format(const codeview::TypeIndex &V, llvm::raw_ostream &Stream, + static void format(const codeview::TypeIndex &V, raw_ostream &Stream, StringRef Style) { if (V.isNoneType()) Stream << "<no type>"; @@ -52,6 +59,7 @@ public: } } }; -} -#endif +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_FORMATTERS_H diff --git a/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h b/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h index 8b1540abf903e..cc0c24301d498 100644 --- a/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h +++ b/include/llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h @@ -1,4 +1,4 @@ -//===- LazyRandomTypeCollection.h ---------------------------- *- C++ --*-===// +//===- LazyRandomTypeCollection.h -------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -10,12 +10,18 @@ #ifndef LLVM_DEBUGINFO_CODEVIEW_LAZYRANDOMTYPECOLLECTION_H #define LLVM_DEBUGINFO_CODEVIEW_LAZYRANDOMTYPECOLLECTION_H +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/Optional.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/BinaryStreamArray.h" #include "llvm/Support/Error.h" #include "llvm/Support/StringSaver.h" +#include <cstdint> +#include <vector> namespace llvm { namespace codeview { @@ -43,7 +49,8 @@ namespace codeview { /// into M chunks of roughly equal size, this yields a worst case lookup time /// of O(N/M) and an amortized time of O(1). class LazyRandomTypeCollection : public TypeCollection { - typedef FixedStreamArray<TypeIndexOffset> PartialOffsetArray; + using PartialOffsetArray = FixedStreamArray<TypeIndexOffset>; + struct CacheEntry { CVType Type; uint32_t Offset; diff --git a/include/llvm/DebugInfo/CodeView/StringsAndChecksums.h b/include/llvm/DebugInfo/CodeView/StringsAndChecksums.h index 708b317164fc7..1a83882246652 100644 --- a/include/llvm/DebugInfo/CodeView/StringsAndChecksums.h +++ b/include/llvm/DebugInfo/CodeView/StringsAndChecksums.h @@ -7,23 +7,18 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_CODEVIEW_STRINGS_AND_CHECKSUMS_H -#define LLVM_DEBUGINFO_CODEVIEW_STRINGS_AND_CHECKSUMS_H +#ifndef LLVM_DEBUGINFO_CODEVIEW_STRINGSANDCHECKSUMS_H +#define LLVM_DEBUGINFO_CODEVIEW_STRINGSANDCHECKSUMS_H #include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h" +#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.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. @@ -83,8 +78,9 @@ 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() {} + StringsAndChecksums() = default; void setStrings(const StringsPtr &SP) { Strings = SP; } void setChecksums(const ChecksumsPtr &CP) { Checksums = CP; } @@ -100,7 +96,7 @@ private: ChecksumsPtr Checksums; }; -} // namespace codeview -} // namespace llvm +} // end namespace codeview +} // end namespace llvm -#endif +#endif // LLVM_DEBUGINFO_CODEVIEW_STRINGSANDCHECKSUMS_H diff --git a/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h b/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h index 7080b04807570..5b6599d8c1db0 100644 --- a/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h +++ b/include/llvm/DebugInfo/CodeView/SymbolDeserializer.h @@ -51,6 +51,10 @@ public: CodeViewContainer Container) : Delegate(Delegate), Container(Container) {} + Error visitSymbolBegin(CVSymbol &Record, uint32_t Offset) override { + return visitSymbolBegin(Record); + } + Error visitSymbolBegin(CVSymbol &Record) override { assert(!Mapping && "Already in a symbol mapping!"); Mapping = llvm::make_unique<MappingInfo>(Record.content(), Container); diff --git a/include/llvm/DebugInfo/CodeView/SymbolRecord.h b/include/llvm/DebugInfo/CodeView/SymbolRecord.h index 1cf77fcdecbe0..7941af8be8af2 100644 --- a/include/llvm/DebugInfo/CodeView/SymbolRecord.h +++ b/include/llvm/DebugInfo/CodeView/SymbolRecord.h @@ -21,8 +21,6 @@ #include "llvm/DebugInfo/CodeView/TypeIndex.h" #include "llvm/Support/BinaryStreamArray.h" #include "llvm/Support/Endian.h" -#include "llvm/Support/Error.h" -#include <cstddef> #include <cstdint> #include <vector> @@ -35,6 +33,7 @@ protected: public: SymbolRecordKind getKind() const { return Kind; } + SymbolRecordKind Kind; }; @@ -153,6 +152,7 @@ public: : SymbolRecord(Kind), RecordOffset(RecordOffset) {} std::vector<TypeIndex> Indices; + uint32_t RecordOffset; }; @@ -165,8 +165,8 @@ struct BinaryAnnotationIterator { int32_t S1; }; - BinaryAnnotationIterator(ArrayRef<uint8_t> Annotations) : Data(Annotations) {} BinaryAnnotationIterator() = default; + BinaryAnnotationIterator(ArrayRef<uint8_t> Annotations) : Data(Annotations) {} BinaryAnnotationIterator(const BinaryAnnotationIterator &Other) : Data(Other.Data) {} @@ -342,9 +342,9 @@ public: : SymbolRecord(SymbolRecordKind::InlineSiteSym), RecordOffset(RecordOffset) {} - llvm::iterator_range<BinaryAnnotationIterator> annotations() const { - return llvm::make_range(BinaryAnnotationIterator(AnnotationData), - BinaryAnnotationIterator()); + iterator_range<BinaryAnnotationIterator> annotations() const { + return make_range(BinaryAnnotationIterator(AnnotationData), + BinaryAnnotationIterator()); } uint32_t Parent; @@ -479,6 +479,7 @@ public: ulittle16_t Register; ulittle16_t MayHaveNoName; }; + explicit DefRangeRegisterSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} DefRangeRegisterSym(uint32_t RecordOffset) : SymbolRecord(SymbolRecordKind::DefRangeRegisterSym), @@ -501,6 +502,7 @@ public: ulittle16_t MayHaveNoName; ulittle32_t OffsetInParent; }; + explicit DefRangeSubfieldRegisterSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} DefRangeSubfieldRegisterSym(uint32_t RecordOffset) @@ -546,6 +548,7 @@ public: ulittle16_t Flags; little32_t BasePointerOffset; }; + explicit DefRangeRegisterRelSym(SymbolRecordKind Kind) : SymbolRecord(Kind) {} explicit DefRangeRegisterRelSym(uint32_t RecordOffset) : SymbolRecord(SymbolRecordKind::DefRangeRegisterRelSym), @@ -935,8 +938,8 @@ public: uint32_t RecordOffset; }; -typedef CVRecord<SymbolKind> CVSymbol; -typedef VarStreamArray<CVSymbol> CVSymbolArray; +using CVSymbol = CVRecord<SymbolKind>; +using CVSymbolArray = VarStreamArray<CVSymbol>; } // end namespace codeview } // end namespace llvm diff --git a/include/llvm/DebugInfo/CodeView/SymbolSerializer.h b/include/llvm/DebugInfo/CodeView/SymbolSerializer.h index 42adbdb4e20f3..b63ced5217b44 100644 --- a/include/llvm/DebugInfo/CodeView/SymbolSerializer.h +++ b/include/llvm/DebugInfo/CodeView/SymbolSerializer.h @@ -1,4 +1,4 @@ -//===- symbolSerializer.h ---------------------------------------*- C++ -*-===// +//===- SymbolSerializer.h ---------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -10,21 +10,20 @@ #ifndef LLVM_DEBUGINFO_CODEVIEW_SYMBOLSERIALIZER_H #define LLVM_DEBUGINFO_CODEVIEW_SYMBOLSERIALIZER_H +#include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/RecordSerialization.h" +#include "llvm/DebugInfo/CodeView/SymbolRecord.h" #include "llvm/DebugInfo/CodeView/SymbolRecordMapping.h" #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h" - -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/ADT/iterator_range.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/BinaryByteStream.h" #include "llvm/Support/BinaryStreamWriter.h" #include "llvm/Support/Error.h" +#include <cstdint> +#include <vector> namespace llvm { -class BinaryStreamWriter; namespace codeview { class SymbolSerializer : public SymbolVisitorCallbacks { @@ -45,6 +44,8 @@ class SymbolSerializer : public SymbolVisitorCallbacks { } public: + SymbolSerializer(BumpPtrAllocator &Storage, CodeViewContainer Container); + template <typename SymType> static CVSymbol writeOneSymbol(SymType &Sym, BumpPtrAllocator &Storage, CodeViewContainer Container) { @@ -57,13 +58,11 @@ public: return Result; } - SymbolSerializer(BumpPtrAllocator &Storage, CodeViewContainer Container); - - virtual Error visitSymbolBegin(CVSymbol &Record) override; - virtual Error visitSymbolEnd(CVSymbol &Record) override; + Error visitSymbolBegin(CVSymbol &Record) override; + Error visitSymbolEnd(CVSymbol &Record) override; #define SYMBOL_RECORD(EnumName, EnumVal, Name) \ - virtual Error visitKnownRecord(CVSymbol &CVR, Name &Record) override { \ + Error visitKnownRecord(CVSymbol &CVR, Name &Record) override { \ return visitKnownRecordImpl(CVR, Record); \ } #define SYMBOL_RECORD_ALIAS(EnumName, EnumVal, Name, AliasName) @@ -75,7 +74,8 @@ private: return Mapping.visitKnownRecord(CVR, Record); } }; -} -} -#endif +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_SYMBOLSERIALIZER_H diff --git a/include/llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h b/include/llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h index 5f4205bd6e082..e29511a67b7f3 100644 --- a/include/llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h +++ b/include/llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h @@ -30,6 +30,14 @@ public: return Error::success(); } + Error visitSymbolBegin(CVSymbol &Record, uint32_t Offset) override { + for (auto Visitor : Pipeline) { + if (auto EC = Visitor->visitSymbolBegin(Record, Offset)) + return EC; + } + return Error::success(); + } + Error visitSymbolBegin(CVSymbol &Record) override { for (auto Visitor : Pipeline) { if (auto EC = Visitor->visitSymbolBegin(Record)) diff --git a/include/llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h b/include/llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h index 2ef7eabdaa9d3..0816f7c62656f 100644 --- a/include/llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h +++ b/include/llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h @@ -29,8 +29,10 @@ public: /// Paired begin/end actions for all symbols. Receives all record data, /// including the fixed-length record prefix. visitSymbolBegin() should - /// return - /// the type of the Symbol, or an error if it cannot be determined. + /// return the type of the Symbol, or an error if it cannot be determined. + virtual Error visitSymbolBegin(CVSymbol &Record, uint32_t Offset) { + return Error::success(); + } virtual Error visitSymbolBegin(CVSymbol &Record) { return Error::success(); } virtual Error visitSymbolEnd(CVSymbol &Record) { return Error::success(); } diff --git a/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h b/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h index c393b42cd27c5..afe8942159e84 100644 --- a/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h +++ b/include/llvm/DebugInfo/CodeView/TypeIndexDiscovery.h @@ -28,6 +28,8 @@ void discoverTypeIndices(ArrayRef<uint8_t> RecordData, SmallVectorImpl<TiReference> &Refs); void discoverTypeIndices(const CVType &Type, SmallVectorImpl<TiReference> &Refs); +void discoverTypeIndices(const CVType &Type, + SmallVectorImpl<TypeIndex> &Indices); /// Discover type indices in symbol records. Returns false if this is an unknown /// record. diff --git a/include/llvm/DebugInfo/CodeView/TypeRecord.h b/include/llvm/DebugInfo/CodeView/TypeRecord.h index 3a64a437aa4d9..2efeb1b3cefd1 100644 --- a/include/llvm/DebugInfo/CodeView/TypeRecord.h +++ b/include/llvm/DebugInfo/CodeView/TypeRecord.h @@ -15,6 +15,7 @@ #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/iterator_range.h" #include "llvm/DebugInfo/CodeView/CVRecord.h" #include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/TypeIndex.h" @@ -25,31 +26,30 @@ #include <vector> namespace llvm { - -class BinaryStreamReader; - namespace codeview { using support::little32_t; using support::ulittle16_t; using support::ulittle32_t; -typedef CVRecord<TypeLeafKind> CVType; -typedef RemappedRecord<TypeLeafKind> RemappedType; +using CVType = CVRecord<TypeLeafKind>; +using RemappedType = RemappedRecord<TypeLeafKind>; struct CVMemberRecord { TypeLeafKind Kind; ArrayRef<uint8_t> Data; }; -typedef VarStreamArray<CVType> CVTypeArray; -typedef iterator_range<CVTypeArray::Iterator> CVTypeRange; +using CVTypeArray = VarStreamArray<CVType>; +using CVTypeRange = iterator_range<CVTypeArray::Iterator>; /// Equvalent to CV_fldattr_t in cvinfo.h. struct MemberAttributes { uint16_t Attrs = 0; + enum { MethodKindShift = 2, }; + MemberAttributes() = default; explicit MemberAttributes(MemberAccess Access) @@ -226,6 +226,7 @@ public: TypeIndex getClassType() const { return ClassType; } TypeIndex getFunctionType() const { return FunctionType; } StringRef getName() const { return Name; } + TypeIndex ClassType; TypeIndex FunctionType; StringRef Name; @@ -330,7 +331,6 @@ public: TypeIndex ReferentType; uint32_t Attrs; - Optional<MemberPointerInfo> MemberInfo; private: @@ -490,6 +490,7 @@ public: UnderlyingType(UnderlyingType) {} TypeIndex getUnderlyingType() const { return UnderlyingType; } + TypeIndex UnderlyingType; }; @@ -505,6 +506,7 @@ public: TypeIndex getType() const { return Type; } uint8_t getBitOffset() const { return BitOffset; } uint8_t getBitSize() const { return BitSize; } + TypeIndex Type; uint8_t BitSize; uint8_t BitOffset; @@ -527,6 +529,7 @@ public: } uint32_t getEntryCount() const { return getSlots().size(); } + ArrayRef<VFTableSlotKind> SlotsRef; std::vector<VFTableSlotKind> Slots; }; @@ -541,9 +544,7 @@ public: Name(Name) {} StringRef getGuid() const { return Guid; } - uint32_t getAge() const { return Age; } - StringRef getName() const { return Name; } StringRef Guid; @@ -560,8 +561,8 @@ public: : TypeRecord(TypeRecordKind::StringId), Id(Id), String(String) {} TypeIndex getId() const { return Id; } - StringRef getString() const { return String; } + TypeIndex Id; StringRef String; }; @@ -576,9 +577,7 @@ public: FunctionType(FunctionType), Name(Name) {} TypeIndex getParentScope() const { return ParentScope; } - TypeIndex getFunctionType() const { return FunctionType; } - StringRef getName() const { return Name; } TypeIndex ParentScope; @@ -635,6 +634,7 @@ public: ArgIndices(ArgIndices.begin(), ArgIndices.end()) {} ArrayRef<TypeIndex> getArgs() const { return ArgIndices; } + SmallVector<TypeIndex, 4> ArgIndices; }; @@ -656,6 +656,7 @@ public: TypeIndex getOverriddenVTable() const { return OverriddenVFTable; } uint32_t getVFPtrOffset() const { return VFPtrOffset; } StringRef getName() const { return makeArrayRef(MethodNames).front(); } + ArrayRef<StringRef> getMethodNames() const { return makeArrayRef(MethodNames).drop_front(); } @@ -707,6 +708,7 @@ public: : TypeRecord(TypeRecordKind::MethodOverloadList), Methods(Methods) {} ArrayRef<OneMethodRecord> getMethods() const { return Methods; } + std::vector<OneMethodRecord> Methods; }; @@ -723,6 +725,7 @@ public: uint16_t getNumOverloads() const { return NumOverloads; } TypeIndex getMethodList() const { return MethodList; } StringRef getName() const { return Name; } + uint16_t NumOverloads; TypeIndex MethodList; StringRef Name; @@ -874,7 +877,6 @@ public: }; } // end namespace codeview - } // end namespace llvm #endif // LLVM_DEBUGINFO_CODEVIEW_TYPERECORD_H diff --git a/include/llvm/DebugInfo/CodeView/TypeSerializer.h b/include/llvm/DebugInfo/CodeView/TypeSerializer.h index 988a2d4aa8346..0e734a8170bdf 100644 --- a/include/llvm/DebugInfo/CodeView/TypeSerializer.h +++ b/include/llvm/DebugInfo/CodeView/TypeSerializer.h @@ -10,19 +10,25 @@ #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPESERIALIZER_H #define LLVM_DEBUGINFO_CODEVIEW_TYPESERIALIZER_H +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/DebugInfo/CodeView/CodeView.h" +#include "llvm/DebugInfo/CodeView/RecordSerialization.h" +#include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/DebugInfo/CodeView/TypeRecordMapping.h" #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" +#include "llvm/Support/Allocator.h" #include "llvm/Support/BinaryByteStream.h" #include "llvm/Support/BinaryStreamWriter.h" - -#include "llvm/ADT/Optional.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/Allocator.h" #include "llvm/Support/Error.h" +#include <cassert> +#include <cstdint> +#include <memory> +#include <vector> namespace llvm { - namespace codeview { class TypeHasher; @@ -46,7 +52,7 @@ class TypeSerializer : public TypeVisitorCallbacks { } }; - typedef SmallVector<MutableArrayRef<uint8_t>, 2> MutableRecordList; + using MutableRecordList = SmallVector<MutableArrayRef<uint8_t>, 2>; static constexpr uint8_t ContinuationLength = 8; BumpPtrAllocator &RecordStorage; @@ -82,7 +88,7 @@ class TypeSerializer : public TypeVisitorCallbacks { public: explicit TypeSerializer(BumpPtrAllocator &Storage, bool Hash = true); - ~TypeSerializer(); + ~TypeSerializer() override; void reset(); @@ -146,7 +152,8 @@ private: return Error::success(); } }; -} -} -#endif +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_TYPESERIALIZER_H diff --git a/include/llvm/DebugInfo/CodeView/TypeServerHandler.h b/include/llvm/DebugInfo/CodeView/TypeServerHandler.h index 35f06eaf6eb40..e96baad9ceae3 100644 --- a/include/llvm/DebugInfo/CodeView/TypeServerHandler.h +++ b/include/llvm/DebugInfo/CodeView/TypeServerHandler.h @@ -10,16 +10,17 @@ #ifndef LLVM_DEBUGINFO_CODEVIEW_TYPESERVERHANDLER_H #define LLVM_DEBUGINFO_CODEVIEW_TYPESERVERHANDLER_H -#include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/Support/Error.h" namespace llvm { namespace codeview { + +class TypeServer2Record; class TypeVisitorCallbacks; class TypeServerHandler { public: - virtual ~TypeServerHandler() {} + virtual ~TypeServerHandler() = default; /// Handle a TypeServer record. If the implementation returns true /// the record will not be processed by the top-level visitor. If @@ -30,7 +31,8 @@ public: return false; } }; -} -} -#endif +} // end namespace codeview +} // end namespace llvm + +#endif // LLVM_DEBUGINFO_CODEVIEW_TYPESERVERHANDLER_H |