[PATCH] D23145: pdbdump: Write a free page map to page 1 or page 2.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 9 07:17:23 PDT 2016


zturner added inline comments.

================
Comment at: lib/DebugInfo/MSF/MSFBuilder.cpp:259
@@ +258,3 @@
+  // for the FPM.
+  uint32_t NumFPMs = alignTo(FreeBlocks.size(), BlockSize) / BlockSize;
+  for (uint32_t I = 0; I != NumFPMs; ++I) {
----------------
Use `msf::getNumFpmIntervals()`

================
Comment at: lib/DebugInfo/PDB/Raw/PDBFileBuilder.cpp:118-132
@@ +117,17 @@
+  // Write free page map.
+  uint32_t BlockSize = Layout.SB->BlockSize;
+  BitVector FPM = Layout.FreePageMap;
+  FPM.resize(alignTo(FPM.size(), BlockSize), true);
+  uint32_t NumFPMBlocks = FPM.size() / BlockSize;
+  for (uint32_t I = 0; I != NumFPMBlocks; ++I) {
+    std::vector<uint8_t> Buf(Layout.SB->BlockSize);
+    for (uint32_t J = 0; J != BlockSize; ++J)
+      if (FPM[I * BlockSize + J])
+        Buf[J / 8] |= 1 << (J % 8);
+
+    uint32_t PageNum = I * BlockSize + Layout.SB->FreeBlockMapBlock;
+    Writer.setOffset(PageNum * BlockSize);
+    if (auto EC = Writer.writeArray(ArrayRef<uint8_t>(Buf)))
+      return EC;
+  }
+
----------------
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>`


https://reviews.llvm.org/D23145





More information about the llvm-commits mailing list