[PATCH] D25356: Define PDBFileBuilder::addStream to add stream.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 7 11:57:40 PDT 2016


On Fri, Oct 7, 2016 at 11:47 AM Rui Ueyama <ruiu at google.com> wrote:

> On Thu, Oct 6, 2016 at 11:42 PM, Zachary Turner <zturner at google.com>
> wrote:
>
> Ok I think I understand this more now.  I don't think we should expose
> this method, because for one thing just writing the data to this stream is
> not sufficient to link it up to the PDB.  It has to be referenced from the
> DBI stream, and is one of the "optional debug streams" that comes at the
> end of the DBI stream.
>
> So instead, how about adding something to DbiStreamBuilder.  It could be
> called
>
> void setDbgStreamBytes(DbgHeaderType Type, ArrayRef<uint8_t> Bytes);
>
>
> I tried this but I think I don't like the result. The problem is that this
> method has to add a new stream to a PDB file, so DbiStreamBuilder is now
> builds not only a DBI stream but other streams. I'd instead add this method
> to PDBFileBuilder so that new streams are owned by a PDBFileBuilder.
> PDBFileBuilder is now responsible to keep the debug indices consistent.
>

Honestly I think I actually like it this way.  the Debug Stream doesn't
make sense without a Dbi Stream, so conceptually it makes sense to have to
ask the Dbi stream to allocate a debug stream for you.  The "ownership" of
the underlying stream all goes to the same place anyway, which is the MSF.
All the various builders are already sharing a reference to a single
MSFBuilder class, so they all have the freedom to allocate new streams as
needed.  The ownership of the streams still belongs to the MSFBuilder.

Currently I'm working on doing writing for the Modi streams (e.g. debug
symbols for each module).  If we follow the same approach, then the
PDBFileBuilder would also have another array of all the Modi streams, which
could number in the hundreds, even though they are really tightly coupled
with the underlying Module.  So if the module goes away, so should the Modi
stream.  I think accessing the builder in the same way as you access the
reading code makes the transition between reading and writing more fluent.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161007/4d623822/attachment.html>


More information about the llvm-commits mailing list