This is an archive of the discontinued LLVM Phabricator instance.

Expose PDBFileBuilder::finalizeMsfLayout.
ClosedPublic

Authored by ruiu on Sep 30 2016, 9:55 AM.

Details

Summary

In many cases, clients of PDBFileBuilder generally needs to know
the exact file size before calling PDBFileBuilder::commit() so that
they can create output files with the exact sizes (this is needed
if you are using mmap'ed IO.)

This patch exposes finalizeMsfLayout and defines getMsf which
returns a MSFLayout object. Because MSFLayout object contains a
superblock which in turn contains the number of blocks, we can
compute the total file size by calling these functions.

Event Timeline

ruiu updated this revision to Diff 73077.Sep 30 2016, 9:55 AM
ruiu retitled this revision from to Expose PDBFileBuilder::finalizeMsfLayout..
ruiu updated this object.
ruiu added a reviewer: zturner.
ruiu added a subscriber: llvm-commits.
zturner added inline comments.Sep 30 2016, 10:32 AM
include/llvm/DebugInfo/PDB/Raw/PDBFileBuilder.h
53

I'm not sure if making this public is a good idea. This leaves open the possibility that someone could mis-use the class.

I can think of two solutions that would still keep this private:

  1. Changing commit so that instead of taking an msf::WritableStream it takes a filename. Then you create the stream in there.
  1. Change the implementation of FileBufferByteStream so that instead of taking a FileOutputBuffer to its constructor, it only takes a filename. Add a method to that class called create(uint64_t size). Then the signature of commit is changed to take an msf::FileBufferByteStream and after internally finalizing the layout, it calls stream.create(layout.size).

What do you think?

ruiu updated this revision to Diff 73117.Sep 30 2016, 12:32 PM
  • Updated as per discussion with Zach.
zturner accepted this revision.Sep 30 2016, 1:35 PM
zturner edited edge metadata.
This revision is now accepted and ready to land.Sep 30 2016, 1:35 PM
This revision was automatically updated to reflect the committed changes.