[PATCH] D25107: Expose PDBFileBuilder::finalizeMsfLayout.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 30 13:43:41 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL282940: Pass a filename instead of a msf::WritableStream to PDBFileBuilder::commit. (authored by ruiu).

Changed prior to commit:
  https://reviews.llvm.org/D25107?vs=73117&id=73130#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25107

Files:
  llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h
  llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
  llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp


Index: llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h
===================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h
+++ llvm/trunk/include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h
@@ -47,7 +47,7 @@
   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;
Index: llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
===================================================================
--- llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
+++ llvm/trunk/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 @@
   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 @@
   }
 
   return Buffer.commit();
-}
\ No newline at end of file
+}
Index: llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
===================================================================
--- llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
+++ llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
@@ -321,14 +321,6 @@
     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 @@
       IpiBuilder.addTypeRecord(R.Record);
   }
 
-  ExitOnErr(Builder.commit(*FileByteStream));
+  ExitOnErr(Builder.commit(opts::yaml2pdb::YamlPdbOutputFile));
 }
 
 static void pdb2Yaml(StringRef Path) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25107.73130.patch
Type: text/x-patch
Size: 3207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160930/2a67f8c0/attachment.bin>


More information about the llvm-commits mailing list