summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h2
-rw-r--r--llvm/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp14
-rw-r--r--llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp10
3 files changed, 13 insertions, 13 deletions
diff --git a/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h b/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h
index 52170a447d1..843ea97aa5f 100644
--- a/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h
+++ b/llvm/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h
@@ -47,7 +47,7 @@ public:
Expected<std::unique_ptr<PDBFile>>
build(std::unique_ptr<msf::WritableStream> PdbFileBuffer);
- Error commit(const msf::WritableStream &Buffer);
+ Error commit(StringRef Filename);
private:
Expected<msf::MSFLayout> finalizeMsfLayout() const;
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
+}
diff --git a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
index ca4666085d6..bfd9058627f 100644
--- a/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
+++ b/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
@@ -321,14 +321,6 @@ static void yamlToPdb(StringRef Path) {
ExitOnErr(make_error<GenericError>(generic_error_code::unspecified,
"Yaml does not contain MSF headers"));
- auto OutFileOrError = FileOutputBuffer::create(
- opts::yaml2pdb::YamlPdbOutputFile, YamlObj.Headers->FileSize);
- if (OutFileOrError.getError())
- ExitOnErr(make_error<GenericError>(generic_error_code::invalid_path,
- opts::yaml2pdb::YamlPdbOutputFile));
-
- auto FileByteStream =
- llvm::make_unique<FileBufferByteStream>(std::move(*OutFileOrError));
PDBFileBuilder Builder(Allocator);
ExitOnErr(Builder.initialize(YamlObj.Headers->SuperBlock));
@@ -382,7 +374,7 @@ static void yamlToPdb(StringRef Path) {
IpiBuilder.addTypeRecord(R.Record);
}
- ExitOnErr(Builder.commit(*FileByteStream));
+ ExitOnErr(Builder.commit(opts::yaml2pdb::YamlPdbOutputFile));
}
static void pdb2Yaml(StringRef Path) {
OpenPOWER on IntegriCloud