[PATCH] D48738: Add the ability to edit stream contents with llvm-pdbutil

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 28 13:08:18 PDT 2018


zturner created this revision.
zturner added a reviewer: inglorion.
Herald added a subscriber: hiraditya.

For experimentation and diagnostic purposes, it's often useful to be able to replace the contents of one stream with a binary blob.  For example, if you have one PDB that works and one that doesn't, this can be useful for helping understand why the broken one is broken.  You can replace stream contents 1 by 1 until something starts working.  This is trickier than it sounds though, because if a stream's size changes it changes the stream directory as well, and in some cases could even cause the file to grow (or shrink).

To do this we load the old MSF layout and create an `MSFBuilder` out of it with the exact same properties as the existing file.  Then we load the new stream contents and update the stream size, which should automatically decide how big the new file should be and where the new stream's blocks will be.  Finally, we re-open the original file in a special mode that allows partial writes, keeping any untouched data intact, then write out only the modified MSF layout and new stream contents.  In some cases -- particularly if a stream shrinks -- there will be "stale" data in the PDB file, but this shouldn't matter because the stream directory keeps track of a stream's *actual* size, so any tool reading the PDB would just ignore the stale data.


https://reviews.llvm.org/D48738

Files:
  llvm/include/llvm/DebugInfo/MSF/MSFBuilder.h
  llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
  llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48738.153376.patch
Type: text/x-patch
Size: 10538 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180628/ba3ad44e/attachment.bin>


More information about the llvm-commits mailing list