#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 {
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();
+++ /dev/null
-//===- 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
#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"
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
#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))
}
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))
}
};
-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
#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:
};
typedef CVRecord<SymbolKind> CVSymbol;
-typedef VarStreamArray<CVSymbol> CVSymbolArray;
+typedef msf::VarStreamArray<CVSymbol> CVSymbolArray;
} // namespace codeview
} // namespace llvm
};
typedef CVRecord<TypeLeafKind> CVType;
-typedef VarStreamArray<CVType> CVTypeArray;
+typedef msf::VarStreamArray<CVType> CVTypeArray;
}
}
//
//===----------------------------------------------------------------------===//
-#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 {
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
//
//===----------------------------------------------------------------------===//
-#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;
};
}
}
-//===- IPDBFile.h - Abstract base class for a PDB file ----------*- C++ -*-===//
+//===- IMsfFile.h - Abstract base class for an MSF file ---------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#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;
}
}
-#endif // LLVM_DEBUGINFO_PDB_RAW_IPDBFILE_H
+#endif // LLVM_DEBUGINFO_MSF_IMSFFILE_H
-//===- IPDBStreamData.h - Base interface for PDB Stream Data ----*- C++ -*-===//
+//===- IMsfStreamData.h - Base interface for Msf Stream Data ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#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
/// 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
-//===- IndexedStreamData.h - Standard PDB Stream Data -----------*- C++ -*-===//
+//===- IndexedStreamData.h - Standard Msf Stream Data -----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#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;
private:
uint32_t StreamIdx;
- const IPDBFile &File;
+ const IMsfFile &File;
};
-}
-}
+} // namespace msf
+} // namespace llvm
-#endif
+#endif // LLVM_DEBUGINFO_MSF_INDEXEDSTREAMDATA_H
-//===- MappedBlockStream.h - Reads stream data from a PDBFile ---*- C++ -*-===//
+//===- MappedBlockStream.h - Discontiguous stream data in an Msf -*- C++
+//-*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#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"
#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;
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;
} // end namespace pdb
} // end namespace llvm
-#endif // LLVM_DEBUGINFO_PDB_RAW_MAPPEDBLOCKSTREAM_H
+#endif // LLVM_DEBUGINFO_MSF_MAPPEDBLOCKSTREAM_H
//
//===----------------------------------------------------------------------===//
-#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"
#include <vector>
namespace llvm {
-namespace pdb {
+namespace msf {
class MsfBuilder {
public:
/// \brief Create a new `MsfBuilder`.
///
/// \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
///
/// \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
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.
/// 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,
std::vector<uint32_t> DirectoryBlocks;
std::vector<std::pair<uint32_t, BlockList>> StreamData;
};
-}
-}
+} // namespace msf
+} // namespace llvm
-#endif
+#endif // LLVM_DEBUGINFO_MSF_MSFBUILDER_H
//
//===----------------------------------------------------------------------===//
-#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"
#include <vector>
namespace llvm {
-namespace pdb {
namespace msf {
static const char Magic[] = {'M', 'i', 'c', 'r', 'o', 's', 'o', 'f',
't', ' ', 'C', '/', 'C', '+', '+', ' ',
// 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.
}
Error validateSuperBlock(const SuperBlock &SB);
-}
-}
-}
+} // namespace msf
+} // namespace llvm
-#endif
+#endif // LLVM_DEBUGINFO_MSF_MSFCOMMON_H
--- /dev/null
+//===- 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
//
//===----------------------------------------------------------------------===//
-#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
uint32_t Index;
};
-} // namespace codeview
+} // namespace msf
} // namespace llvm
-#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMARRAY_H
+#endif // LLVM_DEBUGINFO_MSF_STREAMARRAY_H
//
//===----------------------------------------------------------------------===//
-#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
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
//
//===----------------------------------------------------------------------===//
-#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;
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;
}
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;
StreamRef Stream;
uint32_t Offset;
};
-} // namespace codeview
+} // namespace msf
} // namespace llvm
-#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMREADER_H
+#endif // LLVM_DEBUGINFO_MSF_STREAMREADER_H
//
//===----------------------------------------------------------------------===//
-#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:
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);
}
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;
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);
}
uint32_t ViewOffset;
uint32_t Length;
};
-}
-}
+} // namespace msf
+} // namespace llvm
-#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMREF_H
+#endif // LLVM_DEBUGINFO_MSF_STREAMREF_H
//
//===----------------------------------------------------------------------===//
-#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;
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()),
StreamRef Stream;
uint32_t Offset;
};
-} // namespace codeview
+} // namespace msf
} // namespace llvm
-#endif // LLVM_DEBUGINFO_CODEVIEW_STREAMREADER_H
+#endif // LLVM_DEBUGINFO_MSF_STREAMWRITER_H
#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"
friend class DbiStreamBuilder;
public:
- DbiStream(PDBFile &File, std::unique_ptr<MappedBlockStream> Stream);
+ DbiStream(PDBFile &File, std::unique_ptr<msf::MappedBlockStream> Stream);
~DbiStream();
Error reload();
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();
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;
};
#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"
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;
};
}
}
#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"
};
public:
- InfoStream(std::unique_ptr<MappedBlockStream> Stream);
+ InfoStream(std::unique_ptr<msf::MappedBlockStream> Stream);
Error reload();
Error commit();
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.
#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>
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;
} // end namespace pdb
-namespace codeview {
+namespace msf {
template <> struct VarStreamArrayExtractor<pdb::ModInfo> {
Error operator()(StreamRef Stream, uint32_t &Length,
pdb::ModInfo &Info) const {
return Error::success();
}
};
-}
+} // end namespace msf
} // end namespace llvm
#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 {
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();
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;
};
#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 {
public:
NameHashTable();
- Error load(codeview::StreamReader &Stream);
+ Error load(msf::StreamReader &Stream);
uint32_t getNameCount() const { return NameCount; }
uint32_t getHashVersion() const { return HashVersion; }
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;
#include <cstdint>
namespace llvm {
-namespace codeview {
+namespace msf {
class StreamReader;
class StreamWriter;
}
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;
#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"
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;
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;
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;
};
}
#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 {
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();
std::unique_ptr<DbiStreamBuilder> Dbi;
std::unique_ptr<PDBFile> File;
- std::unique_ptr<MsfBuilder> Msf;
+ std::unique_ptr<msf::MsfBuilder> Msf;
};
}
}
#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"
struct HeaderInfo;
public:
- PublicsStream(PDBFile &File, std::unique_ptr<MappedBlockStream> Stream);
+ PublicsStream(PDBFile &File, std::unique_ptr<msf::MappedBlockStream> Stream);
~PublicsStream();
Error reload();
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;
}
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;
#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();
private:
codeview::CVSymbolArray SymbolRecords;
- std::unique_ptr<MappedBlockStream> Stream;
+ std::unique_ptr<msf::MappedBlockStream> Stream;
};
}
}
#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"
#include "llvm/Support/Error.h"
namespace llvm {
+namespace msf {
+class MappedBlockStream;
+}
namespace pdb {
class PDBFile;
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();
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;
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;
};
#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"
#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"
using namespace llvm;
using namespace llvm::codeview;
+using namespace llvm::msf;
CodeViewDebug::CodeViewDebug(AsmPrinter *AP)
: DebugHandlerBase(AP), OS(*Asm->OutStreamer), CurFn(nullptr) {
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
-add_subdirectory(CodeView)
add_subdirectory(DWARF)
+add_subdirectory(Msf)
+add_subdirectory(CodeView)
add_subdirectory(PDB)
add_subdirectory(Symbolize)
add_llvm_library(LLVMDebugInfoCodeView
- ByteStream.cpp
CodeViewError.cpp
CVTypeVisitor.cpp
EnumTables.cpp
ModuleSubstream.cpp
ModuleSubstreamVisitor.cpp
RecordSerialization.cpp
- StreamReader.cpp
- StreamWriter.cpp
SymbolDumper.cpp
TypeDumper.cpp
TypeRecord.cpp
//===----------------------------------------------------------------------===//
#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
+#include "llvm/DebugInfo/CodeView/CodeViewError.h"
using namespace llvm;
using namespace llvm::codeview;
type = Library
name = DebugInfoCodeView
parent = DebugInfo
-required_libraries = Support
+required_libraries = Support DebugInfoMsf
#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) {}
using namespace llvm;
using namespace llvm::codeview;
+using namespace llvm::msf;
Error IModuleSubstreamVisitor::visitSymbols(StreamRef Data) {
return visitUnknown(ModuleSubstreamKind::Symbols, Data);
#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;
}
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;
#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"
;===------------------------------------------------------------------------===;
[common]
-subdirectories = CodeView DWARF PDB Symbolize
+subdirectories = DWARF Msf CodeView PDB Symbolize
[component_0]
type = Group
//
//===----------------------------------------------------------------------===//
-#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();
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();
}
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();
}
}
namespace llvm {
-namespace codeview {
+namespace msf {
template class ByteStream<true>;
template class ByteStream<false>;
}
--- /dev/null
+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"
+ )
//
//===----------------------------------------------------------------------===//
-#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() {
--- /dev/null
+;===- ./lib/DebugInfo/Msf/LLVMBuild.txt -------------------*- Conf -*--===;
+;
+; The LLVM Compiler Infrastructure
+;
+; This file is distributed under the University of Illinois Open Source
+; License. See LICENSE.TXT for details.
+;
+;===------------------------------------------------------------------------===;
+;
+; This is an LLVMBuild description file for the components in this subdirectory.
+;
+; For more information on the LLVMBuild system, please see:
+;
+; http://llvm.org/docs/LLVMBuild.html
+;
+;===------------------------------------------------------------------------===;
+
+[component_0]
+type = Library
+name = DebugInfoMsf
+parent = DebugInfo
+required_libraries = Support
-//===- MappedBlockStream.cpp - Reads stream data from a PDBFile -----------===//
+//===- MappedBlockStream.cpp - Reads stream data from an MSF file ---------===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
-#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) {}
};
}
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();
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);
// 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;
}
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;
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;
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;
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();
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;
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);
}
//
//===----------------------------------------------------------------------===//
-#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 {
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,
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;
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;
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);
// 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.
}
// 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);
//
//===----------------------------------------------------------------------===//
-#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
// 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();
--- /dev/null
+//===- 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);
+}
//
//===----------------------------------------------------------------------===//
-#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) {}
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();
//
//===----------------------------------------------------------------------===//
-#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) {}
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
type = Library
name = DebugInfoPDB
parent = DebugInfo
-required_libraries = Object Support DebugInfoCodeView
+required_libraries = Object Support DebugInfoCodeView DebugInfoMsf
#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"
using namespace llvm;
using namespace llvm::codeview;
+using namespace llvm::msf;
using namespace llvm::pdb;
using namespace llvm::support;
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;
}
"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.");
"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.");
#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 {
#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))
#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() {}
#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;
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;
#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,
ModStream::~ModStream() {}
Error ModStream::reload() {
- codeview::StreamReader Reader(*Stream);
+ StreamReader Reader(*Stream);
uint32_t SymbolSize = Mod.getSymbolDebugInfoByteSize();
uint32_t C11Size = Mod.getLineInfoByteSize();
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))
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;
#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;
// 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));
return IDs[0];
}
-codeview::FixedStreamArray<support::ulittle32_t>
-NameHashTable::name_ids() const {
+FixedStreamArray<support::ulittle32_t> NameHashTable::name_ids() const {
return IDs;
}
#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.
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.
#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"
using namespace llvm;
using namespace llvm::codeview;
+using namespace llvm::msf;
using namespace llvm::pdb;
namespace {
// 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);
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);
#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"
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) {
#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"
#include "llvm/Support/MathExtras.h"
using namespace llvm;
+using namespace llvm::msf;
using namespace llvm::support;
using namespace llvm::pdb;
// 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))
#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"
#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(),
#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"
#include "llvm/Support/Endian.h"
using namespace llvm;
+using namespace llvm::msf;
using namespace llvm::support;
using namespace llvm::pdb;
SymbolStream::~SymbolStream() {}
Error SymbolStream::reload() {
- codeview::StreamReader Reader(*Stream);
+ StreamReader Reader(*Stream);
if (auto EC = Reader.readArray(SymbolRecords, Stream->getLength()))
return EC;
#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"
using namespace llvm;
using namespace llvm::codeview;
using namespace llvm::support;
+using namespace llvm::msf;
using namespace llvm::pdb;
namespace {
set(LLVM_LINK_COMPONENTS
DebugInfoCodeView
+ DebugInfoMsf
DebugInfoPDB
Object
Support
type = Tool
name = llvm-pdbdump
parent = Tools
-required_libraries = DebugInfoPDB
+required_libraries = DebugInfoMsf DebugInfoPDB
#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"
using namespace llvm;
using namespace llvm::codeview;
+using namespace llvm::msf;
using namespace llvm::pdb;
static void printSectionOffset(llvm::raw_ostream &OS,
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(
MappedBlockStream::createIndexedStream(NameStreamIndex, File);
if (!NameStream)
return NameStream.takeError();
- codeview::StreamReader Reader(**NameStream);
+ StreamReader Reader(**NameStream);
NameHashTable NameTable;
if (auto EC = NameTable.load(Reader))
#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;
#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"
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> {
#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"
using namespace llvm;
using namespace llvm::codeview;
+using namespace llvm::msf;
using namespace llvm::pdb;
namespace {
Object
Support
DebugInfoCodeView
+ DebugInfoMsf
)
add_llvm_tool(llvm-readobj
#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"
#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"
using namespace llvm;
using namespace llvm::object;
using namespace llvm::codeview;
+using namespace llvm::msf;
using namespace llvm::support;
using namespace llvm::Win64EH;
type = Tool
name = llvm-readobj
parent = Tools
-required_libraries = all-targets BitReader Object
+required_libraries = all-targets BitReader Object DebugInfoCodeView DebugInfoMsf
#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()) {}
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();
}
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) {}
};
#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 {