<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, Oct 7, 2016 at 11:47 AM Rui Ueyama <<a href="mailto:ruiu@google.com">ruiu@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg">On Thu, Oct 6, 2016 at 11:42 PM, Zachary Turner <span dir="ltr" class="gmail_msg"><<a href="mailto:zturner@google.com" class="gmail_msg" target="_blank">zturner@google.com</a>></span> wrote:<br class="gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class="gmail_msg">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.<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">So instead, how about adding something to DbiStreamBuilder.  It could be called</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">void setDbgStreamBytes(DbgHeaderType Type, ArrayRef<uint8_t> Bytes);</div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></div></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg">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.</div></div></div></div></blockquote><div><br></div>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.<br><div><br></div><div>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.</div></div></div>