[llvm] r276458 - [msf] Create LLVMDebugInfoMsf
Adrian Prantl via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 25 08:13:51 PDT 2016
Hello Zachary,
it looks like this commit might have broken the -DLLVM_ENABLE_MODULES=1 build.
It is probably just a matter of adding a missing #include:
http://lab.llvm.org:8080/green/view/Experimental/job/clang-stage1-cmake-modulesRDA_build/5567/consoleFull#1761697649ba4694-19c4-4d7e-bec5-911270d8a58c
Would you mind taking a quick look?
thanks,
Adrian
> On Jul 22, 2016, at 12:56 PM, Zachary Turner via llvm-commits <llvm-commits at lists.llvm.org> wrote:
>
> Author: zturner
> Date: Fri Jul 22 14:56:05 2016
> New Revision: 276458
>
> URL: http://llvm.org/viewvc/llvm-project?rev=276458&view=rev
> Log:
> [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.
>
> Added:
> llvm/trunk/include/llvm/DebugInfo/Msf/
> llvm/trunk/include/llvm/DebugInfo/Msf/ByteStream.h
> - copied, changed from r276457, llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h
> llvm/trunk/include/llvm/DebugInfo/Msf/DirectoryStreamData.h
> - copied, changed from r276457, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DirectoryStreamData.h
> llvm/trunk/include/llvm/DebugInfo/Msf/IMsfFile.h
> - copied, changed from r276457, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h
> llvm/trunk/include/llvm/DebugInfo/Msf/IMsfStreamData.h
> - copied, changed from r276457, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBStreamData.h
> llvm/trunk/include/llvm/DebugInfo/Msf/IndexedStreamData.h
> - copied, changed from r276457, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IndexedStreamData.h
> llvm/trunk/include/llvm/DebugInfo/Msf/MappedBlockStream.h
> - copied, changed from r276457, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h
> llvm/trunk/include/llvm/DebugInfo/Msf/MsfBuilder.h
> - copied, changed from r276457, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MsfBuilder.h
> llvm/trunk/include/llvm/DebugInfo/Msf/MsfCommon.h
> - copied, changed from r276457, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MsfCommon.h
> llvm/trunk/include/llvm/DebugInfo/Msf/MsfError.h
> llvm/trunk/include/llvm/DebugInfo/Msf/StreamArray.h
> - copied, changed from r276457, llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h
> llvm/trunk/include/llvm/DebugInfo/Msf/StreamInterface.h
> - copied, changed from r276457, llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h
> llvm/trunk/include/llvm/DebugInfo/Msf/StreamReader.h
> - copied, changed from r276457, llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h
> llvm/trunk/include/llvm/DebugInfo/Msf/StreamRef.h
> - copied, changed from r276457, llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h
> llvm/trunk/include/llvm/DebugInfo/Msf/StreamWriter.h
> - copied, changed from r276457, llvm/trunk/include/llvm/DebugInfo/CodeView/StreamWriter.h
> llvm/trunk/lib/DebugInfo/Msf/
> llvm/trunk/lib/DebugInfo/Msf/ByteStream.cpp
> - copied, changed from r276457, llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp
> llvm/trunk/lib/DebugInfo/Msf/CMakeLists.txt
> llvm/trunk/lib/DebugInfo/Msf/IndexedStreamData.cpp
> - copied, changed from r276457, llvm/trunk/lib/DebugInfo/PDB/Raw/IndexedStreamData.cpp
> llvm/trunk/lib/DebugInfo/Msf/LLVMBuild.txt
> - copied, changed from r276457, llvm/trunk/lib/DebugInfo/CodeView/LLVMBuild.txt
> llvm/trunk/lib/DebugInfo/Msf/MappedBlockStream.cpp
> - copied, changed from r276457, llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp
> llvm/trunk/lib/DebugInfo/Msf/MsfBuilder.cpp
> - copied, changed from r276457, llvm/trunk/lib/DebugInfo/PDB/Raw/MsfBuilder.cpp
> llvm/trunk/lib/DebugInfo/Msf/MsfCommon.cpp
> - copied, changed from r276457, llvm/trunk/lib/DebugInfo/PDB/Raw/MsfCommon.cpp
> llvm/trunk/lib/DebugInfo/Msf/MsfError.cpp
> llvm/trunk/lib/DebugInfo/Msf/StreamReader.cpp
> - copied, changed from r276457, llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp
> llvm/trunk/lib/DebugInfo/Msf/StreamWriter.cpp
> - copied, changed from r276457, llvm/trunk/lib/DebugInfo/CodeView/StreamWriter.cpp
> Removed:
> llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h
> llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewOStream.h
> llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h
> llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h
> llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h
> llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h
> llvm/trunk/include/llvm/DebugInfo/CodeView/StreamWriter.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DirectoryStreamData.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBStreamData.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IndexedStreamData.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MsfBuilder.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MsfCommon.h
> llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp
> llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp
> llvm/trunk/lib/DebugInfo/CodeView/StreamWriter.cpp
> llvm/trunk/lib/DebugInfo/PDB/Raw/IndexedStreamData.cpp
> llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp
> llvm/trunk/lib/DebugInfo/PDB/Raw/MsfBuilder.cpp
> llvm/trunk/lib/DebugInfo/PDB/Raw/MsfCommon.cpp
> Modified:
> llvm/trunk/include/llvm/DebugInfo/CodeView/CVRecord.h
> llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleSubstream.h
> llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleSubstreamVisitor.h
> llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h
> llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DbiStream.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/InfoStream.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModInfo.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameHashTable.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameMap.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFile.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h
> llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h
> llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
> llvm/trunk/lib/CodeGen/AsmPrinter/LLVMBuild.txt
> llvm/trunk/lib/DebugInfo/CMakeLists.txt
> llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt
> llvm/trunk/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
> llvm/trunk/lib/DebugInfo/CodeView/LLVMBuild.txt
> llvm/trunk/lib/DebugInfo/CodeView/ModuleSubstream.cpp
> llvm/trunk/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp
> llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp
> llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
> llvm/trunk/lib/DebugInfo/LLVMBuild.txt
> llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt
> llvm/trunk/lib/DebugInfo/PDB/LLVMBuild.txt
> llvm/trunk/lib/DebugInfo/PDB/Raw/DbiStream.cpp
> llvm/trunk/lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp
> llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStream.cpp
> llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp
> llvm/trunk/lib/DebugInfo/PDB/Raw/ModInfo.cpp
> llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp
> llvm/trunk/lib/DebugInfo/PDB/Raw/NameHashTable.cpp
> llvm/trunk/lib/DebugInfo/PDB/Raw/NameMap.cpp
> llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp
> llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
> llvm/trunk/lib/DebugInfo/PDB/Raw/PublicsStream.cpp
> llvm/trunk/lib/DebugInfo/PDB/Raw/RawSession.cpp
> llvm/trunk/lib/DebugInfo/PDB/Raw/SymbolStream.cpp
> llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp
> llvm/trunk/tools/llvm-pdbdump/CMakeLists.txt
> llvm/trunk/tools/llvm-pdbdump/LLVMBuild.txt
> llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp
> llvm/trunk/tools/llvm-pdbdump/PdbYaml.cpp
> llvm/trunk/tools/llvm-pdbdump/PdbYaml.h
> llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
> llvm/trunk/tools/llvm-readobj/CMakeLists.txt
> llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
> llvm/trunk/tools/llvm-readobj/LLVMBuild.txt
> llvm/trunk/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp
> llvm/trunk/unittests/DebugInfo/PDB/MsfBuilderTest.cpp
>
> Removed: llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h (removed)
> @@ -1,58 +0,0 @@
> -//===- ByteStream.h - Reads stream data from a byte sequence ----*- 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_BYTESTREAM_H
> -#define LLVM_DEBUGINFO_CODEVIEW_BYTESTREAM_H
> -
> -#include "llvm/ADT/ArrayRef.h"
> -#include "llvm/ADT/StringRef.h"
> -#include "llvm/DebugInfo/CodeView/StreamInterface.h"
> -#include "llvm/Support/Error.h"
> -#include <cstdint>
> -#include <memory>
> -#include <type_traits>
> -
> -namespace llvm {
> -namespace codeview {
> -class StreamReader;
> -
> -template <bool Writable = false> class ByteStream : public StreamInterface {
> - typedef typename std::conditional<Writable, MutableArrayRef<uint8_t>,
> - ArrayRef<uint8_t>>::type ArrayType;
> -
> -public:
> - ByteStream() {}
> - explicit ByteStream(ArrayType Data) : Data(Data) {}
> - ~ByteStream() override {}
> -
> - Error readBytes(uint32_t Offset, uint32_t Size,
> - ArrayRef<uint8_t> &Buffer) const override;
> - Error readLongestContiguousChunk(uint32_t Offset,
> - ArrayRef<uint8_t> &Buffer) const override;
> -
> - Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Buffer) const override;
> -
> - uint32_t getLength() const override;
> -
> - Error commit() const override;
> -
> - ArrayRef<uint8_t> data() const { return Data; }
> - StringRef str() const;
> -
> -private:
> - ArrayType Data;
> -};
> -
> -extern template class ByteStream<true>;
> -extern template class ByteStream<false>;
> -
> -} // end namespace pdb
> -} // end namespace llvm
> -
> -#endif // LLVM_DEBUGINFO_CODEVIEW_BYTESTREAM_H
>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/CVRecord.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CVRecord.h?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/CVRecord.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/CVRecord.h Fri Jul 22 14:56:05 2016
> @@ -12,9 +12,10 @@
>
> #include "llvm/ADT/ArrayRef.h"
> #include "llvm/ADT/iterator_range.h"
> +#include "llvm/DebugInfo/CodeView/CodeViewError.h"
> #include "llvm/DebugInfo/CodeView/RecordSerialization.h"
> -#include "llvm/DebugInfo/CodeView/StreamInterface.h"
> -#include "llvm/DebugInfo/CodeView/StreamReader.h"
> +#include "llvm/DebugInfo/Msf/StreamReader.h"
> +#include "llvm/DebugInfo/Msf/StreamRef.h"
> #include "llvm/Support/Endian.h"
>
> namespace llvm {
> @@ -26,10 +27,14 @@ template <typename Kind> struct CVRecord
> ArrayRef<uint8_t> Data;
> ArrayRef<uint8_t> RawData;
> };
> +}
> +namespace msf {
>
> -template <typename Kind> struct VarStreamArrayExtractor<CVRecord<Kind>> {
> +template <typename Kind>
> +struct VarStreamArrayExtractor<codeview::CVRecord<Kind>> {
> Error operator()(StreamRef Stream, uint32_t &Len,
> - CVRecord<Kind> &Item) const {
> + codeview::CVRecord<Kind> &Item) const {
> + using namespace codeview;
> const RecordPrefix *Prefix = nullptr;
> StreamReader Reader(Stream);
> uint32_t Offset = Reader.getOffset();
>
> Removed: llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewOStream.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewOStream.h?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewOStream.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/CodeViewOStream.h (removed)
> @@ -1,39 +0,0 @@
> -//===- CodeViewOStream.h ----------------------------------------*- C++ -*-===//
> -//
> -// The LLVM Compiler Infrastructure
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
> -//===----------------------------------------------------------------------===//
> -
> -#ifndef LLVM_DEBUGINFO_CODEVIEW_CODEVIEWOSTREAM_H
> -#define LLVM_DEBUGINFO_CODEVIEW_CODEVIEWOSTREAM_H
> -
> -#include "llvm/DebugInfo/CodeView/CodeView.h"
> -#include "llvm/DebugInfo/CodeView/TypeIndex.h"
> -
> -namespace llvm {
> -namespace codeview {
> -
> -template <typename Writer> class CodeViewOStream {
> -private:
> - CodeViewOStream(const CodeViewOStream &) = delete;
> - CodeViewOStream &operator=(const CodeViewOStream &) = delete;
> -
> -public:
> - typedef typename Writer::LabelType LabelType;
> -
> -public:
> - explicit CodeViewOStream(Writer &W);
> -
> -private:
> - uint64_t size() const { return W.tell(); }
> -
> -private:
> - Writer &W;
> -};
> -}
> -}
> -
> -#endif
>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleSubstream.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleSubstream.h?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleSubstream.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleSubstream.h Fri Jul 22 14:56:05 2016
> @@ -11,8 +11,8 @@
> #define LLVM_DEBUGINFO_CODEVIEW_MODULESUBSTREAM_H
>
> #include "llvm/DebugInfo/CodeView/CodeView.h"
> -#include "llvm/DebugInfo/CodeView/StreamArray.h"
> -#include "llvm/DebugInfo/CodeView/StreamRef.h"
> +#include "llvm/DebugInfo/Msf/StreamArray.h"
> +#include "llvm/DebugInfo/Msf/StreamRef.h"
> #include "llvm/Support/Endian.h"
> #include "llvm/Support/Error.h"
>
> @@ -59,29 +59,31 @@ struct ColumnNumberEntry {
> class ModuleSubstream {
> public:
> ModuleSubstream();
> - ModuleSubstream(ModuleSubstreamKind Kind, StreamRef Data);
> - static Error initialize(StreamRef Stream, ModuleSubstream &Info);
> + ModuleSubstream(ModuleSubstreamKind Kind, msf::StreamRef Data);
> + static Error initialize(msf::StreamRef Stream, ModuleSubstream &Info);
> uint32_t getRecordLength() const;
> ModuleSubstreamKind getSubstreamKind() const;
> - StreamRef getRecordData() const;
> + msf::StreamRef getRecordData() const;
>
> private:
> ModuleSubstreamKind Kind;
> - StreamRef Data;
> + msf::StreamRef Data;
> };
>
> -template <> struct VarStreamArrayExtractor<ModuleSubstream> {
> +typedef msf::VarStreamArray<ModuleSubstream> ModuleSubstreamArray;
> +} // namespace codeview
> +
> +namespace msf {
> +template <> struct VarStreamArrayExtractor<codeview::ModuleSubstream> {
> Error operator()(StreamRef Stream, uint32_t &Length,
> - ModuleSubstream &Info) const {
> - if (auto EC = ModuleSubstream::initialize(Stream, Info))
> + codeview::ModuleSubstream &Info) const {
> + if (auto EC = codeview::ModuleSubstream::initialize(Stream, Info))
> return EC;
> Length = Info.getRecordLength();
> return Error::success();
> }
> };
> -
> -typedef VarStreamArray<ModuleSubstream> ModuleSubstreamArray;
> -}
> -}
> +} // namespace msf
> +} // namespace llvm
>
> #endif // LLVM_DEBUGINFO_CODEVIEW_MODULESUBSTREAM_H
>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleSubstreamVisitor.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleSubstreamVisitor.h?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleSubstreamVisitor.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/ModuleSubstreamVisitor.h Fri Jul 22 14:56:05 2016
> @@ -14,24 +14,62 @@
> #include "llvm/DebugInfo/CodeView/CodeViewError.h"
> #include "llvm/DebugInfo/CodeView/Line.h"
> #include "llvm/DebugInfo/CodeView/ModuleSubstream.h"
> -#include "llvm/DebugInfo/CodeView/StreamReader.h"
> -#include "llvm/DebugInfo/CodeView/StreamRef.h"
> +#include "llvm/DebugInfo/Msf/StreamReader.h"
> +#include "llvm/DebugInfo/Msf/StreamRef.h"
>
> namespace llvm {
> namespace codeview {
> -
> struct LineColumnEntry {
> support::ulittle32_t NameIndex;
> - FixedStreamArray<LineNumberEntry> LineNumbers;
> - FixedStreamArray<ColumnNumberEntry> Columns;
> + msf::FixedStreamArray<LineNumberEntry> LineNumbers;
> + msf::FixedStreamArray<ColumnNumberEntry> Columns;
> +};
> +
> +struct FileChecksumEntry {
> + uint32_t FileNameOffset; // Byte offset of filename in global stringtable.
> + FileChecksumKind Kind; // The type of checksum.
> + ArrayRef<uint8_t> Checksum; // The bytes of the checksum.
> +};
> +
> +typedef msf::VarStreamArray<LineColumnEntry> LineInfoArray;
> +typedef msf::VarStreamArray<FileChecksumEntry> FileChecksumArray;
> +
> +class IModuleSubstreamVisitor {
> +public:
> + virtual ~IModuleSubstreamVisitor() {}
> +
> + virtual Error visitUnknown(ModuleSubstreamKind Kind, msf::StreamRef Data) = 0;
> + virtual Error visitSymbols(msf::StreamRef Data);
> + virtual Error visitLines(msf::StreamRef Data,
> + const LineSubstreamHeader *Header,
> + const LineInfoArray &Lines);
> + virtual Error visitStringTable(msf::StreamRef Data);
> + virtual Error visitFileChecksums(msf::StreamRef Data,
> + const FileChecksumArray &Checksums);
> + virtual Error visitFrameData(msf::StreamRef Data);
> + virtual Error visitInlineeLines(msf::StreamRef Data);
> + virtual Error visitCrossScopeImports(msf::StreamRef Data);
> + virtual Error visitCrossScopeExports(msf::StreamRef Data);
> + virtual Error visitILLines(msf::StreamRef Data);
> + virtual Error visitFuncMDTokenMap(msf::StreamRef Data);
> + virtual Error visitTypeMDTokenMap(msf::StreamRef Data);
> + virtual Error visitMergedAssemblyInput(msf::StreamRef Data);
> + virtual Error visitCoffSymbolRVA(msf::StreamRef Data);
> };
>
> -template <> class VarStreamArrayExtractor<LineColumnEntry> {
> +Error visitModuleSubstream(const ModuleSubstream &R,
> + IModuleSubstreamVisitor &V);
> +} // namespace codeview
> +
> +namespace msf {
> +template <> class VarStreamArrayExtractor<codeview::LineColumnEntry> {
> public:
> - VarStreamArrayExtractor(const LineSubstreamHeader *Header) : Header(Header) {}
> + VarStreamArrayExtractor(const codeview::LineSubstreamHeader *Header)
> + : Header(Header) {}
>
> Error operator()(StreamRef Stream, uint32_t &Len,
> - LineColumnEntry &Item) const {
> + codeview::LineColumnEntry &Item) const {
> + using namespace codeview;
> const LineFileBlockHeader *BlockHeader;
> StreamReader Reader(Stream);
> if (auto EC = Reader.readObject(BlockHeader))
> @@ -61,19 +99,14 @@ public:
> }
>
> private:
> - const LineSubstreamHeader *Header;
> + const codeview::LineSubstreamHeader *Header;
> };
>
> -struct FileChecksumEntry {
> - uint32_t FileNameOffset; // Byte offset of filename in global stringtable.
> - FileChecksumKind Kind; // The type of checksum.
> - ArrayRef<uint8_t> Checksum; // The bytes of the checksum.
> -};
> -
> -template <> class VarStreamArrayExtractor<FileChecksumEntry> {
> +template <> class VarStreamArrayExtractor<codeview::FileChecksumEntry> {
> public:
> Error operator()(StreamRef Stream, uint32_t &Len,
> - FileChecksumEntry &Item) const {
> + codeview::FileChecksumEntry &Item) const {
> + using namespace codeview;
> const FileChecksum *Header;
> StreamReader Reader(Stream);
> if (auto EC = Reader.readObject(Header))
> @@ -87,35 +120,7 @@ public:
> }
> };
>
> -typedef VarStreamArray<LineColumnEntry> LineInfoArray;
> -typedef VarStreamArray<FileChecksumEntry> FileChecksumArray;
> -
> -class IModuleSubstreamVisitor {
> -public:
> - virtual ~IModuleSubstreamVisitor() {}
> -
> - virtual Error visitUnknown(ModuleSubstreamKind Kind, StreamRef Data) = 0;
> - virtual Error visitSymbols(StreamRef Data);
> - virtual Error visitLines(StreamRef Data, const LineSubstreamHeader *Header,
> - const LineInfoArray &Lines);
> - virtual Error visitStringTable(StreamRef Data);
> - virtual Error visitFileChecksums(StreamRef Data,
> - const FileChecksumArray &Checksums);
> - virtual Error visitFrameData(StreamRef Data);
> - virtual Error visitInlineeLines(StreamRef Data);
> - virtual Error visitCrossScopeImports(StreamRef Data);
> - virtual Error visitCrossScopeExports(StreamRef Data);
> - virtual Error visitILLines(StreamRef Data);
> - virtual Error visitFuncMDTokenMap(StreamRef Data);
> - virtual Error visitTypeMDTokenMap(StreamRef Data);
> - virtual Error visitMergedAssemblyInput(StreamRef Data);
> - virtual Error visitCoffSymbolRVA(StreamRef Data);
> -};
> -
> -Error visitModuleSubstream(const ModuleSubstream &R,
> - IModuleSubstreamVisitor &V);
> -
> -} // namespace codeview
> +} // namespace msf
> } // namespace llvm
>
> #endif // LLVM_DEBUGINFO_CODEVIEW_MODULESUBSTREAMVISITOR_H
>
> Removed: llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h (removed)
> @@ -1,275 +0,0 @@
> -//===- StreamArray.h - Array backed by an arbitrary stream ----------------===//
> -//
> -// 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_STREAMARRAY_H
> -#define LLVM_DEBUGINFO_CODEVIEW_STREAMARRAY_H
> -
> -#include "llvm/DebugInfo/CodeView/StreamRef.h"
> -#include "llvm/Support/Error.h"
> -
> -#include <functional>
> -#include <type_traits>
> -
> -namespace llvm {
> -namespace codeview {
> -
> -/// VarStreamArrayExtractor is intended to be specialized to provide customized
> -/// extraction logic. On input it receives a StreamRef pointing to the
> -/// beginning of the next record, but where the length of the record is not yet
> -/// known. Upon completion, it should return an appropriate Error instance if
> -/// a record could not be extracted, or if one could be extracted it should
> -/// return success and set Len to the number of bytes this record occupied in
> -/// the underlying stream, and it should fill out the fields of the value type
> -/// Item appropriately to represent the current record.
> -///
> -/// You can specialize this template for your own custom value types to avoid
> -/// having to specify a second template argument to VarStreamArray (documented
> -/// below).
> -template <typename T> struct VarStreamArrayExtractor {
> - // Method intentionally deleted. You must provide an explicit specialization
> - // with the following method implemented.
> - Error operator()(StreamRef Stream, uint32_t &Len, T &Item) const = delete;
> -};
> -
> -/// VarStreamArray represents an array of variable length records backed by a
> -/// stream. This could be a contiguous sequence of bytes in memory, it could
> -/// be a file on disk, or it could be a PDB stream where bytes are stored as
> -/// discontiguous blocks in a file. Usually it is desirable to treat arrays
> -/// as contiguous blocks of memory, but doing so with large PDB files, for
> -/// example, could mean allocating huge amounts of memory just to allow
> -/// re-ordering of stream data to be contiguous before iterating over it. By
> -/// abstracting this out, we need not duplicate this memory, and we can
> -/// iterate over arrays in arbitrarily formatted streams. Elements are parsed
> -/// lazily on iteration, so there is no upfront cost associated with building
> -/// a VarStreamArray, no matter how large it may be.
> -///
> -/// You create a VarStreamArray by specifying a ValueType and an Extractor type.
> -/// If you do not specify an Extractor type, it expects you to specialize
> -/// VarStreamArrayExtractor<T> for your ValueType.
> -///
> -/// By default an Extractor is default constructed in the class, but in some
> -/// cases you might find it useful for an Extractor to maintain state across
> -/// extractions. In this case you can provide your own Extractor through a
> -/// secondary constructor. The following examples show various ways of
> -/// creating a VarStreamArray.
> -///
> -/// // Will use VarStreamArrayExtractor<MyType> as the extractor.
> -/// VarStreamArray<MyType> MyTypeArray;
> -///
> -/// // Will use a default-constructed MyExtractor as the extractor.
> -/// VarStreamArray<MyType, MyExtractor> MyTypeArray2;
> -///
> -/// // Will use the specific instance of MyExtractor provided.
> -/// // MyExtractor need not be default-constructible in this case.
> -/// MyExtractor E(SomeContext);
> -/// VarStreamArray<MyType, MyExtractor> MyTypeArray3(E);
> -///
> -template <typename ValueType, typename Extractor> class VarStreamArrayIterator;
> -
> -template <typename ValueType,
> - typename Extractor = VarStreamArrayExtractor<ValueType>>
> -class VarStreamArray {
> - friend class VarStreamArrayIterator<ValueType, Extractor>;
> -
> -public:
> - typedef VarStreamArrayIterator<ValueType, Extractor> Iterator;
> -
> - VarStreamArray() {}
> - explicit VarStreamArray(const Extractor &E) : E(E) {}
> -
> - explicit VarStreamArray(StreamRef Stream) : Stream(Stream) {}
> - VarStreamArray(StreamRef Stream, const Extractor &E) : Stream(Stream), E(E) {}
> -
> - VarStreamArray(const VarStreamArray<ValueType, Extractor> &Other)
> - : Stream(Other.Stream), E(Other.E) {}
> -
> - Iterator begin(bool *HadError = nullptr) const {
> - return Iterator(*this, E, HadError);
> - }
> -
> - Iterator end() const { return Iterator(E); }
> -
> - const Extractor &getExtractor() const { return E; }
> -
> - StreamRef getUnderlyingStream() const { return Stream; }
> -
> -private:
> - StreamRef Stream;
> - Extractor E;
> -};
> -
> -template <typename ValueType, typename Extractor> class VarStreamArrayIterator {
> - typedef VarStreamArrayIterator<ValueType, Extractor> IterType;
> - typedef VarStreamArray<ValueType, Extractor> ArrayType;
> -
> -public:
> - VarStreamArrayIterator(const ArrayType &Array, const Extractor &E,
> - bool *HadError = nullptr)
> - : IterRef(Array.Stream), Array(&Array), HadError(HadError), Extract(E) {
> - if (IterRef.getLength() == 0)
> - moveToEnd();
> - else {
> - auto EC = Extract(IterRef, ThisLen, ThisValue);
> - if (EC) {
> - consumeError(std::move(EC));
> - markError();
> - }
> - }
> - }
> - VarStreamArrayIterator() {}
> - explicit VarStreamArrayIterator(const Extractor &E) : Extract(E) {}
> - ~VarStreamArrayIterator() {}
> -
> - bool operator==(const IterType &R) const {
> - if (Array && R.Array) {
> - // Both have a valid array, make sure they're same.
> - assert(Array == R.Array);
> - return IterRef == R.IterRef;
> - }
> -
> - // Both iterators are at the end.
> - if (!Array && !R.Array)
> - return true;
> -
> - // One is not at the end and one is.
> - return false;
> - }
> -
> - bool operator!=(const IterType &R) { return !(*this == R); }
> -
> - const ValueType &operator*() const {
> - assert(Array && !HasError);
> - return ThisValue;
> - }
> -
> - IterType &operator++() {
> - // We are done with the current record, discard it so that we are
> - // positioned at the next record.
> - IterRef = IterRef.drop_front(ThisLen);
> - if (IterRef.getLength() == 0) {
> - // There is nothing after the current record, we must make this an end
> - // iterator.
> - moveToEnd();
> - } else {
> - // There is some data after the current record.
> - auto EC = Extract(IterRef, ThisLen, ThisValue);
> - if (EC) {
> - consumeError(std::move(EC));
> - markError();
> - } else if (ThisLen == 0) {
> - // An empty record? Make this an end iterator.
> - moveToEnd();
> - }
> - }
> - return *this;
> - }
> -
> - IterType operator++(int) {
> - IterType Original = *this;
> - ++*this;
> - return Original;
> - }
> -
> -private:
> - void moveToEnd() {
> - Array = nullptr;
> - ThisLen = 0;
> - }
> - void markError() {
> - moveToEnd();
> - HasError = true;
> - if (HadError != nullptr)
> - *HadError = true;
> - }
> -
> - ValueType ThisValue;
> - StreamRef IterRef;
> - const ArrayType *Array{nullptr};
> - uint32_t ThisLen{0};
> - bool HasError{false};
> - bool *HadError{nullptr};
> - Extractor Extract;
> -};
> -
> -template <typename T> class FixedStreamArrayIterator;
> -
> -template <typename T> class FixedStreamArray {
> - friend class FixedStreamArrayIterator<T>;
> -
> -public:
> - FixedStreamArray() : Stream() {}
> - FixedStreamArray(StreamRef Stream) : Stream(Stream) {
> - assert(Stream.getLength() % sizeof(T) == 0);
> - }
> -
> - const T &operator[](uint32_t Index) const {
> - assert(Index < size());
> - uint32_t Off = Index * sizeof(T);
> - ArrayRef<uint8_t> Data;
> - if (auto EC = Stream.readBytes(Off, sizeof(T), Data)) {
> - assert(false && "Unexpected failure reading from stream");
> - // This should never happen since we asserted that the stream length was
> - // an exact multiple of the element size.
> - consumeError(std::move(EC));
> - }
> - return *reinterpret_cast<const T *>(Data.data());
> - }
> -
> - uint32_t size() const { return Stream.getLength() / sizeof(T); }
> -
> - FixedStreamArrayIterator<T> begin() const {
> - return FixedStreamArrayIterator<T>(*this, 0);
> - }
> - FixedStreamArrayIterator<T> end() const {
> - return FixedStreamArrayIterator<T>(*this, size());
> - }
> -
> - StreamRef getUnderlyingStream() const { return Stream; }
> -
> -private:
> - StreamRef Stream;
> -};
> -
> -template <typename T> class FixedStreamArrayIterator {
> -public:
> - FixedStreamArrayIterator(const FixedStreamArray<T> &Array, uint32_t Index)
> - : Array(Array), Index(Index) {}
> -
> - bool operator==(const FixedStreamArrayIterator<T> &R) {
> - assert(&Array == &R.Array);
> - return Index == R.Index;
> - }
> -
> - bool operator!=(const FixedStreamArrayIterator<T> &R) {
> - return !(*this == R);
> - }
> -
> - const T &operator*() const { return Array[Index]; }
> -
> - FixedStreamArrayIterator<T> &operator++() {
> - assert(Index < Array.size());
> - ++Index;
> - return *this;
> - }
> -
> - FixedStreamArrayIterator<T> operator++(int) {
> - FixedStreamArrayIterator<T> Original = *this;
> - ++*this;
> - return Original;
> - }
> -
> -private:
> - const FixedStreamArray<T> &Array;
> - uint32_t Index;
> -};
> -
> -} // namespace codeview
> -} // namespace llvm
> -
> -#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMARRAY_H
>
> Removed: llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h (removed)
> @@ -1,55 +0,0 @@
> -//===- StreamInterface.h - Base interface for a stream of data --*- 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_STREAMINTERFACE_H
> -#define LLVM_DEBUGINFO_CODEVIEW_STREAMINTERFACE_H
> -
> -#include "llvm/ADT/ArrayRef.h"
> -#include "llvm/Support/Error.h"
> -#include <cstdint>
> -
> -namespace llvm {
> -namespace codeview {
> -
> -/// StreamInterface abstracts the notion of a data stream. This way, an
> -/// implementation could implement trivial reading from a contiguous memory
> -/// buffer or, as in the case of PDB files, reading from a set of possibly
> -/// discontiguous blocks. The implementation is required to return references
> -/// to stable memory, so if this is not possible (for example in the case of
> -/// a PDB file with discontiguous blocks, it must keep its own pool of temp
> -/// storage.
> -class StreamInterface {
> -public:
> - virtual ~StreamInterface() {}
> -
> - // Given an offset into the stream and a number of bytes, attempt to read
> - // the bytes and set the output ArrayRef to point to a reference into the
> - // stream, without copying any data.
> - virtual Error readBytes(uint32_t Offset, uint32_t Size,
> - ArrayRef<uint8_t> &Buffer) const = 0;
> -
> - // Given an offset into the stream, read as much as possible without copying
> - // any data.
> - virtual Error readLongestContiguousChunk(uint32_t Offset,
> - ArrayRef<uint8_t> &Buffer) const = 0;
> -
> - // Attempt to write the given bytes into the stream at the desired offset.
> - // This will always necessitate a copy. Cannot shrink or grow the stream,
> - // only writes into existing allocated space.
> - virtual Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Data) const = 0;
> -
> - virtual uint32_t getLength() const = 0;
> -
> - virtual Error commit() const = 0;
> -};
> -
> -} // end namespace codeview
> -} // end namespace llvm
> -
> -#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMINTERFACE_H
>
> Removed: llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h (removed)
> @@ -1,111 +0,0 @@
> -//===- StreamReader.h - Reads bytes and objects from a stream ---*- 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_STREAMREADER_H
> -#define LLVM_DEBUGINFO_CODEVIEW_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/Support/Endian.h"
> -#include "llvm/Support/Error.h"
> -
> -#include <string>
> -
> -namespace llvm {
> -namespace codeview {
> -
> -class StreamRef;
> -
> -class StreamReader {
> -public:
> - StreamReader(StreamRef Stream);
> -
> - Error readLongestContiguousChunk(ArrayRef<uint8_t> &Buffer);
> - Error readBytes(ArrayRef<uint8_t> &Buffer, uint32_t Size);
> - Error readInteger(uint16_t &Dest);
> - Error readInteger(uint32_t &Dest);
> - Error readZeroString(StringRef &Dest);
> - Error readFixedString(StringRef &Dest, uint32_t Length);
> - Error readStreamRef(StreamRef &Ref);
> - Error readStreamRef(StreamRef &Ref, uint32_t Length);
> -
> - template <typename T> Error readEnum(T &Dest) {
> - typename std::underlying_type<T>::type N;
> - if (auto EC = readInteger(N))
> - return EC;
> - Dest = static_cast<T>(N);
> - return Error::success();
> - }
> -
> - template <typename T> Error readObject(const T *&Dest) {
> - ArrayRef<uint8_t> Buffer;
> - if (auto EC = readBytes(Buffer, sizeof(T)))
> - return EC;
> - Dest = reinterpret_cast<const T *>(Buffer.data());
> - return Error::success();
> - }
> -
> - template <typename T>
> - Error readArray(ArrayRef<T> &Array, uint32_t NumElements) {
> - ArrayRef<uint8_t> Bytes;
> - if (NumElements == 0) {
> - Array = ArrayRef<T>();
> - return Error::success();
> - }
> -
> - if (NumElements > UINT32_MAX/sizeof(T))
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> -
> - if (auto EC = readBytes(Bytes, NumElements * sizeof(T)))
> - return EC;
> - Array = ArrayRef<T>(reinterpret_cast<const T *>(Bytes.data()), NumElements);
> - return Error::success();
> - }
> -
> - template <typename T, typename U>
> - Error readArray(VarStreamArray<T, U> &Array, uint32_t Size) {
> - StreamRef S;
> - if (auto EC = readStreamRef(S, Size))
> - return EC;
> - Array = VarStreamArray<T, U>(S, Array.getExtractor());
> - return Error::success();
> - }
> -
> - template <typename T>
> - Error readArray(FixedStreamArray<T> &Array, uint32_t NumItems) {
> - if (NumItems == 0) {
> - Array = FixedStreamArray<T>();
> - return Error::success();
> - }
> - uint32_t Length = NumItems * sizeof(T);
> - if (Length / sizeof(T) != NumItems)
> - return make_error<CodeViewError>(cv_error_code::corrupt_record);
> - if (Offset + Length > Stream.getLength())
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> - StreamRef View = Stream.slice(Offset, Length);
> - Array = FixedStreamArray<T>(View);
> - Offset += Length;
> - return Error::success();
> - }
> -
> - void setOffset(uint32_t Off) { Offset = Off; }
> - uint32_t getOffset() const { return Offset; }
> - uint32_t getLength() const { return Stream.getLength(); }
> - uint32_t bytesRemaining() const { return getLength() - getOffset(); }
> -
> -private:
> - StreamRef Stream;
> - uint32_t Offset;
> -};
> -} // namespace codeview
> -} // namespace llvm
> -
> -#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMREADER_H
>
> Removed: llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h (removed)
> @@ -1,104 +0,0 @@
> -//===- StreamRef.h - A copyable reference to a stream -----------*- 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_STREAMREF_H
> -#define LLVM_DEBUGINFO_CODEVIEW_STREAMREF_H
> -
> -#include "llvm/DebugInfo/CodeView/CodeViewError.h"
> -#include "llvm/DebugInfo/CodeView/StreamInterface.h"
> -
> -namespace llvm {
> -namespace codeview {
> -
> -class StreamRef {
> -public:
> - StreamRef() : Stream(nullptr), ViewOffset(0), Length(0) {}
> - StreamRef(const StreamInterface &Stream)
> - : Stream(&Stream), ViewOffset(0), Length(Stream.getLength()) {}
> - StreamRef(const StreamInterface &Stream, uint32_t Offset, uint32_t Length)
> - : Stream(&Stream), ViewOffset(Offset), Length(Length) {}
> -
> - // Use StreamRef.slice() instead.
> - StreamRef(const StreamRef &S, uint32_t Offset, uint32_t Length) = delete;
> -
> - Error readBytes(uint32_t Offset, uint32_t Size,
> - ArrayRef<uint8_t> &Buffer) const {
> - if (ViewOffset + Offset < Offset)
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> - if (Size + Offset > Length)
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> - return Stream->readBytes(ViewOffset + Offset, Size, Buffer);
> - }
> -
> - // Given an offset into the stream, read as much as possible without copying
> - // any data.
> - Error readLongestContiguousChunk(uint32_t Offset,
> - ArrayRef<uint8_t> &Buffer) const {
> - if (Offset >= Length)
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> -
> - if (auto EC = Stream->readLongestContiguousChunk(Offset, Buffer))
> - return EC;
> - // This StreamRef might refer to a smaller window over a larger stream. In
> - // that case we will have read out more bytes than we should return, because
> - // we should not read past the end of the current view.
> - uint32_t MaxLength = Length - Offset;
> - if (Buffer.size() > MaxLength)
> - Buffer = Buffer.slice(0, MaxLength);
> - return Error::success();
> - }
> -
> - Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Data) const {
> - if (Data.size() + Offset > Length)
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> - return Stream->writeBytes(ViewOffset + Offset, Data);
> - }
> -
> - uint32_t getLength() const { return Length; }
> -
> - Error commit() const { return Stream->commit(); }
> -
> - StreamRef drop_front(uint32_t N) const {
> - if (!Stream)
> - return StreamRef();
> -
> - N = std::min(N, Length);
> - return StreamRef(*Stream, ViewOffset + N, Length - N);
> - }
> -
> - StreamRef keep_front(uint32_t N) const {
> - if (!Stream)
> - return StreamRef();
> - N = std::min(N, Length);
> - return StreamRef(*Stream, ViewOffset, N);
> - }
> -
> - StreamRef slice(uint32_t Offset, uint32_t Len) const {
> - return drop_front(Offset).keep_front(Len);
> - }
> -
> - bool operator==(const StreamRef &Other) const {
> - if (Stream != Other.Stream)
> - return false;
> - if (ViewOffset != Other.ViewOffset)
> - return false;
> - if (Length != Other.Length)
> - return false;
> - return true;
> - }
> -
> -private:
> - const StreamInterface *Stream;
> - uint32_t ViewOffset;
> - uint32_t Length;
> -};
> -}
> -}
> -
> -#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMREF_H
>
> Removed: llvm/trunk/include/llvm/DebugInfo/CodeView/StreamWriter.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/StreamWriter.h?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/StreamWriter.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/StreamWriter.h (removed)
> @@ -1,86 +0,0 @@
> -//===- StreamWriter.h - Writes bytes and objects to a stream ----*- 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_STREAMWRITER_H
> -#define LLVM_DEBUGINFO_CODEVIEW_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/Support/Endian.h"
> -#include "llvm/Support/Error.h"
> -
> -#include <string>
> -
> -namespace llvm {
> -namespace codeview {
> -
> -class StreamRef;
> -
> -class StreamWriter {
> -public:
> - StreamWriter(StreamRef Stream);
> -
> - Error writeBytes(ArrayRef<uint8_t> Buffer);
> - Error writeInteger(uint16_t Dest);
> - Error writeInteger(uint32_t Dest);
> - Error writeZeroString(StringRef Str);
> - Error writeFixedString(StringRef Str);
> - Error writeStreamRef(StreamRef Ref);
> - Error writeStreamRef(StreamRef Ref, uint32_t Size);
> -
> - template <typename T> Error writeEnum(T Num) {
> - return writeInteger(
> - static_cast<typename std::underlying_type<T>::type>(Num));
> - }
> -
> - template <typename T> Error writeObject(const T &Obj) {
> - static_assert(!std::is_pointer<T>::value,
> - "writeObject should not be used with pointers, to write "
> - "the pointed-to value dereference the pointer before calling "
> - "writeObject");
> - return writeBytes(
> - ArrayRef<uint8_t>(reinterpret_cast<const uint8_t *>(&Obj), sizeof(T)));
> - }
> -
> - template <typename T> Error writeArray(ArrayRef<T> Array) {
> - if (Array.size() == 0)
> - return Error::success();
> -
> - if (Array.size() > UINT32_MAX / sizeof(T))
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> -
> - return writeBytes(
> - ArrayRef<uint8_t>(reinterpret_cast<const uint8_t *>(Array.data()),
> - Array.size() * sizeof(T)));
> - }
> -
> - template <typename T, typename U>
> - Error writeArray(VarStreamArray<T, U> Array) {
> - return writeStreamRef(Array.getUnderlyingStream());
> - }
> -
> - template <typename T> Error writeArray(FixedStreamArray<T> Array) {
> - return writeStreamRef(Array.getUnderlyingStream());
> - }
> -
> - void setOffset(uint32_t Off) { Offset = Off; }
> - uint32_t getOffset() const { return Offset; }
> - uint32_t getLength() const { return Stream.getLength(); }
> - uint32_t bytesRemaining() const { return getLength() - getOffset(); }
> -
> -private:
> - StreamRef Stream;
> - uint32_t Offset;
> -};
> -} // namespace codeview
> -} // namespace llvm
> -
> -#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMREADER_H
>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/SymbolRecord.h Fri Jul 22 14:56:05 2016
> @@ -15,18 +15,17 @@
> #include "llvm/DebugInfo/CodeView/CVRecord.h"
> #include "llvm/DebugInfo/CodeView/CodeView.h"
> #include "llvm/DebugInfo/CodeView/RecordSerialization.h"
> -#include "llvm/DebugInfo/CodeView/StreamArray.h"
> -#include "llvm/DebugInfo/CodeView/StreamInterface.h"
> #include "llvm/DebugInfo/CodeView/TypeIndex.h"
> +#include "llvm/DebugInfo/Msf/StreamArray.h"
> #include "llvm/Support/Endian.h"
> #include "llvm/Support/Error.h"
>
> namespace llvm {
> namespace codeview {
>
> -using llvm::support::ulittle16_t;
> -using llvm::support::ulittle32_t;
> -using llvm::support::little32_t;
> +using support::ulittle16_t;
> +using support::ulittle32_t;
> +using support::little32_t;
>
> class SymbolRecord {
> protected:
> @@ -1444,7 +1443,7 @@ public:
> };
>
> typedef CVRecord<SymbolKind> CVSymbol;
> -typedef VarStreamArray<CVSymbol> CVSymbolArray;
> +typedef msf::VarStreamArray<CVSymbol> CVSymbolArray;
>
> } // namespace codeview
> } // namespace llvm
>
> Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h Fri Jul 22 14:56:05 2016
> @@ -1195,7 +1195,7 @@ private:
> };
>
> typedef CVRecord<TypeLeafKind> CVType;
> -typedef VarStreamArray<CVType> CVTypeArray;
> +typedef msf::VarStreamArray<CVType> CVTypeArray;
> }
> }
>
>
> Copied: llvm/trunk/include/llvm/DebugInfo/Msf/ByteStream.h (from r276457, llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Msf/ByteStream.h?p2=llvm/trunk/include/llvm/DebugInfo/Msf/ByteStream.h&p1=llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/ByteStream.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/Msf/ByteStream.h Fri Jul 22 14:56:05 2016
> @@ -7,19 +7,19 @@
> //
> //===----------------------------------------------------------------------===//
>
> -#ifndef LLVM_DEBUGINFO_CODEVIEW_BYTESTREAM_H
> -#define LLVM_DEBUGINFO_CODEVIEW_BYTESTREAM_H
> +#ifndef LLVM_DEBUGINFO_MSF_BYTESTREAM_H
> +#define LLVM_DEBUGINFO_MSF_BYTESTREAM_H
>
> #include "llvm/ADT/ArrayRef.h"
> #include "llvm/ADT/StringRef.h"
> -#include "llvm/DebugInfo/CodeView/StreamInterface.h"
> +#include "llvm/DebugInfo/Msf/StreamInterface.h"
> #include "llvm/Support/Error.h"
> #include <cstdint>
> #include <memory>
> #include <type_traits>
>
> namespace llvm {
> -namespace codeview {
> +namespace msf {
> class StreamReader;
>
> template <bool Writable = false> class ByteStream : public StreamInterface {
> @@ -52,7 +52,7 @@ private:
> extern template class ByteStream<true>;
> extern template class ByteStream<false>;
>
> -} // end namespace pdb
> +} // end namespace msf
> } // end namespace llvm
>
> -#endif // LLVM_DEBUGINFO_CODEVIEW_BYTESTREAM_H
> +#endif // LLVM_DEBUGINFO_MSF_BYTESTREAM_H
>
> Copied: llvm/trunk/include/llvm/DebugInfo/Msf/DirectoryStreamData.h (from r276457, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DirectoryStreamData.h)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Msf/DirectoryStreamData.h?p2=llvm/trunk/include/llvm/DebugInfo/Msf/DirectoryStreamData.h&p1=llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DirectoryStreamData.h&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DirectoryStreamData.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/Msf/DirectoryStreamData.h Fri Jul 22 14:56:05 2016
> @@ -7,29 +7,31 @@
> //
> //===----------------------------------------------------------------------===//
>
> -#ifndef LLVM_DEBUGINFO_PDB_RAW_DIRECTORYSTREAMDATA_H
> -#define LLVM_DEBUGINFO_PDB_RAW_DIRECTORYSTREAMDATA_H
> +#ifndef LLVM_DEBUGINFO_MSF_DIRECTORYSTREAMDATA_H
> +#define LLVM_DEBUGINFO_MSF_DIRECTORYSTREAMDATA_H
>
> #include "llvm/ADT/ArrayRef.h"
> -#include "llvm/DebugInfo/PDB/Raw/IPDBStreamData.h"
> -#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
> +#include "llvm/DebugInfo/Msf/IMsfFile.h"
> +#include "llvm/DebugInfo/Msf/IMsfStreamData.h"
> #include "llvm/Support/Endian.h"
>
> namespace llvm {
> -namespace pdb {
> -class IPDBFile;
> +namespace msf {
> +class IMsfFile;
>
> -class DirectoryStreamData : public IPDBStreamData {
> +class DirectoryStreamData : public IMsfStreamData {
> public:
> - DirectoryStreamData(const PDBFile &File) : File(File) {}
> + DirectoryStreamData(uint32_t Length, ArrayRef<support::ulittle32_t> Blocks)
> + : Length(Length), Blocks(Blocks) {}
>
> - virtual uint32_t getLength() { return File.getNumDirectoryBytes(); }
> + virtual uint32_t getLength() { return Length; }
> virtual llvm::ArrayRef<llvm::support::ulittle32_t> getStreamBlocks() {
> - return File.getDirectoryBlockArray();
> + return Blocks;
> }
>
> private:
> - const PDBFile &File;
> + uint32_t Length;
> + ArrayRef<support::ulittle32_t> Blocks;
> };
> }
> }
>
> Copied: llvm/trunk/include/llvm/DebugInfo/Msf/IMsfFile.h (from r276457, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Msf/IMsfFile.h?p2=llvm/trunk/include/llvm/DebugInfo/Msf/IMsfFile.h&p1=llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/Msf/IMsfFile.h Fri Jul 22 14:56:05 2016
> @@ -1,4 +1,4 @@
> -//===- IPDBFile.h - Abstract base class for a PDB file ----------*- C++ -*-===//
> +//===- IMsfFile.h - Abstract base class for an MSF file ---------*- C++ -*-===//
> //
> // The LLVM Compiler Infrastructure
> //
> @@ -7,23 +7,23 @@
> //
> //===----------------------------------------------------------------------===//
>
> -#ifndef LLVM_DEBUGINFO_PDB_RAW_IPDBFILE_H
> -#define LLVM_DEBUGINFO_PDB_RAW_IPDBFILE_H
> +#ifndef LLVM_DEBUGINFO_MSF_IMSFFILE_H
> +#define LLVM_DEBUGINFO_MSF_IMSFFILE_H
>
> #include "llvm/ADT/ArrayRef.h"
> #include "llvm/ADT/StringRef.h"
> -#include "llvm/DebugInfo/CodeView/StreamArray.h"
> +#include "llvm/DebugInfo/Msf/StreamArray.h"
> #include "llvm/Support/Endian.h"
> #include "llvm/Support/Error.h"
>
> #include <stdint.h>
>
> namespace llvm {
> -namespace pdb {
> +namespace msf {
>
> -class IPDBFile {
> +class IMsfFile {
> public:
> - virtual ~IPDBFile() {}
> + virtual ~IMsfFile() {}
>
> virtual uint32_t getBlockSize() const = 0;
> virtual uint32_t getBlockCount() const = 0;
> @@ -41,4 +41,4 @@ public:
> }
> }
>
> -#endif // LLVM_DEBUGINFO_PDB_RAW_IPDBFILE_H
> +#endif // LLVM_DEBUGINFO_MSF_IMSFFILE_H
>
> Copied: llvm/trunk/include/llvm/DebugInfo/Msf/IMsfStreamData.h (from r276457, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBStreamData.h)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Msf/IMsfStreamData.h?p2=llvm/trunk/include/llvm/DebugInfo/Msf/IMsfStreamData.h&p1=llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBStreamData.h&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBStreamData.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/Msf/IMsfStreamData.h Fri Jul 22 14:56:05 2016
> @@ -1,4 +1,4 @@
> -//===- IPDBStreamData.h - Base interface for PDB Stream Data ----*- C++ -*-===//
> +//===- IMsfStreamData.h - Base interface for Msf Stream Data ----*- C++ -*-===//
> //
> // The LLVM Compiler Infrastructure
> //
> @@ -7,15 +7,17 @@
> //
> //===----------------------------------------------------------------------===//
>
> -#ifndef LLVM_DEBUGINFO_PDB_RAW_IPDBSTREAMDATA_H
> -#define LLVM_DEBUGINFO_PDB_RAW_IPDBSTREAMDATA_H
> +#ifndef LLVM_DEBUGINFO_MSF_IMSFSTREAMDATA_H
> +#define LLVM_DEBUGINFO_MSF_IMSFSTREAMDATA_H
>
> #include "llvm/ADT/ArrayRef.h"
> #include "llvm/Support/Endian.h"
>
> +#include <cstdint>
> +
> namespace llvm {
> -namespace pdb {
> -/// IPDBStream abstracts the notion of PDB stream data. Although we already
> +namespace msf {
> +/// IMsfStream abstracts the notion of PDB stream data. Although we already
> /// have another stream abstraction (namely in the form of StreamInterface
> /// and MappedBlockStream), they assume that the stream data is referenced
> /// the same way. Namely, by looking in the directory to get the list of
> @@ -25,14 +27,14 @@ namespace pdb {
> /// notion of stream data further, we can use a MappedBlockStream to read
> /// from the directory itself, or from an indexed stream which references
> /// the directory.
> -class IPDBStreamData {
> +class IMsfStreamData {
> public:
> - virtual ~IPDBStreamData() {}
> + virtual ~IMsfStreamData() {}
>
> virtual uint32_t getLength() = 0;
> virtual ArrayRef<support::ulittle32_t> getStreamBlocks() = 0;
> };
> -}
> -}
> +} // namespace msf
> +} // namespace llvm
>
> -#endif
> +#endif // LLVM_DEBUGINFO_MSF_IMSFSTREAMDATA_H
>
> Copied: llvm/trunk/include/llvm/DebugInfo/Msf/IndexedStreamData.h (from r276457, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IndexedStreamData.h)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Msf/IndexedStreamData.h?p2=llvm/trunk/include/llvm/DebugInfo/Msf/IndexedStreamData.h&p1=llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IndexedStreamData.h&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IndexedStreamData.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/Msf/IndexedStreamData.h Fri Jul 22 14:56:05 2016
> @@ -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
>
> Copied: llvm/trunk/include/llvm/DebugInfo/Msf/MappedBlockStream.h (from r276457, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Msf/MappedBlockStream.h?p2=llvm/trunk/include/llvm/DebugInfo/Msf/MappedBlockStream.h&p1=llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/Msf/MappedBlockStream.h Fri Jul 22 14:56:05 2016
> @@ -1,4 +1,5 @@
> -//===- MappedBlockStream.h - Reads stream data from a PDBFile ---*- C++ -*-===//
> +//===- MappedBlockStream.h - Discontiguous stream data in an Msf -*- C++
> +//-*-===//
> //
> // The LLVM Compiler Infrastructure
> //
> @@ -7,14 +8,14 @@
> //
> //===----------------------------------------------------------------------===//
>
> -#ifndef LLVM_DEBUGINFO_PDB_RAW_MAPPEDBLOCKSTREAM_H
> -#define LLVM_DEBUGINFO_PDB_RAW_MAPPEDBLOCKSTREAM_H
> +#ifndef LLVM_DEBUGINFO_MSF_MAPPEDBLOCKSTREAM_H
> +#define LLVM_DEBUGINFO_MSF_MAPPEDBLOCKSTREAM_H
>
> #include "llvm/ADT/ArrayRef.h"
> #include "llvm/ADT/DenseMap.h"
> #include "llvm/ADT/STLExtras.h"
> -#include "llvm/DebugInfo/CodeView/StreamInterface.h"
> -#include "llvm/DebugInfo/PDB/Raw/IPDBStreamData.h"
> +#include "llvm/DebugInfo/Msf/IMsfStreamData.h"
> +#include "llvm/DebugInfo/Msf/StreamInterface.h"
> #include "llvm/Support/Allocator.h"
> #include "llvm/Support/Endian.h"
> #include "llvm/Support/Error.h"
> @@ -22,12 +23,21 @@
> #include <vector>
>
> namespace llvm {
> -namespace pdb {
> +namespace msf {
>
> -class IPDBFile;
> -class PDBFile;
> +class IMsfFile;
>
> -class MappedBlockStream : public codeview::StreamInterface {
> +/// MappedBlockStream represents data stored in an Msf file into chunks of a
> +/// particular size (called the Block Size), and whose chunks may not be
> +/// necessarily contiguous. The arrangement of these chunks within the file
> +/// is described by some other metadata contained within the Msf file. In
> +/// the case of a standard Msf Stream, the layout of the stream's blocks
> +/// is described by the Msf "directory", but in the case of the directory
> +/// itself, the layout is described by an array at a fixed location within
> +/// the Msf. MappedBlockStream provides methods for reading from and writing
> +/// to one of these streams transparently, as if it were a contiguous sequence
> +/// of bytes.
> +class MappedBlockStream : public StreamInterface {
> public:
> Error readBytes(uint32_t Offset, uint32_t Size,
> ArrayRef<uint8_t> &Buffer) const override;
> @@ -41,21 +51,22 @@ public:
> uint32_t getNumBytesCopied() const;
>
> static Expected<std::unique_ptr<MappedBlockStream>>
> - createIndexedStream(uint32_t StreamIdx, const IPDBFile &File);
> + createIndexedStream(uint32_t StreamIdx, const IMsfFile &File);
> static Expected<std::unique_ptr<MappedBlockStream>>
> - createDirectoryStream(const PDBFile &File);
> + createDirectoryStream(uint32_t Length, ArrayRef<support::ulittle32_t> Blocks,
> + const IMsfFile &File);
>
> llvm::BumpPtrAllocator &getAllocator() { return Pool; }
>
> protected:
> - MappedBlockStream(std::unique_ptr<IPDBStreamData> Data, const IPDBFile &File);
> + MappedBlockStream(std::unique_ptr<IMsfStreamData> Data, const IMsfFile &File);
>
> Error readBytes(uint32_t Offset, MutableArrayRef<uint8_t> Buffer) const;
> bool tryReadContiguously(uint32_t Offset, uint32_t Size,
> ArrayRef<uint8_t> &Buffer) const;
>
> - const IPDBFile &Pdb;
> - std::unique_ptr<IPDBStreamData> Data;
> + const IMsfFile &Msf;
> + std::unique_ptr<IMsfStreamData> Data;
>
> typedef MutableArrayRef<uint8_t> CacheEntry;
> mutable llvm::BumpPtrAllocator Pool;
> @@ -65,4 +76,4 @@ protected:
> } // end namespace pdb
> } // end namespace llvm
>
> -#endif // LLVM_DEBUGINFO_PDB_RAW_MAPPEDBLOCKSTREAM_H
> +#endif // LLVM_DEBUGINFO_MSF_MAPPEDBLOCKSTREAM_H
>
> Copied: llvm/trunk/include/llvm/DebugInfo/Msf/MsfBuilder.h (from r276457, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MsfBuilder.h)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Msf/MsfBuilder.h?p2=llvm/trunk/include/llvm/DebugInfo/Msf/MsfBuilder.h&p1=llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MsfBuilder.h&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MsfBuilder.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/Msf/MsfBuilder.h Fri Jul 22 14:56:05 2016
> @@ -7,14 +7,13 @@
> //
> //===----------------------------------------------------------------------===//
>
> -#ifndef LLVM_DEBUGINFO_PDB_RAW_MSFBUILDER_H
> -#define LLVM_DEBUGINFO_PDB_RAW_MSFBUILDER_H
> +#ifndef LLVM_DEBUGINFO_MSF_MSFBUILDER_H
> +#define LLVM_DEBUGINFO_MSF_MSFBUILDER_H
>
> #include "llvm/ADT/ArrayRef.h"
> #include "llvm/ADT/BitVector.h"
>
> -#include "llvm/DebugInfo/PDB/Raw/MsfCommon.h"
> -#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
> +#include "llvm/DebugInfo/Msf/MsfCommon.h"
>
> #include "llvm/Support/Allocator.h"
> #include "llvm/Support/Endian.h"
> @@ -24,7 +23,7 @@
> #include <vector>
>
> namespace llvm {
> -namespace pdb {
> +namespace msf {
> class MsfBuilder {
> public:
> /// \brief Create a new `MsfBuilder`.
> @@ -34,9 +33,9 @@ public:
> ///
> /// \param MinBlockCount Causes the builder to reserve up front space for
> /// at least `MinBlockCount` blocks. This is useful when using `MsfBuilder`
> - /// to read an existing PDB that you want to write back out later. The
> - /// original PDB file's SuperBlock contains the exact number of blocks used
> - /// by the file, so is a good hint as to how many blocks the new PDB file
> + /// to read an existing MSF that you want to write back out later. The
> + /// original MSF file's SuperBlock contains the exact number of blocks used
> + /// by the file, so is a good hint as to how many blocks the new MSF file
> /// will contain. Furthermore, it is actually necessary in this case. To
> /// preserve stability of the file's layout, it is helpful to try to keep
> /// all streams mapped to their original block numbers. To ensure that this
> @@ -45,7 +44,7 @@ public:
> ///
> /// \param CanGrow If true, any operation which results in an attempt to
> /// locate a free block when all available blocks have been exhausted will
> - /// allocate a new block, thereby growing the size of the final PDB file.
> + /// allocate a new block, thereby growing the size of the final MSF file.
> /// When false, any such attempt will result in an error. This is especially
> /// useful in testing scenarios when you know your test isn't going to do
> /// anything to increase the size of the file, so having an Error returned if
> @@ -61,14 +60,14 @@ public:
> bool CanGrow = true);
>
> /// Request the block map to be at a specific block address. This is useful
> - /// when editing a PDB and you want the layout to be as stable as possible.
> + /// when editing a MSF and you want the layout to be as stable as possible.
> Error setBlockMapAddr(uint32_t Addr);
> Error setDirectoryBlocksHint(ArrayRef<uint32_t> DirBlocks);
> void setFreePageMap(uint32_t Fpm);
> void setUnknown1(uint32_t Unk1);
>
> /// Add a stream to the MSF file with the given size, occupying the given
> - /// list of blocks. This is useful when reading a PDB file and you want a
> + /// list of blocks. This is useful when reading a MSF file and you want a
> /// particular stream to occupy the original set of blocks. If the given
> /// blocks are already allocated, or if the number of blocks specified is
> /// incorrect for the given stream size, this function will return an Error.
> @@ -112,7 +111,7 @@ public:
>
> /// Finalize the layout and build the headers and structures that describe the
> /// MSF layout and can be written directly to the MSF file.
> - Expected<msf::Layout> build();
> + Expected<Layout> build();
>
> private:
> MsfBuilder(uint32_t BlockSize, uint32_t MinBlockCount, bool CanGrow,
> @@ -135,7 +134,7 @@ private:
> std::vector<uint32_t> DirectoryBlocks;
> std::vector<std::pair<uint32_t, BlockList>> StreamData;
> };
> -}
> -}
> +} // namespace msf
> +} // namespace llvm
>
> -#endif
> +#endif // LLVM_DEBUGINFO_MSF_MSFBUILDER_H
>
> Copied: llvm/trunk/include/llvm/DebugInfo/Msf/MsfCommon.h (from r276457, llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MsfCommon.h)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Msf/MsfCommon.h?p2=llvm/trunk/include/llvm/DebugInfo/Msf/MsfCommon.h&p1=llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MsfCommon.h&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MsfCommon.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/Msf/MsfCommon.h Fri Jul 22 14:56:05 2016
> @@ -7,8 +7,8 @@
> //
> //===----------------------------------------------------------------------===//
>
> -#ifndef LLVM_DEBUGINFO_PDB_RAW_MSFCOMMON_H
> -#define LLVM_DEBUGINFO_PDB_RAW_MSFCOMMON_H
> +#ifndef LLVM_DEBUGINFO_MSF_MSFCOMMON_H
> +#define LLVM_DEBUGINFO_MSF_MSFCOMMON_H
>
> #include "llvm/ADT/ArrayRef.h"
>
> @@ -19,7 +19,6 @@
> #include <vector>
>
> namespace llvm {
> -namespace pdb {
> namespace msf {
> static const char Magic[] = {'M', 'i', 'c', 'r', 'o', 's', 'o', 'f',
> 't', ' ', 'C', '/', 'C', '+', '+', ' ',
> @@ -38,7 +37,7 @@ struct SuperBlock {
> // The index of the free block map.
> support::ulittle32_t FreeBlockMapBlock;
> // This contains the number of blocks resident in the file system. In
> - // practice, NumBlocks * BlockSize is equivalent to the size of the PDB
> + // practice, NumBlocks * BlockSize is equivalent to the size of the MSF
> // file.
> support::ulittle32_t NumBlocks;
> // This contains the number of bytes which make up the directory.
> @@ -83,8 +82,7 @@ inline uint64_t blockToOffset(uint64_t B
> }
>
> Error validateSuperBlock(const SuperBlock &SB);
> -}
> -}
> -}
> +} // namespace msf
> +} // namespace llvm
>
> -#endif
> +#endif // LLVM_DEBUGINFO_MSF_MSFCOMMON_H
>
> Added: llvm/trunk/include/llvm/DebugInfo/Msf/MsfError.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Msf/MsfError.h?rev=276458&view=auto
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/Msf/MsfError.h (added)
> +++ llvm/trunk/include/llvm/DebugInfo/Msf/MsfError.h Fri Jul 22 14:56:05 2016
> @@ -0,0 +1,47 @@
> +//===- MsfError.h - Error extensions for Msf Files --------------*- C++ -*-===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
> +//===----------------------------------------------------------------------===//
> +
> +#ifndef LLVM_DEBUGINFO_MSF_MSFERROR_H
> +#define LLVM_DEBUGINFO_MSF_MSFERROR_H
> +
> +#include "llvm/Support/Error.h"
> +
> +#include <string>
> +
> +namespace llvm {
> +namespace msf {
> +enum class msf_error_code {
> + unspecified = 1,
> + insufficient_buffer,
> + not_writable,
> + no_stream,
> + invalid_format,
> + block_in_use
> +};
> +
> +/// Base class for errors originating when parsing raw PDB files
> +class MsfError : public ErrorInfo<MsfError> {
> +public:
> + static char ID;
> + MsfError(msf_error_code C);
> + MsfError(const std::string &Context);
> + MsfError(msf_error_code C, const std::string &Context);
> +
> + void log(raw_ostream &OS) const override;
> + const std::string &getErrorMessage() const;
> + std::error_code convertToErrorCode() const override;
> +
> +private:
> + std::string ErrMsg;
> + msf_error_code Code;
> +};
> +} // namespace msf
> +} // namespace llvm
> +
> +#endif // LLVM_DEBUGINFO_MSF_MSFERROR_H
>
> Copied: llvm/trunk/include/llvm/DebugInfo/Msf/StreamArray.h (from r276457, llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Msf/StreamArray.h?p2=llvm/trunk/include/llvm/DebugInfo/Msf/StreamArray.h&p1=llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/StreamArray.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/Msf/StreamArray.h Fri Jul 22 14:56:05 2016
> @@ -7,17 +7,17 @@
> //
> //===----------------------------------------------------------------------===//
>
> -#ifndef LLVM_DEBUGINFO_CODEVIEW_STREAMARRAY_H
> -#define LLVM_DEBUGINFO_CODEVIEW_STREAMARRAY_H
> +#ifndef LLVM_DEBUGINFO_MSF_STREAMARRAY_H
> +#define LLVM_DEBUGINFO_MSF_STREAMARRAY_H
>
> -#include "llvm/DebugInfo/CodeView/StreamRef.h"
> +#include "llvm/DebugInfo/Msf/StreamRef.h"
> #include "llvm/Support/Error.h"
>
> #include <functional>
> #include <type_traits>
>
> namespace llvm {
> -namespace codeview {
> +namespace msf {
>
> /// VarStreamArrayExtractor is intended to be specialized to provide customized
> /// extraction logic. On input it receives a StreamRef pointing to the
> @@ -269,7 +269,7 @@ private:
> uint32_t Index;
> };
>
> -} // namespace codeview
> +} // namespace msf
> } // namespace llvm
>
> -#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMARRAY_H
> +#endif // LLVM_DEBUGINFO_MSF_STREAMARRAY_H
>
> Copied: llvm/trunk/include/llvm/DebugInfo/Msf/StreamInterface.h (from r276457, llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Msf/StreamInterface.h?p2=llvm/trunk/include/llvm/DebugInfo/Msf/StreamInterface.h&p1=llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/StreamInterface.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/Msf/StreamInterface.h Fri Jul 22 14:56:05 2016
> @@ -7,15 +7,15 @@
> //
> //===----------------------------------------------------------------------===//
>
> -#ifndef LLVM_DEBUGINFO_CODEVIEW_STREAMINTERFACE_H
> -#define LLVM_DEBUGINFO_CODEVIEW_STREAMINTERFACE_H
> +#ifndef LLVM_DEBUGINFO_MSF_STREAMINTERFACE_H
> +#define LLVM_DEBUGINFO_MSF_STREAMINTERFACE_H
>
> #include "llvm/ADT/ArrayRef.h"
> #include "llvm/Support/Error.h"
> #include <cstdint>
>
> namespace llvm {
> -namespace codeview {
> +namespace msf {
>
> /// StreamInterface abstracts the notion of a data stream. This way, an
> /// implementation could implement trivial reading from a contiguous memory
> @@ -49,7 +49,7 @@ public:
> virtual Error commit() const = 0;
> };
>
> -} // end namespace codeview
> +} // end namespace msf
> } // end namespace llvm
>
> -#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMINTERFACE_H
> +#endif // LLVM_DEBUGINFO_MSF_STREAMINTERFACE_H
>
> Copied: llvm/trunk/include/llvm/DebugInfo/Msf/StreamReader.h (from r276457, llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Msf/StreamReader.h?p2=llvm/trunk/include/llvm/DebugInfo/Msf/StreamReader.h&p1=llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/StreamReader.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/Msf/StreamReader.h Fri Jul 22 14:56:05 2016
> @@ -7,20 +7,20 @@
> //
> //===----------------------------------------------------------------------===//
>
> -#ifndef LLVM_DEBUGINFO_CODEVIEW_STREAMREADER_H
> -#define LLVM_DEBUGINFO_CODEVIEW_STREAMREADER_H
> +#ifndef LLVM_DEBUGINFO_MSF_STREAMREADER_H
> +#define LLVM_DEBUGINFO_MSF_STREAMREADER_H
>
> #include "llvm/ADT/ArrayRef.h"
> -#include "llvm/DebugInfo/CodeView/CodeViewError.h"
> -#include "llvm/DebugInfo/CodeView/StreamArray.h"
> -#include "llvm/DebugInfo/CodeView/StreamInterface.h"
> +#include "llvm/DebugInfo/Msf/MsfError.h"
> +#include "llvm/DebugInfo/Msf/StreamArray.h"
> +#include "llvm/DebugInfo/Msf/StreamInterface.h"
> #include "llvm/Support/Endian.h"
> #include "llvm/Support/Error.h"
>
> #include <string>
>
> namespace llvm {
> -namespace codeview {
> +namespace msf {
>
> class StreamRef;
>
> @@ -61,8 +61,8 @@ public:
> return Error::success();
> }
>
> - if (NumElements > UINT32_MAX/sizeof(T))
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> + if (NumElements > UINT32_MAX / sizeof(T))
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
>
> if (auto EC = readBytes(Bytes, NumElements * sizeof(T)))
> return EC;
> @@ -87,9 +87,9 @@ public:
> }
> uint32_t Length = NumItems * sizeof(T);
> if (Length / sizeof(T) != NumItems)
> - return make_error<CodeViewError>(cv_error_code::corrupt_record);
> + return make_error<MsfError>(msf_error_code::invalid_format);
> if (Offset + Length > Stream.getLength())
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
> StreamRef View = Stream.slice(Offset, Length);
> Array = FixedStreamArray<T>(View);
> Offset += Length;
> @@ -105,7 +105,7 @@ private:
> StreamRef Stream;
> uint32_t Offset;
> };
> -} // namespace codeview
> +} // namespace msf
> } // namespace llvm
>
> -#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMREADER_H
> +#endif // LLVM_DEBUGINFO_MSF_STREAMREADER_H
>
> Copied: llvm/trunk/include/llvm/DebugInfo/Msf/StreamRef.h (from r276457, llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Msf/StreamRef.h?p2=llvm/trunk/include/llvm/DebugInfo/Msf/StreamRef.h&p1=llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/StreamRef.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/Msf/StreamRef.h Fri Jul 22 14:56:05 2016
> @@ -7,14 +7,14 @@
> //
> //===----------------------------------------------------------------------===//
>
> -#ifndef LLVM_DEBUGINFO_CODEVIEW_STREAMREF_H
> -#define LLVM_DEBUGINFO_CODEVIEW_STREAMREF_H
> +#ifndef LLVM_DEBUGINFO_MSF_STREAMREF_H
> +#define LLVM_DEBUGINFO_MSF_STREAMREF_H
>
> -#include "llvm/DebugInfo/CodeView/CodeViewError.h"
> -#include "llvm/DebugInfo/CodeView/StreamInterface.h"
> +#include "llvm/DebugInfo/Msf/MsfError.h"
> +#include "llvm/DebugInfo/Msf/StreamInterface.h"
>
> namespace llvm {
> -namespace codeview {
> +namespace msf {
>
> class StreamRef {
> public:
> @@ -30,9 +30,9 @@ public:
> Error readBytes(uint32_t Offset, uint32_t Size,
> ArrayRef<uint8_t> &Buffer) const {
> if (ViewOffset + Offset < Offset)
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
> if (Size + Offset > Length)
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
> return Stream->readBytes(ViewOffset + Offset, Size, Buffer);
> }
>
> @@ -41,7 +41,7 @@ public:
> Error readLongestContiguousChunk(uint32_t Offset,
> ArrayRef<uint8_t> &Buffer) const {
> if (Offset >= Length)
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
>
> if (auto EC = Stream->readLongestContiguousChunk(Offset, Buffer))
> return EC;
> @@ -56,7 +56,7 @@ public:
>
> Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Data) const {
> if (Data.size() + Offset > Length)
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
> return Stream->writeBytes(ViewOffset + Offset, Data);
> }
>
> @@ -98,7 +98,7 @@ private:
> uint32_t ViewOffset;
> uint32_t Length;
> };
> -}
> -}
> +} // namespace msf
> +} // namespace llvm
>
> -#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMREF_H
> +#endif // LLVM_DEBUGINFO_MSF_STREAMREF_H
>
> Copied: llvm/trunk/include/llvm/DebugInfo/Msf/StreamWriter.h (from r276457, llvm/trunk/include/llvm/DebugInfo/CodeView/StreamWriter.h)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/Msf/StreamWriter.h?p2=llvm/trunk/include/llvm/DebugInfo/Msf/StreamWriter.h&p1=llvm/trunk/include/llvm/DebugInfo/CodeView/StreamWriter.h&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/CodeView/StreamWriter.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/Msf/StreamWriter.h Fri Jul 22 14:56:05 2016
> @@ -7,20 +7,20 @@
> //
> //===----------------------------------------------------------------------===//
>
> -#ifndef LLVM_DEBUGINFO_CODEVIEW_STREAMWRITER_H
> -#define LLVM_DEBUGINFO_CODEVIEW_STREAMWRITER_H
> +#ifndef LLVM_DEBUGINFO_MSF_STREAMWRITER_H
> +#define LLVM_DEBUGINFO_MSF_STREAMWRITER_H
>
> #include "llvm/ADT/ArrayRef.h"
> -#include "llvm/DebugInfo/CodeView/CodeViewError.h"
> -#include "llvm/DebugInfo/CodeView/StreamArray.h"
> -#include "llvm/DebugInfo/CodeView/StreamInterface.h"
> +#include "llvm/DebugInfo/Msf/MsfError.h"
> +#include "llvm/DebugInfo/Msf/StreamArray.h"
> +#include "llvm/DebugInfo/Msf/StreamInterface.h"
> #include "llvm/Support/Endian.h"
> #include "llvm/Support/Error.h"
>
> #include <string>
>
> namespace llvm {
> -namespace codeview {
> +namespace msf {
>
> class StreamRef;
>
> @@ -55,7 +55,7 @@ public:
> return Error::success();
>
> if (Array.size() > UINT32_MAX / sizeof(T))
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
>
> return writeBytes(
> ArrayRef<uint8_t>(reinterpret_cast<const uint8_t *>(Array.data()),
> @@ -80,7 +80,7 @@ private:
> StreamRef Stream;
> uint32_t Offset;
> };
> -} // namespace codeview
> +} // namespace msf
> } // namespace llvm
>
> -#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMREADER_H
> +#endif // LLVM_DEBUGINFO_MSF_STREAMWRITER_H
>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DbiStream.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DbiStream.h?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DbiStream.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DbiStream.h Fri Jul 22 14:56:05 2016
> @@ -11,10 +11,10 @@
> #define LLVM_DEBUGINFO_PDB_RAW_PDBDBISTREAM_H
>
> #include "llvm/DebugInfo/CodeView/ModuleSubstream.h"
> -#include "llvm/DebugInfo/CodeView/StreamArray.h"
> -#include "llvm/DebugInfo/CodeView/StreamRef.h"
> +#include "llvm/DebugInfo/Msf/MappedBlockStream.h"
> +#include "llvm/DebugInfo/Msf/StreamArray.h"
> +#include "llvm/DebugInfo/Msf/StreamRef.h"
> #include "llvm/DebugInfo/PDB/PDBTypes.h"
> -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
> #include "llvm/DebugInfo/PDB/Raw/ModInfo.h"
> #include "llvm/DebugInfo/PDB/Raw/NameHashTable.h"
> #include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
> @@ -37,7 +37,7 @@ class DbiStream {
> friend class DbiStreamBuilder;
>
> public:
> - DbiStream(PDBFile &File, std::unique_ptr<MappedBlockStream> Stream);
> + DbiStream(PDBFile &File, std::unique_ptr<msf::MappedBlockStream> Stream);
> ~DbiStream();
> Error reload();
>
> @@ -70,11 +70,11 @@ public:
>
> Expected<StringRef> getFileNameForIndex(uint32_t Index) const;
>
> - codeview::FixedStreamArray<object::coff_section> getSectionHeaders();
> + msf::FixedStreamArray<object::coff_section> getSectionHeaders();
>
> - codeview::FixedStreamArray<object::FpoData> getFpoRecords();
> + msf::FixedStreamArray<object::FpoData> getFpoRecords();
>
> - codeview::FixedStreamArray<SecMapEntry> getSectionMap() const;
> + msf::FixedStreamArray<SecMapEntry> getSectionMap() const;
> void visitSectionContributions(ISectionContribVisitor &Visitor) const;
>
> Error commit();
> @@ -88,33 +88,33 @@ private:
> Error initializeFpoRecords();
>
> PDBFile &Pdb;
> - std::unique_ptr<MappedBlockStream> Stream;
> + std::unique_ptr<msf::MappedBlockStream> Stream;
>
> std::vector<ModuleInfoEx> ModuleInfos;
> NameHashTable ECNames;
>
> - codeview::StreamRef ModInfoSubstream;
> - codeview::StreamRef SecContrSubstream;
> - codeview::StreamRef SecMapSubstream;
> - codeview::StreamRef FileInfoSubstream;
> - codeview::StreamRef TypeServerMapSubstream;
> - codeview::StreamRef ECSubstream;
> + msf::StreamRef ModInfoSubstream;
> + msf::StreamRef SecContrSubstream;
> + msf::StreamRef SecMapSubstream;
> + msf::StreamRef FileInfoSubstream;
> + msf::StreamRef TypeServerMapSubstream;
> + msf::StreamRef ECSubstream;
>
> - codeview::StreamRef NamesBuffer;
> + msf::StreamRef NamesBuffer;
>
> - codeview::FixedStreamArray<support::ulittle16_t> DbgStreams;
> + msf::FixedStreamArray<support::ulittle16_t> DbgStreams;
>
> PdbRaw_DbiSecContribVer SectionContribVersion;
> - codeview::FixedStreamArray<SectionContrib> SectionContribs;
> - codeview::FixedStreamArray<SectionContrib2> SectionContribs2;
> - codeview::FixedStreamArray<SecMapEntry> SectionMap;
> - codeview::FixedStreamArray<support::little32_t> FileNameOffsets;
> + msf::FixedStreamArray<SectionContrib> SectionContribs;
> + msf::FixedStreamArray<SectionContrib2> SectionContribs2;
> + msf::FixedStreamArray<SecMapEntry> SectionMap;
> + msf::FixedStreamArray<support::little32_t> FileNameOffsets;
>
> - std::unique_ptr<MappedBlockStream> SectionHeaderStream;
> - codeview::FixedStreamArray<object::coff_section> SectionHeaders;
> + std::unique_ptr<msf::MappedBlockStream> SectionHeaderStream;
> + msf::FixedStreamArray<object::coff_section> SectionHeaders;
>
> - std::unique_ptr<MappedBlockStream> FpoStream;
> - codeview::FixedStreamArray<object::FpoData> FpoRecords;
> + std::unique_ptr<msf::MappedBlockStream> FpoStream;
> + msf::FixedStreamArray<object::FpoData> FpoRecords;
>
> const DbiStreamHeader *Header;
> };
>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h Fri Jul 22 14:56:05 2016
> @@ -14,7 +14,8 @@
> #include "llvm/ADT/StringSet.h"
> #include "llvm/Support/Error.h"
>
> -#include "llvm/DebugInfo/CodeView/ByteStream.h"
> +#include "llvm/DebugInfo/Msf/ByteStream.h"
> +#include "llvm/DebugInfo/Msf/StreamReader.h"
> #include "llvm/DebugInfo/PDB/PDBTypes.h"
> #include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
> #include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
> @@ -75,9 +76,9 @@ private:
>
> StringMap<uint32_t> SourceFileNames;
>
> - codeview::StreamRef NamesBuffer;
> - codeview::ByteStream<true> ModInfoBuffer;
> - codeview::ByteStream<true> FileInfoBuffer;
> + msf::StreamRef NamesBuffer;
> + msf::ByteStream<true> ModInfoBuffer;
> + msf::ByteStream<true> FileInfoBuffer;
> };
> }
> }
>
> Removed: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DirectoryStreamData.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DirectoryStreamData.h?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DirectoryStreamData.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/DirectoryStreamData.h (removed)
> @@ -1,37 +0,0 @@
> -//===- DirectoryStreamData.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_PDB_RAW_DIRECTORYSTREAMDATA_H
> -#define LLVM_DEBUGINFO_PDB_RAW_DIRECTORYSTREAMDATA_H
> -
> -#include "llvm/ADT/ArrayRef.h"
> -#include "llvm/DebugInfo/PDB/Raw/IPDBStreamData.h"
> -#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
> -#include "llvm/Support/Endian.h"
> -
> -namespace llvm {
> -namespace pdb {
> -class IPDBFile;
> -
> -class DirectoryStreamData : public IPDBStreamData {
> -public:
> - DirectoryStreamData(const PDBFile &File) : File(File) {}
> -
> - virtual uint32_t getLength() { return File.getNumDirectoryBytes(); }
> - virtual llvm::ArrayRef<llvm::support::ulittle32_t> getStreamBlocks() {
> - return File.getDirectoryBlockArray();
> - }
> -
> -private:
> - const PDBFile &File;
> -};
> -}
> -}
> -
> -#endif
>
> Removed: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBFile.h (removed)
> @@ -1,44 +0,0 @@
> -//===- IPDBFile.h - Abstract base class for a PDB file ----------*- 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_PDB_RAW_IPDBFILE_H
> -#define LLVM_DEBUGINFO_PDB_RAW_IPDBFILE_H
> -
> -#include "llvm/ADT/ArrayRef.h"
> -#include "llvm/ADT/StringRef.h"
> -#include "llvm/DebugInfo/CodeView/StreamArray.h"
> -#include "llvm/Support/Endian.h"
> -#include "llvm/Support/Error.h"
> -
> -#include <stdint.h>
> -
> -namespace llvm {
> -namespace pdb {
> -
> -class IPDBFile {
> -public:
> - virtual ~IPDBFile() {}
> -
> - virtual uint32_t getBlockSize() const = 0;
> - virtual uint32_t getBlockCount() const = 0;
> -
> - virtual uint32_t getNumStreams() const = 0;
> - virtual uint32_t getStreamByteSize(uint32_t StreamIndex) const = 0;
> - virtual ArrayRef<support::ulittle32_t>
> - getStreamBlockList(uint32_t StreamIndex) const = 0;
> -
> - virtual Expected<ArrayRef<uint8_t>> getBlockData(uint32_t BlockIndex,
> - uint32_t NumBytes) const = 0;
> - virtual Error setBlockData(uint32_t BlockIndex, uint32_t Offset,
> - ArrayRef<uint8_t> Data) const = 0;
> -};
> -}
> -}
> -
> -#endif // LLVM_DEBUGINFO_PDB_RAW_IPDBFILE_H
>
> Removed: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBStreamData.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBStreamData.h?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBStreamData.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IPDBStreamData.h (removed)
> @@ -1,38 +0,0 @@
> -//===- IPDBStreamData.h - Base interface for PDB Stream Data ----*- 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_PDB_RAW_IPDBSTREAMDATA_H
> -#define LLVM_DEBUGINFO_PDB_RAW_IPDBSTREAMDATA_H
> -
> -#include "llvm/ADT/ArrayRef.h"
> -#include "llvm/Support/Endian.h"
> -
> -namespace llvm {
> -namespace pdb {
> -/// IPDBStream 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
> -/// stream blocks, and by looking in the array of stream lengths to get the
> -/// length. This breaks down for the directory itself, however, since its
> -/// length and list of blocks are stored elsewhere. By abstracting the
> -/// 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 {
> -public:
> - virtual ~IPDBStreamData() {}
> -
> - virtual uint32_t getLength() = 0;
> - virtual ArrayRef<support::ulittle32_t> getStreamBlocks() = 0;
> -};
> -}
> -}
> -
> -#endif
>
> Removed: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IndexedStreamData.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IndexedStreamData.h?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IndexedStreamData.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/IndexedStreamData.h (removed)
> @@ -1,34 +0,0 @@
> -//===- IndexedStreamData.h - Standard PDB Stream Data -----------*- 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_PDB_RAW_INDEXEDSTREAMDATA_H
> -#define LLVM_DEBUGINFO_PDB_RAW_INDEXEDSTREAMDATA_H
> -
> -#include "llvm/DebugInfo/PDB/Raw/IPDBStreamData.h"
> -
> -namespace llvm {
> -namespace pdb {
> -class IPDBFile;
> -
> -class IndexedStreamData : public IPDBStreamData {
> -public:
> - IndexedStreamData(uint32_t StreamIdx, const IPDBFile &File);
> - virtual ~IndexedStreamData() {}
> -
> - uint32_t getLength() override;
> - ArrayRef<support::ulittle32_t> getStreamBlocks() override;
> -
> -private:
> - uint32_t StreamIdx;
> - const IPDBFile &File;
> -};
> -}
> -}
> -
> -#endif
>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/InfoStream.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/InfoStream.h?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/InfoStream.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/InfoStream.h Fri Jul 22 14:56:05 2016
> @@ -11,8 +11,8 @@
> #define LLVM_DEBUGINFO_PDB_RAW_PDBINFOSTREAM_H
>
> #include "llvm/ADT/StringMap.h"
> +#include "llvm/DebugInfo/Msf/MappedBlockStream.h"
> #include "llvm/DebugInfo/PDB/PDBTypes.h"
> -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
> #include "llvm/DebugInfo/PDB/Raw/NameMap.h"
> #include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
>
> @@ -35,7 +35,7 @@ class InfoStream {
> };
>
> public:
> - InfoStream(std::unique_ptr<MappedBlockStream> Stream);
> + InfoStream(std::unique_ptr<msf::MappedBlockStream> Stream);
>
> Error reload();
> Error commit();
> @@ -49,7 +49,7 @@ public:
> iterator_range<StringMapConstIterator<uint32_t>> named_streams() const;
>
> private:
> - std::unique_ptr<MappedBlockStream> Stream;
> + std::unique_ptr<msf::MappedBlockStream> Stream;
>
> // PDB file format version. We only support VC70. See the enumeration
> // `PdbRaw_ImplVer` for the other possible values.
>
> Removed: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MappedBlockStream.h (removed)
> @@ -1,68 +0,0 @@
> -//===- MappedBlockStream.h - Reads stream data from a PDBFile ---*- 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_PDB_RAW_MAPPEDBLOCKSTREAM_H
> -#define LLVM_DEBUGINFO_PDB_RAW_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/Support/Allocator.h"
> -#include "llvm/Support/Endian.h"
> -#include "llvm/Support/Error.h"
> -#include <cstdint>
> -#include <vector>
> -
> -namespace llvm {
> -namespace pdb {
> -
> -class IPDBFile;
> -class PDBFile;
> -
> -class MappedBlockStream : public codeview::StreamInterface {
> -public:
> - Error readBytes(uint32_t Offset, uint32_t Size,
> - ArrayRef<uint8_t> &Buffer) const override;
> - Error readLongestContiguousChunk(uint32_t Offset,
> - ArrayRef<uint8_t> &Buffer) const override;
> - Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Buffer) const override;
> -
> - uint32_t getLength() const override;
> - Error commit() const override;
> -
> - uint32_t getNumBytesCopied() const;
> -
> - static Expected<std::unique_ptr<MappedBlockStream>>
> - createIndexedStream(uint32_t StreamIdx, const IPDBFile &File);
> - static Expected<std::unique_ptr<MappedBlockStream>>
> - createDirectoryStream(const PDBFile &File);
> -
> - llvm::BumpPtrAllocator &getAllocator() { return Pool; }
> -
> -protected:
> - MappedBlockStream(std::unique_ptr<IPDBStreamData> Data, const IPDBFile &File);
> -
> - Error readBytes(uint32_t Offset, MutableArrayRef<uint8_t> Buffer) const;
> - bool tryReadContiguously(uint32_t Offset, uint32_t Size,
> - ArrayRef<uint8_t> &Buffer) const;
> -
> - const IPDBFile &Pdb;
> - std::unique_ptr<IPDBStreamData> Data;
> -
> - typedef MutableArrayRef<uint8_t> CacheEntry;
> - mutable llvm::BumpPtrAllocator Pool;
> - mutable DenseMap<uint32_t, std::vector<CacheEntry>> CacheMap;
> -};
> -
> -} // end namespace pdb
> -} // end namespace llvm
> -
> -#endif // LLVM_DEBUGINFO_PDB_RAW_MAPPEDBLOCKSTREAM_H
>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModInfo.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModInfo.h?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModInfo.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModInfo.h Fri Jul 22 14:56:05 2016
> @@ -11,8 +11,8 @@
> #define LLVM_DEBUGINFO_PDB_RAW_MODINFO_H
>
> #include "llvm/ADT/StringRef.h"
> -#include "llvm/DebugInfo/CodeView/StreamArray.h"
> -#include "llvm/DebugInfo/CodeView/StreamRef.h"
> +#include "llvm/DebugInfo/Msf/StreamArray.h"
> +#include "llvm/DebugInfo/Msf/StreamRef.h"
> #include "llvm/DebugInfo/PDB/Raw/RawTypes.h"
> #include "llvm/Support/Endian.h"
> #include <cstdint>
> @@ -29,7 +29,7 @@ public:
> ModInfo(const ModInfo &Info);
> ~ModInfo();
>
> - static Error initialize(codeview::StreamRef Stream, ModInfo &Info);
> + static Error initialize(msf::StreamRef Stream, ModInfo &Info);
>
> bool hasECInfo() const;
> uint16_t getTypeServerIndex() const;
> @@ -63,7 +63,7 @@ struct ModuleInfoEx {
>
> } // end namespace pdb
>
> -namespace codeview {
> +namespace msf {
> template <> struct VarStreamArrayExtractor<pdb::ModInfo> {
> Error operator()(StreamRef Stream, uint32_t &Length,
> pdb::ModInfo &Info) const {
> @@ -73,7 +73,7 @@ template <> struct VarStreamArrayExtract
> return Error::success();
> }
> };
> -}
> +} // end namespace msf
>
> } // end namespace llvm
>
>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/ModStream.h Fri Jul 22 14:56:05 2016
> @@ -13,10 +13,10 @@
> #include "llvm/ADT/iterator_range.h"
> #include "llvm/DebugInfo/CodeView/CVRecord.h"
> #include "llvm/DebugInfo/CodeView/ModuleSubstream.h"
> -#include "llvm/DebugInfo/CodeView/StreamArray.h"
> -#include "llvm/DebugInfo/CodeView/StreamRef.h"
> #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
> -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
> +#include "llvm/DebugInfo/Msf/MappedBlockStream.h"
> +#include "llvm/DebugInfo/Msf/StreamArray.h"
> +#include "llvm/DebugInfo/Msf/StreamRef.h"
> #include "llvm/Support/Error.h"
>
> namespace llvm {
> @@ -26,7 +26,8 @@ class ModInfo;
>
> class ModStream {
> public:
> - ModStream(const ModInfo &Module, std::unique_ptr<MappedBlockStream> Stream);
> + ModStream(const ModInfo &Module,
> + std::unique_ptr<msf::MappedBlockStream> Stream);
> ~ModStream();
>
> Error reload();
> @@ -42,12 +43,12 @@ public:
> private:
> const ModInfo &Mod;
>
> - std::unique_ptr<MappedBlockStream> Stream;
> + std::unique_ptr<msf::MappedBlockStream> Stream;
>
> codeview::CVSymbolArray SymbolsSubstream;
> - codeview::StreamRef LinesSubstream;
> - codeview::StreamRef C13LinesSubstream;
> - codeview::StreamRef GlobalRefsSubstream;
> + msf::StreamRef LinesSubstream;
> + msf::StreamRef C13LinesSubstream;
> + msf::StreamRef GlobalRefsSubstream;
>
> codeview::ModuleSubstreamArray LineInfo;
> };
>
> Removed: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MsfBuilder.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MsfBuilder.h?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MsfBuilder.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MsfBuilder.h (removed)
> @@ -1,141 +0,0 @@
> -//===- MSFBuilder.h - MSF Directory & Metadata Builder ----------*- 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_PDB_RAW_MSFBUILDER_H
> -#define LLVM_DEBUGINFO_PDB_RAW_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/Support/Allocator.h"
> -#include "llvm/Support/Endian.h"
> -#include "llvm/Support/Error.h"
> -
> -#include <utility>
> -#include <vector>
> -
> -namespace llvm {
> -namespace pdb {
> -class MsfBuilder {
> -public:
> - /// \brief Create a new `MsfBuilder`.
> - ///
> - /// \param BlockSize The internal block size used by the PDB file. See
> - /// isValidBlockSize() for a list of valid block sizes.
> - ///
> - /// \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
> - /// 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
> - /// is possible, space for all blocks must be allocated beforehand so that
> - /// streams can be assigned to them.
> - ///
> - /// \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.
> - /// 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
> - /// it were to happen would catch a programming error
> - ///
> - /// \returns an llvm::Error representing whether the operation succeeded or
> - /// failed. Currently the only way this can fail is if an invalid block size
> - /// is specified, or `MinBlockCount` does not leave enough room for the
> - /// mandatory reserved blocks required by an MSF file.
> - static Expected<MsfBuilder> create(BumpPtrAllocator &Allocator,
> - uint32_t BlockSize,
> - uint32_t MinBlockCount = 0,
> - 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.
> - Error setBlockMapAddr(uint32_t Addr);
> - Error setDirectoryBlocksHint(ArrayRef<uint32_t> DirBlocks);
> - void setFreePageMap(uint32_t Fpm);
> - void setUnknown1(uint32_t Unk1);
> -
> - /// Add a stream to the MSF file with the given size, occupying the given
> - /// list of blocks. This is useful when reading a PDB file and you want a
> - /// 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.
> - Error addStream(uint32_t Size, ArrayRef<uint32_t> Blocks);
> -
> - /// Add a stream to the MSF file with the given size, occupying any available
> - /// blocks that the builder decides to use. This is useful when building a
> - /// new PDB file from scratch and you don't care what blocks a stream occupies
> - /// but you just want it to work.
> - Error addStream(uint32_t Size);
> -
> - /// Update the size of an existing stream. This will allocate or deallocate
> - /// blocks as needed to match the requested size. This can fail if `CanGrow`
> - /// was set to false when initializing the `MsfBuilder`.
> - Error setStreamSize(uint32_t Idx, uint32_t Size);
> -
> - /// Get the total number of streams in the MSF layout. This should return 1
> - /// for every call to `addStream`.
> - uint32_t getNumStreams() const;
> -
> - /// Get the size of a stream by index.
> - uint32_t getStreamSize(uint32_t StreamIdx) const;
> -
> - /// Get the list of blocks allocated to a particular stream.
> - ArrayRef<uint32_t> getStreamBlocks(uint32_t StreamIdx) const;
> -
> - /// Get the total number of blocks that will be allocated to actual data in
> - /// this MSF file.
> - uint32_t getNumUsedBlocks() const;
> -
> - /// Get the total number of blocks that exist in the MSF file but are not
> - /// allocated to any valid data.
> - uint32_t getNumFreeBlocks() const;
> -
> - /// Get the total number of blocks in the MSF file. In practice this is equal
> - /// to `getNumUsedBlocks() + getNumFreeBlocks()`.
> - uint32_t getTotalBlockCount() const;
> -
> - /// Check whether a particular block is allocated or free.
> - bool isBlockFree(uint32_t Idx) const;
> -
> - /// Finalize the layout and build the headers and structures that describe the
> - /// MSF layout and can be written directly to the MSF file.
> - Expected<msf::Layout> build();
> -
> -private:
> - MsfBuilder(uint32_t BlockSize, uint32_t MinBlockCount, bool CanGrow,
> - BumpPtrAllocator &Allocator);
> -
> - Error allocateBlocks(uint32_t NumBlocks, MutableArrayRef<uint32_t> Blocks);
> - uint32_t computeDirectoryByteSize() const;
> -
> - typedef std::vector<uint32_t> BlockList;
> -
> - BumpPtrAllocator &Allocator;
> -
> - bool IsGrowable;
> - uint32_t FreePageMap;
> - uint32_t Unknown1;
> - uint32_t BlockSize;
> - uint32_t MininumBlocks;
> - uint32_t BlockMapAddr;
> - BitVector FreeBlocks;
> - std::vector<uint32_t> DirectoryBlocks;
> - std::vector<std::pair<uint32_t, BlockList>> StreamData;
> -};
> -}
> -}
> -
> -#endif
>
> Removed: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MsfCommon.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MsfCommon.h?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MsfCommon.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/MsfCommon.h (removed)
> @@ -1,90 +0,0 @@
> -//===- MsfCommon.h - Common types and functions 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_PDB_RAW_MSFCOMMON_H
> -#define LLVM_DEBUGINFO_PDB_RAW_MSFCOMMON_H
> -
> -#include "llvm/ADT/ArrayRef.h"
> -
> -#include "llvm/Support/Endian.h"
> -#include "llvm/Support/Error.h"
> -#include "llvm/Support/MathExtras.h"
> -
> -#include <vector>
> -
> -namespace llvm {
> -namespace pdb {
> -namespace msf {
> -static const char Magic[] = {'M', 'i', 'c', 'r', 'o', 's', 'o', 'f',
> - 't', ' ', 'C', '/', 'C', '+', '+', ' ',
> - 'M', 'S', 'F', ' ', '7', '.', '0', '0',
> - '\r', '\n', '\x1a', 'D', 'S', '\0', '\0', '\0'};
> -
> -// The superblock is overlaid at the beginning of the file (offset 0).
> -// It starts with a magic header and is followed by information which
> -// describes the layout of the file system.
> -struct SuperBlock {
> - char MagicBytes[sizeof(Magic)];
> - // The file system is split into a variable number of fixed size elements.
> - // These elements are referred to as blocks. The size of a block may vary
> - // from system to system.
> - support::ulittle32_t BlockSize;
> - // 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
> - // file.
> - support::ulittle32_t NumBlocks;
> - // This contains the number of bytes which make up the directory.
> - support::ulittle32_t NumDirectoryBytes;
> - // This field's purpose is not yet known.
> - support::ulittle32_t Unknown1;
> - // This contains the block # of the block map.
> - support::ulittle32_t BlockMapAddr;
> -};
> -
> -struct Layout {
> - SuperBlock *SB;
> - ArrayRef<support::ulittle32_t> DirectoryBlocks;
> - ArrayRef<support::ulittle32_t> StreamSizes;
> - std::vector<ArrayRef<support::ulittle32_t>> StreamMap;
> -};
> -
> -inline bool isValidBlockSize(uint32_t Size) {
> - switch (Size) {
> - case 512:
> - case 1024:
> - case 2048:
> - case 4096:
> - return true;
> - }
> - return false;
> -}
> -
> -// Super Block, Fpm0, Fpm1, and Block Map
> -inline uint32_t getMinimumBlockCount() { return 4; }
> -
> -// Super Block, Fpm0, and Fpm1 are reserved. The Block Map, although required
> -// need not be at block 3.
> -inline uint32_t getFirstUnreservedBlock() { return 3; }
> -
> -inline uint64_t bytesToBlocks(uint64_t NumBytes, uint64_t BlockSize) {
> - return alignTo(NumBytes, BlockSize) / BlockSize;
> -}
> -
> -inline uint64_t blockToOffset(uint64_t BlockNumber, uint64_t BlockSize) {
> - return BlockNumber * BlockSize;
> -}
> -
> -Error validateSuperBlock(const SuperBlock &SB);
> -}
> -}
> -}
> -
> -#endif
>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameHashTable.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameHashTable.h?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameHashTable.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameHashTable.h Fri Jul 22 14:56:05 2016
> @@ -12,15 +12,15 @@
>
> #include "llvm/ADT/ArrayRef.h"
> #include "llvm/ADT/StringRef.h"
> -#include "llvm/DebugInfo/CodeView/StreamArray.h"
> -#include "llvm/DebugInfo/CodeView/StreamRef.h"
> +#include "llvm/DebugInfo/Msf/StreamArray.h"
> +#include "llvm/DebugInfo/Msf/StreamRef.h"
> #include "llvm/Support/Endian.h"
> #include "llvm/Support/Error.h"
> #include <cstdint>
> #include <vector>
>
> namespace llvm {
> -namespace codeview {
> +namespace msf {
> class StreamReader;
> }
> namespace pdb {
> @@ -29,7 +29,7 @@ class NameHashTable {
> public:
> NameHashTable();
>
> - Error load(codeview::StreamReader &Stream);
> + Error load(msf::StreamReader &Stream);
>
> uint32_t getNameCount() const { return NameCount; }
> uint32_t getHashVersion() const { return HashVersion; }
> @@ -38,11 +38,11 @@ public:
> StringRef getStringForID(uint32_t ID) const;
> uint32_t getIDForString(StringRef Str) const;
>
> - codeview::FixedStreamArray<support::ulittle32_t> name_ids() const;
> + msf::FixedStreamArray<support::ulittle32_t> name_ids() const;
>
> private:
> - codeview::StreamRef NamesBuffer;
> - codeview::FixedStreamArray<support::ulittle32_t> IDs;
> + msf::StreamRef NamesBuffer;
> + msf::FixedStreamArray<support::ulittle32_t> IDs;
> uint32_t Signature;
> uint32_t HashVersion;
> uint32_t NameCount;
>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameMap.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameMap.h?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameMap.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/NameMap.h Fri Jul 22 14:56:05 2016
> @@ -16,7 +16,7 @@
> #include <cstdint>
>
> namespace llvm {
> -namespace codeview {
> +namespace msf {
> class StreamReader;
> class StreamWriter;
> }
> @@ -28,8 +28,8 @@ class NameMap {
> public:
> NameMap();
>
> - Error load(codeview::StreamReader &Stream);
> - Error commit(codeview::StreamWriter &Writer);
> + Error load(msf::StreamReader &Stream);
> + Error commit(msf::StreamWriter &Writer);
>
> bool tryGetValue(StringRef Name, uint32_t &Value) const;
>
>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFile.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFile.h?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFile.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFile.h Fri Jul 22 14:56:05 2016
> @@ -11,10 +11,10 @@
> #define LLVM_DEBUGINFO_PDB_RAW_PDBFILE_H
>
> #include "llvm/ADT/DenseMap.h"
> -#include "llvm/DebugInfo/CodeView/StreamArray.h"
> -#include "llvm/DebugInfo/CodeView/StreamInterface.h"
> -#include "llvm/DebugInfo/PDB/Raw/IPDBFile.h"
> -#include "llvm/DebugInfo/PDB/Raw/MsfCommon.h"
> +#include "llvm/DebugInfo/Msf/IMsfFile.h"
> +#include "llvm/DebugInfo/Msf/MsfCommon.h"
> +#include "llvm/DebugInfo/Msf/StreamArray.h"
> +#include "llvm/DebugInfo/Msf/StreamInterface.h"
> #include "llvm/Support/Allocator.h"
> #include "llvm/Support/Endian.h"
> #include "llvm/Support/Error.h"
> @@ -24,25 +24,25 @@
>
> namespace llvm {
>
> -namespace codeview {
> +namespace msf {
> +class MappedBlockStream;
> class StreamInterface;
> }
>
> namespace pdb {
> class DbiStream;
> class InfoStream;
> -class MappedBlockStream;
> class NameHashTable;
> class PDBFileBuilder;
> class PublicsStream;
> class SymbolStream;
> class TpiStream;
>
> -class PDBFile : public IPDBFile {
> +class PDBFile : public msf::IMsfFile {
> friend PDBFileBuilder;
>
> public:
> - explicit PDBFile(std::unique_ptr<codeview::StreamInterface> PdbFileBuffer);
> + explicit PDBFile(std::unique_ptr<msf::StreamInterface> PdbFileBuffer);
> ~PDBFile() override;
>
> uint32_t getFreeBlockMapBlock() const;
> @@ -91,7 +91,7 @@ private:
>
> BumpPtrAllocator Allocator;
>
> - std::unique_ptr<codeview::StreamInterface> Buffer;
> + std::unique_ptr<msf::StreamInterface> Buffer;
> const msf::SuperBlock *SB;
> ArrayRef<support::ulittle32_t> StreamSizes;
> ArrayRef<support::ulittle32_t> DirectoryBlocks;
> @@ -103,8 +103,8 @@ private:
> std::unique_ptr<TpiStream> Ipi;
> std::unique_ptr<PublicsStream> Publics;
> std::unique_ptr<SymbolStream> Symbols;
> - std::unique_ptr<MappedBlockStream> DirectoryStream;
> - std::unique_ptr<MappedBlockStream> StringTableStream;
> + std::unique_ptr<msf::MappedBlockStream> DirectoryStream;
> + std::unique_ptr<msf::MappedBlockStream> StringTableStream;
> std::unique_ptr<NameHashTable> StringTable;
> };
> }
>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h Fri Jul 22 14:56:05 2016
> @@ -13,17 +13,16 @@
> #include "llvm/ADT/ArrayRef.h"
> #include "llvm/ADT/BitVector.h"
> #include "llvm/ADT/Optional.h"
> +#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
> #include "llvm/Support/Endian.h"
> #include "llvm/Support/Error.h"
>
> -#include "llvm/DebugInfo/PDB/Raw/MsfBuilder.h"
> -#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
> -
> #include <memory>
> #include <vector>
>
> namespace llvm {
> -namespace codeview {
> +namespace msf {
> +class MsfBuilder;
> class StreamInterface;
> }
> namespace pdb {
> @@ -33,14 +32,13 @@ class PDBFile;
>
> class PDBFileBuilder {
> public:
> - explicit PDBFileBuilder(
> - std::unique_ptr<codeview::StreamInterface> FileBuffer);
> + explicit PDBFileBuilder(std::unique_ptr<msf::StreamInterface> FileBuffer);
> PDBFileBuilder(const PDBFileBuilder &) = delete;
> PDBFileBuilder &operator=(const PDBFileBuilder &) = delete;
>
> Error initialize(const msf::SuperBlock &Super);
>
> - MsfBuilder &getMsfBuilder();
> + msf::MsfBuilder &getMsfBuilder();
> InfoStreamBuilder &getInfoBuilder();
> DbiStreamBuilder &getDbiBuilder();
>
> @@ -51,7 +49,7 @@ private:
> std::unique_ptr<DbiStreamBuilder> Dbi;
>
> std::unique_ptr<PDBFile> File;
> - std::unique_ptr<MsfBuilder> Msf;
> + std::unique_ptr<msf::MsfBuilder> Msf;
> };
> }
> }
>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PublicsStream.h Fri Jul 22 14:56:05 2016
> @@ -10,10 +10,10 @@
> #ifndef LLVM_DEBUGINFO_PDB_RAW_PUBLICSSTREAM_H
> #define LLVM_DEBUGINFO_PDB_RAW_PUBLICSSTREAM_H
>
> -#include "llvm/DebugInfo/CodeView/StreamArray.h"
> #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
> +#include "llvm/DebugInfo/Msf/MappedBlockStream.h"
> +#include "llvm/DebugInfo/Msf/StreamArray.h"
> #include "llvm/DebugInfo/PDB/PDBTypes.h"
> -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
> #include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
> #include "llvm/DebugInfo/PDB/Raw/RawTypes.h"
>
> @@ -29,7 +29,7 @@ class PublicsStream {
> struct HeaderInfo;
>
> public:
> - PublicsStream(PDBFile &File, std::unique_ptr<MappedBlockStream> Stream);
> + PublicsStream(PDBFile &File, std::unique_ptr<msf::MappedBlockStream> Stream);
> ~PublicsStream();
> Error reload();
>
> @@ -38,16 +38,16 @@ public:
> uint32_t getNumBuckets() const { return NumBuckets; }
> iterator_range<codeview::CVSymbolArray::Iterator>
> getSymbols(bool *HadError) const;
> - codeview::FixedStreamArray<support::ulittle32_t> getHashBuckets() const {
> + msf::FixedStreamArray<support::ulittle32_t> getHashBuckets() const {
> return HashBuckets;
> }
> - codeview::FixedStreamArray<support::ulittle32_t> getAddressMap() const {
> + msf::FixedStreamArray<support::ulittle32_t> getAddressMap() const {
> return AddressMap;
> }
> - codeview::FixedStreamArray<support::ulittle32_t> getThunkMap() const {
> + msf::FixedStreamArray<support::ulittle32_t> getThunkMap() const {
> return ThunkMap;
> }
> - codeview::FixedStreamArray<SectionOffset> getSectionOffsets() const {
> + msf::FixedStreamArray<SectionOffset> getSectionOffsets() const {
> return SectionOffsets;
> }
>
> @@ -56,14 +56,14 @@ public:
> private:
> PDBFile &Pdb;
>
> - std::unique_ptr<MappedBlockStream> Stream;
> + std::unique_ptr<msf::MappedBlockStream> Stream;
> uint32_t NumBuckets = 0;
> ArrayRef<uint8_t> Bitmap;
> - codeview::FixedStreamArray<PSHashRecord> HashRecords;
> - codeview::FixedStreamArray<support::ulittle32_t> HashBuckets;
> - codeview::FixedStreamArray<support::ulittle32_t> AddressMap;
> - codeview::FixedStreamArray<support::ulittle32_t> ThunkMap;
> - codeview::FixedStreamArray<SectionOffset> SectionOffsets;
> + msf::FixedStreamArray<PSHashRecord> HashRecords;
> + msf::FixedStreamArray<support::ulittle32_t> HashBuckets;
> + msf::FixedStreamArray<support::ulittle32_t> AddressMap;
> + msf::FixedStreamArray<support::ulittle32_t> ThunkMap;
> + msf::FixedStreamArray<SectionOffset> SectionOffsets;
>
> const HeaderInfo *Header;
> const GSIHashHeader *HashHdr;
>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/SymbolStream.h Fri Jul 22 14:56:05 2016
> @@ -10,19 +10,20 @@
> #ifndef LLVM_DEBUGINFO_PDB_RAW_PDBSYMBOLSTREAM_H
> #define LLVM_DEBUGINFO_PDB_RAW_PDBSYMBOLSTREAM_H
>
> -#include "llvm/DebugInfo/CodeView/StreamArray.h"
> #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
> -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
>
> #include "llvm/Support/Error.h"
>
> namespace llvm {
> +namespace msf {
> +class MappedBlockStream;
> +}
> namespace pdb {
> class PDBFile;
>
> class SymbolStream {
> public:
> - SymbolStream(std::unique_ptr<MappedBlockStream> Stream);
> + SymbolStream(std::unique_ptr<msf::MappedBlockStream> Stream);
> ~SymbolStream();
> Error reload();
>
> @@ -33,7 +34,7 @@ public:
>
> private:
> codeview::CVSymbolArray SymbolRecords;
> - std::unique_ptr<MappedBlockStream> Stream;
> + std::unique_ptr<msf::MappedBlockStream> Stream;
> };
> }
> }
>
> Modified: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h (original)
> +++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/TpiStream.h Fri Jul 22 14:56:05 2016
> @@ -10,11 +10,9 @@
> #ifndef LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAM_H
> #define LLVM_DEBUGINFO_PDB_RAW_PDBTPISTREAM_H
>
> -#include "llvm/DebugInfo/CodeView/StreamArray.h"
> -#include "llvm/DebugInfo/CodeView/StreamRef.h"
> #include "llvm/DebugInfo/CodeView/TypeRecord.h"
> +#include "llvm/DebugInfo/Msf/StreamArray.h"
> #include "llvm/DebugInfo/PDB/PDBTypes.h"
> -#include "llvm/DebugInfo/PDB/Raw/MappedBlockStream.h"
> #include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
> #include "llvm/DebugInfo/PDB/Raw/RawTypes.h"
> #include "llvm/Support/raw_ostream.h"
> @@ -22,6 +20,9 @@
> #include "llvm/Support/Error.h"
>
> namespace llvm {
> +namespace msf {
> +class MappedBlockStream;
> +}
> namespace pdb {
> class PDBFile;
>
> @@ -29,7 +30,8 @@ class TpiStream {
> struct HeaderInfo;
>
> public:
> - TpiStream(const PDBFile &File, std::unique_ptr<MappedBlockStream> Stream);
> + TpiStream(const PDBFile &File,
> + std::unique_ptr<msf::MappedBlockStream> Stream);
> ~TpiStream();
> Error reload();
>
> @@ -43,9 +45,9 @@ public:
>
> uint32_t getHashKeySize() const;
> uint32_t NumHashBuckets() const;
> - codeview::FixedStreamArray<support::ulittle32_t> getHashValues() const;
> - codeview::FixedStreamArray<TypeIndexOffset> getTypeIndexOffsets() const;
> - codeview::FixedStreamArray<TypeIndexOffset> getHashAdjustments() const;
> + msf::FixedStreamArray<support::ulittle32_t> getHashValues() const;
> + msf::FixedStreamArray<TypeIndexOffset> getTypeIndexOffsets() const;
> + msf::FixedStreamArray<TypeIndexOffset> getHashAdjustments() const;
>
> iterator_range<codeview::CVTypeArray::Iterator> types(bool *HadError) const;
>
> @@ -55,14 +57,14 @@ private:
> Error verifyHashValues();
>
> const PDBFile &Pdb;
> - std::unique_ptr<MappedBlockStream> Stream;
> + std::unique_ptr<msf::MappedBlockStream> Stream;
>
> codeview::CVTypeArray TypeRecords;
>
> - std::unique_ptr<MappedBlockStream> HashStream;
> - codeview::FixedStreamArray<support::ulittle32_t> HashValues;
> - codeview::FixedStreamArray<TypeIndexOffset> TypeIndexOffsets;
> - codeview::FixedStreamArray<TypeIndexOffset> HashAdjustments;
> + std::unique_ptr<msf::MappedBlockStream> HashStream;
> + msf::FixedStreamArray<support::ulittle32_t> HashValues;
> + msf::FixedStreamArray<TypeIndexOffset> TypeIndexOffsets;
> + msf::FixedStreamArray<TypeIndexOffset> HashAdjustments;
>
> const HeaderInfo *Header;
> };
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Fri Jul 22 14:56:05 2016
> @@ -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) {
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/LLVMBuild.txt
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/LLVMBuild.txt?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/LLVMBuild.txt (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/LLVMBuild.txt Fri Jul 22 14:56:05 2016
> @@ -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
>
> Modified: llvm/trunk/lib/DebugInfo/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CMakeLists.txt?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/CMakeLists.txt (original)
> +++ llvm/trunk/lib/DebugInfo/CMakeLists.txt Fri Jul 22 14:56:05 2016
> @@ -1,4 +1,5 @@
> -add_subdirectory(CodeView)
> add_subdirectory(DWARF)
> +add_subdirectory(Msf)
> +add_subdirectory(CodeView)
> add_subdirectory(PDB)
> add_subdirectory(Symbolize)
>
> Removed: llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp (removed)
> @@ -1,79 +0,0 @@
> -//===- ByteStream.cpp - Reads stream data from a byte sequence ------------===//
> -//
> -// The LLVM Compiler Infrastructure
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
> -//===----------------------------------------------------------------------===//
> -
> -#include "llvm/DebugInfo/CodeView/ByteStream.h"
> -#include "llvm/DebugInfo/CodeView/CodeViewError.h"
> -#include "llvm/DebugInfo/CodeView/StreamReader.h"
> -#include <cstring>
> -
> -using namespace llvm;
> -using namespace llvm::codeview;
> -
> -static Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Src,
> - ArrayRef<uint8_t> Dest) {
> - return make_error<CodeViewError>(cv_error_code::operation_unsupported,
> - "ByteStream is immutable.");
> -}
> -
> -static Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Src,
> - MutableArrayRef<uint8_t> Dest) {
> - if (Dest.size() < Src.size())
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> - if (Offset > Src.size() - Dest.size())
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> -
> - ::memcpy(Dest.data() + Offset, Src.data(), Src.size());
> - return Error::success();
> -}
> -
> -template <bool Writable>
> -Error ByteStream<Writable>::readBytes(uint32_t Offset, uint32_t Size,
> - ArrayRef<uint8_t> &Buffer) const {
> - if (Offset > Data.size())
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> - if (Data.size() < Size + Offset)
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> - Buffer = Data.slice(Offset, Size);
> - return Error::success();
> -}
> -
> -template <bool Writable>
> -Error ByteStream<Writable>::readLongestContiguousChunk(
> - uint32_t Offset, ArrayRef<uint8_t> &Buffer) const {
> - if (Offset >= Data.size())
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> - Buffer = Data.slice(Offset);
> - return Error::success();
> -}
> -
> -template <bool Writable>
> -Error ByteStream<Writable>::writeBytes(uint32_t Offset,
> - ArrayRef<uint8_t> Buffer) const {
> - return ::writeBytes(Offset, Buffer, Data);
> -}
> -
> -template <bool Writable> uint32_t ByteStream<Writable>::getLength() const {
> - return Data.size();
> -}
> -
> -template <bool Writable> Error ByteStream<Writable>::commit() const {
> - return Error::success();
> -}
> -
> -template <bool Writable> StringRef ByteStream<Writable>::str() const {
> - const char *CharData = reinterpret_cast<const char *>(Data.data());
> - return StringRef(CharData, Data.size());
> -}
> -
> -namespace llvm {
> -namespace codeview {
> -template class ByteStream<true>;
> -template class ByteStream<false>;
> -}
> -}
>
> Modified: llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt (original)
> +++ llvm/trunk/lib/DebugInfo/CodeView/CMakeLists.txt Fri Jul 22 14:56:05 2016
> @@ -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
>
> Modified: llvm/trunk/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/CVTypeVisitor.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/CodeView/CVTypeVisitor.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/CodeView/CVTypeVisitor.cpp Fri Jul 22 14:56:05 2016
> @@ -8,6 +8,7 @@
> //===----------------------------------------------------------------------===//
>
> #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
> +#include "llvm/DebugInfo/CodeView/CodeViewError.h"
>
> using namespace llvm;
> using namespace llvm::codeview;
>
> Modified: llvm/trunk/lib/DebugInfo/CodeView/LLVMBuild.txt
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/LLVMBuild.txt?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/CodeView/LLVMBuild.txt (original)
> +++ llvm/trunk/lib/DebugInfo/CodeView/LLVMBuild.txt Fri Jul 22 14:56:05 2016
> @@ -19,4 +19,4 @@
> type = Library
> name = DebugInfoCodeView
> parent = DebugInfo
> -required_libraries = Support
> +required_libraries = Support DebugInfoMsf
>
> Modified: llvm/trunk/lib/DebugInfo/CodeView/ModuleSubstream.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ModuleSubstream.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/CodeView/ModuleSubstream.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/CodeView/ModuleSubstream.cpp Fri Jul 22 14:56:05 2016
> @@ -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) {}
>
>
> Modified: llvm/trunk/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/CodeView/ModuleSubstreamVisitor.cpp Fri Jul 22 14:56:05 2016
> @@ -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);
>
> Removed: llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp (removed)
> @@ -1,93 +0,0 @@
> -//===- StreamReader.cpp - Reads bytes and objects from a stream -----------===//
> -//
> -// The LLVM Compiler Infrastructure
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
> -//===----------------------------------------------------------------------===//
> -
> -#include "llvm/DebugInfo/CodeView/StreamReader.h"
> -
> -#include "llvm/DebugInfo/CodeView/CodeViewError.h"
> -#include "llvm/DebugInfo/CodeView/StreamRef.h"
> -
> -using namespace llvm;
> -using namespace llvm::codeview;
> -
> -StreamReader::StreamReader(StreamRef S) : Stream(S), Offset(0) {}
> -
> -Error StreamReader::readLongestContiguousChunk(ArrayRef<uint8_t> &Buffer) {
> - if (auto EC = Stream.readLongestContiguousChunk(Offset, Buffer))
> - return EC;
> - Offset += Buffer.size();
> - return Error::success();
> -}
> -
> -Error StreamReader::readBytes(ArrayRef<uint8_t> &Buffer, uint32_t Size) {
> - if (auto EC = Stream.readBytes(Offset, Size, Buffer))
> - return EC;
> - Offset += Size;
> - return Error::success();
> -}
> -
> -Error StreamReader::readInteger(uint16_t &Dest) {
> - const support::ulittle16_t *P;
> - if (auto EC = readObject(P))
> - return EC;
> - Dest = *P;
> - return Error::success();
> -}
> -
> -Error StreamReader::readInteger(uint32_t &Dest) {
> - const support::ulittle32_t *P;
> - if (auto EC = readObject(P))
> - return EC;
> - Dest = *P;
> - return Error::success();
> -}
> -
> -Error StreamReader::readZeroString(StringRef &Dest) {
> - uint32_t Length = 0;
> - // First compute the length of the string by reading 1 byte at a time.
> - uint32_t OriginalOffset = getOffset();
> - const char *C;
> - do {
> - if (auto EC = readObject(C))
> - return EC;
> - if (*C != '\0')
> - ++Length;
> - } while (*C != '\0');
> - // Now go back and request a reference for that many bytes.
> - uint32_t NewOffset = getOffset();
> - setOffset(OriginalOffset);
> -
> - ArrayRef<uint8_t> Data;
> - if (auto EC = readBytes(Data, Length))
> - return EC;
> - Dest = StringRef(reinterpret_cast<const char *>(Data.begin()), Data.size());
> -
> - // Now set the offset back to where it was after we calculated the length.
> - setOffset(NewOffset);
> - return Error::success();
> -}
> -
> -Error StreamReader::readFixedString(StringRef &Dest, uint32_t Length) {
> - ArrayRef<uint8_t> Bytes;
> - if (auto EC = readBytes(Bytes, Length))
> - return EC;
> - Dest = StringRef(reinterpret_cast<const char *>(Bytes.begin()), Bytes.size());
> - return Error::success();
> -}
> -
> -Error StreamReader::readStreamRef(StreamRef &Ref) {
> - return readStreamRef(Ref, bytesRemaining());
> -}
> -
> -Error StreamReader::readStreamRef(StreamRef &Ref, uint32_t Length) {
> - if (bytesRemaining() < Length)
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> - Ref = Stream.slice(Offset, Length);
> - Offset += Length;
> - return Error::success();
> -}
>
> Removed: llvm/trunk/lib/DebugInfo/CodeView/StreamWriter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/StreamWriter.cpp?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/CodeView/StreamWriter.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/CodeView/StreamWriter.cpp (removed)
> @@ -1,78 +0,0 @@
> -//===- StreamWrite.cpp - Writes bytes and objects to a stream -------------===//
> -//
> -// The LLVM Compiler Infrastructure
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
> -//===----------------------------------------------------------------------===//
> -
> -#include "llvm/DebugInfo/CodeView/StreamWriter.h"
> -
> -#include "llvm/DebugInfo/CodeView/CodeViewError.h"
> -#include "llvm/DebugInfo/CodeView/StreamReader.h"
> -#include "llvm/DebugInfo/CodeView/StreamRef.h"
> -
> -using namespace llvm;
> -using namespace llvm::codeview;
> -
> -StreamWriter::StreamWriter(StreamRef S) : Stream(S), Offset(0) {}
> -
> -Error StreamWriter::writeBytes(ArrayRef<uint8_t> Buffer) {
> - if (auto EC = Stream.writeBytes(Offset, Buffer))
> - return EC;
> - Offset += Buffer.size();
> - return Error::success();
> -}
> -
> -Error StreamWriter::writeInteger(uint16_t Int) {
> - return writeObject(support::ulittle16_t(Int));
> -}
> -
> -Error StreamWriter::writeInteger(uint32_t Int) {
> - return writeObject(support::ulittle32_t(Int));
> -}
> -
> -Error StreamWriter::writeZeroString(StringRef Str) {
> - if (auto EC = writeFixedString(Str))
> - return EC;
> - if (auto EC = writeObject('\0'))
> - return EC;
> -
> - return Error::success();
> -}
> -
> -Error StreamWriter::writeFixedString(StringRef Str) {
> - ArrayRef<uint8_t> Bytes(Str.bytes_begin(), Str.bytes_end());
> - if (auto EC = Stream.writeBytes(Offset, Bytes))
> - return EC;
> -
> - Offset += Str.size();
> - return Error::success();
> -}
> -
> -Error StreamWriter::writeStreamRef(StreamRef Ref) {
> - if (auto EC = writeStreamRef(Ref, Ref.getLength()))
> - return EC;
> - // Don't increment Offset here, it is done by the overloaded call to
> - // writeStreamRef.
> - return Error::success();
> -}
> -
> -Error StreamWriter::writeStreamRef(StreamRef Ref, uint32_t Length) {
> - Ref = Ref.slice(0, Length);
> -
> - StreamReader SrcReader(Ref);
> - // This is a bit tricky. If we just call readBytes, we are requiring that it
> - // return us the entire stream as a contiguous buffer. For large streams this
> - // will allocate a huge amount of space from the pool. Instead, iterate over
> - // each contiguous chunk until we've consumed the entire stream.
> - while (SrcReader.bytesRemaining() > 0) {
> - ArrayRef<uint8_t> Chunk;
> - if (auto EC = SrcReader.readLongestContiguousChunk(Chunk))
> - return EC;
> - if (auto EC = writeBytes(Chunk))
> - return EC;
> - }
> - return Error::success();
> -}
>
> Modified: llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/CodeView/TypeDumper.cpp Fri Jul 22 14:56:05 2016
> @@ -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 CVTypeArr
> }
>
> Error CVTypeDumper::dump(ArrayRef<uint8_t> 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;
>
>
> Modified: llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/CodeView/TypeStreamMerger.cpp Fri Jul 22 14:56:05 2016
> @@ -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"
>
> Modified: llvm/trunk/lib/DebugInfo/LLVMBuild.txt
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/LLVMBuild.txt?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/LLVMBuild.txt (original)
> +++ llvm/trunk/lib/DebugInfo/LLVMBuild.txt Fri Jul 22 14:56:05 2016
> @@ -16,7 +16,7 @@
> ;===------------------------------------------------------------------------===;
>
> [common]
> -subdirectories = CodeView DWARF PDB Symbolize
> +subdirectories = DWARF Msf CodeView PDB Symbolize
>
> [component_0]
> type = Group
>
> Copied: llvm/trunk/lib/DebugInfo/Msf/ByteStream.cpp (from r276457, llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Msf/ByteStream.cpp?p2=llvm/trunk/lib/DebugInfo/Msf/ByteStream.cpp&p1=llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/CodeView/ByteStream.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/Msf/ByteStream.cpp Fri Jul 22 14:56:05 2016
> @@ -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 <cstring>
>
> using namespace llvm;
> -using namespace llvm::codeview;
> +using namespace llvm::msf;
>
> static Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Src,
> ArrayRef<uint8_t> Dest) {
> - return make_error<CodeViewError>(cv_error_code::operation_unsupported,
> - "ByteStream is immutable.");
> + return make_error<MsfError>(msf_error_code::not_writable,
> + "ByteStream is immutable.");
> }
>
> static Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Src,
> MutableArrayRef<uint8_t> Dest) {
> if (Dest.size() < Src.size())
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
> if (Offset > Src.size() - Dest.size())
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
>
> ::memcpy(Dest.data() + Offset, Src.data(), Src.size());
> return Error::success();
> @@ -36,9 +36,9 @@ template <bool Writable>
> Error ByteStream<Writable>::readBytes(uint32_t Offset, uint32_t Size,
> ArrayRef<uint8_t> &Buffer) const {
> if (Offset > Data.size())
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
> if (Data.size() < Size + Offset)
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
> Buffer = Data.slice(Offset, Size);
> return Error::success();
> }
> @@ -47,7 +47,7 @@ template <bool Writable>
> Error ByteStream<Writable>::readLongestContiguousChunk(
> uint32_t Offset, ArrayRef<uint8_t> &Buffer) const {
> if (Offset >= Data.size())
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
> Buffer = Data.slice(Offset);
> return Error::success();
> }
> @@ -72,7 +72,7 @@ template <bool Writable> StringRef ByteS
> }
>
> namespace llvm {
> -namespace codeview {
> +namespace msf {
> template class ByteStream<true>;
> template class ByteStream<false>;
> }
>
> Added: llvm/trunk/lib/DebugInfo/Msf/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Msf/CMakeLists.txt?rev=276458&view=auto
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/Msf/CMakeLists.txt (added)
> +++ llvm/trunk/lib/DebugInfo/Msf/CMakeLists.txt Fri Jul 22 14:56:05 2016
> @@ -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"
> + )
>
> Copied: llvm/trunk/lib/DebugInfo/Msf/IndexedStreamData.cpp (from r276457, llvm/trunk/lib/DebugInfo/PDB/Raw/IndexedStreamData.cpp)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Msf/IndexedStreamData.cpp?p2=llvm/trunk/lib/DebugInfo/Msf/IndexedStreamData.cpp&p1=llvm/trunk/lib/DebugInfo/PDB/Raw/IndexedStreamData.cpp&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/IndexedStreamData.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/Msf/IndexedStreamData.cpp Fri Jul 22 14:56:05 2016
> @@ -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() {
>
> Copied: llvm/trunk/lib/DebugInfo/Msf/LLVMBuild.txt (from r276457, llvm/trunk/lib/DebugInfo/CodeView/LLVMBuild.txt)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Msf/LLVMBuild.txt?p2=llvm/trunk/lib/DebugInfo/Msf/LLVMBuild.txt&p1=llvm/trunk/lib/DebugInfo/CodeView/LLVMBuild.txt&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/CodeView/LLVMBuild.txt (original)
> +++ llvm/trunk/lib/DebugInfo/Msf/LLVMBuild.txt Fri Jul 22 14:56:05 2016
> @@ -1,4 +1,4 @@
> -;===- ./lib/DebugInfo/CodeView/LLVMBuild.txt -------------------*- Conf -*--===;
> +;===- ./lib/DebugInfo/Msf/LLVMBuild.txt -------------------*- Conf -*--===;
> ;
> ; The LLVM Compiler Infrastructure
> ;
> @@ -17,6 +17,6 @@
>
> [component_0]
> type = Library
> -name = DebugInfoCodeView
> +name = DebugInfoMsf
> parent = DebugInfo
> required_libraries = Support
>
> Copied: llvm/trunk/lib/DebugInfo/Msf/MappedBlockStream.cpp (from r276457, llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Msf/MappedBlockStream.cpp?p2=llvm/trunk/lib/DebugInfo/Msf/MappedBlockStream.cpp&p1=llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/Msf/MappedBlockStream.cpp Fri Jul 22 14:56:05 2016
> @@ -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<IPDBStreamData> Data,
> - const IPDBFile &File)
> + MappedBlockStreamImpl(std::unique_ptr<IMsfStreamData> Data,
> + const IMsfFile &File)
> : MappedBlockStream(std::move(Data), File) {}
> };
> }
> @@ -35,17 +34,17 @@ static Interval intersect(const Interval
> std::min(I1.second, I2.second));
> }
>
> -MappedBlockStream::MappedBlockStream(std::unique_ptr<IPDBStreamData> Data,
> - const IPDBFile &Pdb)
> - : Pdb(Pdb), Data(std::move(Data)) {}
> +MappedBlockStream::MappedBlockStream(std::unique_ptr<IMsfStreamData> Data,
> + const IMsfFile &File)
> + : Msf(File), Data(std::move(Data)) {}
>
> Error MappedBlockStream::readBytes(uint32_t Offset, uint32_t Size,
> ArrayRef<uint8_t> &Buffer) const {
> // Make sure we aren't trying to read beyond the end of the stream.
> if (Size > Data->getLength())
> - return make_error<RawError>(raw_error_code::insufficient_buffer);
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
> if (Offset > Data->getLength() - Size)
> - return make_error<RawError>(raw_error_code::insufficient_buffer);
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
>
> if (tryReadContiguously(Offset, Size, Buffer))
> return Error::success();
> @@ -123,23 +122,23 @@ Error MappedBlockStream::readLongestCont
> uint32_t Offset, ArrayRef<uint8_t> &Buffer) const {
> // Make sure we aren't trying to read beyond the end of the stream.
> if (Offset >= Data->getLength())
> - return make_error<RawError>(raw_error_code::insufficient_buffer);
> - uint32_t First = Offset / Pdb.getBlockSize();
> + return make_error<MsfError>(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::tryReadContiguou
> // 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::tryReadContiguou
> }
>
> 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::tryReadContiguou
>
> Error MappedBlockStream::readBytes(uint32_t Offset,
> MutableArrayRef<uint8_t> 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<RawError>(raw_error_code::insufficient_buffer);
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
> if (Offset > Data->getLength() - Buffer.size())
> - return make_error<RawError>(raw_error_code::insufficient_buffer);
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
>
> uint32_t BytesLeft = Buffer.size();
> uint32_t BytesWritten = 0;
> @@ -203,14 +202,14 @@ Error MappedBlockStream::readBytes(uint3
> 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(uint
> ArrayRef<uint8_t> Buffer) const {
> // Make sure we aren't trying to write beyond the end of the stream.
> if (Buffer.size() > Data->getLength())
> - return make_error<RawError>(raw_error_code::insufficient_buffer);
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
>
> if (Offset > Data->getLength() - Buffer.size())
> - return make_error<RawError>(raw_error_code::insufficient_buffer);
> + return make_error<MsfError>(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(uint
> 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<uint8_t> 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::getNumBytesC
>
> Expected<std::unique_ptr<MappedBlockStream>>
> MappedBlockStream::createIndexedStream(uint32_t StreamIdx,
> - const IPDBFile &File) {
> + const IMsfFile &File) {
> if (StreamIdx >= File.getNumStreams())
> - return make_error<RawError>(raw_error_code::no_stream);
> + return make_error<MsfError>(msf_error_code::no_stream);
>
> auto Data = llvm::make_unique<IndexedStreamData>(StreamIdx, File);
> return llvm::make_unique<MappedBlockStreamImpl>(std::move(Data), File);
> }
>
> Expected<std::unique_ptr<MappedBlockStream>>
> -MappedBlockStream::createDirectoryStream(const PDBFile &File) {
> - auto Data = llvm::make_unique<DirectoryStreamData>(File);
> +MappedBlockStream::createDirectoryStream(uint32_t Length,
> + ArrayRef<support::ulittle32_t> Blocks,
> + const IMsfFile &File) {
> + auto Data = llvm::make_unique<DirectoryStreamData>(Length, Blocks);
> return llvm::make_unique<MappedBlockStreamImpl>(std::move(Data), File);
> }
>
> Copied: llvm/trunk/lib/DebugInfo/Msf/MsfBuilder.cpp (from r276457, llvm/trunk/lib/DebugInfo/PDB/Raw/MsfBuilder.cpp)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Msf/MsfBuilder.cpp?p2=llvm/trunk/lib/DebugInfo/Msf/MsfBuilder.cpp&p1=llvm/trunk/lib/DebugInfo/PDB/Raw/MsfBuilder.cpp&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/MsfBuilder.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/Msf/MsfBuilder.cpp Fri Jul 22 14:56:05 2016
> @@ -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 BlockSiz
> Expected<MsfBuilder> MsfBuilder::create(BumpPtrAllocator &Allocator,
> uint32_t BlockSize,
> uint32_t MinBlockCount, bool CanGrow) {
> - if (!msf::isValidBlockSize(BlockSize))
> - return make_error<RawError>(raw_error_code::unspecified,
> + if (!isValidBlockSize(BlockSize))
> + return make_error<MsfError>(msf_error_code::invalid_format,
> "The requested block size is unsupported");
>
> return MsfBuilder(BlockSize,
> @@ -53,14 +52,15 @@ Error MsfBuilder::setBlockMapAddr(uint32
>
> if (Addr >= FreeBlocks.size()) {
> if (!IsGrowable)
> - return make_error<RawError>(raw_error_code::unspecified,
> + return make_error<MsfError>(msf_error_code::insufficient_buffer,
> "Cannot grow the number of blocks");
> FreeBlocks.resize(Addr + 1);
> }
>
> if (!isBlockFree(Addr))
> - return make_error<RawError>(raw_error_code::unspecified,
> - "Attempt to reuse an allocated block");
> + return make_error<MsfError>(
> + 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
> FreeBlocks[B] = true;
> for (auto B : DirBlocks) {
> if (!isBlockFree(B)) {
> - return make_error<RawError>(raw_error_code::unspecified,
> + return make_error<MsfError>(msf_error_code::unspecified,
> "Attempt to reuse an allocated block");
> }
> FreeBlocks[B] = false;
> @@ -94,7 +94,7 @@ Error MsfBuilder::allocateBlocks(uint32_
> uint32_t NumFreeBlocks = FreeBlocks.count();
> if (NumFreeBlocks < NumBlocks) {
> if (!IsGrowable)
> - return make_error<RawError>(raw_error_code::unspecified,
> + return make_error<MsfError>(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 Siz
> // of bytes, and verify that all requested blocks are free.
> uint32_t ReqBlocks = bytesToBlocks(Size, BlockSize);
> if (ReqBlocks != Blocks.size())
> - return make_error<RawError>(
> - raw_error_code::unspecified,
> + return make_error<MsfError>(
> + 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<RawError>(
> - raw_error_code::unspecified,
> + return make_error<MsfError>(
> + 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<Layout> 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<ulittle32_t>(NumDirectoryBlocks);
>
> Copied: llvm/trunk/lib/DebugInfo/Msf/MsfCommon.cpp (from r276457, llvm/trunk/lib/DebugInfo/PDB/Raw/MsfCommon.cpp)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Msf/MsfCommon.cpp?p2=llvm/trunk/lib/DebugInfo/Msf/MsfCommon.cpp&p1=llvm/trunk/lib/DebugInfo/PDB/Raw/MsfCommon.cpp&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/MsfCommon.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/Msf/MsfCommon.cpp Fri Jul 22 14:56:05 2016
> @@ -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<RawError>(raw_error_code::corrupt_file,
> + return make_error<MsfError>(msf_error_code::invalid_format,
> "MSF magic header doesn't match");
>
> if (!isValidBlockSize(SB.BlockSize))
> - return make_error<RawError>(raw_error_code::corrupt_file,
> + return make_error<MsfError>(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<RawError>(raw_error_code::corrupt_file,
> + return make_error<MsfError>(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
> // 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<RawError>(raw_error_code::corrupt_file,
> + return make_error<MsfError>(msf_error_code::invalid_format,
> "Too many directory blocks.");
>
> if (SB.BlockMapAddr == 0)
> - return make_error<RawError>(raw_error_code::corrupt_file,
> + return make_error<MsfError>(msf_error_code::invalid_format,
> "Block 0 is reserved");
>
> return Error::success();
>
> Added: llvm/trunk/lib/DebugInfo/Msf/MsfError.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Msf/MsfError.cpp?rev=276458&view=auto
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/Msf/MsfError.cpp (added)
> +++ llvm/trunk/lib/DebugInfo/Msf/MsfError.cpp Fri Jul 22 14:56:05 2016
> @@ -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<msf_error_code>(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<MsfErrorCategory> 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<int>(Code), *Category);
> +}
>
> Copied: llvm/trunk/lib/DebugInfo/Msf/StreamReader.cpp (from r276457, llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Msf/StreamReader.cpp?p2=llvm/trunk/lib/DebugInfo/Msf/StreamReader.cpp&p1=llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/CodeView/StreamReader.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/Msf/StreamReader.cpp Fri Jul 22 14:56:05 2016
> @@ -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(Stream
>
> Error StreamReader::readStreamRef(StreamRef &Ref, uint32_t Length) {
> if (bytesRemaining() < Length)
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
> Ref = Stream.slice(Offset, Length);
> Offset += Length;
> return Error::success();
>
> Copied: llvm/trunk/lib/DebugInfo/Msf/StreamWriter.cpp (from r276457, llvm/trunk/lib/DebugInfo/CodeView/StreamWriter.cpp)
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Msf/StreamWriter.cpp?p2=llvm/trunk/lib/DebugInfo/Msf/StreamWriter.cpp&p1=llvm/trunk/lib/DebugInfo/CodeView/StreamWriter.cpp&r1=276457&r2=276458&rev=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/CodeView/StreamWriter.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/Msf/StreamWriter.cpp Fri Jul 22 14:56:05 2016
> @@ -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) {}
>
>
> Modified: llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/CMakeLists.txt Fri Jul 22 14:56:05 2016
> @@ -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
>
> Modified: llvm/trunk/lib/DebugInfo/PDB/LLVMBuild.txt
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/LLVMBuild.txt?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/LLVMBuild.txt (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/LLVMBuild.txt Fri Jul 22 14:56:05 2016
> @@ -19,5 +19,5 @@
> type = Library
> name = DebugInfoPDB
> parent = DebugInfo
> -required_libraries = Object Support DebugInfoCodeView
> +required_libraries = Object Support DebugInfoCodeView DebugInfoMsf
>
>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/DbiStream.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/DbiStream.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/DbiStream.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/DbiStream.cpp Fri Jul 22 14:56:05 2016
> @@ -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()
> return static_cast<PDB_Machine>(Machine);
> }
>
> -codeview::FixedStreamArray<object::coff_section>
> -DbiStream::getSectionHeaders() {
> +msf::FixedStreamArray<object::coff_section> DbiStream::getSectionHeaders() {
> return SectionHeaders;
> }
>
> -codeview::FixedStreamArray<object::FpoData> DbiStream::getFpoRecords() {
> +msf::FixedStreamArray<object::FpoData> DbiStream::getFpoRecords() {
> return FpoRecords;
> }
>
> ArrayRef<ModuleInfoEx> DbiStream::modules() const { return ModuleInfos; }
> -codeview::FixedStreamArray<SecMapEntry> DbiStream::getSectionMap() const {
> +msf::FixedStreamArray<SecMapEntry> DbiStream::getSectionMap() const {
> return SectionMap;
> }
>
> @@ -283,7 +283,7 @@ Error DbiStream::initializeSectionHeader
> "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<RawError>(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<RawError>(raw_error_code::corrupt_file,
> "Corrupted New FPO stream.");
>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/DbiStreamBuilder.cpp Fri Jul 22 14:56:05 2016
> @@ -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 {
>
> Removed: llvm/trunk/lib/DebugInfo/PDB/Raw/IndexedStreamData.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/IndexedStreamData.cpp?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/IndexedStreamData.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/IndexedStreamData.cpp (removed)
> @@ -1,25 +0,0 @@
> -//===- IndexedStreamData.cpp - Standard PDB Stream Data ---------*- 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/PDB/Raw/IndexedStreamData.h"
> -#include "llvm/DebugInfo/PDB/Raw/IPDBFile.h"
> -
> -using namespace llvm;
> -using namespace llvm::pdb;
> -
> -IndexedStreamData::IndexedStreamData(uint32_t StreamIdx, const IPDBFile &File)
> - : StreamIdx(StreamIdx), File(File) {}
> -
> -uint32_t IndexedStreamData::getLength() {
> - return File.getStreamByteSize(StreamIdx);
> -}
> -
> -ArrayRef<support::ulittle32_t> IndexedStreamData::getStreamBlocks() {
> - return File.getStreamBlockList(StreamIdx);
> -}
>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStream.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStream.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStream.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStream.cpp Fri Jul 22 14:56:05 2016
> @@ -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<MappedBlockStream> Stream)
> : Stream(std::move(Stream)) {}
>
> Error InfoStream::reload() {
> - codeview::StreamReader Reader(*Stream);
> + StreamReader Reader(*Stream);
>
> const HeaderInfo *H;
> if (auto EC = Reader.readObject(H))
>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/InfoStreamBuilder.cpp Fri Jul 22 14:56:05 2016
> @@ -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() {}
>
> Removed: llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/MappedBlockStream.cpp (removed)
> @@ -1,310 +0,0 @@
> -//===- MappedBlockStream.cpp - Reads stream data from a PDBFile -----------===//
> -//
> -// The LLVM Compiler Infrastructure
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
> -//===----------------------------------------------------------------------===//
> -
> -#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"
> -
> -using namespace llvm;
> -using namespace llvm::pdb;
> -
> -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.
> -class MappedBlockStreamImpl : public MappedBlockStream {
> -public:
> - MappedBlockStreamImpl(std::unique_ptr<IPDBStreamData> Data,
> - const IPDBFile &File)
> - : MappedBlockStream(std::move(Data), File) {}
> -};
> -}
> -
> -typedef std::pair<uint32_t, uint32_t> Interval;
> -static Interval intersect(const Interval &I1, const Interval &I2) {
> - return std::make_pair(std::max(I1.first, I2.first),
> - std::min(I1.second, I2.second));
> -}
> -
> -MappedBlockStream::MappedBlockStream(std::unique_ptr<IPDBStreamData> Data,
> - const IPDBFile &Pdb)
> - : Pdb(Pdb), Data(std::move(Data)) {}
> -
> -Error MappedBlockStream::readBytes(uint32_t Offset, uint32_t Size,
> - ArrayRef<uint8_t> &Buffer) const {
> - // Make sure we aren't trying to read beyond the end of the stream.
> - if (Size > Data->getLength())
> - return make_error<RawError>(raw_error_code::insufficient_buffer);
> - if (Offset > Data->getLength() - Size)
> - return make_error<RawError>(raw_error_code::insufficient_buffer);
> -
> - if (tryReadContiguously(Offset, Size, Buffer))
> - return Error::success();
> -
> - auto CacheIter = CacheMap.find(Offset);
> - if (CacheIter != CacheMap.end()) {
> - // Try to find an alloc that was large enough for this request.
> - for (auto &Entry : CacheIter->second) {
> - if (Entry.size() >= Size) {
> - Buffer = Entry.slice(0, Size);
> - return Error::success();
> - }
> - }
> - }
> -
> - // We couldn't find a buffer that started at the correct offset (the most
> - // common scenario). Try to see if there is a buffer that starts at some
> - // other offset but overlaps the desired range.
> - for (auto &CacheItem : CacheMap) {
> - Interval RequestExtent = std::make_pair(Offset, Offset + Size);
> -
> - // We already checked this one on the fast path above.
> - if (CacheItem.first == Offset)
> - continue;
> - // If the initial extent of the cached item is beyond the ending extent
> - // of the request, there is no overlap.
> - if (CacheItem.first >= Offset + Size)
> - continue;
> -
> - // We really only have to check the last item in the list, since we append
> - // in order of increasing length.
> - if (CacheItem.second.empty())
> - continue;
> -
> - auto CachedAlloc = CacheItem.second.back();
> - // If the initial extent of the request is beyond the ending extent of
> - // the cached item, there is no overlap.
> - Interval CachedExtent =
> - std::make_pair(CacheItem.first, CacheItem.first + CachedAlloc.size());
> - if (RequestExtent.first >= CachedExtent.first + CachedExtent.second)
> - continue;
> -
> - Interval Intersection = intersect(CachedExtent, RequestExtent);
> - // Only use this if the entire request extent is contained in the cached
> - // extent.
> - if (Intersection != RequestExtent)
> - continue;
> -
> - uint32_t CacheRangeOffset =
> - AbsoluteDifference(CachedExtent.first, Intersection.first);
> - Buffer = CachedAlloc.slice(CacheRangeOffset, Size);
> - return Error::success();
> - }
> -
> - // Otherwise allocate a large enough buffer in the pool, memcpy the data
> - // into it, and return an ArrayRef to that. Do not touch existing pool
> - // allocations, as existing clients may be holding a pointer which must
> - // not be invalidated.
> - uint8_t *WriteBuffer = static_cast<uint8_t *>(Pool.Allocate(Size, 8));
> - if (auto EC = readBytes(Offset, MutableArrayRef<uint8_t>(WriteBuffer, Size)))
> - return EC;
> -
> - if (CacheIter != CacheMap.end()) {
> - CacheIter->second.emplace_back(WriteBuffer, Size);
> - } else {
> - std::vector<CacheEntry> List;
> - List.emplace_back(WriteBuffer, Size);
> - CacheMap.insert(std::make_pair(Offset, List));
> - }
> - Buffer = ArrayRef<uint8_t>(WriteBuffer, Size);
> - return Error::success();
> -}
> -
> -Error MappedBlockStream::readLongestContiguousChunk(
> - uint32_t Offset, ArrayRef<uint8_t> &Buffer) const {
> - // Make sure we aren't trying to read beyond the end of the stream.
> - if (Offset >= Data->getLength())
> - return make_error<RawError>(raw_error_code::insufficient_buffer);
> - uint32_t First = Offset / Pdb.getBlockSize();
> - uint32_t Last = First;
> -
> - auto BlockList = Data->getStreamBlocks();
> - while (Last < Pdb.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 BlockSpan = Last - First + 1;
> - uint32_t ByteSpan =
> - BytesFromFirstBlock + (BlockSpan - 1) * Pdb.getBlockSize();
> - auto Result = Pdb.getBlockData(BlockList[First], Pdb.getBlockSize());
> - if (!Result)
> - return Result.takeError();
> - Buffer = Result->drop_front(OffsetInFirstBlock);
> - Buffer = ArrayRef<uint8_t>(Buffer.data(), ByteSpan);
> - return Error::success();
> -}
> -
> -uint32_t MappedBlockStream::getLength() const { return Data->getLength(); }
> -
> -Error MappedBlockStream::commit() const { return Error::success(); }
> -
> -bool MappedBlockStream::tryReadContiguously(uint32_t Offset, uint32_t Size,
> - ArrayRef<uint8_t> &Buffer) const {
> - // Attempt to fulfill the request with a reference directly into the stream.
> - // This can work even if the request crosses a block boundary, provided that
> - // 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 BytesFromFirstBlock =
> - std::min(Size, Pdb.getBlockSize() - OffsetInBlock);
> - uint32_t NumAdditionalBlocks =
> - llvm::alignTo(Size - BytesFromFirstBlock, Pdb.getBlockSize()) /
> - Pdb.getBlockSize();
> -
> - auto BlockList = Data->getStreamBlocks();
> - uint32_t RequiredContiguousBlocks = NumAdditionalBlocks + 1;
> - uint32_t E = BlockList[BlockNum];
> - for (uint32_t I = 0; I < RequiredContiguousBlocks; ++I, ++E) {
> - if (BlockList[I + BlockNum] != E)
> - return false;
> - }
> -
> - uint32_t FirstBlockAddr = BlockList[BlockNum];
> - auto Result = Pdb.getBlockData(FirstBlockAddr, Pdb.getBlockSize());
> - if (!Result) {
> - consumeError(Result.takeError());
> - return false;
> - }
> - auto Data = Result->drop_front(OffsetInBlock);
> - Buffer = ArrayRef<uint8_t>(Data.data(), Size);
> - return true;
> -}
> -
> -Error MappedBlockStream::readBytes(uint32_t Offset,
> - MutableArrayRef<uint8_t> Buffer) const {
> - uint32_t BlockNum = Offset / Pdb.getBlockSize();
> - uint32_t OffsetInBlock = Offset % Pdb.getBlockSize();
> -
> - // Make sure we aren't trying to read beyond the end of the stream.
> - if (Buffer.size() > Data->getLength())
> - return make_error<RawError>(raw_error_code::insufficient_buffer);
> - if (Offset > Data->getLength() - Buffer.size())
> - return make_error<RawError>(raw_error_code::insufficient_buffer);
> -
> - uint32_t BytesLeft = Buffer.size();
> - uint32_t BytesWritten = 0;
> - uint8_t *WriteBuffer = Buffer.data();
> - auto BlockList = Data->getStreamBlocks();
> - while (BytesLeft > 0) {
> - uint32_t StreamBlockAddr = BlockList[BlockNum];
> -
> - auto Result = Pdb.getBlockData(StreamBlockAddr, Pdb.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);
> - ::memcpy(WriteBuffer + BytesWritten, ChunkStart, BytesInChunk);
> -
> - BytesWritten += BytesInChunk;
> - BytesLeft -= BytesInChunk;
> - ++BlockNum;
> - OffsetInBlock = 0;
> - }
> -
> - return Error::success();
> -}
> -
> -Error MappedBlockStream::writeBytes(uint32_t Offset,
> - ArrayRef<uint8_t> Buffer) const {
> - // Make sure we aren't trying to write beyond the end of the stream.
> - if (Buffer.size() > Data->getLength())
> - return make_error<RawError>(raw_error_code::insufficient_buffer);
> -
> - if (Offset > Data->getLength() - Buffer.size())
> - return make_error<RawError>(raw_error_code::insufficient_buffer);
> -
> - uint32_t BlockNum = Offset / Pdb.getBlockSize();
> - uint32_t OffsetInBlock = Offset % Pdb.getBlockSize();
> -
> - uint32_t BytesLeft = Buffer.size();
> - auto BlockList = Data->getStreamBlocks();
> - uint32_t BytesWritten = 0;
> - while (BytesLeft > 0) {
> - uint32_t StreamBlockAddr = BlockList[BlockNum];
> - uint32_t BytesToWriteInChunk =
> - std::min(BytesLeft, Pdb.getBlockSize() - OffsetInBlock);
> -
> - const uint8_t *Chunk = Buffer.data() + BytesWritten;
> - ArrayRef<uint8_t> ChunkData(Chunk, BytesToWriteInChunk);
> - if (auto EC = Pdb.setBlockData(StreamBlockAddr, OffsetInBlock, ChunkData))
> - return EC;
> -
> - BytesLeft -= BytesToWriteInChunk;
> - BytesWritten += BytesToWriteInChunk;
> - ++BlockNum;
> - OffsetInBlock = 0;
> - }
> -
> - // If this write overlapped a read which previously came from the pool,
> - // someone may still be holding a pointer to that alloc which is now invalid.
> - // Compute the overlapping range and update the cache entry, so any
> - // outstanding buffers are automatically updated.
> - for (const auto &MapEntry : CacheMap) {
> - // If the end of the written extent precedes the beginning of the cached
> - // extent, ignore this map entry.
> - if (Offset + BytesWritten < MapEntry.first)
> - continue;
> - for (const auto &Alloc : MapEntry.second) {
> - // If the end of the cached extent precedes the beginning of the written
> - // extent, ignore this alloc.
> - if (MapEntry.first + Alloc.size() < Offset)
> - continue;
> -
> - // If we get here, they are guaranteed to overlap.
> - Interval WriteInterval = std::make_pair(Offset, Offset + BytesWritten);
> - Interval CachedInterval =
> - std::make_pair(MapEntry.first, MapEntry.first + Alloc.size());
> - // If they overlap, we need to write the new data into the overlapping
> - // range.
> - auto Intersection = intersect(WriteInterval, CachedInterval);
> - assert(Intersection.first <= Intersection.second);
> -
> - uint32_t Length = Intersection.second - Intersection.first;
> - uint32_t SrcOffset =
> - AbsoluteDifference(WriteInterval.first, Intersection.first);
> - uint32_t DestOffset =
> - AbsoluteDifference(CachedInterval.first, Intersection.first);
> - ::memcpy(Alloc.data() + DestOffset, Buffer.data() + SrcOffset, Length);
> - }
> - }
> -
> - return Error::success();
> -}
> -
> -uint32_t MappedBlockStream::getNumBytesCopied() const {
> - return static_cast<uint32_t>(Pool.getBytesAllocated());
> -}
> -
> -Expected<std::unique_ptr<MappedBlockStream>>
> -MappedBlockStream::createIndexedStream(uint32_t StreamIdx,
> - const IPDBFile &File) {
> - if (StreamIdx >= File.getNumStreams())
> - return make_error<RawError>(raw_error_code::no_stream);
> -
> - auto Data = llvm::make_unique<IndexedStreamData>(StreamIdx, File);
> - return llvm::make_unique<MappedBlockStreamImpl>(std::move(Data), File);
> -}
> -
> -Expected<std::unique_ptr<MappedBlockStream>>
> -MappedBlockStream::createDirectoryStream(const PDBFile &File) {
> - auto Data = llvm::make_unique<DirectoryStreamData>(File);
> - return llvm::make_unique<MappedBlockStreamImpl>(std::move(Data), File);
> -}
>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/ModInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/ModInfo.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/ModInfo.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/ModInfo.cpp Fri Jul 22 14:56:05 2016
> @@ -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;
>
>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/ModStream.cpp Fri Jul 22 14:56:05 2016
> @@ -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 &Modu
> 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<RawError>(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;
>
>
> Removed: llvm/trunk/lib/DebugInfo/PDB/Raw/MsfBuilder.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/MsfBuilder.cpp?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/MsfBuilder.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/MsfBuilder.cpp (removed)
> @@ -1,279 +0,0 @@
> -//===- MSFBuilder.cpp - MSF Directory & Metadata Builder --------*- 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/PDB/Raw/MsfBuilder.h"
> -#include "llvm/DebugInfo/PDB/Raw/RawError.h"
> -
> -using namespace llvm;
> -using namespace llvm::pdb;
> -using namespace llvm::pdb::msf;
> -using namespace llvm::support;
> -
> -namespace {
> -const uint32_t kSuperBlockBlock = 0;
> -const uint32_t kFreePageMap0Block = 1;
> -const uint32_t kFreePageMap1Block = 2;
> -const uint32_t kNumReservedPages = 3;
> -
> -const uint32_t kDefaultBlockMapAddr = kNumReservedPages;
> -}
> -
> -MsfBuilder::MsfBuilder(uint32_t BlockSize, uint32_t MinBlockCount, bool CanGrow,
> - BumpPtrAllocator &Allocator)
> - : Allocator(Allocator), IsGrowable(CanGrow), BlockSize(BlockSize),
> - MininumBlocks(MinBlockCount), BlockMapAddr(kDefaultBlockMapAddr),
> - FreeBlocks(MinBlockCount, true) {
> - FreeBlocks[kSuperBlockBlock] = false;
> - FreeBlocks[kFreePageMap0Block] = false;
> - FreeBlocks[kFreePageMap1Block] = false;
> - FreeBlocks[BlockMapAddr] = false;
> -}
> -
> -Expected<MsfBuilder> MsfBuilder::create(BumpPtrAllocator &Allocator,
> - uint32_t BlockSize,
> - uint32_t MinBlockCount, bool CanGrow) {
> - if (!msf::isValidBlockSize(BlockSize))
> - return make_error<RawError>(raw_error_code::unspecified,
> - "The requested block size is unsupported");
> -
> - return MsfBuilder(BlockSize,
> - std::max(MinBlockCount, msf::getMinimumBlockCount()),
> - CanGrow, Allocator);
> -}
> -
> -Error MsfBuilder::setBlockMapAddr(uint32_t Addr) {
> - if (Addr == BlockMapAddr)
> - return Error::success();
> -
> - if (Addr >= FreeBlocks.size()) {
> - if (!IsGrowable)
> - return make_error<RawError>(raw_error_code::unspecified,
> - "Cannot grow the number of blocks");
> - FreeBlocks.resize(Addr + 1);
> - }
> -
> - if (!isBlockFree(Addr))
> - return make_error<RawError>(raw_error_code::unspecified,
> - "Attempt to reuse an allocated block");
> - FreeBlocks[BlockMapAddr] = true;
> - FreeBlocks[Addr] = false;
> - BlockMapAddr = Addr;
> - return Error::success();
> -}
> -
> -void MsfBuilder::setFreePageMap(uint32_t Fpm) { FreePageMap = Fpm; }
> -
> -void MsfBuilder::setUnknown1(uint32_t Unk1) { Unknown1 = Unk1; }
> -
> -Error MsfBuilder::setDirectoryBlocksHint(ArrayRef<uint32_t> DirBlocks) {
> - for (auto B : DirectoryBlocks)
> - FreeBlocks[B] = true;
> - for (auto B : DirBlocks) {
> - if (!isBlockFree(B)) {
> - return make_error<RawError>(raw_error_code::unspecified,
> - "Attempt to reuse an allocated block");
> - }
> - FreeBlocks[B] = false;
> - }
> -
> - DirectoryBlocks = DirBlocks;
> - return Error::success();
> -}
> -
> -Error MsfBuilder::allocateBlocks(uint32_t NumBlocks,
> - MutableArrayRef<uint32_t> Blocks) {
> - if (NumBlocks == 0)
> - return Error::success();
> -
> - uint32_t NumFreeBlocks = FreeBlocks.count();
> - if (NumFreeBlocks < NumBlocks) {
> - if (!IsGrowable)
> - return make_error<RawError>(raw_error_code::unspecified,
> - "There are no free Blocks in the file");
> - uint32_t AllocBlocks = NumBlocks - NumFreeBlocks;
> - FreeBlocks.resize(AllocBlocks + FreeBlocks.size(), true);
> - }
> -
> - int I = 0;
> - int Block = FreeBlocks.find_first();
> - do {
> - assert(Block != -1 && "We ran out of Blocks!");
> -
> - uint32_t NextBlock = static_cast<uint32_t>(Block);
> - Blocks[I++] = NextBlock;
> - FreeBlocks.reset(NextBlock);
> - Block = FreeBlocks.find_next(Block);
> - } while (--NumBlocks > 0);
> - return Error::success();
> -}
> -
> -uint32_t MsfBuilder::getNumUsedBlocks() const {
> - return getTotalBlockCount() - getNumFreeBlocks();
> -}
> -
> -uint32_t MsfBuilder::getNumFreeBlocks() const { return FreeBlocks.count(); }
> -
> -uint32_t MsfBuilder::getTotalBlockCount() const { return FreeBlocks.size(); }
> -
> -bool MsfBuilder::isBlockFree(uint32_t Idx) const { return FreeBlocks[Idx]; }
> -
> -Error MsfBuilder::addStream(uint32_t Size, ArrayRef<uint32_t> Blocks) {
> - // Add a new stream mapped to the specified blocks. Verify that the specified
> - // blocks are both necessary and sufficient for holding the requested number
> - // of bytes, and verify that all requested blocks are free.
> - uint32_t ReqBlocks = bytesToBlocks(Size, BlockSize);
> - if (ReqBlocks != Blocks.size())
> - return make_error<RawError>(
> - raw_error_code::unspecified,
> - "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<RawError>(
> - raw_error_code::unspecified,
> - "Attempt to re-use an already allocated block");
> - }
> - // Mark all the blocks occupied by the new stream as not free.
> - for (auto Block : Blocks) {
> - FreeBlocks.reset(Block);
> - }
> - StreamData.push_back(std::make_pair(Size, Blocks));
> - return Error::success();
> -}
> -
> -Error MsfBuilder::addStream(uint32_t Size) {
> - uint32_t ReqBlocks = bytesToBlocks(Size, BlockSize);
> - std::vector<uint32_t> NewBlocks;
> - NewBlocks.resize(ReqBlocks);
> - if (auto EC = allocateBlocks(ReqBlocks, NewBlocks))
> - return EC;
> - StreamData.push_back(std::make_pair(Size, NewBlocks));
> - return Error::success();
> -}
> -
> -Error MsfBuilder::setStreamSize(uint32_t Idx, uint32_t Size) {
> - uint32_t OldSize = getStreamSize(Idx);
> - if (OldSize == Size)
> - return Error::success();
> -
> - uint32_t NewBlocks = bytesToBlocks(Size, BlockSize);
> - uint32_t OldBlocks = bytesToBlocks(OldSize, BlockSize);
> -
> - if (NewBlocks > OldBlocks) {
> - uint32_t AddedBlocks = NewBlocks - OldBlocks;
> - // If we're growing, we have to allocate new Blocks.
> - std::vector<uint32_t> AddedBlockList;
> - AddedBlockList.resize(AddedBlocks);
> - if (auto EC = allocateBlocks(AddedBlocks, AddedBlockList))
> - return EC;
> - auto &CurrentBlocks = StreamData[Idx].second;
> - CurrentBlocks.insert(CurrentBlocks.end(), AddedBlockList.begin(),
> - AddedBlockList.end());
> - } else if (OldBlocks > NewBlocks) {
> - // For shrinking, free all the Blocks in the Block map, update the stream
> - // data, then shrink the directory.
> - uint32_t RemovedBlocks = OldBlocks - NewBlocks;
> - auto CurrentBlocks = ArrayRef<uint32_t>(StreamData[Idx].second);
> - auto RemovedBlockList = CurrentBlocks.drop_front(NewBlocks);
> - for (auto P : RemovedBlockList)
> - FreeBlocks[P] = true;
> - StreamData[Idx].second = CurrentBlocks.drop_back(RemovedBlocks);
> - }
> -
> - StreamData[Idx].first = Size;
> - return Error::success();
> -}
> -
> -uint32_t MsfBuilder::getNumStreams() const { return StreamData.size(); }
> -
> -uint32_t MsfBuilder::getStreamSize(uint32_t StreamIdx) const {
> - return StreamData[StreamIdx].first;
> -}
> -
> -ArrayRef<uint32_t> MsfBuilder::getStreamBlocks(uint32_t StreamIdx) const {
> - return StreamData[StreamIdx].second;
> -}
> -
> -uint32_t MsfBuilder::computeDirectoryByteSize() const {
> - // The directory has the following layout, where each item is a ulittle32_t:
> - // NumStreams
> - // StreamSizes[NumStreams]
> - // StreamBlocks[NumStreams][]
> - uint32_t Size = sizeof(ulittle32_t); // NumStreams
> - Size += StreamData.size() * sizeof(ulittle32_t); // StreamSizes
> - for (const auto &D : StreamData) {
> - uint32_t ExpectedNumBlocks = bytesToBlocks(D.first, BlockSize);
> - assert(ExpectedNumBlocks == D.second.size() &&
> - "Unexpected number of blocks");
> - Size += ExpectedNumBlocks * sizeof(ulittle32_t);
> - }
> - return Size;
> -}
> -
> -Expected<Layout> MsfBuilder::build() {
> - Layout L;
> - L.SB = Allocator.Allocate<SuperBlock>();
> - std::memcpy(L.SB->MagicBytes, Magic, sizeof(Magic));
> - L.SB->BlockMapAddr = BlockMapAddr;
> - L.SB->BlockSize = BlockSize;
> - L.SB->NumDirectoryBytes = computeDirectoryByteSize();
> - L.SB->FreeBlockMapBlock = FreePageMap;
> - L.SB->Unknown1 = Unknown1;
> -
> - uint32_t NumDirectoryBlocks =
> - bytesToBlocks(L.SB->NumDirectoryBytes, BlockSize);
> - if (NumDirectoryBlocks > DirectoryBlocks.size()) {
> - // Our hint wasn't enough to satisfy the entire directory. Allocate
> - // remaining pages.
> - std::vector<uint32_t> ExtraBlocks;
> - uint32_t NumExtraBlocks = NumDirectoryBlocks - DirectoryBlocks.size();
> - ExtraBlocks.resize(NumExtraBlocks);
> - if (auto EC = allocateBlocks(NumExtraBlocks, ExtraBlocks))
> - return std::move(EC);
> - DirectoryBlocks.insert(DirectoryBlocks.end(), ExtraBlocks.begin(),
> - ExtraBlocks.end());
> - } else if (NumDirectoryBlocks < DirectoryBlocks.size()) {
> - uint32_t NumUnnecessaryBlocks = DirectoryBlocks.size() - NumDirectoryBlocks;
> - for (auto B :
> - ArrayRef<uint32_t>(DirectoryBlocks).drop_back(NumUnnecessaryBlocks))
> - FreeBlocks[B] = true;
> - DirectoryBlocks.resize(NumDirectoryBlocks);
> - }
> -
> - // 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.
> - L.SB->NumBlocks = FreeBlocks.size();
> -
> - ulittle32_t *DirBlocks = Allocator.Allocate<ulittle32_t>(NumDirectoryBlocks);
> - std::uninitialized_copy_n(DirectoryBlocks.begin(), NumDirectoryBlocks,
> - DirBlocks);
> - L.DirectoryBlocks = ArrayRef<ulittle32_t>(DirBlocks, NumDirectoryBlocks);
> -
> - // The stream sizes should be re-allocated as a stable pointer and the stream
> - // map should have each of its entries allocated as a separate stable pointer.
> - if (StreamData.size() > 0) {
> - ulittle32_t *Sizes = Allocator.Allocate<ulittle32_t>(StreamData.size());
> - L.StreamSizes = ArrayRef<ulittle32_t>(Sizes, StreamData.size());
> - L.StreamMap.resize(StreamData.size());
> - for (uint32_t I = 0; I < StreamData.size(); ++I) {
> - Sizes[I] = StreamData[I].first;
> - ulittle32_t *BlockList =
> - Allocator.Allocate<ulittle32_t>(StreamData[I].second.size());
> - std::uninitialized_copy_n(StreamData[I].second.begin(),
> - StreamData[I].second.size(), BlockList);
> - L.StreamMap[I] =
> - ArrayRef<ulittle32_t>(BlockList, StreamData[I].second.size());
> - }
> - }
> -
> - return L;
> -}
>
> Removed: llvm/trunk/lib/DebugInfo/PDB/Raw/MsfCommon.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/MsfCommon.cpp?rev=276457&view=auto
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/MsfCommon.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/MsfCommon.cpp (removed)
> @@ -1,48 +0,0 @@
> -//===- MsfCommon.cpp - Common types and functions 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/PDB/Raw/MsfCommon.h"
> -#include "llvm/DebugInfo/PDB/Raw/RawError.h"
> -
> -using namespace llvm;
> -using namespace llvm::pdb::msf;
> -
> -Error llvm::pdb::msf::validateSuperBlock(const SuperBlock &SB) {
> - // Check the magic bytes.
> - if (std::memcmp(SB.MagicBytes, Magic, sizeof(Magic)) != 0)
> - return make_error<RawError>(raw_error_code::corrupt_file,
> - "MSF magic header doesn't match");
> -
> - if (!isValidBlockSize(SB.BlockSize))
> - return make_error<RawError>(raw_error_code::corrupt_file,
> - "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<RawError>(raw_error_code::corrupt_file,
> - "Directory size is not multiple of 4.");
> -
> - // The number of blocks which comprise the directory is a simple function of
> - // the number of bytes it contains.
> - uint64_t NumDirectoryBlocks =
> - bytesToBlocks(SB.NumDirectoryBytes, SB.BlockSize);
> -
> - // The directory, as we understand it, is a block which consists of a list of
> - // 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<RawError>(raw_error_code::corrupt_file,
> - "Too many directory blocks.");
> -
> - if (SB.BlockMapAddr == 0)
> - return make_error<RawError>(raw_error_code::corrupt_file,
> - "Block 0 is reserved");
> -
> - return Error::success();
> -}
>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/NameHashTable.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/NameHashTable.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/NameHashTable.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/NameHashTable.cpp Fri Jul 22 14:56:05 2016
> @@ -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(
> // 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(S
> return IDs[0];
> }
>
> -codeview::FixedStreamArray<support::ulittle32_t>
> -NameHashTable::name_ids() const {
> +FixedStreamArray<support::ulittle32_t> NameHashTable::name_ids() const {
> return IDs;
> }
>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/NameMap.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/NameMap.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/NameMap.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/NameMap.cpp Fri Jul 22 14:56:05 2016
> @@ -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::StreamRead
> 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.
>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp Fri Jul 22 14:56:05 2016
> @@ -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);
>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp Fri Jul 22 14:56:05 2016
> @@ -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<codeview::StreamInterface> FileBuffer)
> +PDBFileBuilder::PDBFileBuilder(std::unique_ptr<msf::StreamInterface> FileBuffer)
> : File(llvm::make_unique<PDBFile>(std::move(FileBuffer))) {}
>
> Error PDBFileBuilder::initialize(const msf::SuperBlock &Super) {
>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/PublicsStream.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/PublicsStream.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/PublicsStream.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/PublicsStream.cpp Fri Jul 22 14:56:05 2016
> @@ -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() con
> // 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))
>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/RawSession.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/RawSession.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/RawSession.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/RawSession.cpp Fri Jul 22 14:56:05 2016
> @@ -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<false> {
> +class InputByteStream : public ByteStream<false> {
> public:
> explicit InputByteStream(std::unique_ptr<MemoryBuffer> Buffer)
> : ByteStream(ArrayRef<uint8_t>(Buffer->getBuffer().bytes_begin(),
>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/SymbolStream.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/SymbolStream.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/SymbolStream.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/SymbolStream.cpp Fri Jul 22 14:56:05 2016
> @@ -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_p
> SymbolStream::~SymbolStream() {}
>
> Error SymbolStream::reload() {
> - codeview::StreamReader Reader(*Stream);
> + StreamReader Reader(*Stream);
>
> if (auto EC = Reader.readArray(SymbolRecords, Stream->getLength()))
> return EC;
>
> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/TpiStream.cpp Fri Jul 22 14:56:05 2016
> @@ -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 {
>
> Modified: llvm/trunk/tools/llvm-pdbdump/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/CMakeLists.txt?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-pdbdump/CMakeLists.txt (original)
> +++ llvm/trunk/tools/llvm-pdbdump/CMakeLists.txt Fri Jul 22 14:56:05 2016
> @@ -1,5 +1,6 @@
> set(LLVM_LINK_COMPONENTS
> DebugInfoCodeView
> + DebugInfoMsf
> DebugInfoPDB
> Object
> Support
>
> Modified: llvm/trunk/tools/llvm-pdbdump/LLVMBuild.txt
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/LLVMBuild.txt?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-pdbdump/LLVMBuild.txt (original)
> +++ llvm/trunk/tools/llvm-pdbdump/LLVMBuild.txt Fri Jul 22 14:56:05 2016
> @@ -19,5 +19,5 @@
> type = Tool
> name = llvm-pdbdump
> parent = Tools
> -required_libraries = DebugInfoPDB
> +required_libraries = DebugInfoMsf DebugInfoPDB
>
>
> Modified: llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp (original)
> +++ llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp Fri Jul 22 14:56:05 2016
> @@ -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<uint8_t> 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))
>
> Modified: llvm/trunk/tools/llvm-pdbdump/PdbYaml.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/PdbYaml.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-pdbdump/PdbYaml.cpp (original)
> +++ llvm/trunk/tools/llvm-pdbdump/PdbYaml.cpp Fri Jul 22 14:56:05 2016
> @@ -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;
>
> Modified: llvm/trunk/tools/llvm-pdbdump/PdbYaml.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/PdbYaml.h?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-pdbdump/PdbYaml.h (original)
> +++ llvm/trunk/tools/llvm-pdbdump/PdbYaml.h Fri Jul 22 14:56:05 2016
> @@ -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<pdb::ya
> static void mapping(IO &IO, pdb::yaml::MsfHeaders &Obj);
> };
>
> -template <> struct MappingTraits<pdb::msf::SuperBlock> {
> - static void mapping(IO &IO, pdb::msf::SuperBlock &SB);
> +template <> struct MappingTraits<msf::SuperBlock> {
> + static void mapping(IO &IO, msf::SuperBlock &SB);
> };
>
> template <> struct MappingTraits<pdb::yaml::StreamBlockList> {
>
> Modified: llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp (original)
> +++ llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp Fri Jul 22 14:56:05 2016
> @@ -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 {
>
> Modified: llvm/trunk/tools/llvm-readobj/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/CMakeLists.txt?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-readobj/CMakeLists.txt (original)
> +++ llvm/trunk/tools/llvm-readobj/CMakeLists.txt Fri Jul 22 14:56:05 2016
> @@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
> Object
> Support
> DebugInfoCodeView
> + DebugInfoMsf
> )
>
> add_llvm_tool(llvm-readobj
>
> Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
> +++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Fri Jul 22 14:56:05 2016
> @@ -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;
>
>
> Modified: llvm/trunk/tools/llvm-readobj/LLVMBuild.txt
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/LLVMBuild.txt?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-readobj/LLVMBuild.txt (original)
> +++ llvm/trunk/tools/llvm-readobj/LLVMBuild.txt Fri Jul 22 14:56:05 2016
> @@ -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
>
> Modified: llvm/trunk/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp (original)
> +++ llvm/trunk/unittests/DebugInfo/PDB/MappedBlockStreamTest.cpp Fri Jul 22 14:56:05 2016
> @@ -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 <unordered_map>
>
> 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<uint32_t> Blocks, MutableArrayRef<uint8_t> 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<uint8_t> SrcData) const override {
> if (BlockIndex >= Blocks.size())
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> + return make_error<MsfError>(msf_error_code::insufficient_buffer);
> if (Offset > getBlockSize() - SrcData.size())
> - return make_error<CodeViewError>(cv_error_code::insufficient_buffer);
> + return make_error<MsfError>(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<IPDBStreamData> Data,
> - const IPDBFile &File)
> + MappedBlockStreamImpl(std::unique_ptr<IMsfStreamData> Data,
> + const IMsfFile &File)
> : MappedBlockStream(std::move(Data), File) {}
> };
>
>
> Modified: llvm/trunk/unittests/DebugInfo/PDB/MsfBuilderTest.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/DebugInfo/PDB/MsfBuilderTest.cpp?rev=276458&r1=276457&r2=276458&view=diff
> ==============================================================================
> --- llvm/trunk/unittests/DebugInfo/PDB/MsfBuilderTest.cpp (original)
> +++ llvm/trunk/unittests/DebugInfo/PDB/MsfBuilderTest.cpp Fri Jul 22 14:56:05 2016
> @@ -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 {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list