summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2016-09-30 20:34:44 +0000
committerRui Ueyama <ruiu@google.com>2016-09-30 20:34:44 +0000
commitfc22cef98ed96ac3aa471b66315ebc54e3421762 (patch)
tree1fbfa0bf268c529479a2109968b575f013e20044 /llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
parente2d19c3d1e97ac4796b418abc9a26751fd932029 (diff)
downloadbcm5719-llvm-fc22cef98ed96ac3aa471b66315ebc54e3421762.tar.gz
bcm5719-llvm-fc22cef98ed96ac3aa471b66315ebc54e3421762.zip
Pass a filename instead of a msf::WritableStream to PDBFileBuilder::commit.
WritableStream needs the exact file size to open a file, but until we fix the final layout of a PDB file, we don't know the size of the file. This patch changes the parameter type of PDBFileBuilder::commit to solve that chiecken-and-egg problem. Now the function opens a file after fixing the layout, so it can create a file with the exact size. Differential Revision: https://reviews.llvm.org/D25107 llvm-svn: 282940
Diffstat (limited to 'llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp')
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp b/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
index 165b03cf370..5b9f9461608 100644
--- a/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
@@ -14,6 +14,7 @@
#include "llvm/DebugInfo/MSF/MSFBuilder.h"
#include "llvm/DebugInfo/MSF/StreamInterface.h"
#include "llvm/DebugInfo/MSF/StreamWriter.h"
+#include "llvm/DebugInfo/PDB/GenericError.h"
#include "llvm/DebugInfo/PDB/Raw/DbiStream.h"
#include "llvm/DebugInfo/PDB/Raw/DbiStreamBuilder.h"
#include "llvm/DebugInfo/PDB/Raw/InfoStream.h"
@@ -138,13 +139,20 @@ PDBFileBuilder::build(std::unique_ptr<msf::WritableStream> PdbFileBuffer) {
return std::move(File);
}
-Error PDBFileBuilder::commit(const msf::WritableStream &Buffer) {
- StreamWriter Writer(Buffer);
+Error PDBFileBuilder::commit(StringRef Filename) {
auto ExpectedLayout = finalizeMsfLayout();
if (!ExpectedLayout)
return ExpectedLayout.takeError();
auto &Layout = *ExpectedLayout;
+ uint64_t Filesize = Layout.SB->BlockSize * Layout.SB->NumBlocks;
+ auto OutFileOrError = FileOutputBuffer::create(Filename, Filesize);
+ if (OutFileOrError.getError())
+ return llvm::make_error<pdb::GenericError>(generic_error_code::invalid_path,
+ Filename);
+ FileBufferByteStream Buffer(std::move(*OutFileOrError));
+ StreamWriter Writer(Buffer);
+
if (auto EC = Writer.writeObject(*Layout.SB))
return EC;
uint32_t BlockMapOffset =
@@ -189,4 +197,4 @@ Error PDBFileBuilder::commit(const msf::WritableStream &Buffer) {
}
return Buffer.commit();
-} \ No newline at end of file
+}
OpenPOWER on IntegriCloud