From de0ff2102f505c0f828d412cbd920e838658aedd Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Fri, 22 Jul 2016 19:56:05 +0000 Subject: [PATCH] [msf] Create LLVMDebugInfoMsf This provides a better layering of responsibilities among different aspects of PDB writing code. Some of the MSF related code was contained in CodeView, and some was in PDB prior to this. Further, we were often saying PDB when we meant MSF, and the two are actually independent of each other since in theory you can have other types of data besides PDB data in an MSF. So, this patch separates the MSF specific code into its own library, with no dependencies on anything else, and DebugInfoCodeView and DebugInfoPDB take dependencies on DebugInfoMsf. llvm-svn: 276458 --- include/llvm/DebugInfo/CodeView/CVRecord.h | 13 ++- .../llvm/DebugInfo/CodeView/CodeViewOStream.h | 39 -------- .../llvm/DebugInfo/CodeView/ModuleSubstream.h | 28 +++--- .../CodeView/ModuleSubstreamVisitor.h | 97 ++++++++++--------- .../llvm/DebugInfo/CodeView/SymbolRecord.h | 11 +-- include/llvm/DebugInfo/CodeView/TypeRecord.h | 2 +- .../DebugInfo/{CodeView => Msf}/ByteStream.h | 12 +-- .../{PDB/Raw => Msf}/DirectoryStreamData.h | 24 ++--- .../{PDB/Raw/IPDBFile.h => Msf/IMsfFile.h} | 16 +-- .../IPDBStreamData.h => Msf/IMsfStreamData.h} | 22 +++-- .../{PDB/Raw => Msf}/IndexedStreamData.h | 24 ++--- .../{PDB/Raw => Msf}/MappedBlockStream.h | 41 +++++--- .../DebugInfo/{PDB/Raw => Msf}/MsfBuilder.h | 29 +++--- .../DebugInfo/{PDB/Raw => Msf}/MsfCommon.h | 14 ++- include/llvm/DebugInfo/Msf/MsfError.h | 47 +++++++++ .../DebugInfo/{CodeView => Msf}/StreamArray.h | 12 +-- .../{CodeView => Msf}/StreamInterface.h | 10 +- .../{CodeView => Msf}/StreamReader.h | 24 ++--- .../DebugInfo/{CodeView => Msf}/StreamRef.h | 24 ++--- .../{CodeView => Msf}/StreamWriter.h | 18 ++-- include/llvm/DebugInfo/PDB/Raw/DbiStream.h | 48 ++++----- .../llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h | 9 +- include/llvm/DebugInfo/PDB/Raw/InfoStream.h | 6 +- include/llvm/DebugInfo/PDB/Raw/ModInfo.h | 10 +- include/llvm/DebugInfo/PDB/Raw/ModStream.h | 17 ++-- .../llvm/DebugInfo/PDB/Raw/NameHashTable.h | 14 +-- include/llvm/DebugInfo/PDB/Raw/NameMap.h | 6 +- include/llvm/DebugInfo/PDB/Raw/PDBFile.h | 22 ++--- .../llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h | 14 ++- .../llvm/DebugInfo/PDB/Raw/PublicsStream.h | 26 ++--- include/llvm/DebugInfo/PDB/Raw/SymbolStream.h | 9 +- include/llvm/DebugInfo/PDB/Raw/TpiStream.h | 26 ++--- lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 4 +- lib/CodeGen/AsmPrinter/LLVMBuild.txt | 2 +- lib/DebugInfo/CMakeLists.txt | 3 +- lib/DebugInfo/CodeView/CMakeLists.txt | 3 - lib/DebugInfo/CodeView/CVTypeVisitor.cpp | 1 + lib/DebugInfo/CodeView/LLVMBuild.txt | 2 +- lib/DebugInfo/CodeView/ModuleSubstream.cpp | 3 +- .../CodeView/ModuleSubstreamVisitor.cpp | 1 + lib/DebugInfo/CodeView/TypeDumper.cpp | 6 +- lib/DebugInfo/CodeView/TypeStreamMerger.cpp | 1 - lib/DebugInfo/LLVMBuild.txt | 2 +- .../{CodeView => Msf}/ByteStream.cpp | 24 ++--- lib/DebugInfo/Msf/CMakeLists.txt | 12 +++ .../{PDB/Raw => Msf}/IndexedStreamData.cpp | 8 +- lib/DebugInfo/Msf/LLVMBuild.txt | 22 +++++ .../{PDB/Raw => Msf}/MappedBlockStream.cpp | 95 +++++++++--------- lib/DebugInfo/{PDB/Raw => Msf}/MsfBuilder.cpp | 34 +++---- lib/DebugInfo/{PDB/Raw => Msf}/MsfCommon.cpp | 18 ++-- lib/DebugInfo/Msf/MsfError.cpp | 70 +++++++++++++ .../{CodeView => Msf}/StreamReader.cpp | 10 +- .../{CodeView => Msf}/StreamWriter.cpp | 10 +- lib/DebugInfo/PDB/CMakeLists.txt | 4 - lib/DebugInfo/PDB/LLVMBuild.txt | 2 +- lib/DebugInfo/PDB/Raw/DbiStream.cpp | 20 ++-- lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp | 5 +- lib/DebugInfo/PDB/Raw/InfoStream.cpp | 9 +- lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp | 5 +- lib/DebugInfo/PDB/Raw/ModInfo.cpp | 7 +- lib/DebugInfo/PDB/Raw/ModStream.cpp | 11 ++- lib/DebugInfo/PDB/Raw/NameHashTable.cpp | 10 +- lib/DebugInfo/PDB/Raw/NameMap.cpp | 10 +- lib/DebugInfo/PDB/Raw/PDBFile.cpp | 19 ++-- lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp | 9 +- lib/DebugInfo/PDB/Raw/PublicsStream.cpp | 9 +- lib/DebugInfo/PDB/Raw/RawSession.cpp | 7 +- lib/DebugInfo/PDB/Raw/SymbolStream.cpp | 9 +- lib/DebugInfo/PDB/Raw/TpiStream.cpp | 7 +- tools/llvm-pdbdump/CMakeLists.txt | 1 + tools/llvm-pdbdump/LLVMBuild.txt | 2 +- tools/llvm-pdbdump/LLVMOutputStyle.cpp | 9 +- tools/llvm-pdbdump/PdbYaml.cpp | 1 + tools/llvm-pdbdump/PdbYaml.h | 6 +- tools/llvm-pdbdump/llvm-pdbdump.cpp | 4 +- tools/llvm-readobj/CMakeLists.txt | 1 + tools/llvm-readobj/COFFDumper.cpp | 3 +- tools/llvm-readobj/LLVMBuild.txt | 2 +- .../DebugInfo/PDB/MappedBlockStreamTest.cpp | 29 +++--- unittests/DebugInfo/PDB/MsfBuilderTest.cpp | 7 +- 80 files changed, 705 insertions(+), 548 deletions(-) delete mode 100644 include/llvm/DebugInfo/CodeView/CodeViewOStream.h rename include/llvm/DebugInfo/{CodeView => Msf}/ByteStream.h (86%) rename include/llvm/DebugInfo/{PDB/Raw => Msf}/DirectoryStreamData.h (50%) rename include/llvm/DebugInfo/{PDB/Raw/IPDBFile.h => Msf/IMsfFile.h} (77%) rename include/llvm/DebugInfo/{PDB/Raw/IPDBStreamData.h => Msf/IMsfStreamData.h} (73%) rename include/llvm/DebugInfo/{PDB/Raw => Msf}/IndexedStreamData.h (50%) rename include/llvm/DebugInfo/{PDB/Raw => Msf}/MappedBlockStream.h (51%) rename include/llvm/DebugInfo/{PDB/Raw => Msf}/MsfBuilder.h (90%) rename include/llvm/DebugInfo/{PDB/Raw => Msf}/MsfCommon.h (94%) create mode 100644 include/llvm/DebugInfo/Msf/MsfError.h rename include/llvm/DebugInfo/{CodeView => Msf}/StreamArray.h (97%) rename include/llvm/DebugInfo/{CodeView => Msf}/StreamInterface.h (90%) rename include/llvm/DebugInfo/{CodeView => Msf}/StreamReader.h (82%) rename include/llvm/DebugInfo/{CodeView => Msf}/StreamRef.h (83%) rename include/llvm/DebugInfo/{CodeView => Msf}/StreamWriter.h (84%) rename lib/DebugInfo/{CodeView => Msf}/ByteStream.cpp (73%) create mode 100644 lib/DebugInfo/Msf/CMakeLists.txt rename lib/DebugInfo/{PDB/Raw => Msf}/IndexedStreamData.cpp (82%) create mode 100644 lib/DebugInfo/Msf/LLVMBuild.txt rename lib/DebugInfo/{PDB/Raw => Msf}/MappedBlockStream.cpp (76%) rename lib/DebugInfo/{PDB/Raw => Msf}/MsfBuilder.cpp (92%) rename lib/DebugInfo/{PDB/Raw => Msf}/MsfCommon.cpp (74%) create mode 100644 lib/DebugInfo/Msf/MsfError.cpp rename lib/DebugInfo/{CodeView => Msf}/StreamReader.cpp (90%) rename lib/DebugInfo/{CodeView => Msf}/StreamWriter.cpp (90%) diff --git a/include/llvm/DebugInfo/CodeView/CVRecord.h b/include/llvm/DebugInfo/CodeView/CVRecord.h index dba359fcbe8..30c13ce5880 100644 --- a/include/llvm/DebugInfo/CodeView/CVRecord.h +++ b/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 struct CVRecord { ArrayRef Data; ArrayRef RawData; }; +} +namespace msf { -template struct VarStreamArrayExtractor> { +template +struct VarStreamArrayExtractor> { Error operator()(StreamRef Stream, uint32_t &Len, - CVRecord &Item) const { + codeview::CVRecord &Item) const { + using namespace codeview; const RecordPrefix *Prefix = nullptr; StreamReader Reader(Stream); uint32_t Offset = Reader.getOffset(); diff --git a/include/llvm/DebugInfo/CodeView/CodeViewOStream.h b/include/llvm/DebugInfo/CodeView/CodeViewOStream.h deleted file mode 100644 index 14d057a249a..00000000000 --- a/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 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/include/llvm/DebugInfo/CodeView/ModuleSubstream.h b/include/llvm/DebugInfo/CodeView/ModuleSubstream.h index 6affac801d4..a530a5d888a 100644 --- a/include/llvm/DebugInfo/CodeView/ModuleSubstream.h +++ b/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 { +typedef msf::VarStreamArray ModuleSubstreamArray; +} // namespace codeview + +namespace msf { +template <> struct VarStreamArrayExtractor { 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 ModuleSubstreamArray; -} -} +} // namespace msf +} // namespace llvm #endif // LLVM_DEBUGINFO_CODEVIEW_MODULESUBSTREAM_H diff --git a/include/llvm/DebugInfo/CodeView/ModuleSubstreamVisitor.h b/include/llvm/DebugInfo/CodeView/ModuleSubstreamVisitor.h index 6df23090371..697bc7d787a 100644 --- a/include/llvm/DebugInfo/CodeView/ModuleSubstreamVisitor.h +++ b/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 LineNumbers; - FixedStreamArray Columns; + msf::FixedStreamArray LineNumbers; + msf::FixedStreamArray Columns; }; -template <> class VarStreamArrayExtractor { +struct FileChecksumEntry { + uint32_t FileNameOffset; // Byte offset of filename in global stringtable. + FileChecksumKind Kind; // The type of checksum. + ArrayRef Checksum; // The bytes of the checksum. +}; + +typedef msf::VarStreamArray LineInfoArray; +typedef msf::VarStreamArray FileChecksumArray; + +class IModuleSubstreamVisitor { public: - VarStreamArrayExtractor(const LineSubstreamHeader *Header) : Header(Header) {} + 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); +}; + +Error visitModuleSubstream(const ModuleSubstream &R, + IModuleSubstreamVisitor &V); +} // namespace codeview + +namespace msf { +template <> class VarStreamArrayExtractor { +public: + 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 Checksum; // The bytes of the checksum. -}; - -template <> class VarStreamArrayExtractor { +template <> class VarStreamArrayExtractor { 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 LineInfoArray; -typedef VarStreamArray 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/include/llvm/DebugInfo/CodeView/SymbolRecord.h b/include/llvm/DebugInfo/CodeView/SymbolRecord.h index 77e894fba4a..b3974ecb862 100644 --- a/include/llvm/DebugInfo/CodeView/SymbolRecord.h +++ b/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 CVSymbol; -typedef VarStreamArray CVSymbolArray; +typedef msf::VarStreamArray CVSymbolArray; } // namespace codeview } // namespace llvm diff --git a/include/llvm/DebugInfo/CodeView/TypeRecord.h b/include/llvm/DebugInfo/CodeView/TypeRecord.h index 42751fbd4af..bbb3769333c 100644 --- a/include/llvm/DebugInfo/CodeView/TypeRecord.h +++ b/include/llvm/DebugInfo/CodeView/TypeRecord.h @@ -1195,7 +1195,7 @@ private: }; typedef CVRecord CVType; -typedef VarStreamArray CVTypeArray; +typedef msf::VarStreamArray CVTypeArray; } } diff --git a/include/llvm/DebugInfo/CodeView/ByteStream.h b/include/llvm/DebugInfo/Msf/ByteStream.h similarity index 86% rename from include/llvm/DebugInfo/CodeView/ByteStream.h rename to include/llvm/DebugInfo/Msf/ByteStream.h index f398c93723e..621848cf3d2 100644 --- a/include/llvm/DebugInfo/CodeView/ByteStream.h +++ b/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 #include #include namespace llvm { -namespace codeview { +namespace msf { class StreamReader; template class ByteStream : public StreamInterface { @@ -52,7 +52,7 @@ private: extern template class ByteStream; extern template class ByteStream; -} // end namespace pdb +} // end namespace msf } // end namespace llvm -#endif // LLVM_DEBUGINFO_CODEVIEW_BYTESTREAM_H +#endif // LLVM_DEBUGINFO_MSF_BYTESTREAM_H diff --git a/include/llvm/DebugInfo/PDB/Raw/DirectoryStreamData.h b/include/llvm/DebugInfo/Msf/DirectoryStreamData.h similarity index 50% rename from include/llvm/DebugInfo/PDB/Raw/DirectoryStreamData.h rename to include/llvm/DebugInfo/Msf/DirectoryStreamData.h index 0f354315122..283d9b283e6 100644 --- a/include/llvm/DebugInfo/PDB/Raw/DirectoryStreamData.h +++ b/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 Blocks) + : Length(Length), Blocks(Blocks) {} - virtual uint32_t getLength() { return File.getNumDirectoryBytes(); } + virtual uint32_t getLength() { return Length; } virtual llvm::ArrayRef getStreamBlocks() { - return File.getDirectoryBlockArray(); + return Blocks; } private: - const PDBFile &File; + uint32_t Length; + ArrayRef Blocks; }; } } diff --git a/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h b/include/llvm/DebugInfo/Msf/IMsfFile.h similarity index 77% rename from include/llvm/DebugInfo/PDB/Raw/IPDBFile.h rename to include/llvm/DebugInfo/Msf/IMsfFile.h index fccea2ac247..1c7eeb92d28 100644 --- a/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h +++ b/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 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/include/llvm/DebugInfo/PDB/Raw/IPDBStreamData.h b/include/llvm/DebugInfo/Msf/IMsfStreamData.h similarity index 73% rename from include/llvm/DebugInfo/PDB/Raw/IPDBStreamData.h rename to include/llvm/DebugInfo/Msf/IMsfStreamData.h index ab3c9f77075..0b70d90f8d2 100644 --- a/include/llvm/DebugInfo/PDB/Raw/IPDBStreamData.h +++ b/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 + 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 getStreamBlocks() = 0; }; -} -} +} // namespace msf +} // namespace llvm -#endif +#endif // LLVM_DEBUGINFO_MSF_IMSFSTREAMDATA_H diff --git a/include/llvm/DebugInfo/PDB/Raw/IndexedStreamData.h b/include/llvm/DebugInfo/Msf/IndexedStreamData.h similarity index 50% rename from include/llvm/DebugInfo/PDB/Raw/IndexedStreamData.h rename to include/llvm/DebugInfo/Msf/IndexedStreamData.h index 30563bc5b89..ff9d8b37f19 100644 --- a/include/llvm/DebugInfo/PDB/Raw/IndexedStreamData.h +++ b/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/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h b/include/llvm/DebugInfo/Msf/MappedBlockStream.h similarity index 51% rename from include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h rename to include/llvm/DebugInfo/Msf/MappedBlockStream.h index 36424c0d16a..9f8e04521b5 100644 --- a/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h +++ b/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 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 &Buffer) const override; @@ -41,21 +51,22 @@ public: uint32_t getNumBytesCopied() const; static Expected> - createIndexedStream(uint32_t StreamIdx, const IPDBFile &File); + createIndexedStream(uint32_t StreamIdx, const IMsfFile &File); static Expected> - createDirectoryStream(const PDBFile &File); + createDirectoryStream(uint32_t Length, ArrayRef Blocks, + const IMsfFile &File); llvm::BumpPtrAllocator &getAllocator() { return Pool; } protected: - MappedBlockStream(std::unique_ptr Data, const IPDBFile &File); + MappedBlockStream(std::unique_ptr Data, const IMsfFile &File); Error readBytes(uint32_t Offset, MutableArrayRef Buffer) const; bool tryReadContiguously(uint32_t Offset, uint32_t Size, ArrayRef &Buffer) const; - const IPDBFile &Pdb; - std::unique_ptr Data; + const IMsfFile &Msf; + std::unique_ptr Data; typedef MutableArrayRef 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/include/llvm/DebugInfo/PDB/Raw/MsfBuilder.h b/include/llvm/DebugInfo/Msf/MsfBuilder.h similarity index 90% rename from include/llvm/DebugInfo/PDB/Raw/MsfBuilder.h rename to include/llvm/DebugInfo/Msf/MsfBuilder.h index 92d9bc042cc..814e1655745 100644 --- a/include/llvm/DebugInfo/PDB/Raw/MsfBuilder.h +++ b/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 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 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 build(); + Expected build(); private: MsfBuilder(uint32_t BlockSize, uint32_t MinBlockCount, bool CanGrow, @@ -135,7 +134,7 @@ private: std::vector DirectoryBlocks; std::vector> StreamData; }; -} -} +} // namespace msf +} // namespace llvm -#endif +#endif // LLVM_DEBUGINFO_MSF_MSFBUILDER_H diff --git a/include/llvm/DebugInfo/PDB/Raw/MsfCommon.h b/include/llvm/DebugInfo/Msf/MsfCommon.h similarity index 94% rename from include/llvm/DebugInfo/PDB/Raw/MsfCommon.h rename to include/llvm/DebugInfo/Msf/MsfCommon.h index 2f6a6986eba..98bfb3b7d1a 100644 --- a/include/llvm/DebugInfo/PDB/Raw/MsfCommon.h +++ b/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 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/include/llvm/DebugInfo/Msf/MsfError.h b/include/llvm/DebugInfo/Msf/MsfError.h new file mode 100644 index 00000000000..4cdbaec3962 --- /dev/null +++ b/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 + +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 { +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/include/llvm/DebugInfo/CodeView/StreamArray.h b/include/llvm/DebugInfo/Msf/StreamArray.h similarity index 97% rename from include/llvm/DebugInfo/CodeView/StreamArray.h rename to include/llvm/DebugInfo/Msf/StreamArray.h index 0b9349aac75..dcdae8f00a0 100644 --- a/include/llvm/DebugInfo/CodeView/StreamArray.h +++ b/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 #include 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/include/llvm/DebugInfo/CodeView/StreamInterface.h b/include/llvm/DebugInfo/Msf/StreamInterface.h similarity index 90% rename from include/llvm/DebugInfo/CodeView/StreamInterface.h rename to include/llvm/DebugInfo/Msf/StreamInterface.h index 241aec45787..7a886e39289 100644 --- a/include/llvm/DebugInfo/CodeView/StreamInterface.h +++ b/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 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/include/llvm/DebugInfo/CodeView/StreamReader.h b/include/llvm/DebugInfo/Msf/StreamReader.h similarity index 82% rename from include/llvm/DebugInfo/CodeView/StreamReader.h rename to include/llvm/DebugInfo/Msf/StreamReader.h index 2f497c2c43f..3d03f406551 100644 --- a/include/llvm/DebugInfo/CodeView/StreamReader.h +++ b/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 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(cv_error_code::insufficient_buffer); + if (NumElements > UINT32_MAX / sizeof(T)) + return make_error(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(cv_error_code::corrupt_record); + return make_error(msf_error_code::invalid_format); if (Offset + Length > Stream.getLength()) - return make_error(cv_error_code::insufficient_buffer); + return make_error(msf_error_code::insufficient_buffer); StreamRef View = Stream.slice(Offset, Length); Array = FixedStreamArray(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/include/llvm/DebugInfo/CodeView/StreamRef.h b/include/llvm/DebugInfo/Msf/StreamRef.h similarity index 83% rename from include/llvm/DebugInfo/CodeView/StreamRef.h rename to include/llvm/DebugInfo/Msf/StreamRef.h index a4f244a3228..e87d298a834 100644 --- a/include/llvm/DebugInfo/CodeView/StreamRef.h +++ b/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 &Buffer) const { if (ViewOffset + Offset < Offset) - return make_error(cv_error_code::insufficient_buffer); + return make_error(msf_error_code::insufficient_buffer); if (Size + Offset > Length) - return make_error(cv_error_code::insufficient_buffer); + return make_error(msf_error_code::insufficient_buffer); return Stream->readBytes(ViewOffset + Offset, Size, Buffer); } @@ -41,7 +41,7 @@ public: Error readLongestContiguousChunk(uint32_t Offset, ArrayRef &Buffer) const { if (Offset >= Length) - return make_error(cv_error_code::insufficient_buffer); + return make_error(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 Data) const { if (Data.size() + Offset > Length) - return make_error(cv_error_code::insufficient_buffer); + return make_error(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/include/llvm/DebugInfo/CodeView/StreamWriter.h b/include/llvm/DebugInfo/Msf/StreamWriter.h similarity index 84% rename from include/llvm/DebugInfo/CodeView/StreamWriter.h rename to include/llvm/DebugInfo/Msf/StreamWriter.h index 4d393d2ef79..a4cf3576a3e 100644 --- a/include/llvm/DebugInfo/CodeView/StreamWriter.h +++ b/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 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(cv_error_code::insufficient_buffer); + return make_error(msf_error_code::insufficient_buffer); return writeBytes( ArrayRef(reinterpret_cast(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/include/llvm/DebugInfo/PDB/Raw/DbiStream.h b/include/llvm/DebugInfo/PDB/Raw/DbiStream.h index 3d2552e1c63..bbdf0dfd562 100644 --- a/include/llvm/DebugInfo/PDB/Raw/DbiStream.h +++ b/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 Stream); + DbiStream(PDBFile &File, std::unique_ptr Stream); ~DbiStream(); Error reload(); @@ -70,11 +70,11 @@ public: Expected getFileNameForIndex(uint32_t Index) const; - codeview::FixedStreamArray getSectionHeaders(); + msf::FixedStreamArray getSectionHeaders(); - codeview::FixedStreamArray getFpoRecords(); + msf::FixedStreamArray getFpoRecords(); - codeview::FixedStreamArray getSectionMap() const; + msf::FixedStreamArray getSectionMap() const; void visitSectionContributions(ISectionContribVisitor &Visitor) const; Error commit(); @@ -88,33 +88,33 @@ private: Error initializeFpoRecords(); PDBFile &Pdb; - std::unique_ptr Stream; + std::unique_ptr Stream; std::vector 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 DbgStreams; + msf::FixedStreamArray DbgStreams; PdbRaw_DbiSecContribVer SectionContribVersion; - codeview::FixedStreamArray SectionContribs; - codeview::FixedStreamArray SectionContribs2; - codeview::FixedStreamArray SectionMap; - codeview::FixedStreamArray FileNameOffsets; + msf::FixedStreamArray SectionContribs; + msf::FixedStreamArray SectionContribs2; + msf::FixedStreamArray SectionMap; + msf::FixedStreamArray FileNameOffsets; - std::unique_ptr SectionHeaderStream; - codeview::FixedStreamArray SectionHeaders; + std::unique_ptr SectionHeaderStream; + msf::FixedStreamArray SectionHeaders; - std::unique_ptr FpoStream; - codeview::FixedStreamArray FpoRecords; + std::unique_ptr FpoStream; + msf::FixedStreamArray FpoRecords; const DbiStreamHeader *Header; }; diff --git a/include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h b/include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h index 747f5cc0493..7abe9546f88 100644 --- a/include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h +++ b/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 SourceFileNames; - codeview::StreamRef NamesBuffer; - codeview::ByteStream ModInfoBuffer; - codeview::ByteStream FileInfoBuffer; + msf::StreamRef NamesBuffer; + msf::ByteStream ModInfoBuffer; + msf::ByteStream FileInfoBuffer; }; } } diff --git a/include/llvm/DebugInfo/PDB/Raw/InfoStream.h b/include/llvm/DebugInfo/PDB/Raw/InfoStream.h index 1980bec7153..bc6aebb156a 100644 --- a/include/llvm/DebugInfo/PDB/Raw/InfoStream.h +++ b/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 Stream); + InfoStream(std::unique_ptr Stream); Error reload(); Error commit(); @@ -49,7 +49,7 @@ public: iterator_range> named_streams() const; private: - std::unique_ptr Stream; + std::unique_ptr Stream; // PDB file format version. We only support VC70. See the enumeration // `PdbRaw_ImplVer` for the other possible values. diff --git a/include/llvm/DebugInfo/PDB/Raw/ModInfo.h b/include/llvm/DebugInfo/PDB/Raw/ModInfo.h index 62282c28017..cdb3735fcb4 100644 --- a/include/llvm/DebugInfo/PDB/Raw/ModInfo.h +++ b/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 @@ -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 { Error operator()(StreamRef Stream, uint32_t &Length, pdb::ModInfo &Info) const { @@ -73,7 +73,7 @@ template <> struct VarStreamArrayExtractor { return Error::success(); } }; -} +} // end namespace msf } // end namespace llvm diff --git a/include/llvm/DebugInfo/PDB/Raw/ModStream.h b/include/llvm/DebugInfo/PDB/Raw/ModStream.h index d22962cc1e2..bee4075aaf2 100644 --- a/include/llvm/DebugInfo/PDB/Raw/ModStream.h +++ b/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 Stream); + ModStream(const ModInfo &Module, + std::unique_ptr Stream); ~ModStream(); Error reload(); @@ -42,12 +43,12 @@ public: private: const ModInfo &Mod; - std::unique_ptr Stream; + std::unique_ptr 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/include/llvm/DebugInfo/PDB/Raw/NameHashTable.h b/include/llvm/DebugInfo/PDB/Raw/NameHashTable.h index c9e060a3a70..7de26f3b270 100644 --- a/include/llvm/DebugInfo/PDB/Raw/NameHashTable.h +++ b/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 #include 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 name_ids() const; + msf::FixedStreamArray name_ids() const; private: - codeview::StreamRef NamesBuffer; - codeview::FixedStreamArray IDs; + msf::StreamRef NamesBuffer; + msf::FixedStreamArray IDs; uint32_t Signature; uint32_t HashVersion; uint32_t NameCount; diff --git a/include/llvm/DebugInfo/PDB/Raw/NameMap.h b/include/llvm/DebugInfo/PDB/Raw/NameMap.h index 8a9b0d187ac..ca1a6541dfb 100644 --- a/include/llvm/DebugInfo/PDB/Raw/NameMap.h +++ b/include/llvm/DebugInfo/PDB/Raw/NameMap.h @@ -16,7 +16,7 @@ #include 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/include/llvm/DebugInfo/PDB/Raw/PDBFile.h b/include/llvm/DebugInfo/PDB/Raw/PDBFile.h index f4d7eb47d3b..9a08b858f19 100644 --- a/include/llvm/DebugInfo/PDB/Raw/PDBFile.h +++ b/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 PdbFileBuffer); + explicit PDBFile(std::unique_ptr PdbFileBuffer); ~PDBFile() override; uint32_t getFreeBlockMapBlock() const; @@ -91,7 +91,7 @@ private: BumpPtrAllocator Allocator; - std::unique_ptr Buffer; + std::unique_ptr Buffer; const msf::SuperBlock *SB; ArrayRef StreamSizes; ArrayRef DirectoryBlocks; @@ -103,8 +103,8 @@ private: std::unique_ptr Ipi; std::unique_ptr Publics; std::unique_ptr Symbols; - std::unique_ptr DirectoryStream; - std::unique_ptr StringTableStream; + std::unique_ptr DirectoryStream; + std::unique_ptr StringTableStream; std::unique_ptr StringTable; }; } diff --git a/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h b/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h index 47c755b4326..891e919e585 100644 --- a/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h +++ b/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 #include 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 FileBuffer); + explicit PDBFileBuilder(std::unique_ptr 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 Dbi; std::unique_ptr File; - std::unique_ptr Msf; + std::unique_ptr Msf; }; } } diff --git a/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h b/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h index f5bfb0ed60a..a302d853b8a 100644 --- a/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h +++ b/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 Stream); + PublicsStream(PDBFile &File, std::unique_ptr Stream); ~PublicsStream(); Error reload(); @@ -38,16 +38,16 @@ public: uint32_t getNumBuckets() const { return NumBuckets; } iterator_range getSymbols(bool *HadError) const; - codeview::FixedStreamArray getHashBuckets() const { + msf::FixedStreamArray getHashBuckets() const { return HashBuckets; } - codeview::FixedStreamArray getAddressMap() const { + msf::FixedStreamArray getAddressMap() const { return AddressMap; } - codeview::FixedStreamArray getThunkMap() const { + msf::FixedStreamArray getThunkMap() const { return ThunkMap; } - codeview::FixedStreamArray getSectionOffsets() const { + msf::FixedStreamArray getSectionOffsets() const { return SectionOffsets; } @@ -56,14 +56,14 @@ public: private: PDBFile &Pdb; - std::unique_ptr Stream; + std::unique_ptr Stream; uint32_t NumBuckets = 0; ArrayRef Bitmap; - codeview::FixedStreamArray HashRecords; - codeview::FixedStreamArray HashBuckets; - codeview::FixedStreamArray AddressMap; - codeview::FixedStreamArray ThunkMap; - codeview::FixedStreamArray SectionOffsets; + msf::FixedStreamArray HashRecords; + msf::FixedStreamArray HashBuckets; + msf::FixedStreamArray AddressMap; + msf::FixedStreamArray ThunkMap; + msf::FixedStreamArray SectionOffsets; const HeaderInfo *Header; const GSIHashHeader *HashHdr; diff --git a/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h b/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h index 685a23411a3..41d5e6ad64a 100644 --- a/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h +++ b/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 Stream); + SymbolStream(std::unique_ptr Stream); ~SymbolStream(); Error reload(); @@ -33,7 +34,7 @@ public: private: codeview::CVSymbolArray SymbolRecords; - std::unique_ptr Stream; + std::unique_ptr Stream; }; } } diff --git a/include/llvm/DebugInfo/PDB/Raw/TpiStream.h b/include/llvm/DebugInfo/PDB/Raw/TpiStream.h index 4f36d70aabe..31c02675d10 100644 --- a/include/llvm/DebugInfo/PDB/Raw/TpiStream.h +++ b/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 Stream); + TpiStream(const PDBFile &File, + std::unique_ptr Stream); ~TpiStream(); Error reload(); @@ -43,9 +45,9 @@ public: uint32_t getHashKeySize() const; uint32_t NumHashBuckets() const; - codeview::FixedStreamArray getHashValues() const; - codeview::FixedStreamArray getTypeIndexOffsets() const; - codeview::FixedStreamArray getHashAdjustments() const; + msf::FixedStreamArray getHashValues() const; + msf::FixedStreamArray getTypeIndexOffsets() const; + msf::FixedStreamArray getHashAdjustments() const; iterator_range types(bool *HadError) const; @@ -55,14 +57,14 @@ private: Error verifyHashValues(); const PDBFile &Pdb; - std::unique_ptr Stream; + std::unique_ptr Stream; codeview::CVTypeArray TypeRecords; - std::unique_ptr HashStream; - codeview::FixedStreamArray HashValues; - codeview::FixedStreamArray TypeIndexOffsets; - codeview::FixedStreamArray HashAdjustments; + std::unique_ptr HashStream; + msf::FixedStreamArray HashValues; + msf::FixedStreamArray TypeIndexOffsets; + msf::FixedStreamArray HashAdjustments; const HeaderInfo *Header; }; diff --git a/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index b0ba5712220..10c76e793bd 100644 --- a/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -13,7 +13,6 @@ #include "CodeViewDebug.h" #include "llvm/ADT/TinyPtrVector.h" -#include "llvm/DebugInfo/CodeView/ByteStream.h" #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h" #include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/FieldListRecordBuilder.h" @@ -23,6 +22,8 @@ #include "llvm/DebugInfo/CodeView/TypeIndex.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" +#include "llvm/DebugInfo/Msf/ByteStream.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" #include "llvm/IR/Constants.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCSectionCOFF.h" @@ -35,6 +36,7 @@ using namespace llvm; using namespace llvm::codeview; +using namespace llvm::msf; CodeViewDebug::CodeViewDebug(AsmPrinter *AP) : DebugHandlerBase(AP), OS(*Asm->OutStreamer), CurFn(nullptr) { diff --git a/lib/CodeGen/AsmPrinter/LLVMBuild.txt b/lib/CodeGen/AsmPrinter/LLVMBuild.txt index e741a1a4c4e..3b240f21fc0 100644 --- a/lib/CodeGen/AsmPrinter/LLVMBuild.txt +++ b/lib/CodeGen/AsmPrinter/LLVMBuild.txt @@ -19,4 +19,4 @@ type = Library name = AsmPrinter parent = Libraries -required_libraries = Analysis CodeGen Core DebugInfoCodeView MC MCParser Support Target TransformUtils +required_libraries = Analysis CodeGen Core DebugInfoCodeView DebugInfoMsf MC MCParser Support Target TransformUtils diff --git a/lib/DebugInfo/CMakeLists.txt b/lib/DebugInfo/CMakeLists.txt index 2c2848d1e5c..944dfb67cbe 100644 --- a/lib/DebugInfo/CMakeLists.txt +++ b/lib/DebugInfo/CMakeLists.txt @@ -1,4 +1,5 @@ -add_subdirectory(CodeView) add_subdirectory(DWARF) +add_subdirectory(Msf) +add_subdirectory(CodeView) add_subdirectory(PDB) add_subdirectory(Symbolize) diff --git a/lib/DebugInfo/CodeView/CMakeLists.txt b/lib/DebugInfo/CodeView/CMakeLists.txt index 47297a9131e..d8c21953967 100644 --- a/lib/DebugInfo/CodeView/CMakeLists.txt +++ b/lib/DebugInfo/CodeView/CMakeLists.txt @@ -1,5 +1,4 @@ add_llvm_library(LLVMDebugInfoCodeView - ByteStream.cpp CodeViewError.cpp CVTypeVisitor.cpp EnumTables.cpp @@ -11,8 +10,6 @@ add_llvm_library(LLVMDebugInfoCodeView ModuleSubstream.cpp ModuleSubstreamVisitor.cpp RecordSerialization.cpp - StreamReader.cpp - StreamWriter.cpp SymbolDumper.cpp TypeDumper.cpp TypeRecord.cpp diff --git a/lib/DebugInfo/CodeView/CVTypeVisitor.cpp b/lib/DebugInfo/CodeView/CVTypeVisitor.cpp index 09f72214c52..f1f9acf570d 100644 --- a/lib/DebugInfo/CodeView/CVTypeVisitor.cpp +++ b/lib/DebugInfo/CodeView/CVTypeVisitor.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h" +#include "llvm/DebugInfo/CodeView/CodeViewError.h" using namespace llvm; using namespace llvm::codeview; diff --git a/lib/DebugInfo/CodeView/LLVMBuild.txt b/lib/DebugInfo/CodeView/LLVMBuild.txt index 4db23376fce..c1e35abf150 100644 --- a/lib/DebugInfo/CodeView/LLVMBuild.txt +++ b/lib/DebugInfo/CodeView/LLVMBuild.txt @@ -19,4 +19,4 @@ type = Library name = DebugInfoCodeView parent = DebugInfo -required_libraries = Support +required_libraries = Support DebugInfoMsf diff --git a/lib/DebugInfo/CodeView/ModuleSubstream.cpp b/lib/DebugInfo/CodeView/ModuleSubstream.cpp index 2e31ed6b5b7..5ab8212d3bd 100644 --- a/lib/DebugInfo/CodeView/ModuleSubstream.cpp +++ b/lib/DebugInfo/CodeView/ModuleSubstream.cpp @@ -9,10 +9,11 @@ #include "llvm/DebugInfo/CodeView/ModuleSubstream.h" -#include "llvm/DebugInfo/CodeView/StreamReader.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" using namespace llvm; using namespace llvm::codeview; +using namespace llvm::msf; ModuleSubstream::ModuleSubstream() : Kind(ModuleSubstreamKind::None) {} diff --git a/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp b/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp index 6f237ee67fe..e4fe8d8053a 100644 --- a/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp +++ b/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp @@ -11,6 +11,7 @@ using namespace llvm; using namespace llvm::codeview; +using namespace llvm::msf; Error IModuleSubstreamVisitor::visitSymbols(StreamRef Data) { return visitUnknown(ModuleSubstreamKind::Symbols, Data); diff --git a/lib/DebugInfo/CodeView/TypeDumper.cpp b/lib/DebugInfo/CodeView/TypeDumper.cpp index 345e2a49888..cf5adb6b75e 100644 --- a/lib/DebugInfo/CodeView/TypeDumper.cpp +++ b/lib/DebugInfo/CodeView/TypeDumper.cpp @@ -12,7 +12,7 @@ #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h" #include "llvm/DebugInfo/CodeView/TypeIndex.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/DebugInfo/CodeView/ByteStream.h" +#include "llvm/DebugInfo/Msf/ByteStream.h" #include "llvm/Support/ScopedPrinter.h" using namespace llvm; @@ -681,9 +681,9 @@ Error CVTypeDumper::dump(const CVTypeArray &Types) { } Error CVTypeDumper::dump(ArrayRef Data) { - ByteStream<> Stream(Data); + msf::ByteStream<> Stream(Data); CVTypeArray Types; - StreamReader Reader(Stream); + msf::StreamReader Reader(Stream); if (auto EC = Reader.readArray(Types, Reader.getLength())) return EC; diff --git a/lib/DebugInfo/CodeView/TypeStreamMerger.cpp b/lib/DebugInfo/CodeView/TypeStreamMerger.cpp index ebfda2462be..8c2bc072cd9 100644 --- a/lib/DebugInfo/CodeView/TypeStreamMerger.cpp +++ b/lib/DebugInfo/CodeView/TypeStreamMerger.cpp @@ -12,7 +12,6 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h" #include "llvm/DebugInfo/CodeView/FieldListRecordBuilder.h" -#include "llvm/DebugInfo/CodeView/StreamRef.h" #include "llvm/DebugInfo/CodeView/TypeIndex.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h" diff --git a/lib/DebugInfo/LLVMBuild.txt b/lib/DebugInfo/LLVMBuild.txt index 23a5a3db562..876c43a5749 100644 --- a/lib/DebugInfo/LLVMBuild.txt +++ b/lib/DebugInfo/LLVMBuild.txt @@ -16,7 +16,7 @@ ;===------------------------------------------------------------------------===; [common] -subdirectories = CodeView DWARF PDB Symbolize +subdirectories = DWARF Msf CodeView PDB Symbolize [component_0] type = Group diff --git a/lib/DebugInfo/CodeView/ByteStream.cpp b/lib/DebugInfo/Msf/ByteStream.cpp similarity index 73% rename from lib/DebugInfo/CodeView/ByteStream.cpp rename to lib/DebugInfo/Msf/ByteStream.cpp index 2c43bc6958d..32fcbccaacc 100644 --- a/lib/DebugInfo/CodeView/ByteStream.cpp +++ b/lib/DebugInfo/Msf/ByteStream.cpp @@ -7,26 +7,26 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DebugInfo/CodeView/ByteStream.h" -#include "llvm/DebugInfo/CodeView/CodeViewError.h" -#include "llvm/DebugInfo/CodeView/StreamReader.h" +#include "llvm/DebugInfo/Msf/ByteStream.h" +#include "llvm/DebugInfo/Msf/MsfError.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" #include using namespace llvm; -using namespace llvm::codeview; +using namespace llvm::msf; static Error writeBytes(uint32_t Offset, ArrayRef Src, ArrayRef Dest) { - return make_error(cv_error_code::operation_unsupported, - "ByteStream is immutable."); + return make_error(msf_error_code::not_writable, + "ByteStream is immutable."); } static Error writeBytes(uint32_t Offset, ArrayRef Src, MutableArrayRef Dest) { if (Dest.size() < Src.size()) - return make_error(cv_error_code::insufficient_buffer); + return make_error(msf_error_code::insufficient_buffer); if (Offset > Src.size() - Dest.size()) - return make_error(cv_error_code::insufficient_buffer); + return make_error(msf_error_code::insufficient_buffer); ::memcpy(Dest.data() + Offset, Src.data(), Src.size()); return Error::success(); @@ -36,9 +36,9 @@ template Error ByteStream::readBytes(uint32_t Offset, uint32_t Size, ArrayRef &Buffer) const { if (Offset > Data.size()) - return make_error(cv_error_code::insufficient_buffer); + return make_error(msf_error_code::insufficient_buffer); if (Data.size() < Size + Offset) - return make_error(cv_error_code::insufficient_buffer); + return make_error(msf_error_code::insufficient_buffer); Buffer = Data.slice(Offset, Size); return Error::success(); } @@ -47,7 +47,7 @@ template Error ByteStream::readLongestContiguousChunk( uint32_t Offset, ArrayRef &Buffer) const { if (Offset >= Data.size()) - return make_error(cv_error_code::insufficient_buffer); + return make_error(msf_error_code::insufficient_buffer); Buffer = Data.slice(Offset); return Error::success(); } @@ -72,7 +72,7 @@ template StringRef ByteStream::str() const { } namespace llvm { -namespace codeview { +namespace msf { template class ByteStream; template class ByteStream; } diff --git a/lib/DebugInfo/Msf/CMakeLists.txt b/lib/DebugInfo/Msf/CMakeLists.txt new file mode 100644 index 00000000000..49a71a8409c --- /dev/null +++ b/lib/DebugInfo/Msf/CMakeLists.txt @@ -0,0 +1,12 @@ +add_llvm_library(LLVMDebugInfoMsf + ByteStream.cpp + IndexedStreamData.cpp + MappedBlockStream.cpp + MsfBuilder.cpp + MsfCommon.cpp + MsfError.cpp + StreamReader.cpp + StreamWriter.cpp + ADDITIONAL_HEADER_DIRS + "${LLVM_MAIN_INCLUDE_DIR}/llvm/DebugInfo/MSF" + ) diff --git a/lib/DebugInfo/PDB/Raw/IndexedStreamData.cpp b/lib/DebugInfo/Msf/IndexedStreamData.cpp similarity index 82% rename from lib/DebugInfo/PDB/Raw/IndexedStreamData.cpp rename to lib/DebugInfo/Msf/IndexedStreamData.cpp index 9bd16ea76ef..81303aeb8f4 100644 --- a/lib/DebugInfo/PDB/Raw/IndexedStreamData.cpp +++ b/lib/DebugInfo/Msf/IndexedStreamData.cpp @@ -7,13 +7,13 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DebugInfo/PDB/Raw/IndexedStreamData.h" -#include "llvm/DebugInfo/PDB/Raw/IPDBFile.h" +#include "llvm/DebugInfo/Msf/IndexedStreamData.h" +#include "llvm/DebugInfo/Msf/IMsfFile.h" using namespace llvm; -using namespace llvm::pdb; +using namespace llvm::msf; -IndexedStreamData::IndexedStreamData(uint32_t StreamIdx, const IPDBFile &File) +IndexedStreamData::IndexedStreamData(uint32_t StreamIdx, const IMsfFile &File) : StreamIdx(StreamIdx), File(File) {} uint32_t IndexedStreamData::getLength() { diff --git a/lib/DebugInfo/Msf/LLVMBuild.txt b/lib/DebugInfo/Msf/LLVMBuild.txt new file mode 100644 index 00000000000..4598c437a93 --- /dev/null +++ b/lib/DebugInfo/Msf/LLVMBuild.txt @@ -0,0 +1,22 @@ +;===- ./lib/DebugInfo/Msf/LLVMBuild.txt -------------------*- Conf -*--===; +; +; The LLVM Compiler Infrastructure +; +; This file is distributed under the University of Illinois Open Source +; License. See LICENSE.TXT for details. +; +;===------------------------------------------------------------------------===; +; +; This is an LLVMBuild description file for the components in this subdirectory. +; +; For more information on the LLVMBuild system, please see: +; +; http://llvm.org/docs/LLVMBuild.html +; +;===------------------------------------------------------------------------===; + +[component_0] +type = Library +name = DebugInfoMsf +parent = DebugInfo +required_libraries = Support diff --git a/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp b/lib/DebugInfo/Msf/MappedBlockStream.cpp similarity index 76% rename from lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp rename to lib/DebugInfo/Msf/MappedBlockStream.cpp index 92b2048c3c2..f2c80122169 100644 --- a/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp +++ b/lib/DebugInfo/Msf/MappedBlockStream.cpp @@ -1,4 +1,4 @@ -//===- MappedBlockStream.cpp - Reads stream data from a PDBFile -----------===// +//===- MappedBlockStream.cpp - Reads stream data from an MSF file ---------===// // // The LLVM Compiler Infrastructure // @@ -7,24 +7,23 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h" -#include "llvm/DebugInfo/PDB/Raw/DirectoryStreamData.h" -#include "llvm/DebugInfo/PDB/Raw/IPDBStreamData.h" -#include "llvm/DebugInfo/PDB/Raw/IndexedStreamData.h" -#include "llvm/DebugInfo/PDB/Raw/PDBFile.h" -#include "llvm/DebugInfo/PDB/Raw/RawError.h" +#include "llvm/DebugInfo/Msf/MappedBlockStream.h" +#include "llvm/DebugInfo/Msf/DirectoryStreamData.h" +#include "llvm/DebugInfo/Msf/IMsfStreamData.h" +#include "llvm/DebugInfo/Msf/IndexedStreamData.h" +#include "llvm/DebugInfo/Msf/MsfError.h" using namespace llvm; -using namespace llvm::pdb; +using namespace llvm::msf; namespace { -// This exists so that we can use make_unique while still keeping the -// constructor of MappedBlockStream private, forcing users to go through -// the `create` interface. +// This exists so that we can use make_unique (which requires a public default +// constructor, while still keeping the constructor of MappedBlockStream +// protected, forcing users to go through the `create` interface. class MappedBlockStreamImpl : public MappedBlockStream { public: - MappedBlockStreamImpl(std::unique_ptr Data, - const IPDBFile &File) + MappedBlockStreamImpl(std::unique_ptr Data, + const IMsfFile &File) : MappedBlockStream(std::move(Data), File) {} }; } @@ -35,17 +34,17 @@ static Interval intersect(const Interval &I1, const Interval &I2) { std::min(I1.second, I2.second)); } -MappedBlockStream::MappedBlockStream(std::unique_ptr Data, - const IPDBFile &Pdb) - : Pdb(Pdb), Data(std::move(Data)) {} +MappedBlockStream::MappedBlockStream(std::unique_ptr Data, + const IMsfFile &File) + : Msf(File), Data(std::move(Data)) {} Error MappedBlockStream::readBytes(uint32_t Offset, uint32_t Size, ArrayRef &Buffer) const { // Make sure we aren't trying to read beyond the end of the stream. if (Size > Data->getLength()) - return make_error(raw_error_code::insufficient_buffer); + return make_error(msf_error_code::insufficient_buffer); if (Offset > Data->getLength() - Size) - return make_error(raw_error_code::insufficient_buffer); + return make_error(msf_error_code::insufficient_buffer); if (tryReadContiguously(Offset, Size, Buffer)) return Error::success(); @@ -123,23 +122,23 @@ Error MappedBlockStream::readLongestContiguousChunk( uint32_t Offset, ArrayRef &Buffer) const { // Make sure we aren't trying to read beyond the end of the stream. if (Offset >= Data->getLength()) - return make_error(raw_error_code::insufficient_buffer); - uint32_t First = Offset / Pdb.getBlockSize(); + return make_error(msf_error_code::insufficient_buffer); + uint32_t First = Offset / Msf.getBlockSize(); uint32_t Last = First; auto BlockList = Data->getStreamBlocks(); - while (Last < Pdb.getBlockCount() - 1) { + while (Last < Msf.getBlockCount() - 1) { if (BlockList[Last] != BlockList[Last + 1] - 1) break; ++Last; } - uint32_t OffsetInFirstBlock = Offset % Pdb.getBlockSize(); - uint32_t BytesFromFirstBlock = Pdb.getBlockSize() - OffsetInFirstBlock; + uint32_t OffsetInFirstBlock = Offset % Msf.getBlockSize(); + uint32_t BytesFromFirstBlock = Msf.getBlockSize() - OffsetInFirstBlock; uint32_t BlockSpan = Last - First + 1; uint32_t ByteSpan = - BytesFromFirstBlock + (BlockSpan - 1) * Pdb.getBlockSize(); - auto Result = Pdb.getBlockData(BlockList[First], Pdb.getBlockSize()); + BytesFromFirstBlock + (BlockSpan - 1) * Msf.getBlockSize(); + auto Result = Msf.getBlockData(BlockList[First], Msf.getBlockSize()); if (!Result) return Result.takeError(); Buffer = Result->drop_front(OffsetInFirstBlock); @@ -158,13 +157,13 @@ bool MappedBlockStream::tryReadContiguously(uint32_t Offset, uint32_t Size, // all subsequent blocks are contiguous. For example, a 10k read with a 4k // block size can be filled with a reference if, from the starting offset, // 3 blocks in a row are contiguous. - uint32_t BlockNum = Offset / Pdb.getBlockSize(); - uint32_t OffsetInBlock = Offset % Pdb.getBlockSize(); + uint32_t BlockNum = Offset / Msf.getBlockSize(); + uint32_t OffsetInBlock = Offset % Msf.getBlockSize(); uint32_t BytesFromFirstBlock = - std::min(Size, Pdb.getBlockSize() - OffsetInBlock); + std::min(Size, Msf.getBlockSize() - OffsetInBlock); uint32_t NumAdditionalBlocks = - llvm::alignTo(Size - BytesFromFirstBlock, Pdb.getBlockSize()) / - Pdb.getBlockSize(); + llvm::alignTo(Size - BytesFromFirstBlock, Msf.getBlockSize()) / + Msf.getBlockSize(); auto BlockList = Data->getStreamBlocks(); uint32_t RequiredContiguousBlocks = NumAdditionalBlocks + 1; @@ -175,7 +174,7 @@ bool MappedBlockStream::tryReadContiguously(uint32_t Offset, uint32_t Size, } uint32_t FirstBlockAddr = BlockList[BlockNum]; - auto Result = Pdb.getBlockData(FirstBlockAddr, Pdb.getBlockSize()); + auto Result = Msf.getBlockData(FirstBlockAddr, Msf.getBlockSize()); if (!Result) { consumeError(Result.takeError()); return false; @@ -187,14 +186,14 @@ bool MappedBlockStream::tryReadContiguously(uint32_t Offset, uint32_t Size, Error MappedBlockStream::readBytes(uint32_t Offset, MutableArrayRef Buffer) const { - uint32_t BlockNum = Offset / Pdb.getBlockSize(); - uint32_t OffsetInBlock = Offset % Pdb.getBlockSize(); + uint32_t BlockNum = Offset / Msf.getBlockSize(); + uint32_t OffsetInBlock = Offset % Msf.getBlockSize(); // Make sure we aren't trying to read beyond the end of the stream. if (Buffer.size() > Data->getLength()) - return make_error(raw_error_code::insufficient_buffer); + return make_error(msf_error_code::insufficient_buffer); if (Offset > Data->getLength() - Buffer.size()) - return make_error(raw_error_code::insufficient_buffer); + return make_error(msf_error_code::insufficient_buffer); uint32_t BytesLeft = Buffer.size(); uint32_t BytesWritten = 0; @@ -203,14 +202,14 @@ Error MappedBlockStream::readBytes(uint32_t Offset, while (BytesLeft > 0) { uint32_t StreamBlockAddr = BlockList[BlockNum]; - auto Result = Pdb.getBlockData(StreamBlockAddr, Pdb.getBlockSize()); + auto Result = Msf.getBlockData(StreamBlockAddr, Msf.getBlockSize()); if (!Result) return Result.takeError(); auto Data = *Result; const uint8_t *ChunkStart = Data.data() + OffsetInBlock; uint32_t BytesInChunk = - std::min(BytesLeft, Pdb.getBlockSize() - OffsetInBlock); + std::min(BytesLeft, Msf.getBlockSize() - OffsetInBlock); ::memcpy(WriteBuffer + BytesWritten, ChunkStart, BytesInChunk); BytesWritten += BytesInChunk; @@ -226,13 +225,13 @@ Error MappedBlockStream::writeBytes(uint32_t Offset, ArrayRef Buffer) const { // Make sure we aren't trying to write beyond the end of the stream. if (Buffer.size() > Data->getLength()) - return make_error(raw_error_code::insufficient_buffer); + return make_error(msf_error_code::insufficient_buffer); if (Offset > Data->getLength() - Buffer.size()) - return make_error(raw_error_code::insufficient_buffer); + return make_error(msf_error_code::insufficient_buffer); - uint32_t BlockNum = Offset / Pdb.getBlockSize(); - uint32_t OffsetInBlock = Offset % Pdb.getBlockSize(); + uint32_t BlockNum = Offset / Msf.getBlockSize(); + uint32_t OffsetInBlock = Offset % Msf.getBlockSize(); uint32_t BytesLeft = Buffer.size(); auto BlockList = Data->getStreamBlocks(); @@ -240,11 +239,11 @@ Error MappedBlockStream::writeBytes(uint32_t Offset, while (BytesLeft > 0) { uint32_t StreamBlockAddr = BlockList[BlockNum]; uint32_t BytesToWriteInChunk = - std::min(BytesLeft, Pdb.getBlockSize() - OffsetInBlock); + std::min(BytesLeft, Msf.getBlockSize() - OffsetInBlock); const uint8_t *Chunk = Buffer.data() + BytesWritten; ArrayRef ChunkData(Chunk, BytesToWriteInChunk); - if (auto EC = Pdb.setBlockData(StreamBlockAddr, OffsetInBlock, ChunkData)) + if (auto EC = Msf.setBlockData(StreamBlockAddr, OffsetInBlock, ChunkData)) return EC; BytesLeft -= BytesToWriteInChunk; @@ -295,16 +294,18 @@ uint32_t MappedBlockStream::getNumBytesCopied() const { Expected> MappedBlockStream::createIndexedStream(uint32_t StreamIdx, - const IPDBFile &File) { + const IMsfFile &File) { if (StreamIdx >= File.getNumStreams()) - return make_error(raw_error_code::no_stream); + return make_error(msf_error_code::no_stream); auto Data = llvm::make_unique(StreamIdx, File); return llvm::make_unique(std::move(Data), File); } Expected> -MappedBlockStream::createDirectoryStream(const PDBFile &File) { - auto Data = llvm::make_unique(File); +MappedBlockStream::createDirectoryStream(uint32_t Length, + ArrayRef Blocks, + const IMsfFile &File) { + auto Data = llvm::make_unique(Length, Blocks); return llvm::make_unique(std::move(Data), File); } diff --git a/lib/DebugInfo/PDB/Raw/MsfBuilder.cpp b/lib/DebugInfo/Msf/MsfBuilder.cpp similarity index 92% rename from lib/DebugInfo/PDB/Raw/MsfBuilder.cpp rename to lib/DebugInfo/Msf/MsfBuilder.cpp index 16b086bdaa9..e6f15d8877e 100644 --- a/lib/DebugInfo/PDB/Raw/MsfBuilder.cpp +++ b/lib/DebugInfo/Msf/MsfBuilder.cpp @@ -7,12 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DebugInfo/PDB/Raw/MsfBuilder.h" -#include "llvm/DebugInfo/PDB/Raw/RawError.h" +#include "llvm/DebugInfo/Msf/MsfBuilder.h" +#include "llvm/DebugInfo/Msf/MsfError.h" using namespace llvm; -using namespace llvm::pdb; -using namespace llvm::pdb::msf; +using namespace llvm::msf; using namespace llvm::support; namespace { @@ -38,8 +37,8 @@ MsfBuilder::MsfBuilder(uint32_t BlockSize, uint32_t MinBlockCount, bool CanGrow, Expected MsfBuilder::create(BumpPtrAllocator &Allocator, uint32_t BlockSize, uint32_t MinBlockCount, bool CanGrow) { - if (!msf::isValidBlockSize(BlockSize)) - return make_error(raw_error_code::unspecified, + if (!isValidBlockSize(BlockSize)) + return make_error(msf_error_code::invalid_format, "The requested block size is unsupported"); return MsfBuilder(BlockSize, @@ -53,14 +52,15 @@ Error MsfBuilder::setBlockMapAddr(uint32_t Addr) { if (Addr >= FreeBlocks.size()) { if (!IsGrowable) - return make_error(raw_error_code::unspecified, + return make_error(msf_error_code::insufficient_buffer, "Cannot grow the number of blocks"); FreeBlocks.resize(Addr + 1); } if (!isBlockFree(Addr)) - return make_error(raw_error_code::unspecified, - "Attempt to reuse an allocated block"); + return make_error( + msf_error_code::block_in_use, + "Requested block map address is already in use"); FreeBlocks[BlockMapAddr] = true; FreeBlocks[Addr] = false; BlockMapAddr = Addr; @@ -76,7 +76,7 @@ Error MsfBuilder::setDirectoryBlocksHint(ArrayRef DirBlocks) { FreeBlocks[B] = true; for (auto B : DirBlocks) { if (!isBlockFree(B)) { - return make_error(raw_error_code::unspecified, + return make_error(msf_error_code::unspecified, "Attempt to reuse an allocated block"); } FreeBlocks[B] = false; @@ -94,7 +94,7 @@ Error MsfBuilder::allocateBlocks(uint32_t NumBlocks, uint32_t NumFreeBlocks = FreeBlocks.count(); if (NumFreeBlocks < NumBlocks) { if (!IsGrowable) - return make_error(raw_error_code::unspecified, + return make_error(msf_error_code::insufficient_buffer, "There are no free Blocks in the file"); uint32_t AllocBlocks = NumBlocks - NumFreeBlocks; FreeBlocks.resize(AllocBlocks + FreeBlocks.size(), true); @@ -129,16 +129,16 @@ Error MsfBuilder::addStream(uint32_t Size, ArrayRef Blocks) { // of bytes, and verify that all requested blocks are free. uint32_t ReqBlocks = bytesToBlocks(Size, BlockSize); if (ReqBlocks != Blocks.size()) - return make_error( - raw_error_code::unspecified, + return make_error( + msf_error_code::invalid_format, "Incorrect number of blocks for requested stream size"); for (auto Block : Blocks) { if (Block >= FreeBlocks.size()) FreeBlocks.resize(Block + 1, true); if (!FreeBlocks.test(Block)) - return make_error( - raw_error_code::unspecified, + return make_error( + msf_error_code::unspecified, "Attempt to re-use an already allocated block"); } // Mark all the blocks occupied by the new stream as not free. @@ -249,8 +249,8 @@ Expected MsfBuilder::build() { } // Don't set the number of blocks in the file until after allocating Blocks - // for - // the directory, since the allocation might cause the file to need to grow. + // for the directory, since the allocation might cause the file to need to + // grow. L.SB->NumBlocks = FreeBlocks.size(); ulittle32_t *DirBlocks = Allocator.Allocate(NumDirectoryBlocks); diff --git a/lib/DebugInfo/PDB/Raw/MsfCommon.cpp b/lib/DebugInfo/Msf/MsfCommon.cpp similarity index 74% rename from lib/DebugInfo/PDB/Raw/MsfCommon.cpp rename to lib/DebugInfo/Msf/MsfCommon.cpp index 5d97f33e110..e22087f705f 100644 --- a/lib/DebugInfo/PDB/Raw/MsfCommon.cpp +++ b/lib/DebugInfo/Msf/MsfCommon.cpp @@ -7,25 +7,25 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DebugInfo/PDB/Raw/MsfCommon.h" -#include "llvm/DebugInfo/PDB/Raw/RawError.h" +#include "llvm/DebugInfo/Msf/MsfCommon.h" +#include "llvm/DebugInfo/Msf/MsfError.h" using namespace llvm; -using namespace llvm::pdb::msf; +using namespace llvm::msf; -Error llvm::pdb::msf::validateSuperBlock(const SuperBlock &SB) { +Error llvm::msf::validateSuperBlock(const SuperBlock &SB) { // Check the magic bytes. if (std::memcmp(SB.MagicBytes, Magic, sizeof(Magic)) != 0) - return make_error(raw_error_code::corrupt_file, + return make_error(msf_error_code::invalid_format, "MSF magic header doesn't match"); if (!isValidBlockSize(SB.BlockSize)) - return make_error(raw_error_code::corrupt_file, + return make_error(msf_error_code::invalid_format, "Unsupported block size."); // We don't support directories whose sizes aren't a multiple of four bytes. if (SB.NumDirectoryBytes % sizeof(support::ulittle32_t) != 0) - return make_error(raw_error_code::corrupt_file, + return make_error(msf_error_code::invalid_format, "Directory size is not multiple of 4."); // The number of blocks which comprise the directory is a simple function of @@ -37,11 +37,11 @@ Error llvm::pdb::msf::validateSuperBlock(const SuperBlock &SB) { // block numbers. It is unclear what would happen if the number of blocks // couldn't fit on a single block. if (NumDirectoryBlocks > SB.BlockSize / sizeof(support::ulittle32_t)) - return make_error(raw_error_code::corrupt_file, + return make_error(msf_error_code::invalid_format, "Too many directory blocks."); if (SB.BlockMapAddr == 0) - return make_error(raw_error_code::corrupt_file, + return make_error(msf_error_code::invalid_format, "Block 0 is reserved"); return Error::success(); diff --git a/lib/DebugInfo/Msf/MsfError.cpp b/lib/DebugInfo/Msf/MsfError.cpp new file mode 100644 index 00000000000..246beb9b0de --- /dev/null +++ b/lib/DebugInfo/Msf/MsfError.cpp @@ -0,0 +1,70 @@ +//===- MsfError.cpp - 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. +// +//===----------------------------------------------------------------------===// + +#include "llvm/DebugInfo/Msf/MsfError.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/ManagedStatic.h" + +using namespace llvm; +using namespace llvm::msf; + +namespace { +// FIXME: This class is only here to support the transition to llvm::Error. It +// will be removed once this transition is complete. Clients should prefer to +// deal with the Error value directly, rather than converting to error_code. +class MsfErrorCategory : public std::error_category { +public: + const char *name() const LLVM_NOEXCEPT override { return "llvm.msf"; } + + std::string message(int Condition) const override { + switch (static_cast(Condition)) { + case msf_error_code::unspecified: + return "An unknown error has occurred."; + case msf_error_code::insufficient_buffer: + return "The buffer is not large enough to read the requested number of " + "bytes."; + case msf_error_code::not_writable: + return "The specified stream is not writable."; + case msf_error_code::no_stream: + return "The specified stream does not exist."; + case msf_error_code::invalid_format: + return "The data is in an unexpected format."; + case msf_error_code::block_in_use: + return "The block is already in use."; + } + llvm_unreachable("Unrecognized msf_error_code"); + } +}; +} // end anonymous namespace + +static ManagedStatic Category; + +char MsfError::ID = 0; + +MsfError::MsfError(msf_error_code C) : MsfError(C, "") {} + +MsfError::MsfError(const std::string &Context) + : MsfError(msf_error_code::unspecified, Context) {} + +MsfError::MsfError(msf_error_code C, const std::string &Context) : Code(C) { + ErrMsg = "Msf Error: "; + std::error_code EC = convertToErrorCode(); + if (Code != msf_error_code::unspecified) + ErrMsg += EC.message() + " "; + if (!Context.empty()) + ErrMsg += Context; +} + +void MsfError::log(raw_ostream &OS) const { OS << ErrMsg << "\n"; } + +const std::string &MsfError::getErrorMessage() const { return ErrMsg; } + +std::error_code MsfError::convertToErrorCode() const { + return std::error_code(static_cast(Code), *Category); +} diff --git a/lib/DebugInfo/CodeView/StreamReader.cpp b/lib/DebugInfo/Msf/StreamReader.cpp similarity index 90% rename from lib/DebugInfo/CodeView/StreamReader.cpp rename to lib/DebugInfo/Msf/StreamReader.cpp index 64e45487322..a2f0f49c3d9 100644 --- a/lib/DebugInfo/CodeView/StreamReader.cpp +++ b/lib/DebugInfo/Msf/StreamReader.cpp @@ -7,13 +7,13 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DebugInfo/CodeView/StreamReader.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" -#include "llvm/DebugInfo/CodeView/CodeViewError.h" -#include "llvm/DebugInfo/CodeView/StreamRef.h" +#include "llvm/DebugInfo/Msf/MsfError.h" +#include "llvm/DebugInfo/Msf/StreamRef.h" using namespace llvm; -using namespace llvm::codeview; +using namespace llvm::msf; StreamReader::StreamReader(StreamRef S) : Stream(S), Offset(0) {} @@ -86,7 +86,7 @@ Error StreamReader::readStreamRef(StreamRef &Ref) { Error StreamReader::readStreamRef(StreamRef &Ref, uint32_t Length) { if (bytesRemaining() < Length) - return make_error(cv_error_code::insufficient_buffer); + return make_error(msf_error_code::insufficient_buffer); Ref = Stream.slice(Offset, Length); Offset += Length; return Error::success(); diff --git a/lib/DebugInfo/CodeView/StreamWriter.cpp b/lib/DebugInfo/Msf/StreamWriter.cpp similarity index 90% rename from lib/DebugInfo/CodeView/StreamWriter.cpp rename to lib/DebugInfo/Msf/StreamWriter.cpp index 90eafbb9c83..eb11012c475 100644 --- a/lib/DebugInfo/CodeView/StreamWriter.cpp +++ b/lib/DebugInfo/Msf/StreamWriter.cpp @@ -7,14 +7,14 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DebugInfo/CodeView/StreamWriter.h" +#include "llvm/DebugInfo/Msf/StreamWriter.h" -#include "llvm/DebugInfo/CodeView/CodeViewError.h" -#include "llvm/DebugInfo/CodeView/StreamReader.h" -#include "llvm/DebugInfo/CodeView/StreamRef.h" +#include "llvm/DebugInfo/Msf/MsfError.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" +#include "llvm/DebugInfo/Msf/StreamRef.h" using namespace llvm; -using namespace llvm::codeview; +using namespace llvm::msf; StreamWriter::StreamWriter(StreamRef S) : Stream(S), Offset(0) {} diff --git a/lib/DebugInfo/PDB/CMakeLists.txt b/lib/DebugInfo/PDB/CMakeLists.txt index b5a2bc1600f..126be38167b 100644 --- a/lib/DebugInfo/PDB/CMakeLists.txt +++ b/lib/DebugInfo/PDB/CMakeLists.txt @@ -32,14 +32,10 @@ add_pdb_impl_folder(Raw Raw/DbiStreamBuilder.cpp Raw/EnumTables.cpp Raw/Hash.cpp - Raw/IndexedStreamData.cpp Raw/InfoStream.cpp Raw/InfoStreamBuilder.cpp - Raw/MappedBlockStream.cpp Raw/ModInfo.cpp Raw/ModStream.cpp - Raw/MsfBuilder.cpp - Raw/MsfCommon.cpp Raw/NameHashTable.cpp Raw/NameMap.cpp Raw/NameMapBuilder.cpp diff --git a/lib/DebugInfo/PDB/LLVMBuild.txt b/lib/DebugInfo/PDB/LLVMBuild.txt index 76e537a57fc..a2196837723 100644 --- a/lib/DebugInfo/PDB/LLVMBuild.txt +++ b/lib/DebugInfo/PDB/LLVMBuild.txt @@ -19,5 +19,5 @@ type = Library name = DebugInfoPDB parent = DebugInfo -required_libraries = Object Support DebugInfoCodeView +required_libraries = Object Support DebugInfoCodeView DebugInfoMsf diff --git a/lib/DebugInfo/PDB/Raw/DbiStream.cpp b/lib/DebugInfo/PDB/Raw/DbiStream.cpp index 430a84f93a2..1bad0009c37 100644 --- a/lib/DebugInfo/PDB/Raw/DbiStream.cpp +++ b/lib/DebugInfo/PDB/Raw/DbiStream.cpp @@ -9,11 +9,11 @@ #include "llvm/DebugInfo/PDB/Raw/DbiStream.h" -#include "llvm/DebugInfo/CodeView/StreamArray.h" -#include "llvm/DebugInfo/CodeView/StreamReader.h" -#include "llvm/DebugInfo/CodeView/StreamWriter.h" +#include "llvm/DebugInfo/Msf/IndexedStreamData.h" +#include "llvm/DebugInfo/Msf/StreamArray.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" +#include "llvm/DebugInfo/Msf/StreamWriter.h" #include "llvm/DebugInfo/PDB/Raw/ISectionContribVisitor.h" -#include "llvm/DebugInfo/PDB/Raw/IndexedStreamData.h" #include "llvm/DebugInfo/PDB/Raw/InfoStream.h" #include "llvm/DebugInfo/PDB/Raw/ModInfo.h" #include "llvm/DebugInfo/PDB/Raw/NameHashTable.h" @@ -25,6 +25,7 @@ using namespace llvm; using namespace llvm::codeview; +using namespace llvm::msf; using namespace llvm::pdb; using namespace llvm::support; @@ -204,17 +205,16 @@ PDB_Machine DbiStream::getMachineType() const { return static_cast(Machine); } -codeview::FixedStreamArray -DbiStream::getSectionHeaders() { +msf::FixedStreamArray DbiStream::getSectionHeaders() { return SectionHeaders; } -codeview::FixedStreamArray DbiStream::getFpoRecords() { +msf::FixedStreamArray DbiStream::getFpoRecords() { return FpoRecords; } ArrayRef DbiStream::modules() const { return ModuleInfos; } -codeview::FixedStreamArray DbiStream::getSectionMap() const { +msf::FixedStreamArray DbiStream::getSectionMap() const { return SectionMap; } @@ -283,7 +283,7 @@ Error DbiStream::initializeSectionHeadersData() { "Corrupted section header stream."); size_t NumSections = StreamLen / sizeof(object::coff_section); - codeview::StreamReader Reader(**SHS); + msf::StreamReader Reader(**SHS); if (auto EC = Reader.readArray(SectionHeaders, NumSections)) return make_error(raw_error_code::corrupt_file, "Could not read a bitmap."); @@ -316,7 +316,7 @@ Error DbiStream::initializeFpoRecords() { "Corrupted New FPO stream."); size_t NumRecords = StreamLen / sizeof(object::FpoData); - codeview::StreamReader Reader(**FS); + msf::StreamReader Reader(**FS); if (auto EC = Reader.readArray(FpoRecords, NumRecords)) return make_error(raw_error_code::corrupt_file, "Corrupted New FPO stream."); diff --git a/lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp b/lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp index 751f869c52a..7a688cb8968 100644 --- a/lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp +++ b/lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp @@ -9,13 +9,14 @@ #include "llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h" -#include "llvm/DebugInfo/CodeView/StreamWriter.h" +#include "llvm/DebugInfo/Msf/MappedBlockStream.h" +#include "llvm/DebugInfo/Msf/StreamWriter.h" #include "llvm/DebugInfo/PDB/Raw/DbiStream.h" -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h" using namespace llvm; using namespace llvm::codeview; +using namespace llvm::msf; using namespace llvm::pdb; namespace { diff --git a/lib/DebugInfo/PDB/Raw/InfoStream.cpp b/lib/DebugInfo/PDB/Raw/InfoStream.cpp index c33a764587c..3d1bcdfd849 100644 --- a/lib/DebugInfo/PDB/Raw/InfoStream.cpp +++ b/lib/DebugInfo/PDB/Raw/InfoStream.cpp @@ -10,22 +10,23 @@ #include "llvm/DebugInfo/PDB/Raw/InfoStream.h" #include "llvm/ADT/BitVector.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/DebugInfo/CodeView/StreamReader.h" -#include "llvm/DebugInfo/CodeView/StreamWriter.h" -#include "llvm/DebugInfo/PDB/Raw/IndexedStreamData.h" +#include "llvm/DebugInfo/Msf/IndexedStreamData.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" +#include "llvm/DebugInfo/Msf/StreamWriter.h" #include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/DebugInfo/PDB/Raw/RawConstants.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h" using namespace llvm; using namespace llvm::codeview; +using namespace llvm::msf; using namespace llvm::pdb; InfoStream::InfoStream(std::unique_ptr Stream) : Stream(std::move(Stream)) {} Error InfoStream::reload() { - codeview::StreamReader Reader(*Stream); + StreamReader Reader(*Stream); const HeaderInfo *H; if (auto EC = Reader.readObject(H)) diff --git a/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp b/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp index 7be9cc32db9..444aba6be0b 100644 --- a/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp +++ b/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp @@ -9,13 +9,14 @@ #include "llvm/DebugInfo/PDB/Raw/InfoStreamBuilder.h" -#include "llvm/DebugInfo/CodeView/StreamWriter.h" +#include "llvm/DebugInfo/Msf/MappedBlockStream.h" +#include "llvm/DebugInfo/Msf/StreamWriter.h" #include "llvm/DebugInfo/PDB/Raw/InfoStream.h" -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h" using namespace llvm; using namespace llvm::codeview; +using namespace llvm::msf; using namespace llvm::pdb; InfoStreamBuilder::InfoStreamBuilder() {} diff --git a/lib/DebugInfo/PDB/Raw/ModInfo.cpp b/lib/DebugInfo/PDB/Raw/ModInfo.cpp index 9d0a0ae6e36..89a03ec3a4d 100644 --- a/lib/DebugInfo/PDB/Raw/ModInfo.cpp +++ b/lib/DebugInfo/PDB/Raw/ModInfo.cpp @@ -9,11 +9,12 @@ #include "llvm/DebugInfo/PDB/Raw/ModInfo.h" -#include "llvm/DebugInfo/CodeView/StreamReader.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" #include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/Support/Endian.h" using namespace llvm; +using namespace llvm::msf; using namespace llvm::pdb; using namespace llvm::support; @@ -26,8 +27,8 @@ ModInfo::ModInfo(const ModInfo &Info) ModInfo::~ModInfo() {} -Error ModInfo::initialize(codeview::StreamRef Stream, ModInfo &Info) { - codeview::StreamReader Reader(Stream); +Error ModInfo::initialize(StreamRef Stream, ModInfo &Info) { + StreamReader Reader(Stream); if (auto EC = Reader.readObject(Info.Layout)) return EC; diff --git a/lib/DebugInfo/PDB/Raw/ModStream.cpp b/lib/DebugInfo/PDB/Raw/ModStream.cpp index 3415fcd4779..39e9dfaf3e2 100644 --- a/lib/DebugInfo/PDB/Raw/ModStream.cpp +++ b/lib/DebugInfo/PDB/Raw/ModStream.cpp @@ -9,14 +9,15 @@ #include "llvm/DebugInfo/PDB/Raw/ModStream.h" -#include "llvm/DebugInfo/CodeView/StreamReader.h" -#include "llvm/DebugInfo/PDB/Raw/IndexedStreamData.h" +#include "llvm/DebugInfo/Msf/IndexedStreamData.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" #include "llvm/DebugInfo/PDB/Raw/ModInfo.h" #include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h" #include "llvm/DebugInfo/PDB/Raw/RawTypes.h" using namespace llvm; +using namespace llvm::msf; using namespace llvm::pdb; ModStream::ModStream(const ModInfo &Module, @@ -26,7 +27,7 @@ ModStream::ModStream(const ModInfo &Module, ModStream::~ModStream() {} Error ModStream::reload() { - codeview::StreamReader Reader(*Stream); + StreamReader Reader(*Stream); uint32_t SymbolSize = Mod.getSymbolDebugInfoByteSize(); uint32_t C11Size = Mod.getLineInfoByteSize(); @@ -36,7 +37,7 @@ Error ModStream::reload() { return llvm::make_error(raw_error_code::corrupt_file, "Module has both C11 and C13 line info"); - codeview::StreamRef S; + StreamRef S; uint32_t SymbolSubstreamSig = 0; if (auto EC = Reader.readInteger(SymbolSubstreamSig)) @@ -49,7 +50,7 @@ Error ModStream::reload() { if (auto EC = Reader.readStreamRef(C13LinesSubstream, C13Size)) return EC; - codeview::StreamReader LineReader(C13LinesSubstream); + StreamReader LineReader(C13LinesSubstream); if (auto EC = LineReader.readArray(LineInfo, LineReader.bytesRemaining())) return EC; diff --git a/lib/DebugInfo/PDB/Raw/NameHashTable.cpp b/lib/DebugInfo/PDB/Raw/NameHashTable.cpp index ae4ebf27721..3e22e7686bd 100644 --- a/lib/DebugInfo/PDB/Raw/NameHashTable.cpp +++ b/lib/DebugInfo/PDB/Raw/NameHashTable.cpp @@ -10,18 +10,19 @@ #include "llvm/DebugInfo/PDB/Raw/NameHashTable.h" #include "llvm/ADT/ArrayRef.h" -#include "llvm/DebugInfo/CodeView/StreamReader.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" #include "llvm/DebugInfo/PDB/Raw/Hash.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h" #include "llvm/Support/Endian.h" using namespace llvm; +using namespace llvm::msf; using namespace llvm::support; using namespace llvm::pdb; NameHashTable::NameHashTable() : Signature(0), HashVersion(0), NameCount(0) {} -Error NameHashTable::load(codeview::StreamReader &Stream) { +Error NameHashTable::load(StreamReader &Stream) { struct Header { support::ulittle32_t Signature; support::ulittle32_t HashVersion; @@ -72,7 +73,7 @@ StringRef NameHashTable::getStringForID(uint32_t ID) const { // the starting offset of the string we're looking for. So just seek into // the desired offset and a read a null terminated stream from that offset. StringRef Result; - codeview::StreamReader NameReader(NamesBuffer); + StreamReader NameReader(NamesBuffer); NameReader.setOffset(ID); if (auto EC = NameReader.readZeroString(Result)) consumeError(std::move(EC)); @@ -98,7 +99,6 @@ uint32_t NameHashTable::getIDForString(StringRef Str) const { return IDs[0]; } -codeview::FixedStreamArray -NameHashTable::name_ids() const { +FixedStreamArray NameHashTable::name_ids() const { return IDs; } diff --git a/lib/DebugInfo/PDB/Raw/NameMap.cpp b/lib/DebugInfo/PDB/Raw/NameMap.cpp index b8a4eb79a48..e17600986c9 100644 --- a/lib/DebugInfo/PDB/Raw/NameMap.cpp +++ b/lib/DebugInfo/PDB/Raw/NameMap.cpp @@ -9,17 +9,17 @@ #include "llvm/DebugInfo/PDB/Raw/NameMap.h" #include "llvm/ADT/SparseBitVector.h" -#include "llvm/DebugInfo/CodeView/StreamReader.h" -#include "llvm/DebugInfo/CodeView/StreamWriter.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" +#include "llvm/DebugInfo/Msf/StreamWriter.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h" using namespace llvm; -using namespace llvm::codeview; +using namespace llvm::msf; using namespace llvm::pdb; NameMap::NameMap() {} -Error NameMap::load(codeview::StreamReader &Stream) { +Error NameMap::load(StreamReader &Stream) { // This is some sort of weird string-set/hash table encoded in the stream. // It starts with the number of bytes in the table. @@ -145,7 +145,7 @@ Error NameMap::load(codeview::StreamReader &Stream) { return Error::success(); } -Error NameMap::commit(codeview::StreamWriter &Writer) { +Error NameMap::commit(StreamWriter &Writer) { // The first field is the number of bytes of string data. So add // up the length of all strings plus a null terminator for each // one. diff --git a/lib/DebugInfo/PDB/Raw/PDBFile.cpp b/lib/DebugInfo/PDB/Raw/PDBFile.cpp index 95016753dc1..b44a474b63d 100644 --- a/lib/DebugInfo/PDB/Raw/PDBFile.cpp +++ b/lib/DebugInfo/PDB/Raw/PDBFile.cpp @@ -10,13 +10,13 @@ #include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/ADT/ArrayRef.h" -#include "llvm/DebugInfo/CodeView/StreamArray.h" -#include "llvm/DebugInfo/CodeView/StreamInterface.h" -#include "llvm/DebugInfo/CodeView/StreamReader.h" -#include "llvm/DebugInfo/CodeView/StreamWriter.h" +#include "llvm/DebugInfo/Msf/DirectoryStreamData.h" +#include "llvm/DebugInfo/Msf/IndexedStreamData.h" +#include "llvm/DebugInfo/Msf/StreamArray.h" +#include "llvm/DebugInfo/Msf/StreamInterface.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" +#include "llvm/DebugInfo/Msf/StreamWriter.h" #include "llvm/DebugInfo/PDB/Raw/DbiStream.h" -#include "llvm/DebugInfo/PDB/Raw/DirectoryStreamData.h" -#include "llvm/DebugInfo/PDB/Raw/IndexedStreamData.h" #include "llvm/DebugInfo/PDB/Raw/InfoStream.h" #include "llvm/DebugInfo/PDB/Raw/NameHashTable.h" #include "llvm/DebugInfo/PDB/Raw/PublicsStream.h" @@ -29,6 +29,7 @@ using namespace llvm; using namespace llvm::codeview; +using namespace llvm::msf; using namespace llvm::pdb; namespace { @@ -130,7 +131,8 @@ Error PDBFile::parseStreamData() { // is exactly what we are attempting to parse. By specifying a custom // subclass of IPDBStreamData which only accesses the fields that have already // been parsed, we can avoid this and reuse MappedBlockStream. - auto DS = MappedBlockStream::createDirectoryStream(*this); + auto DS = MappedBlockStream::createDirectoryStream( + SB->NumDirectoryBytes, getDirectoryBlockArray(), *this); if (!DS) return DS.takeError(); StreamReader Reader(**DS); @@ -315,7 +317,8 @@ Error PDBFile::commit() { if (auto EC = Writer.writeArray(DirectoryBlocks)) return EC; - auto DS = MappedBlockStream::createDirectoryStream(*this); + auto DS = MappedBlockStream::createDirectoryStream( + SB->NumDirectoryBytes, getDirectoryBlockArray(), *this); if (!DS) return DS.takeError(); auto DirStream = std::move(*DS); diff --git a/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp b/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp index 7ed7abefd53..c6bcd5106ca 100644 --- a/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp +++ b/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp @@ -11,8 +11,9 @@ #include "llvm/ADT/BitVector.h" -#include "llvm/DebugInfo/CodeView/StreamInterface.h" -#include "llvm/DebugInfo/CodeView/StreamWriter.h" +#include "llvm/DebugInfo/Msf/MsfBuilder.h" +#include "llvm/DebugInfo/Msf/StreamInterface.h" +#include "llvm/DebugInfo/Msf/StreamWriter.h" #include "llvm/DebugInfo/PDB/Raw/DbiStream.h" #include "llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h" #include "llvm/DebugInfo/PDB/Raw/InfoStream.h" @@ -21,11 +22,11 @@ using namespace llvm; using namespace llvm::codeview; +using namespace llvm::msf; using namespace llvm::pdb; using namespace llvm::support; -PDBFileBuilder::PDBFileBuilder( - std::unique_ptr FileBuffer) +PDBFileBuilder::PDBFileBuilder(std::unique_ptr FileBuffer) : File(llvm::make_unique(std::move(FileBuffer))) {} Error PDBFileBuilder::initialize(const msf::SuperBlock &Super) { diff --git a/lib/DebugInfo/PDB/Raw/PublicsStream.cpp b/lib/DebugInfo/PDB/Raw/PublicsStream.cpp index af3d2d026b4..426efb8fd88 100644 --- a/lib/DebugInfo/PDB/Raw/PublicsStream.cpp +++ b/lib/DebugInfo/PDB/Raw/PublicsStream.cpp @@ -25,10 +25,10 @@ #include "llvm/DebugInfo/PDB/Raw/PublicsStream.h" #include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/StreamReader.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/DebugInfo/PDB/Raw/IndexedStreamData.h" -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h" +#include "llvm/DebugInfo/Msf/IndexedStreamData.h" +#include "llvm/DebugInfo/Msf/MappedBlockStream.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" #include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/DebugInfo/PDB/Raw/RawConstants.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h" @@ -40,6 +40,7 @@ #include "llvm/Support/MathExtras.h" using namespace llvm; +using namespace llvm::msf; using namespace llvm::support; using namespace llvm::pdb; @@ -86,7 +87,7 @@ uint32_t PublicsStream::getAddrMap() const { return Header->AddrMap; } // we skip over the hash table which we believe contains information about // public symbols. Error PublicsStream::reload() { - codeview::StreamReader Reader(*Stream); + StreamReader Reader(*Stream); // Check stream size. if (Reader.bytesRemaining() < sizeof(HeaderInfo) + sizeof(GSIHashHeader)) diff --git a/lib/DebugInfo/PDB/Raw/RawSession.cpp b/lib/DebugInfo/PDB/Raw/RawSession.cpp index 455d33140dd..e734aebf47f 100644 --- a/lib/DebugInfo/PDB/Raw/RawSession.cpp +++ b/lib/DebugInfo/PDB/Raw/RawSession.cpp @@ -9,8 +9,8 @@ #include "llvm/DebugInfo/PDB/Raw/RawSession.h" -#include "llvm/DebugInfo/CodeView/ByteStream.h" -#include "llvm/DebugInfo/CodeView/StreamInterface.h" +#include "llvm/DebugInfo/Msf/ByteStream.h" +#include "llvm/DebugInfo/Msf/StreamInterface.h" #include "llvm/DebugInfo/PDB/GenericError.h" #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" #include "llvm/DebugInfo/PDB/IPDBSourceFile.h" @@ -23,13 +23,14 @@ #include "llvm/Support/MemoryBuffer.h" using namespace llvm; +using namespace llvm::msf; using namespace llvm::pdb; namespace { // We need a class which behaves like an immutable ByteStream, but whose data // is backed by an llvm::MemoryBuffer. It also needs to own the underlying // MemoryBuffer, so this simple adapter is a good way to achieve that. -class InputByteStream : public codeview::ByteStream { +class InputByteStream : public ByteStream { public: explicit InputByteStream(std::unique_ptr Buffer) : ByteStream(ArrayRef(Buffer->getBuffer().bytes_begin(), diff --git a/lib/DebugInfo/PDB/Raw/SymbolStream.cpp b/lib/DebugInfo/PDB/Raw/SymbolStream.cpp index 41b2a64bfb1..f98b5d4688b 100644 --- a/lib/DebugInfo/PDB/Raw/SymbolStream.cpp +++ b/lib/DebugInfo/PDB/Raw/SymbolStream.cpp @@ -10,10 +10,10 @@ #include "llvm/DebugInfo/PDB/Raw/SymbolStream.h" #include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/StreamReader.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" -#include "llvm/DebugInfo/PDB/Raw/IndexedStreamData.h" -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h" +#include "llvm/DebugInfo/Msf/IndexedStreamData.h" +#include "llvm/DebugInfo/Msf/MappedBlockStream.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" #include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/DebugInfo/PDB/Raw/RawConstants.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h" @@ -21,6 +21,7 @@ #include "llvm/Support/Endian.h" using namespace llvm; +using namespace llvm::msf; using namespace llvm::support; using namespace llvm::pdb; @@ -30,7 +31,7 @@ SymbolStream::SymbolStream(std::unique_ptr Stream) SymbolStream::~SymbolStream() {} Error SymbolStream::reload() { - codeview::StreamReader Reader(*Stream); + StreamReader Reader(*Stream); if (auto EC = Reader.readArray(SymbolRecords, Stream->getLength())) return EC; diff --git a/lib/DebugInfo/PDB/Raw/TpiStream.cpp b/lib/DebugInfo/PDB/Raw/TpiStream.cpp index 5617e57ccf6..f642940bbc9 100644 --- a/lib/DebugInfo/PDB/Raw/TpiStream.cpp +++ b/lib/DebugInfo/PDB/Raw/TpiStream.cpp @@ -11,12 +11,12 @@ #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h" #include "llvm/DebugInfo/CodeView/CodeView.h" -#include "llvm/DebugInfo/CodeView/StreamReader.h" #include "llvm/DebugInfo/CodeView/TypeIndex.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" +#include "llvm/DebugInfo/Msf/IndexedStreamData.h" +#include "llvm/DebugInfo/Msf/MappedBlockStream.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" #include "llvm/DebugInfo/PDB/Raw/Hash.h" -#include "llvm/DebugInfo/PDB/Raw/IndexedStreamData.h" -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h" #include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/DebugInfo/PDB/Raw/RawConstants.h" #include "llvm/DebugInfo/PDB/Raw/RawError.h" @@ -27,6 +27,7 @@ using namespace llvm; using namespace llvm::codeview; using namespace llvm::support; +using namespace llvm::msf; using namespace llvm::pdb; namespace { diff --git a/tools/llvm-pdbdump/CMakeLists.txt b/tools/llvm-pdbdump/CMakeLists.txt index f725edfaf3d..3a630ab55f8 100644 --- a/tools/llvm-pdbdump/CMakeLists.txt +++ b/tools/llvm-pdbdump/CMakeLists.txt @@ -1,5 +1,6 @@ set(LLVM_LINK_COMPONENTS DebugInfoCodeView + DebugInfoMsf DebugInfoPDB Object Support diff --git a/tools/llvm-pdbdump/LLVMBuild.txt b/tools/llvm-pdbdump/LLVMBuild.txt index 487768935dd..38f6e54fbcf 100644 --- a/tools/llvm-pdbdump/LLVMBuild.txt +++ b/tools/llvm-pdbdump/LLVMBuild.txt @@ -19,5 +19,5 @@ type = Tool name = llvm-pdbdump parent = Tools -required_libraries = DebugInfoPDB +required_libraries = DebugInfoMsf DebugInfoPDB diff --git a/tools/llvm-pdbdump/LLVMOutputStyle.cpp b/tools/llvm-pdbdump/LLVMOutputStyle.cpp index 6d94295d126..428df0630a0 100644 --- a/tools/llvm-pdbdump/LLVMOutputStyle.cpp +++ b/tools/llvm-pdbdump/LLVMOutputStyle.cpp @@ -13,11 +13,13 @@ #include "llvm/DebugInfo/CodeView/EnumTables.h" #include "llvm/DebugInfo/CodeView/ModuleSubstreamVisitor.h" #include "llvm/DebugInfo/CodeView/SymbolDumper.h" +#include "llvm/DebugInfo/Msf/IndexedStreamData.h" +#include "llvm/DebugInfo/Msf/MappedBlockStream.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" #include "llvm/DebugInfo/PDB/PDBExtras.h" #include "llvm/DebugInfo/PDB/Raw/DbiStream.h" #include "llvm/DebugInfo/PDB/Raw/EnumTables.h" #include "llvm/DebugInfo/PDB/Raw/ISectionContribVisitor.h" -#include "llvm/DebugInfo/PDB/Raw/IndexedStreamData.h" #include "llvm/DebugInfo/PDB/Raw/InfoStream.h" #include "llvm/DebugInfo/PDB/Raw/ModInfo.h" #include "llvm/DebugInfo/PDB/Raw/ModStream.h" @@ -31,6 +33,7 @@ using namespace llvm; using namespace llvm::codeview; +using namespace llvm::msf; using namespace llvm::pdb; static void printSectionOffset(llvm::raw_ostream &OS, @@ -260,7 +263,7 @@ Error LLVMOutputStyle::dumpStreamData() { auto S = MappedBlockStream::createIndexedStream(DumpStreamNum, File); if (!S) return S.takeError(); - codeview::StreamReader R(**S); + StreamReader R(**S); while (R.bytesRemaining() > 0) { ArrayRef Data; uint32_t BytesToReadInBlock = std::min( @@ -313,7 +316,7 @@ Error LLVMOutputStyle::dumpNamedStream() { MappedBlockStream::createIndexedStream(NameStreamIndex, File); if (!NameStream) return NameStream.takeError(); - codeview::StreamReader Reader(**NameStream); + StreamReader Reader(**NameStream); NameHashTable NameTable; if (auto EC = NameTable.load(Reader)) diff --git a/tools/llvm-pdbdump/PdbYaml.cpp b/tools/llvm-pdbdump/PdbYaml.cpp index 9674ded4927..efbfa2ea93a 100644 --- a/tools/llvm-pdbdump/PdbYaml.cpp +++ b/tools/llvm-pdbdump/PdbYaml.cpp @@ -13,6 +13,7 @@ #include "llvm/DebugInfo/PDB/Raw/PDBFile.h" using namespace llvm; +using namespace llvm::msf; using namespace llvm::yaml; using namespace llvm::pdb; using namespace llvm::pdb::yaml; diff --git a/tools/llvm-pdbdump/PdbYaml.h b/tools/llvm-pdbdump/PdbYaml.h index 4488d742410..a21236b3279 100644 --- a/tools/llvm-pdbdump/PdbYaml.h +++ b/tools/llvm-pdbdump/PdbYaml.h @@ -13,8 +13,8 @@ #include "OutputStyle.h" #include "llvm/ADT/Optional.h" +#include "llvm/DebugInfo/Msf/MsfCommon.h" #include "llvm/DebugInfo/PDB/PDBTypes.h" -#include "llvm/DebugInfo/PDB/Raw/MsfCommon.h" #include "llvm/DebugInfo/PDB/Raw/PDBFile.h" #include "llvm/DebugInfo/PDB/Raw/RawConstants.h" #include "llvm/Support/Endian.h" @@ -91,8 +91,8 @@ template <> struct MappingTraits { static void mapping(IO &IO, pdb::yaml::MsfHeaders &Obj); }; -template <> struct MappingTraits { - static void mapping(IO &IO, pdb::msf::SuperBlock &SB); +template <> struct MappingTraits { + static void mapping(IO &IO, msf::SuperBlock &SB); }; template <> struct MappingTraits { diff --git a/tools/llvm-pdbdump/llvm-pdbdump.cpp b/tools/llvm-pdbdump/llvm-pdbdump.cpp index 0600bcd952c..53e27d6cf13 100644 --- a/tools/llvm-pdbdump/llvm-pdbdump.cpp +++ b/tools/llvm-pdbdump/llvm-pdbdump.cpp @@ -29,7 +29,8 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Config/config.h" -#include "llvm/DebugInfo/CodeView/ByteStream.h" +#include "llvm/DebugInfo/Msf/ByteStream.h" +#include "llvm/DebugInfo/Msf/MsfBuilder.h" #include "llvm/DebugInfo/PDB/GenericError.h" #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" #include "llvm/DebugInfo/PDB/IPDBRawSymbol.h" @@ -65,6 +66,7 @@ using namespace llvm; using namespace llvm::codeview; +using namespace llvm::msf; using namespace llvm::pdb; namespace { diff --git a/tools/llvm-readobj/CMakeLists.txt b/tools/llvm-readobj/CMakeLists.txt index 7477f5b035d..24ac2d85c7a 100644 --- a/tools/llvm-readobj/CMakeLists.txt +++ b/tools/llvm-readobj/CMakeLists.txt @@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS Object Support DebugInfoCodeView + DebugInfoMsf ) add_llvm_tool(llvm-readobj diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp index 348f5b43556..b6f7d436168 100644 --- a/tools/llvm-readobj/COFFDumper.cpp +++ b/tools/llvm-readobj/COFFDumper.cpp @@ -22,7 +22,6 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" -#include "llvm/DebugInfo/CodeView/ByteStream.h" #include "llvm/DebugInfo/CodeView/CodeView.h" #include "llvm/DebugInfo/CodeView/Line.h" #include "llvm/DebugInfo/CodeView/MemoryTypeTableBuilder.h" @@ -34,6 +33,7 @@ #include "llvm/DebugInfo/CodeView/TypeIndex.h" #include "llvm/DebugInfo/CodeView/TypeRecord.h" #include "llvm/DebugInfo/CodeView/TypeStreamMerger.h" +#include "llvm/DebugInfo/Msf/ByteStream.h" #include "llvm/Object/COFF.h" #include "llvm/Object/ObjectFile.h" #include "llvm/Support/COFF.h" @@ -53,6 +53,7 @@ using namespace llvm; using namespace llvm::object; using namespace llvm::codeview; +using namespace llvm::msf; using namespace llvm::support; using namespace llvm::Win64EH; diff --git a/tools/llvm-readobj/LLVMBuild.txt b/tools/llvm-readobj/LLVMBuild.txt index e75f1951201..c7219ac5f35 100644 --- a/tools/llvm-readobj/LLVMBuild.txt +++ b/tools/llvm-readobj/LLVMBuild.txt @@ -19,4 +19,4 @@ type = Tool name = llvm-readobj parent = Tools -required_libraries = all-targets BitReader Object +required_libraries = all-targets BitReader Object DebugInfoCodeView DebugInfoMsf diff --git a/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp b/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp index 6f9e86c4f26..0762ef89fb1 100644 --- a/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp +++ b/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp @@ -9,28 +9,27 @@ #include "ErrorChecking.h" -#include "llvm/DebugInfo/CodeView/ByteStream.h" -#include "llvm/DebugInfo/CodeView/StreamReader.h" -#include "llvm/DebugInfo/CodeView/StreamRef.h" -#include "llvm/DebugInfo/CodeView/StreamWriter.h" -#include "llvm/DebugInfo/PDB/Raw/IPDBFile.h" -#include "llvm/DebugInfo/PDB/Raw/IPDBStreamData.h" -#include "llvm/DebugInfo/PDB/Raw/IndexedStreamData.h" -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h" +#include "llvm/DebugInfo/Msf/ByteStream.h" +#include "llvm/DebugInfo/Msf/IMsfFile.h" +#include "llvm/DebugInfo/Msf/IMsfStreamData.h" +#include "llvm/DebugInfo/Msf/IndexedStreamData.h" +#include "llvm/DebugInfo/Msf/MappedBlockStream.h" +#include "llvm/DebugInfo/Msf/StreamReader.h" +#include "llvm/DebugInfo/Msf/StreamRef.h" +#include "llvm/DebugInfo/Msf/StreamWriter.h" #include "gtest/gtest.h" #include using namespace llvm; -using namespace llvm::codeview; -using namespace llvm::pdb; +using namespace llvm::msf; namespace { static const uint32_t BlocksAry[] = {0, 1, 2, 5, 4, 3, 6, 7, 8, 9}; static uint8_t DataAry[] = {'A', 'B', 'C', 'F', 'E', 'D', 'G', 'H', 'I', 'J'}; -class DiscontiguousFile : public IPDBFile { +class DiscontiguousFile : public IMsfFile { public: DiscontiguousFile(ArrayRef Blocks, MutableArrayRef Data) : Blocks(Blocks.begin(), Blocks.end()), Data(Data.begin(), Data.end()) {} @@ -55,9 +54,9 @@ public: Error setBlockData(uint32_t BlockIndex, uint32_t Offset, ArrayRef SrcData) const override { if (BlockIndex >= Blocks.size()) - return make_error(cv_error_code::insufficient_buffer); + return make_error(msf_error_code::insufficient_buffer); if (Offset > getBlockSize() - SrcData.size()) - return make_error(cv_error_code::insufficient_buffer); + return make_error(msf_error_code::insufficient_buffer); ::memcpy(&Data[BlockIndex] + Offset, SrcData.data(), SrcData.size()); return Error::success(); } @@ -69,8 +68,8 @@ private: class MappedBlockStreamImpl : public MappedBlockStream { public: - MappedBlockStreamImpl(std::unique_ptr Data, - const IPDBFile &File) + MappedBlockStreamImpl(std::unique_ptr Data, + const IMsfFile &File) : MappedBlockStream(std::move(Data), File) {} }; diff --git a/unittests/DebugInfo/PDB/MsfBuilderTest.cpp b/unittests/DebugInfo/PDB/MsfBuilderTest.cpp index ac292a73a8f..bb337118de2 100644 --- a/unittests/DebugInfo/PDB/MsfBuilderTest.cpp +++ b/unittests/DebugInfo/PDB/MsfBuilderTest.cpp @@ -9,14 +9,13 @@ #include "ErrorChecking.h" -#include "llvm/DebugInfo/PDB/Raw/MsfBuilder.h" -#include "llvm/DebugInfo/PDB/Raw/MsfCommon.h" +#include "llvm/DebugInfo/Msf/MsfBuilder.h" +#include "llvm/DebugInfo/Msf/MsfCommon.h" #include "gtest/gtest.h" using namespace llvm; -using namespace llvm::pdb; -using namespace llvm::pdb::msf; +using namespace llvm::msf; namespace { class MsfBuilderTest : public testing::Test {