summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-07-28 19:12:28 +0000
committerZachary Turner <zturner@google.com>2016-07-28 19:12:28 +0000
commitd66889cbae749ceffca88f094274e2d64c2cb8f8 (patch)
tree81e34f9af216751ced0d50609d558d2f15277b46 /llvm/tools
parent199f48a5f0d5aee8737880a78d81216d60cf785d (diff)
downloadbcm5719-llvm-d66889cbae749ceffca88f094274e2d64c2cb8f8.tar.gz
bcm5719-llvm-d66889cbae749ceffca88f094274e2d64c2cb8f8.zip
[pdb] Refactor library to more clearly separate reading/writing
Reviewed By: amccarth, ruiu Differential Revision: https://reviews.llvm.org/D22693 llvm-svn: 277019
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp30
-rw-r--r--llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp27
-rw-r--r--llvm/tools/llvm-readobj/COFFDumper.cpp4
3 files changed, 17 insertions, 44 deletions
diff --git a/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp b/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
index 6448b38cf47..95ea48d8f43 100644
--- a/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
+++ b/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
@@ -259,10 +259,9 @@ Error LLVMOutputStyle::dumpStreamData() {
if (DumpStreamNum >= StreamCount)
return make_error<RawError>(raw_error_code::no_stream);
- auto S = MappedBlockStream::createIndexedStream(DumpStreamNum, File);
- if (!S)
- return S.takeError();
- StreamReader R(**S);
+ auto S = MappedBlockStream::createIndexedStream(
+ File.getMsfLayout(), File.getMsfBuffer(), DumpStreamNum);
+ StreamReader R(*S);
while (R.bytesRemaining() > 0) {
ArrayRef<uint8_t> Data;
uint32_t BytesToReadInBlock = std::min(
@@ -311,11 +310,9 @@ Error LLVMOutputStyle::dumpNamedStream() {
DictScope D(P, Name);
P.printNumber("Index", NameStreamIndex);
- auto NameStream =
- MappedBlockStream::createIndexedStream(NameStreamIndex, File);
- if (!NameStream)
- return NameStream.takeError();
- StreamReader Reader(**NameStream);
+ auto NameStream = MappedBlockStream::createIndexedStream(
+ File.getMsfLayout(), File.getMsfBuffer(), NameStreamIndex);
+ StreamReader Reader(*NameStream);
NameHashTable NameTable;
if (auto EC = NameTable.load(Reader))
@@ -486,10 +483,10 @@ Error LLVMOutputStyle::dumpDbiStream() {
(opts::raw::DumpModuleSyms || opts::raw::DumpSymRecordBytes);
if (HasModuleDI && (ShouldDumpSymbols || opts::raw::DumpLineInfo)) {
auto ModStreamData = MappedBlockStream::createIndexedStream(
- Modi.Info.getModuleStreamIndex(), File);
- if (!ModStreamData)
- return ModStreamData.takeError();
- ModStream ModS(Modi.Info, std::move(*ModStreamData));
+ File.getMsfLayout(), File.getMsfBuffer(),
+ Modi.Info.getModuleStreamIndex());
+
+ ModStream ModS(Modi.Info, std::move(ModStreamData));
if (auto EC = ModS.reload())
return EC;
@@ -519,7 +516,7 @@ Error LLVMOutputStyle::dumpDbiStream() {
public:
RecordVisitor(ScopedPrinter &P, PDBFile &F) : P(P), F(F) {}
Error visitUnknown(ModuleSubstreamKind Kind,
- StreamRef Stream) override {
+ ReadableStreamRef Stream) override {
DictScope DD(P, "Unknown");
ArrayRef<uint8_t> Data;
StreamReader R(Stream);
@@ -532,7 +529,7 @@ Error LLVMOutputStyle::dumpDbiStream() {
return Error::success();
}
Error
- visitFileChecksums(StreamRef Data,
+ visitFileChecksums(ReadableStreamRef Data,
const FileChecksumArray &Checksums) override {
DictScope DD(P, "FileChecksums");
for (const auto &C : Checksums) {
@@ -548,7 +545,8 @@ Error LLVMOutputStyle::dumpDbiStream() {
return Error::success();
}
- Error visitLines(StreamRef Data, const LineSubstreamHeader *Header,
+ Error visitLines(ReadableStreamRef Data,
+ const LineSubstreamHeader *Header,
const LineInfoArray &Lines) override {
DictScope DD(P, "Lines");
for (const auto &L : Lines) {
diff --git a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
index 6c7d6058e8d..e8951886215 100644
--- a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
+++ b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
@@ -69,27 +69,6 @@ using namespace llvm::codeview;
using namespace llvm::msf;
using namespace llvm::pdb;
-namespace {
-// A simple adapter that acts like a ByteStream but holds ownership over
-// and underlying FileOutputBuffer.
-class FileBufferByteStream : public ByteStream<true> {
-public:
- FileBufferByteStream(std::unique_ptr<FileOutputBuffer> Buffer)
- : ByteStream(MutableArrayRef<uint8_t>(Buffer->getBufferStart(),
- Buffer->getBufferEnd())),
- FileBuffer(std::move(Buffer)) {}
-
- Error commit() const override {
- if (FileBuffer->commit())
- return llvm::make_error<RawError>(raw_error_code::not_writable);
- return Error::success();
- }
-
-private:
- std::unique_ptr<FileOutputBuffer> FileBuffer;
-};
-}
-
namespace opts {
cl::SubCommand RawSubcommand("raw", "Dump raw structure of the PDB file");
@@ -395,11 +374,7 @@ static void yamlToPdb(StringRef Path) {
}
}
- auto Pdb = Builder.build(std::move(FileByteStream));
- ExitOnErr(Pdb.takeError());
-
- auto &PdbFile = *Pdb;
- ExitOnErr(PdbFile->commit());
+ ExitOnErr(Builder.commit(*FileByteStream));
}
static void pdb2Yaml(StringRef Path) {
diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp
index b6f7d436168..12a4292e238 100644
--- a/llvm/tools/llvm-readobj/COFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/COFFDumper.cpp
@@ -954,7 +954,7 @@ void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection,
SectionContents);
CVSymbolDumper CVSD(W, CVTD, std::move(CODD), opts::CodeViewSubsectionBytes);
- ByteStream<> Stream(BinaryData);
+ ByteStream Stream(BinaryData);
CVSymbolArray Symbols;
StreamReader Reader(Stream);
if (auto EC = Reader.readArray(Symbols, Reader.getLength())) {
@@ -1062,7 +1062,7 @@ void COFFDumper::mergeCodeViewTypes(MemoryTypeTableBuilder &CVTypes) {
error(object_error::parse_failed);
ArrayRef<uint8_t> Bytes(reinterpret_cast<const uint8_t *>(Data.data()),
Data.size());
- ByteStream<> Stream(Bytes);
+ ByteStream Stream(Bytes);
CVTypeArray Types;
StreamReader Reader(Stream);
if (auto EC = Reader.readArray(Types, Reader.getLength())) {
OpenPOWER on IntegriCloud