This is an archive of the discontinued LLVM Phabricator instance.

pdbdump: Write a free page map to page 1 or page 2.
Needs ReviewPublic

Authored by ruiu on Aug 3 2016, 5:30 PM.

Details

Reviewers
zturner
Summary

As I wrote in a comment, llvm-pdbdump seems to not be able to restore
stream 0 correctly. That is why we get different results for empty.pdb
and our pdb file.

This patch is to write only one FPM. So it still cannot produce large
PDBs which need more than one FPM page.

Diff Detail

Event Timeline

ruiu updated this revision to Diff 66741.Aug 3 2016, 5:30 PM
ruiu retitled this revision from to pdbdump: Write a free page map to page 1 or page 2..
ruiu updated this object.
ruiu added a reviewer: zturner.
ruiu added a subscriber: llvm-commits.
ruiu added a comment.Aug 3 2016, 5:52 PM

I guess incremental patches are a preferred way, so in either way, don't you think submitting this is a good idea?

zturner added inline comments.Aug 3 2016, 6:13 PM
lib/DebugInfo/MSF/MSFBuilder.cpp
261

Can we use false instead of 0?

lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
130

To fix the page 0 problem, how about this:

auto L = Layout.FreePageMap;
for (uint32_t BlockNumber : Layout.StreamMap[0].second)
  L[BlockNumber] = true;

and then write L instead of Layout.FreePageMap?

ruiu updated this revision to Diff 67288.Aug 8 2016, 11:48 PM

Support split free page map blocks.

At first, I tried to add FreePageMapBlocks to MSFLayout (as analogous
to DirectoryBlocks) to store the block numbers for split FPMs. But
then I realized that that information can be computed later because the
block layout for the split FPM is fixed. So I moved the logic to
PDBFileBuilder.

zturner added inline comments.Aug 9 2016, 7:17 AM
lib/DebugInfo/MSF/MSFBuilder.cpp
259

Use msf::getNumFpmIntervals()

lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp
130–144

This whole block can be written as:

auto FpmStream = WritableMappedBlockStream::createFpmStream(Layout);
StreamWriter FpmWriter(FpmStream);
if (auto EC = FpmWriter.writeBytes(Layout.FreePageMap.getAsByteArray()))
  return EC;

You would need to create the function BitVector::getAsByteArray() and have it return an ArrayRef<uint8_t>

ruiu updated this revision to Diff 67370.Aug 9 2016, 10:40 AM
  • Define BitVector::getAsByteVector.
ruiu added a comment.Aug 9 2016, 10:42 AM

We cannot return an ArrayRef to the internal buffer because of endianness issue. The internal vector is not a byte array, but an array of the word size (32 or 64 bits), so if we return it as a byte array, the result would be different on the BE than on the LE machine. One thing we could do is to return a std::vector as I did in this patch. I'm not sure if this is the right thing to do, though. The other approach would be to use byte instead of word as the internal buffer type. Do you want me to try it?

ruiu updated this revision to Diff 68641.Aug 18 2016, 6:20 PM
  • Updated to remove changes to BitVector.