[PATCH] D22308: [pdb] Introduce an MsfBuilder class for laying out PDB files

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 13 15:24:17 PDT 2016


zturner added inline comments.

================
Comment at: include/llvm/DebugInfo/PDB/Raw/MsfBuilder.h:33
@@ +32,3 @@
+                  bool CanGrow = true);
+  void reset();
+
----------------
ruiu wrote:
> What's the use case of `reset()`? You can create as many instances of this class as you want, so wouldn't it be easier to make it a non-reusable class?
`build()` calls `reset()` after it's done to invalidate the entire structure so you have to start over.  It would be nice if you could call `build()`, make one or two simple changes, then call `build()` again, but it's a little bit tricky for technical reasons, so for now I'm just having `build()` invalidate it.

================
Comment at: include/llvm/DebugInfo/PDB/Raw/MsfBuilder.h:67
@@ +66,3 @@
+  BitVector FreePages;
+  std::vector<std::pair<uint32_t, BlockList>> StreamData;
+};
----------------
ruiu wrote:
> Which member contains streams' actual data?
> 
> Ahh, so this class is to constructs only the MSF header, and stream data is managed separately outside of this class. Is this correct? So it seems that you'd use this class to create a MSF directory, obtain a Layout object, and write each stream as the returned layout. Not sure how you would handle actual file writing, but this is probably just out of scope of this patch.
Correct, this is only to generate in-memory objects that describe the layout of an MSF.  I have some file writing in other patches but I didn't want to submit it all at once.  But the short version is you create a `PDBFileBuilder` which will contain an `MsfBuilder`, then add streams to the `MsfBuilder`, then make some edits using the `PDBFileBuilder` (like setting fields from the individual streams to a different value).

Since my use case right now is editing a PDB (i.e. reading one in, making some changes, writing it back out), there's no code yet to generate one from scratch.  But all the writing to disk and setting stream fields and serializing is working, so it should be easy to extend to generate a PDB from scratch.


http://reviews.llvm.org/D22308





More information about the llvm-commits mailing list