diff options
Diffstat (limited to 'llvm/include')
32 files changed, 374 insertions, 340 deletions
diff --git a/llvm/include/llvm/DebugInfo/CodeView/CVRecord.h b/llvm/include/llvm/DebugInfo/CodeView/CVRecord.h index dba359fcbe8..30c13ce5880 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/CVRecord.h +++ b/llvm/include/llvm/DebugInfo/CodeView/CVRecord.h @@ -12,9 +12,10 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/iterator_range.h" +#include "llvm/DebugInfo/CodeView/CodeViewError.h" #include "llvm/DebugInfo/CodeView/RecordSerialization.h" -#include "llvm/DebugInfo/CodeView/StreamInterface.h" -#include "llvm/DebugInfo/CodeView/StreamReader.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" +#include "llvm/DebugInfo/Msf/StreamRef.h" #include "llvm/Support/Endian.h" namespace llvm { @@ -26,10 +27,14 @@ template <typename Kind> struct CVRecord { ArrayRef<uint8_t> Data; ArrayRef<uint8_t> RawData; }; +} +namespace msf { -template <typename Kind> struct VarStreamArrayExtractor<CVRecord<Kind>> { +template <typename Kind> +struct VarStreamArrayExtractor<codeview::CVRecord<Kind>> { Error operator()(StreamRef Stream, uint32_t &Len, - CVRecord<Kind> &Item) const { + codeview::CVRecord<Kind> &Item) const { + using namespace codeview; const RecordPrefix *Prefix = nullptr; StreamReader Reader(Stream); uint32_t Offset = Reader.getOffset(); diff --git a/llvm/include/llvm/DebugInfo/CodeView/CodeViewOStream.h b/llvm/include/llvm/DebugInfo/CodeView/CodeViewOStream.h deleted file mode 100644 index 14d057a249a..00000000000 --- a/llvm/include/llvm/DebugInfo/CodeView/CodeViewOStream.h +++ /dev/null @@ -1,39 +0,0 @@ -//===- CodeViewOStream.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_CODEVIEWOSTREAM_H -#define LLVM_DEBUGINFO_CODEVIEW_CODEVIEWOSTREAM_H - -#include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/TypeIndex.h" - -namespace llvm { -namespace codeview { - -template <typename Writer> class CodeViewOStream { -private: - CodeViewOStream(const CodeViewOStream &) = delete; - CodeViewOStream &operator=(const CodeViewOStream &) = delete; - -public: - typedef typename Writer::LabelType LabelType; - -public: - explicit CodeViewOStream(Writer &W); - -private: - uint64_t size() const { return W.tell(); } - -private: - Writer &W; -}; -} -} - -#endif diff --git a/llvm/include/llvm/DebugInfo/CodeView/ModuleSubstream.h b/llvm/include/llvm/DebugInfo/CodeView/ModuleSubstream.h index 6affac801d4..a530a5d888a 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/ModuleSubstream.h +++ b/llvm/include/llvm/DebugInfo/CodeView/ModuleSubstream.h @@ -11,8 +11,8 @@ #define LLVM_DEBUGINFO_CODEVIEW_MODULESUBSTREAM_H #include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/StreamArray.h" -#include "llvm/DebugInfo/CodeView/StreamRef.h" +#include "llvm/DebugInfo/Msf/StreamArray.h" +#include "llvm/DebugInfo/Msf/StreamRef.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" @@ -59,29 +59,31 @@ struct ColumnNumberEntry { class ModuleSubstream { public: ModuleSubstream(); - ModuleSubstream(ModuleSubstreamKind Kind, StreamRef Data); - static Error initialize(StreamRef Stream, ModuleSubstream &Info); + ModuleSubstream(ModuleSubstreamKind Kind, msf::StreamRef Data); + static Error initialize(msf::StreamRef Stream, ModuleSubstream &Info); uint32_t getRecordLength() const; ModuleSubstreamKind getSubstreamKind() const; - StreamRef getRecordData() const; + msf::StreamRef getRecordData() const; private: ModuleSubstreamKind Kind; - StreamRef Data; + msf::StreamRef Data; }; -template <> struct VarStreamArrayExtractor<ModuleSubstream> { +typedef msf::VarStreamArray<ModuleSubstream> ModuleSubstreamArray; +} // namespace codeview + +namespace msf { +template <> struct VarStreamArrayExtractor<codeview::ModuleSubstream> { Error operator()(StreamRef Stream, uint32_t &Length, - ModuleSubstream &Info) const { - if (auto EC = ModuleSubstream::initialize(Stream, Info)) + codeview::ModuleSubstream &Info) const { + if (auto EC = codeview::ModuleSubstream::initialize(Stream, Info)) return EC; Length = Info.getRecordLength(); return Error::success(); } }; - -typedef VarStreamArray<ModuleSubstream> ModuleSubstreamArray; -} -} +} // namespace msf +} // namespace llvm #endif // LLVM_DEBUGINFO_CODEVIEW_MODULESUBSTREAM_H diff --git a/llvm/include/llvm/DebugInfo/CodeView/ModuleSubstreamVisitor.h b/llvm/include/llvm/DebugInfo/CodeView/ModuleSubstreamVisitor.h index 6df23090371..697bc7d787a 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/ModuleSubstreamVisitor.h +++ b/llvm/include/llvm/DebugInfo/CodeView/ModuleSubstreamVisitor.h @@ -14,24 +14,62 @@ #include "llvm/DebugInfo/CodeView/CodeViewError.h" #include "llvm/DebugInfo/CodeView/Line.h" #include "llvm/DebugInfo/CodeView/ModuleSubstream.h" -#include "llvm/DebugInfo/CodeView/StreamReader.h" -#include "llvm/DebugInfo/CodeView/StreamRef.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" +#include "llvm/DebugInfo/Msf/StreamRef.h" namespace llvm { namespace codeview { - struct LineColumnEntry { support::ulittle32_t NameIndex; - FixedStreamArray<LineNumberEntry> LineNumbers; - FixedStreamArray<ColumnNumberEntry> Columns; + msf::FixedStreamArray<LineNumberEntry> LineNumbers; + msf::FixedStreamArray<ColumnNumberEntry> Columns; +}; + +struct FileChecksumEntry { + uint32_t FileNameOffset; // Byte offset of filename in global stringtable. + FileChecksumKind Kind; // The type of checksum. + ArrayRef<uint8_t> Checksum; // The bytes of the checksum. +}; + +typedef msf::VarStreamArray<LineColumnEntry> LineInfoArray; +typedef msf::VarStreamArray<FileChecksumEntry> FileChecksumArray; + +class IModuleSubstreamVisitor { +public: + virtual ~IModuleSubstreamVisitor() {} + + virtual Error visitUnknown(ModuleSubstreamKind Kind, msf::StreamRef Data) = 0; + virtual Error visitSymbols(msf::StreamRef Data); + virtual Error visitLines(msf::StreamRef Data, + const LineSubstreamHeader *Header, + const LineInfoArray &Lines); + virtual Error visitStringTable(msf::StreamRef Data); + virtual Error visitFileChecksums(msf::StreamRef Data, + const FileChecksumArray &Checksums); + virtual Error visitFrameData(msf::StreamRef Data); + virtual Error visitInlineeLines(msf::StreamRef Data); + virtual Error visitCrossScopeImports(msf::StreamRef Data); + virtual Error visitCrossScopeExports(msf::StreamRef Data); + virtual Error visitILLines(msf::StreamRef Data); + virtual Error visitFuncMDTokenMap(msf::StreamRef Data); + virtual Error visitTypeMDTokenMap(msf::StreamRef Data); + virtual Error visitMergedAssemblyInput(msf::StreamRef Data); + virtual Error visitCoffSymbolRVA(msf::StreamRef Data); }; -template <> class VarStreamArrayExtractor<LineColumnEntry> { +Error visitModuleSubstream(const ModuleSubstream &R, + IModuleSubstreamVisitor &V); +} // namespace codeview + +namespace msf { +template <> class VarStreamArrayExtractor<codeview::LineColumnEntry> { public: - VarStreamArrayExtractor(const LineSubstreamHeader *Header) : Header(Header) {} + VarStreamArrayExtractor(const codeview::LineSubstreamHeader *Header) + : Header(Header) {} Error operator()(StreamRef Stream, uint32_t &Len, - LineColumnEntry &Item) const { + codeview::LineColumnEntry &Item) const { + using namespace codeview; const LineFileBlockHeader *BlockHeader; StreamReader Reader(Stream); if (auto EC = Reader.readObject(BlockHeader)) @@ -61,19 +99,14 @@ public: } private: - const LineSubstreamHeader *Header; + const codeview::LineSubstreamHeader *Header; }; -struct FileChecksumEntry { - uint32_t FileNameOffset; // Byte offset of filename in global stringtable. - FileChecksumKind Kind; // The type of checksum. - ArrayRef<uint8_t> Checksum; // The bytes of the checksum. -}; - -template <> class VarStreamArrayExtractor<FileChecksumEntry> { +template <> class VarStreamArrayExtractor<codeview::FileChecksumEntry> { public: Error operator()(StreamRef Stream, uint32_t &Len, - FileChecksumEntry &Item) const { + codeview::FileChecksumEntry &Item) const { + using namespace codeview; const FileChecksum *Header; StreamReader Reader(Stream); if (auto EC = Reader.readObject(Header)) @@ -87,35 +120,7 @@ public: } }; -typedef VarStreamArray<LineColumnEntry> LineInfoArray; -typedef VarStreamArray<FileChecksumEntry> FileChecksumArray; - -class IModuleSubstreamVisitor { -public: - virtual ~IModuleSubstreamVisitor() {} - - virtual Error visitUnknown(ModuleSubstreamKind Kind, StreamRef Data) = 0; - virtual Error visitSymbols(StreamRef Data); - virtual Error visitLines(StreamRef Data, const LineSubstreamHeader *Header, - const LineInfoArray &Lines); - virtual Error visitStringTable(StreamRef Data); - virtual Error visitFileChecksums(StreamRef Data, - const FileChecksumArray &Checksums); - virtual Error visitFrameData(StreamRef Data); - virtual Error visitInlineeLines(StreamRef Data); - virtual Error visitCrossScopeImports(StreamRef Data); - virtual Error visitCrossScopeExports(StreamRef Data); - virtual Error visitILLines(StreamRef Data); - virtual Error visitFuncMDTokenMap(StreamRef Data); - virtual Error visitTypeMDTokenMap(StreamRef Data); - virtual Error visitMergedAssemblyInput(StreamRef Data); - virtual Error visitCoffSymbolRVA(StreamRef Data); -}; - -Error visitModuleSubstream(const ModuleSubstream &R, - IModuleSubstreamVisitor &V); - -} // namespace codeview +} // namespace msf } // namespace llvm #endif // LLVM_DEBUGINFO_CODEVIEW_MODULESUBSTREAMVISITOR_H diff --git a/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h b/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h index 77e894fba4a..b3974ecb862 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h +++ b/llvm/include/llvm/DebugInfo/CodeView/SymbolRecord.h @@ -15,18 +15,17 @@ #include "llvm/DebugInfo/CodeView/CVRecord.h" #include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/RecordSerialization.h" -#include "llvm/DebugInfo/CodeView/StreamArray.h" -#include "llvm/DebugInfo/CodeView/StreamInterface.h" #include "llvm/DebugInfo/CodeView/TypeIndex.h" +#include "llvm/DebugInfo/Msf/StreamArray.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" namespace llvm { namespace codeview { -using llvm::support::ulittle16_t; -using llvm::support::ulittle32_t; -using llvm::support::little32_t; +using support::ulittle16_t; +using support::ulittle32_t; +using support::little32_t; class SymbolRecord { protected: @@ -1444,7 +1443,7 @@ public: }; typedef CVRecord<SymbolKind> CVSymbol; -typedef VarStreamArray<CVSymbol> CVSymbolArray; +typedef msf::VarStreamArray<CVSymbol> CVSymbolArray; } // namespace codeview } // namespace llvm diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h b/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h index 42751fbd4af..bbb3769333c 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h +++ b/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h @@ -1195,7 +1195,7 @@ private: }; typedef CVRecord<TypeLeafKind> CVType; -typedef VarStreamArray<CVType> CVTypeArray; +typedef msf::VarStreamArray<CVType> CVTypeArray; } } diff --git a/llvm/include/llvm/DebugInfo/CodeView/ByteStream.h b/llvm/include/llvm/DebugInfo/Msf/ByteStream.h index f398c93723e..621848cf3d2 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/ByteStream.h +++ b/llvm/include/llvm/DebugInfo/Msf/ByteStream.h @@ -7,19 +7,19 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_CODEVIEW_BYTESTREAM_H -#define LLVM_DEBUGINFO_CODEVIEW_BYTESTREAM_H +#ifndef LLVM_DEBUGINFO_MSF_BYTESTREAM_H +#define LLVM_DEBUGINFO_MSF_BYTESTREAM_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/StreamInterface.h" +#include "llvm/DebugInfo/Msf/StreamInterface.h" #include "llvm/Support/Error.h" #include <cstdint> #include <memory> #include <type_traits> namespace llvm { -namespace codeview { +namespace msf { class StreamReader; template <bool Writable = false> class ByteStream : public StreamInterface { @@ -52,7 +52,7 @@ private: extern template class ByteStream<true>; extern template class ByteStream<false>; -} // end namespace pdb +} // end namespace msf } // end namespace llvm -#endif // LLVM_DEBUGINFO_CODEVIEW_BYTESTREAM_H +#endif // LLVM_DEBUGINFO_MSF_BYTESTREAM_H diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/DirectoryStreamData.h b/llvm/include/llvm/DebugInfo/Msf/DirectoryStreamData.h index 0f354315122..283d9b283e6 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/DirectoryStreamData.h +++ b/llvm/include/llvm/DebugInfo/Msf/DirectoryStreamData.h @@ -7,29 +7,31 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_PDB_RAW_DIRECTORYSTREAMDATA_H -#define LLVM_DEBUGINFO_PDB_RAW_DIRECTORYSTREAMDATA_H +#ifndef LLVM_DEBUGINFO_MSF_DIRECTORYSTREAMDATA_H +#define LLVM_DEBUGINFO_MSF_DIRECTORYSTREAMDATA_H #include "llvm/ADT/ArrayRef.h" -#include "llvm/DebugInfo/PDB/Raw/IPDBStreamData.h" -#include "llvm/DebugInfo/PDB/Raw/PDBFile.h" +#include "llvm/DebugInfo/Msf/IMsfFile.h" +#include "llvm/DebugInfo/Msf/IMsfStreamData.h" #include "llvm/Support/Endian.h" namespace llvm { -namespace pdb { -class IPDBFile; +namespace msf { +class IMsfFile; -class DirectoryStreamData : public IPDBStreamData { +class DirectoryStreamData : public IMsfStreamData { public: - DirectoryStreamData(const PDBFile &File) : File(File) {} + DirectoryStreamData(uint32_t Length, ArrayRef<support::ulittle32_t> Blocks) + : Length(Length), Blocks(Blocks) {} - virtual uint32_t getLength() { return File.getNumDirectoryBytes(); } + virtual uint32_t getLength() { return Length; } virtual llvm::ArrayRef<llvm::support::ulittle32_t> getStreamBlocks() { - return File.getDirectoryBlockArray(); + return Blocks; } private: - const PDBFile &File; + uint32_t Length; + ArrayRef<support::ulittle32_t> Blocks; }; } } diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h b/llvm/include/llvm/DebugInfo/Msf/IMsfFile.h index fccea2ac247..1c7eeb92d28 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h +++ b/llvm/include/llvm/DebugInfo/Msf/IMsfFile.h @@ -1,4 +1,4 @@ -//===- IPDBFile.h - Abstract base class for a PDB file ----------*- C++ -*-===// +//===- IMsfFile.h - Abstract base class for an MSF file ---------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,23 +7,23 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_PDB_RAW_IPDBFILE_H -#define LLVM_DEBUGINFO_PDB_RAW_IPDBFILE_H +#ifndef LLVM_DEBUGINFO_MSF_IMSFFILE_H +#define LLVM_DEBUGINFO_MSF_IMSFFILE_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/StreamArray.h" +#include "llvm/DebugInfo/Msf/StreamArray.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" #include <stdint.h> namespace llvm { -namespace pdb { +namespace msf { -class IPDBFile { +class IMsfFile { public: - virtual ~IPDBFile() {} + virtual ~IMsfFile() {} virtual uint32_t getBlockSize() const = 0; virtual uint32_t getBlockCount() const = 0; @@ -41,4 +41,4 @@ public: } } -#endif // LLVM_DEBUGINFO_PDB_RAW_IPDBFILE_H +#endif // LLVM_DEBUGINFO_MSF_IMSFFILE_H diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/IPDBStreamData.h b/llvm/include/llvm/DebugInfo/Msf/IMsfStreamData.h index ab3c9f77075..0b70d90f8d2 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/IPDBStreamData.h +++ b/llvm/include/llvm/DebugInfo/Msf/IMsfStreamData.h @@ -1,4 +1,4 @@ -//===- IPDBStreamData.h - Base interface for PDB Stream Data ----*- C++ -*-===// +//===- IMsfStreamData.h - Base interface for Msf Stream Data ----*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,15 +7,17 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_PDB_RAW_IPDBSTREAMDATA_H -#define LLVM_DEBUGINFO_PDB_RAW_IPDBSTREAMDATA_H +#ifndef LLVM_DEBUGINFO_MSF_IMSFSTREAMDATA_H +#define LLVM_DEBUGINFO_MSF_IMSFSTREAMDATA_H #include "llvm/ADT/ArrayRef.h" #include "llvm/Support/Endian.h" +#include <cstdint> + namespace llvm { -namespace pdb { -/// IPDBStream abstracts the notion of PDB stream data. Although we already +namespace msf { +/// IMsfStream abstracts the notion of PDB stream data. Although we already /// have another stream abstraction (namely in the form of StreamInterface /// and MappedBlockStream), they assume that the stream data is referenced /// the same way. Namely, by looking in the directory to get the list of @@ -25,14 +27,14 @@ namespace pdb { /// notion of stream data further, we can use a MappedBlockStream to read /// from the directory itself, or from an indexed stream which references /// the directory. -class IPDBStreamData { +class IMsfStreamData { public: - virtual ~IPDBStreamData() {} + virtual ~IMsfStreamData() {} virtual uint32_t getLength() = 0; virtual ArrayRef<support::ulittle32_t> getStreamBlocks() = 0; }; -} -} +} // namespace msf +} // namespace llvm -#endif +#endif // LLVM_DEBUGINFO_MSF_IMSFSTREAMDATA_H diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/IndexedStreamData.h b/llvm/include/llvm/DebugInfo/Msf/IndexedStreamData.h index 30563bc5b89..ff9d8b37f19 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/IndexedStreamData.h +++ b/llvm/include/llvm/DebugInfo/Msf/IndexedStreamData.h @@ -1,4 +1,4 @@ -//===- IndexedStreamData.h - Standard PDB Stream Data -----------*- C++ -*-===// +//===- IndexedStreamData.h - Standard Msf Stream Data -----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,18 +7,18 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_PDB_RAW_INDEXEDSTREAMDATA_H -#define LLVM_DEBUGINFO_PDB_RAW_INDEXEDSTREAMDATA_H +#ifndef LLVM_DEBUGINFO_MSF_INDEXEDSTREAMDATA_H +#define LLVM_DEBUGINFO_MSF_INDEXEDSTREAMDATA_H -#include "llvm/DebugInfo/PDB/Raw/IPDBStreamData.h" +#include "llvm/DebugInfo/Msf/IMsfStreamData.h" namespace llvm { -namespace pdb { -class IPDBFile; +namespace msf { +class IMsfFile; -class IndexedStreamData : public IPDBStreamData { +class IndexedStreamData : public IMsfStreamData { public: - IndexedStreamData(uint32_t StreamIdx, const IPDBFile &File); + IndexedStreamData(uint32_t StreamIdx, const IMsfFile &File); virtual ~IndexedStreamData() {} uint32_t getLength() override; @@ -26,9 +26,9 @@ public: private: uint32_t StreamIdx; - const IPDBFile &File; + const IMsfFile &File; }; -} -} +} // namespace msf +} // namespace llvm -#endif +#endif // LLVM_DEBUGINFO_MSF_INDEXEDSTREAMDATA_H diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h b/llvm/include/llvm/DebugInfo/Msf/MappedBlockStream.h index 36424c0d16a..9f8e04521b5 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h +++ b/llvm/include/llvm/DebugInfo/Msf/MappedBlockStream.h @@ -1,4 +1,5 @@ -//===- MappedBlockStream.h - Reads stream data from a PDBFile ---*- C++ -*-===// +//===- MappedBlockStream.h - Discontiguous stream data in an Msf -*- C++ +//-*-===// // // The LLVM Compiler Infrastructure // @@ -7,14 +8,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_PDB_RAW_MAPPEDBLOCKSTREAM_H -#define LLVM_DEBUGINFO_PDB_RAW_MAPPEDBLOCKSTREAM_H +#ifndef LLVM_DEBUGINFO_MSF_MAPPEDBLOCKSTREAM_H +#define LLVM_DEBUGINFO_MSF_MAPPEDBLOCKSTREAM_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/DebugInfo/CodeView/StreamInterface.h" -#include "llvm/DebugInfo/PDB/Raw/IPDBStreamData.h" +#include "llvm/DebugInfo/Msf/IMsfStreamData.h" +#include "llvm/DebugInfo/Msf/StreamInterface.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" @@ -22,12 +23,21 @@ #include <vector> namespace llvm { -namespace pdb { +namespace msf { -class IPDBFile; -class PDBFile; +class IMsfFile; -class MappedBlockStream : public codeview::StreamInterface { +/// MappedBlockStream represents data stored in an Msf file into chunks of a +/// particular size (called the Block Size), and whose chunks may not be +/// necessarily contiguous. The arrangement of these chunks within the file +/// is described by some other metadata contained within the Msf file. In +/// the case of a standard Msf Stream, the layout of the stream's blocks +/// is described by the Msf "directory", but in the case of the directory +/// itself, the layout is described by an array at a fixed location within +/// the Msf. MappedBlockStream provides methods for reading from and writing +/// to one of these streams transparently, as if it were a contiguous sequence +/// of bytes. +class MappedBlockStream : public StreamInterface { public: Error readBytes(uint32_t Offset, uint32_t Size, ArrayRef<uint8_t> &Buffer) const override; @@ -41,21 +51,22 @@ public: uint32_t getNumBytesCopied() const; static Expected<std::unique_ptr<MappedBlockStream>> - createIndexedStream(uint32_t StreamIdx, const IPDBFile &File); + createIndexedStream(uint32_t StreamIdx, const IMsfFile &File); static Expected<std::unique_ptr<MappedBlockStream>> - createDirectoryStream(const PDBFile &File); + createDirectoryStream(uint32_t Length, ArrayRef<support::ulittle32_t> Blocks, + const IMsfFile &File); llvm::BumpPtrAllocator &getAllocator() { return Pool; } protected: - MappedBlockStream(std::unique_ptr<IPDBStreamData> Data, const IPDBFile &File); + MappedBlockStream(std::unique_ptr<IMsfStreamData> Data, const IMsfFile &File); Error readBytes(uint32_t Offset, MutableArrayRef<uint8_t> Buffer) const; bool tryReadContiguously(uint32_t Offset, uint32_t Size, ArrayRef<uint8_t> &Buffer) const; - const IPDBFile &Pdb; - std::unique_ptr<IPDBStreamData> Data; + const IMsfFile &Msf; + std::unique_ptr<IMsfStreamData> Data; typedef MutableArrayRef<uint8_t> CacheEntry; mutable llvm::BumpPtrAllocator Pool; @@ -65,4 +76,4 @@ protected: } // end namespace pdb } // end namespace llvm -#endif // LLVM_DEBUGINFO_PDB_RAW_MAPPEDBLOCKSTREAM_H +#endif // LLVM_DEBUGINFO_MSF_MAPPEDBLOCKSTREAM_H diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/MsfBuilder.h b/llvm/include/llvm/DebugInfo/Msf/MsfBuilder.h index 92d9bc042cc..814e1655745 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/MsfBuilder.h +++ b/llvm/include/llvm/DebugInfo/Msf/MsfBuilder.h @@ -7,14 +7,13 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_PDB_RAW_MSFBUILDER_H -#define LLVM_DEBUGINFO_PDB_RAW_MSFBUILDER_H +#ifndef LLVM_DEBUGINFO_MSF_MSFBUILDER_H +#define LLVM_DEBUGINFO_MSF_MSFBUILDER_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/BitVector.h" -#include "llvm/DebugInfo/PDB/Raw/MsfCommon.h" -#include "llvm/DebugInfo/PDB/Raw/PDBFile.h" +#include "llvm/DebugInfo/Msf/MsfCommon.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Endian.h" @@ -24,7 +23,7 @@ #include <vector> namespace llvm { -namespace pdb { +namespace msf { class MsfBuilder { public: /// \brief Create a new `MsfBuilder`. @@ -34,9 +33,9 @@ public: /// /// \param MinBlockCount Causes the builder to reserve up front space for /// at least `MinBlockCount` blocks. This is useful when using `MsfBuilder` - /// to read an existing PDB that you want to write back out later. The - /// original PDB file's SuperBlock contains the exact number of blocks used - /// by the file, so is a good hint as to how many blocks the new PDB file + /// to read an existing MSF that you want to write back out later. The + /// original MSF file's SuperBlock contains the exact number of blocks used + /// by the file, so is a good hint as to how many blocks the new MSF file /// will contain. Furthermore, it is actually necessary in this case. To /// preserve stability of the file's layout, it is helpful to try to keep /// all streams mapped to their original block numbers. To ensure that this @@ -45,7 +44,7 @@ public: /// /// \param CanGrow If true, any operation which results in an attempt to /// locate a free block when all available blocks have been exhausted will - /// allocate a new block, thereby growing the size of the final PDB file. + /// allocate a new block, thereby growing the size of the final MSF file. /// When false, any such attempt will result in an error. This is especially /// useful in testing scenarios when you know your test isn't going to do /// anything to increase the size of the file, so having an Error returned if @@ -61,14 +60,14 @@ public: bool CanGrow = true); /// Request the block map to be at a specific block address. This is useful - /// when editing a PDB and you want the layout to be as stable as possible. + /// when editing a MSF and you want the layout to be as stable as possible. Error setBlockMapAddr(uint32_t Addr); Error setDirectoryBlocksHint(ArrayRef<uint32_t> DirBlocks); void setFreePageMap(uint32_t Fpm); void setUnknown1(uint32_t Unk1); /// Add a stream to the MSF file with the given size, occupying the given - /// list of blocks. This is useful when reading a PDB file and you want a + /// list of blocks. This is useful when reading a MSF file and you want a /// particular stream to occupy the original set of blocks. If the given /// blocks are already allocated, or if the number of blocks specified is /// incorrect for the given stream size, this function will return an Error. @@ -112,7 +111,7 @@ public: /// Finalize the layout and build the headers and structures that describe the /// MSF layout and can be written directly to the MSF file. - Expected<msf::Layout> build(); + Expected<Layout> build(); private: MsfBuilder(uint32_t BlockSize, uint32_t MinBlockCount, bool CanGrow, @@ -135,7 +134,7 @@ private: std::vector<uint32_t> DirectoryBlocks; std::vector<std::pair<uint32_t, BlockList>> StreamData; }; -} -} +} // namespace msf +} // namespace llvm -#endif +#endif // LLVM_DEBUGINFO_MSF_MSFBUILDER_H diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/MsfCommon.h b/llvm/include/llvm/DebugInfo/Msf/MsfCommon.h index 2f6a6986eba..98bfb3b7d1a 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/MsfCommon.h +++ b/llvm/include/llvm/DebugInfo/Msf/MsfCommon.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_PDB_RAW_MSFCOMMON_H -#define LLVM_DEBUGINFO_PDB_RAW_MSFCOMMON_H +#ifndef LLVM_DEBUGINFO_MSF_MSFCOMMON_H +#define LLVM_DEBUGINFO_MSF_MSFCOMMON_H #include "llvm/ADT/ArrayRef.h" @@ -19,7 +19,6 @@ #include <vector> namespace llvm { -namespace pdb { namespace msf { static const char Magic[] = {'M', 'i', 'c', 'r', 'o', 's', 'o', 'f', 't', ' ', 'C', '/', 'C', '+', '+', ' ', @@ -38,7 +37,7 @@ struct SuperBlock { // The index of the free block map. support::ulittle32_t FreeBlockMapBlock; // This contains the number of blocks resident in the file system. In - // practice, NumBlocks * BlockSize is equivalent to the size of the PDB + // practice, NumBlocks * BlockSize is equivalent to the size of the MSF // file. support::ulittle32_t NumBlocks; // This contains the number of bytes which make up the directory. @@ -83,8 +82,7 @@ inline uint64_t blockToOffset(uint64_t BlockNumber, uint64_t BlockSize) { } Error validateSuperBlock(const SuperBlock &SB); -} -} -} +} // namespace msf +} // namespace llvm -#endif +#endif // LLVM_DEBUGINFO_MSF_MSFCOMMON_H diff --git a/llvm/include/llvm/DebugInfo/Msf/MsfError.h b/llvm/include/llvm/DebugInfo/Msf/MsfError.h new file mode 100644 index 00000000000..4cdbaec3962 --- /dev/null +++ b/llvm/include/llvm/DebugInfo/Msf/MsfError.h @@ -0,0 +1,47 @@ +//===- MsfError.h - Error extensions for Msf Files --------------*- 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_MSF_MSFERROR_H +#define LLVM_DEBUGINFO_MSF_MSFERROR_H + +#include "llvm/Support/Error.h" + +#include <string> + +namespace llvm { +namespace msf { +enum class msf_error_code { + unspecified = 1, + insufficient_buffer, + not_writable, + no_stream, + invalid_format, + block_in_use +}; + +/// Base class for errors originating when parsing raw PDB files +class MsfError : public ErrorInfo<MsfError> { +public: + static char ID; + MsfError(msf_error_code C); + MsfError(const std::string &Context); + MsfError(msf_error_code C, const std::string &Context); + + void log(raw_ostream &OS) const override; + const std::string &getErrorMessage() const; + std::error_code convertToErrorCode() const override; + +private: + std::string ErrMsg; + msf_error_code Code; +}; +} // namespace msf +} // namespace llvm + +#endif // LLVM_DEBUGINFO_MSF_MSFERROR_H diff --git a/llvm/include/llvm/DebugInfo/CodeView/StreamArray.h b/llvm/include/llvm/DebugInfo/Msf/StreamArray.h index 0b9349aac75..dcdae8f00a0 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/StreamArray.h +++ b/llvm/include/llvm/DebugInfo/Msf/StreamArray.h @@ -7,17 +7,17 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_CODEVIEW_STREAMARRAY_H -#define LLVM_DEBUGINFO_CODEVIEW_STREAMARRAY_H +#ifndef LLVM_DEBUGINFO_MSF_STREAMARRAY_H +#define LLVM_DEBUGINFO_MSF_STREAMARRAY_H -#include "llvm/DebugInfo/CodeView/StreamRef.h" +#include "llvm/DebugInfo/Msf/StreamRef.h" #include "llvm/Support/Error.h" #include <functional> #include <type_traits> namespace llvm { -namespace codeview { +namespace msf { /// VarStreamArrayExtractor is intended to be specialized to provide customized /// extraction logic. On input it receives a StreamRef pointing to the @@ -269,7 +269,7 @@ private: uint32_t Index; }; -} // namespace codeview +} // namespace msf } // namespace llvm -#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMARRAY_H +#endif // LLVM_DEBUGINFO_MSF_STREAMARRAY_H diff --git a/llvm/include/llvm/DebugInfo/CodeView/StreamInterface.h b/llvm/include/llvm/DebugInfo/Msf/StreamInterface.h index 241aec45787..7a886e39289 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/StreamInterface.h +++ b/llvm/include/llvm/DebugInfo/Msf/StreamInterface.h @@ -7,15 +7,15 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_CODEVIEW_STREAMINTERFACE_H -#define LLVM_DEBUGINFO_CODEVIEW_STREAMINTERFACE_H +#ifndef LLVM_DEBUGINFO_MSF_STREAMINTERFACE_H +#define LLVM_DEBUGINFO_MSF_STREAMINTERFACE_H #include "llvm/ADT/ArrayRef.h" #include "llvm/Support/Error.h" #include <cstdint> namespace llvm { -namespace codeview { +namespace msf { /// StreamInterface abstracts the notion of a data stream. This way, an /// implementation could implement trivial reading from a contiguous memory @@ -49,7 +49,7 @@ public: virtual Error commit() const = 0; }; -} // end namespace codeview +} // end namespace msf } // end namespace llvm -#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMINTERFACE_H +#endif // LLVM_DEBUGINFO_MSF_STREAMINTERFACE_H diff --git a/llvm/include/llvm/DebugInfo/CodeView/StreamReader.h b/llvm/include/llvm/DebugInfo/Msf/StreamReader.h index 2f497c2c43f..3d03f406551 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/StreamReader.h +++ b/llvm/include/llvm/DebugInfo/Msf/StreamReader.h @@ -7,20 +7,20 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_CODEVIEW_STREAMREADER_H -#define LLVM_DEBUGINFO_CODEVIEW_STREAMREADER_H +#ifndef LLVM_DEBUGINFO_MSF_STREAMREADER_H +#define LLVM_DEBUGINFO_MSF_STREAMREADER_H #include "llvm/ADT/ArrayRef.h" -#include "llvm/DebugInfo/CodeView/CodeViewError.h" -#include "llvm/DebugInfo/CodeView/StreamArray.h" -#include "llvm/DebugInfo/CodeView/StreamInterface.h" +#include "llvm/DebugInfo/Msf/MsfError.h" +#include "llvm/DebugInfo/Msf/StreamArray.h" +#include "llvm/DebugInfo/Msf/StreamInterface.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" #include <string> namespace llvm { -namespace codeview { +namespace msf { class StreamRef; @@ -61,8 +61,8 @@ public: return Error::success(); } - if (NumElements > UINT32_MAX/sizeof(T)) - return make_error<CodeViewError>(cv_error_code::insufficient_buffer); + if (NumElements > UINT32_MAX / sizeof(T)) + return make_error<MsfError>(msf_error_code::insufficient_buffer); if (auto EC = readBytes(Bytes, NumElements * sizeof(T))) return EC; @@ -87,9 +87,9 @@ public: } uint32_t Length = NumItems * sizeof(T); if (Length / sizeof(T) != NumItems) - return make_error<CodeViewError>(cv_error_code::corrupt_record); + return make_error<MsfError>(msf_error_code::invalid_format); if (Offset + Length > Stream.getLength()) - return make_error<CodeViewError>(cv_error_code::insufficient_buffer); + return make_error<MsfError>(msf_error_code::insufficient_buffer); StreamRef View = Stream.slice(Offset, Length); Array = FixedStreamArray<T>(View); Offset += Length; @@ -105,7 +105,7 @@ private: StreamRef Stream; uint32_t Offset; }; -} // namespace codeview +} // namespace msf } // namespace llvm -#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMREADER_H +#endif // LLVM_DEBUGINFO_MSF_STREAMREADER_H diff --git a/llvm/include/llvm/DebugInfo/CodeView/StreamRef.h b/llvm/include/llvm/DebugInfo/Msf/StreamRef.h index a4f244a3228..e87d298a834 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/StreamRef.h +++ b/llvm/include/llvm/DebugInfo/Msf/StreamRef.h @@ -7,14 +7,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_CODEVIEW_STREAMREF_H -#define LLVM_DEBUGINFO_CODEVIEW_STREAMREF_H +#ifndef LLVM_DEBUGINFO_MSF_STREAMREF_H +#define LLVM_DEBUGINFO_MSF_STREAMREF_H -#include "llvm/DebugInfo/CodeView/CodeViewError.h" -#include "llvm/DebugInfo/CodeView/StreamInterface.h" +#include "llvm/DebugInfo/Msf/MsfError.h" +#include "llvm/DebugInfo/Msf/StreamInterface.h" namespace llvm { -namespace codeview { +namespace msf { class StreamRef { public: @@ -30,9 +30,9 @@ public: Error readBytes(uint32_t Offset, uint32_t Size, ArrayRef<uint8_t> &Buffer) const { if (ViewOffset + Offset < Offset) - return make_error<CodeViewError>(cv_error_code::insufficient_buffer); + return make_error<MsfError>(msf_error_code::insufficient_buffer); if (Size + Offset > Length) - return make_error<CodeViewError>(cv_error_code::insufficient_buffer); + return make_error<MsfError>(msf_error_code::insufficient_buffer); return Stream->readBytes(ViewOffset + Offset, Size, Buffer); } @@ -41,7 +41,7 @@ public: Error readLongestContiguousChunk(uint32_t Offset, ArrayRef<uint8_t> &Buffer) const { if (Offset >= Length) - return make_error<CodeViewError>(cv_error_code::insufficient_buffer); + return make_error<MsfError>(msf_error_code::insufficient_buffer); if (auto EC = Stream->readLongestContiguousChunk(Offset, Buffer)) return EC; @@ -56,7 +56,7 @@ public: Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Data) const { if (Data.size() + Offset > Length) - return make_error<CodeViewError>(cv_error_code::insufficient_buffer); + return make_error<MsfError>(msf_error_code::insufficient_buffer); return Stream->writeBytes(ViewOffset + Offset, Data); } @@ -98,7 +98,7 @@ private: uint32_t ViewOffset; uint32_t Length; }; -} -} +} // namespace msf +} // namespace llvm -#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMREF_H +#endif // LLVM_DEBUGINFO_MSF_STREAMREF_H diff --git a/llvm/include/llvm/DebugInfo/CodeView/StreamWriter.h b/llvm/include/llvm/DebugInfo/Msf/StreamWriter.h index 4d393d2ef79..a4cf3576a3e 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/StreamWriter.h +++ b/llvm/include/llvm/DebugInfo/Msf/StreamWriter.h @@ -7,20 +7,20 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_DEBUGINFO_CODEVIEW_STREAMWRITER_H -#define LLVM_DEBUGINFO_CODEVIEW_STREAMWRITER_H +#ifndef LLVM_DEBUGINFO_MSF_STREAMWRITER_H +#define LLVM_DEBUGINFO_MSF_STREAMWRITER_H #include "llvm/ADT/ArrayRef.h" -#include "llvm/DebugInfo/CodeView/CodeViewError.h" -#include "llvm/DebugInfo/CodeView/StreamArray.h" -#include "llvm/DebugInfo/CodeView/StreamInterface.h" +#include "llvm/DebugInfo/Msf/MsfError.h" +#include "llvm/DebugInfo/Msf/StreamArray.h" +#include "llvm/DebugInfo/Msf/StreamInterface.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" #include <string> namespace llvm { -namespace codeview { +namespace msf { class StreamRef; @@ -55,7 +55,7 @@ public: return Error::success(); if (Array.size() > UINT32_MAX / sizeof(T)) - return make_error<CodeViewError>(cv_error_code::insufficient_buffer); + return make_error<MsfError>(msf_error_code::insufficient_buffer); return writeBytes( ArrayRef<uint8_t>(reinterpret_cast<const uint8_t *>(Array.data()), @@ -80,7 +80,7 @@ private: StreamRef Stream; uint32_t Offset; }; -} // namespace codeview +} // namespace msf } // namespace llvm -#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMREADER_H +#endif // LLVM_DEBUGINFO_MSF_STREAMWRITER_H diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/DbiStream.h b/llvm/include/llvm/DebugInfo/PDB/Raw/DbiStream.h index 3d2552e1c63..bbdf0dfd562 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/DbiStream.h +++ b/llvm/include/llvm/DebugInfo/PDB/Raw/DbiStream.h @@ -11,10 +11,10 @@ #define LLVM_DEBUGINFO_PDB_RAW_PDBDBISTREAM_H #include "llvm/DebugInfo/CodeView/ModuleSubstream.h" -#include "llvm/DebugInfo/CodeView/StreamArray.h" -#include "llvm/DebugInfo/CodeView/StreamRef.h" +#include "llvm/DebugInfo/Msf/MappedBlockStream.h" +#include "llvm/DebugInfo/Msf/StreamArray.h" +#include "llvm/DebugInfo/Msf/StreamRef.h" #include "llvm/DebugInfo/PDB/PDBTypes.h" -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h" #include "llvm/DebugInfo/PDB/Raw/ModInfo.h" #include "llvm/DebugInfo/PDB/Raw/NameHashTable.h" #include "llvm/DebugInfo/PDB/Raw/RawConstants.h" @@ -37,7 +37,7 @@ class DbiStream { friend class DbiStreamBuilder; public: - DbiStream(PDBFile &File, std::unique_ptr<MappedBlockStream> Stream); + DbiStream(PDBFile &File, std::unique_ptr<msf::MappedBlockStream> Stream); ~DbiStream(); Error reload(); @@ -70,11 +70,11 @@ public: Expected<StringRef> getFileNameForIndex(uint32_t Index) const; - codeview::FixedStreamArray<object::coff_section> getSectionHeaders(); + msf::FixedStreamArray<object::coff_section> getSectionHeaders(); - codeview::FixedStreamArray<object::FpoData> getFpoRecords(); + msf::FixedStreamArray<object::FpoData> getFpoRecords(); - codeview::FixedStreamArray<SecMapEntry> getSectionMap() const; + msf::FixedStreamArray<SecMapEntry> getSectionMap() const; void visitSectionContributions(ISectionContribVisitor &Visitor) const; Error commit(); @@ -88,33 +88,33 @@ private: Error initializeFpoRecords(); PDBFile &Pdb; - std::unique_ptr<MappedBlockStream> Stream; + std::unique_ptr<msf::MappedBlockStream> Stream; std::vector<ModuleInfoEx> ModuleInfos; NameHashTable ECNames; - codeview::StreamRef ModInfoSubstream; - codeview::StreamRef SecContrSubstream; - codeview::StreamRef SecMapSubstream; - codeview::StreamRef FileInfoSubstream; - codeview::StreamRef TypeServerMapSubstream; - codeview::StreamRef ECSubstream; + msf::StreamRef ModInfoSubstream; + msf::StreamRef SecContrSubstream; + msf::StreamRef SecMapSubstream; + msf::StreamRef FileInfoSubstream; + msf::StreamRef TypeServerMapSubstream; + msf::StreamRef ECSubstream; - codeview::StreamRef NamesBuffer; + msf::StreamRef NamesBuffer; - codeview::FixedStreamArray<support::ulittle16_t> DbgStreams; + msf::FixedStreamArray<support::ulittle16_t> DbgStreams; PdbRaw_DbiSecContribVer SectionContribVersion; - codeview::FixedStreamArray<SectionContrib> SectionContribs; - codeview::FixedStreamArray<SectionContrib2> SectionContribs2; - codeview::FixedStreamArray<SecMapEntry> SectionMap; - codeview::FixedStreamArray<support::little32_t> FileNameOffsets; + msf::FixedStreamArray<SectionContrib> SectionContribs; + msf::FixedStreamArray<SectionContrib2> SectionContribs2; + msf::FixedStreamArray<SecMapEntry> SectionMap; + msf::FixedStreamArray<support::little32_t> FileNameOffsets; - std::unique_ptr<MappedBlockStream> SectionHeaderStream; - codeview::FixedStreamArray<object::coff_section> SectionHeaders; + std::unique_ptr<msf::MappedBlockStream> SectionHeaderStream; + msf::FixedStreamArray<object::coff_section> SectionHeaders; - std::unique_ptr<MappedBlockStream> FpoStream; - codeview::FixedStreamArray<object::FpoData> FpoRecords; + std::unique_ptr<msf::MappedBlockStream> FpoStream; + msf::FixedStreamArray<object::FpoData> FpoRecords; const DbiStreamHeader *Header; }; diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h b/llvm/include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h index 747f5cc0493..7abe9546f88 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h +++ b/llvm/include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h @@ -14,7 +14,8 @@ #include "llvm/ADT/StringSet.h" #include "llvm/Support/Error.h" -#include "llvm/DebugInfo/CodeView/ByteStream.h" +#include "llvm/DebugInfo/Msf/ByteStream.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" #include "llvm/DebugInfo/PDB/PDBTypes.h" #include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/DebugInfo/PDB/Raw/RawConstants.h" @@ -75,9 +76,9 @@ private: StringMap<uint32_t> SourceFileNames; - codeview::StreamRef NamesBuffer; - codeview::ByteStream<true> ModInfoBuffer; - codeview::ByteStream<true> FileInfoBuffer; + msf::StreamRef NamesBuffer; + msf::ByteStream<true> ModInfoBuffer; + msf::ByteStream<true> FileInfoBuffer; }; } } diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/InfoStream.h b/llvm/include/llvm/DebugInfo/PDB/Raw/InfoStream.h index 1980bec7153..bc6aebb156a 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/InfoStream.h +++ b/llvm/include/llvm/DebugInfo/PDB/Raw/InfoStream.h @@ -11,8 +11,8 @@ #define LLVM_DEBUGINFO_PDB_RAW_PDBINFOSTREAM_H #include "llvm/ADT/StringMap.h" +#include "llvm/DebugInfo/Msf/MappedBlockStream.h" #include "llvm/DebugInfo/PDB/PDBTypes.h" -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h" #include "llvm/DebugInfo/PDB/Raw/NameMap.h" #include "llvm/DebugInfo/PDB/Raw/RawConstants.h" @@ -35,7 +35,7 @@ class InfoStream { }; public: - InfoStream(std::unique_ptr<MappedBlockStream> Stream); + InfoStream(std::unique_ptr<msf::MappedBlockStream> Stream); Error reload(); Error commit(); @@ -49,7 +49,7 @@ public: iterator_range<StringMapConstIterator<uint32_t>> named_streams() const; private: - std::unique_ptr<MappedBlockStream> Stream; + std::unique_ptr<msf::MappedBlockStream> Stream; // PDB file format version. We only support VC70. See the enumeration // `PdbRaw_ImplVer` for the other possible values. diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/ModInfo.h b/llvm/include/llvm/DebugInfo/PDB/Raw/ModInfo.h index 62282c28017..cdb3735fcb4 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/ModInfo.h +++ b/llvm/include/llvm/DebugInfo/PDB/Raw/ModInfo.h @@ -11,8 +11,8 @@ #define LLVM_DEBUGINFO_PDB_RAW_MODINFO_H #include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/StreamArray.h" -#include "llvm/DebugInfo/CodeView/StreamRef.h" +#include "llvm/DebugInfo/Msf/StreamArray.h" +#include "llvm/DebugInfo/Msf/StreamRef.h" #include "llvm/DebugInfo/PDB/Raw/RawTypes.h" #include "llvm/Support/Endian.h" #include <cstdint> @@ -29,7 +29,7 @@ public: ModInfo(const ModInfo &Info); ~ModInfo(); - static Error initialize(codeview::StreamRef Stream, ModInfo &Info); + static Error initialize(msf::StreamRef Stream, ModInfo &Info); bool hasECInfo() const; uint16_t getTypeServerIndex() const; @@ -63,7 +63,7 @@ struct ModuleInfoEx { } // end namespace pdb -namespace codeview { +namespace msf { template <> struct VarStreamArrayExtractor<pdb::ModInfo> { Error operator()(StreamRef Stream, uint32_t &Length, pdb::ModInfo &Info) const { @@ -73,7 +73,7 @@ template <> struct VarStreamArrayExtractor<pdb::ModInfo> { return Error::success(); } }; -} +} // end namespace msf } // end namespace llvm diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/ModStream.h b/llvm/include/llvm/DebugInfo/PDB/Raw/ModStream.h index d22962cc1e2..bee4075aaf2 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/ModStream.h +++ b/llvm/include/llvm/DebugInfo/PDB/Raw/ModStream.h @@ -13,10 +13,10 @@ #include "llvm/ADT/iterator_range.h" #include "llvm/DebugInfo/CodeView/CVRecord.h" #include "llvm/DebugInfo/CodeView/ModuleSubstream.h" -#include "llvm/DebugInfo/CodeView/StreamArray.h" -#include "llvm/DebugInfo/CodeView/StreamRef.h" #include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h" +#include "llvm/DebugInfo/Msf/MappedBlockStream.h" +#include "llvm/DebugInfo/Msf/StreamArray.h" +#include "llvm/DebugInfo/Msf/StreamRef.h" #include "llvm/Support/Error.h" namespace llvm { @@ -26,7 +26,8 @@ class ModInfo; class ModStream { public: - ModStream(const ModInfo &Module, std::unique_ptr<MappedBlockStream> Stream); + ModStream(const ModInfo &Module, + std::unique_ptr<msf::MappedBlockStream> Stream); ~ModStream(); Error reload(); @@ -42,12 +43,12 @@ public: private: const ModInfo &Mod; - std::unique_ptr<MappedBlockStream> Stream; + std::unique_ptr<msf::MappedBlockStream> Stream; codeview::CVSymbolArray SymbolsSubstream; - codeview::StreamRef LinesSubstream; - codeview::StreamRef C13LinesSubstream; - codeview::StreamRef GlobalRefsSubstream; + msf::StreamRef LinesSubstream; + msf::StreamRef C13LinesSubstream; + msf::StreamRef GlobalRefsSubstream; codeview::ModuleSubstreamArray LineInfo; }; diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/NameHashTable.h b/llvm/include/llvm/DebugInfo/PDB/Raw/NameHashTable.h index c9e060a3a70..7de26f3b270 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/NameHashTable.h +++ b/llvm/include/llvm/DebugInfo/PDB/Raw/NameHashTable.h @@ -12,15 +12,15 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" -#include "llvm/DebugInfo/CodeView/StreamArray.h" -#include "llvm/DebugInfo/CodeView/StreamRef.h" +#include "llvm/DebugInfo/Msf/StreamArray.h" +#include "llvm/DebugInfo/Msf/StreamRef.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" #include <cstdint> #include <vector> namespace llvm { -namespace codeview { +namespace msf { class StreamReader; } namespace pdb { @@ -29,7 +29,7 @@ class NameHashTable { public: NameHashTable(); - Error load(codeview::StreamReader &Stream); + Error load(msf::StreamReader &Stream); uint32_t getNameCount() const { return NameCount; } uint32_t getHashVersion() const { return HashVersion; } @@ -38,11 +38,11 @@ public: StringRef getStringForID(uint32_t ID) const; uint32_t getIDForString(StringRef Str) const; - codeview::FixedStreamArray<support::ulittle32_t> name_ids() const; + msf::FixedStreamArray<support::ulittle32_t> name_ids() const; private: - codeview::StreamRef NamesBuffer; - codeview::FixedStreamArray<support::ulittle32_t> IDs; + msf::StreamRef NamesBuffer; + msf::FixedStreamArray<support::ulittle32_t> IDs; uint32_t Signature; uint32_t HashVersion; uint32_t NameCount; diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/NameMap.h b/llvm/include/llvm/DebugInfo/PDB/Raw/NameMap.h index 8a9b0d187ac..ca1a6541dfb 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/NameMap.h +++ b/llvm/include/llvm/DebugInfo/PDB/Raw/NameMap.h @@ -16,7 +16,7 @@ #include <cstdint> namespace llvm { -namespace codeview { +namespace msf { class StreamReader; class StreamWriter; } @@ -28,8 +28,8 @@ class NameMap { public: NameMap(); - Error load(codeview::StreamReader &Stream); - Error commit(codeview::StreamWriter &Writer); + Error load(msf::StreamReader &Stream); + Error commit(msf::StreamWriter &Writer); bool tryGetValue(StringRef Name, uint32_t &Value) const; diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFile.h b/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFile.h index f4d7eb47d3b..9a08b858f19 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFile.h +++ b/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFile.h @@ -11,10 +11,10 @@ #define LLVM_DEBUGINFO_PDB_RAW_PDBFILE_H #include "llvm/ADT/DenseMap.h" -#include "llvm/DebugInfo/CodeView/StreamArray.h" -#include "llvm/DebugInfo/CodeView/StreamInterface.h" -#include "llvm/DebugInfo/PDB/Raw/IPDBFile.h" -#include "llvm/DebugInfo/PDB/Raw/MsfCommon.h" +#include "llvm/DebugInfo/Msf/IMsfFile.h" +#include "llvm/DebugInfo/Msf/MsfCommon.h" +#include "llvm/DebugInfo/Msf/StreamArray.h" +#include "llvm/DebugInfo/Msf/StreamInterface.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" @@ -24,25 +24,25 @@ namespace llvm { -namespace codeview { +namespace msf { +class MappedBlockStream; class StreamInterface; } namespace pdb { class DbiStream; class InfoStream; -class MappedBlockStream; class NameHashTable; class PDBFileBuilder; class PublicsStream; class SymbolStream; class TpiStream; -class PDBFile : public IPDBFile { +class PDBFile : public msf::IMsfFile { friend PDBFileBuilder; public: - explicit PDBFile(std::unique_ptr<codeview::StreamInterface> PdbFileBuffer); + explicit PDBFile(std::unique_ptr<msf::StreamInterface> PdbFileBuffer); ~PDBFile() override; uint32_t getFreeBlockMapBlock() const; @@ -91,7 +91,7 @@ private: BumpPtrAllocator Allocator; - std::unique_ptr<codeview::StreamInterface> Buffer; + std::unique_ptr<msf::StreamInterface> Buffer; const msf::SuperBlock *SB; ArrayRef<support::ulittle32_t> StreamSizes; ArrayRef<support::ulittle32_t> DirectoryBlocks; @@ -103,8 +103,8 @@ private: std::unique_ptr<TpiStream> Ipi; std::unique_ptr<PublicsStream> Publics; std::unique_ptr<SymbolStream> Symbols; - std::unique_ptr<MappedBlockStream> DirectoryStream; - std::unique_ptr<MappedBlockStream> StringTableStream; + std::unique_ptr<msf::MappedBlockStream> DirectoryStream; + std::unique_ptr<msf::MappedBlockStream> StringTableStream; std::unique_ptr<NameHashTable> StringTable; }; } diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h b/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h index 47c755b4326..891e919e585 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h +++ b/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h @@ -13,17 +13,16 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/BitVector.h" #include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" -#include "llvm/DebugInfo/PDB/Raw/MsfBuilder.h" -#include "llvm/DebugInfo/PDB/Raw/PDBFile.h" - #include <memory> #include <vector> namespace llvm { -namespace codeview { +namespace msf { +class MsfBuilder; class StreamInterface; } namespace pdb { @@ -33,14 +32,13 @@ class PDBFile; class PDBFileBuilder { public: - explicit PDBFileBuilder( - std::unique_ptr<codeview::StreamInterface> FileBuffer); + explicit PDBFileBuilder(std::unique_ptr<msf::StreamInterface> FileBuffer); PDBFileBuilder(const PDBFileBuilder &) = delete; PDBFileBuilder &operator=(const PDBFileBuilder &) = delete; Error initialize(const msf::SuperBlock &Super); - MsfBuilder &getMsfBuilder(); + msf::MsfBuilder &getMsfBuilder(); InfoStreamBuilder &getInfoBuilder(); DbiStreamBuilder &getDbiBuilder(); @@ -51,7 +49,7 @@ private: std::unique_ptr<DbiStreamBuilder> Dbi; std::unique_ptr<PDBFile> File; - std::unique_ptr<MsfBuilder> Msf; + std::unique_ptr<msf::MsfBuilder> Msf; }; } } diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h b/llvm/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h index f5bfb0ed60a..a302d853b8a 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h +++ b/llvm/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h @@ -10,10 +10,10 @@ #ifndef LLVM_DEBUGINFO_PDB_RAW_PUBLICSSTREAM_H #define LLVM_DEBUGINFO_PDB_RAW_PUBLICSSTREAM_H -#include "llvm/DebugInfo/CodeView/StreamArray.h" #include "llvm/DebugInfo/CodeView/SymbolRecord.h" +#include "llvm/DebugInfo/Msf/MappedBlockStream.h" +#include "llvm/DebugInfo/Msf/StreamArray.h" #include "llvm/DebugInfo/PDB/PDBTypes.h" -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h" #include "llvm/DebugInfo/PDB/Raw/RawConstants.h" #include "llvm/DebugInfo/PDB/Raw/RawTypes.h" @@ -29,7 +29,7 @@ class PublicsStream { struct HeaderInfo; public: - PublicsStream(PDBFile &File, std::unique_ptr<MappedBlockStream> Stream); + PublicsStream(PDBFile &File, std::unique_ptr<msf::MappedBlockStream> Stream); ~PublicsStream(); Error reload(); @@ -38,16 +38,16 @@ public: uint32_t getNumBuckets() const { return NumBuckets; } iterator_range<codeview::CVSymbolArray::Iterator> getSymbols(bool *HadError) const; - codeview::FixedStreamArray<support::ulittle32_t> getHashBuckets() const { + msf::FixedStreamArray<support::ulittle32_t> getHashBuckets() const { return HashBuckets; } - codeview::FixedStreamArray<support::ulittle32_t> getAddressMap() const { + msf::FixedStreamArray<support::ulittle32_t> getAddressMap() const { return AddressMap; } - codeview::FixedStreamArray<support::ulittle32_t> getThunkMap() const { + msf::FixedStreamArray<support::ulittle32_t> getThunkMap() const { return ThunkMap; } - codeview::FixedStreamArray<SectionOffset> getSectionOffsets() const { + msf::FixedStreamArray<SectionOffset> getSectionOffsets() const { return SectionOffsets; } @@ -56,14 +56,14 @@ public: private: PDBFile &Pdb; - std::unique_ptr<MappedBlockStream> Stream; + std::unique_ptr<msf::MappedBlockStream> Stream; uint32_t NumBuckets = 0; ArrayRef<uint8_t> Bitmap; - codeview::FixedStreamArray<PSHashRecord> HashRecords; - codeview::FixedStreamArray<support::ulittle32_t> HashBuckets; - codeview::FixedStreamArray<support::ulittle32_t> AddressMap; - codeview::FixedStreamArray<support::ulittle32_t> ThunkMap; - codeview::FixedStreamArray<SectionOffset> SectionOffsets; + msf::FixedStreamArray<PSHashRecord> HashRecords; + msf::FixedStreamArray<support::ulittle32_t> HashBuckets; + msf::FixedStreamArray<support::ulittle32_t> AddressMap; + msf::FixedStreamArray<support::ulittle32_t> ThunkMap; + msf::FixedStreamArray<SectionOffset> SectionOffsets; const HeaderInfo *Header; const GSIHashHeader *HashHdr; diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h b/llvm/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h index 685a23411a3..41d5e6ad64a 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h +++ b/llvm/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h @@ -10,19 +10,20 @@ #ifndef LLVM_DEBUGINFO_PDB_RAW_PDBSYMBOLSTREAM_H #define LLVM_DEBUGINFO_PDB_RAW_PDBSYMBOLSTREAM_H -#include "llvm/DebugInfo/CodeView/StreamArray.h" #include "llvm/DebugInfo/CodeView/SymbolRecord.h" -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h" #include "llvm/Support/Error.h" namespace llvm { +namespace msf { +class MappedBlockStream; +} namespace pdb { class PDBFile; class SymbolStream { public: - SymbolStream(std::unique_ptr<MappedBlockStream> Stream); + SymbolStream(std::unique_ptr<msf::MappedBlockStream> Stream); ~SymbolStream(); Error reload(); @@ -33,7 +34,7 @@ public: private: codeview::CVSymbolArray SymbolRecords; - std::unique_ptr<MappedBlockStream> Stream; + std::unique_ptr<msf::MappedBlockStream> Stream; }; } } diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/TpiStream.h b/llvm/include/llvm/DebugInfo/PDB/Raw/TpiStream.h index 4f36d70aabe..31c02675d10 100644 --- a/llvm/include/llvm/DebugInfo/PDB/Raw/TpiStream.h +++ b/llvm/include/llvm/DebugInfo/PDB/Raw/TpiStream.h @@ -10,11 +10,9 @@ #ifndef LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAM_H #define LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAM_H -#include "llvm/DebugInfo/CodeView/StreamArray.h" -#include "llvm/DebugInfo/CodeView/StreamRef.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/Msf/StreamArray.h" #include "llvm/DebugInfo/PDB/PDBTypes.h" -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h" #include "llvm/DebugInfo/PDB/Raw/RawConstants.h" #include "llvm/DebugInfo/PDB/Raw/RawTypes.h" #include "llvm/Support/raw_ostream.h" @@ -22,6 +20,9 @@ #include "llvm/Support/Error.h" namespace llvm { +namespace msf { +class MappedBlockStream; +} namespace pdb { class PDBFile; @@ -29,7 +30,8 @@ class TpiStream { struct HeaderInfo; public: - TpiStream(const PDBFile &File, std::unique_ptr<MappedBlockStream> Stream); + TpiStream(const PDBFile &File, + std::unique_ptr<msf::MappedBlockStream> Stream); ~TpiStream(); Error reload(); @@ -43,9 +45,9 @@ public: uint32_t getHashKeySize() const; uint32_t NumHashBuckets() const; - codeview::FixedStreamArray<support::ulittle32_t> getHashValues() const; - codeview::FixedStreamArray<TypeIndexOffset> getTypeIndexOffsets() const; - codeview::FixedStreamArray<TypeIndexOffset> getHashAdjustments() const; + msf::FixedStreamArray<support::ulittle32_t> getHashValues() const; + msf::FixedStreamArray<TypeIndexOffset> getTypeIndexOffsets() const; + msf::FixedStreamArray<TypeIndexOffset> getHashAdjustments() const; iterator_range<codeview::CVTypeArray::Iterator> types(bool *HadError) const; @@ -55,14 +57,14 @@ private: Error verifyHashValues(); const PDBFile &Pdb; - std::unique_ptr<MappedBlockStream> Stream; + std::unique_ptr<msf::MappedBlockStream> Stream; codeview::CVTypeArray TypeRecords; - std::unique_ptr<MappedBlockStream> HashStream; - codeview::FixedStreamArray<support::ulittle32_t> HashValues; - codeview::FixedStreamArray<TypeIndexOffset> TypeIndexOffsets; - codeview::FixedStreamArray<TypeIndexOffset> HashAdjustments; + std::unique_ptr<msf::MappedBlockStream> HashStream; + msf::FixedStreamArray<support::ulittle32_t> HashValues; + msf::FixedStreamArray<TypeIndexOffset> TypeIndexOffsets; + msf::FixedStreamArray<TypeIndexOffset> HashAdjustments; const HeaderInfo *Header; }; |