[llvm] r277216 - pdbdump: Dump Free Page Map contents.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 29 14:54:12 PDT 2016
If you are talking about FPMs for larger files, yes, but before that we
need to figure out the exact file format.
On Fri, Jul 29, 2016 at 2:52 PM, David Majnemer <david.majnemer at gmail.com>
wrote:
> Do you intend to implement reading of the second fpm in a later patch?
>
>
> On Friday, July 29, 2016, Rui Ueyama via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> Author: ruiu
>> Date: Fri Jul 29 16:38:00 2016
>> New Revision: 277216
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=277216&view=rev
>> Log:
>> pdbdump: Dump Free Page Map contents.
>>
>> Differential Revision: https://reviews.llvm.org/D22974
>>
>> Modified:
>> llvm/trunk/include/llvm/DebugInfo/MSF/MSFCommon.h
>> llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp
>> llvm/trunk/test/DebugInfo/PDB/pdbdump-headers.test
>> llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp
>> llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.h
>> llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
>> llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.h
>>
>> Modified: llvm/trunk/include/llvm/DebugInfo/MSF/MSFCommon.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/MSF/MSFCommon.h?rev=277216&r1=277215&r2=277216&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/include/llvm/DebugInfo/MSF/MSFCommon.h (original)
>> +++ llvm/trunk/include/llvm/DebugInfo/MSF/MSFCommon.h Fri Jul 29 16:38:00
>> 2016
>> @@ -11,6 +11,7 @@
>> #define LLVM_DEBUGINFO_MSF_MSFCOMMON_H
>>
>> #include "llvm/ADT/ArrayRef.h"
>> +#include "llvm/ADT/BitVector.h"
>>
>> #include "llvm/Support/Endian.h"
>> #include "llvm/Support/Error.h"
>> @@ -51,6 +52,7 @@ struct SuperBlock {
>> struct MSFLayout {
>> MSFLayout() : SB(nullptr) {}
>> const SuperBlock *SB;
>> + BitVector FreePageMap;
>> ArrayRef<support::ulittle32_t> DirectoryBlocks;
>> ArrayRef<support::ulittle32_t> StreamSizes;
>> std::vector<ArrayRef<support::ulittle32_t>> StreamMap;
>>
>> Modified: llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp?rev=277216&r1=277215&r2=277216&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp (original)
>> +++ llvm/trunk/lib/DebugInfo/PDB/Raw/PDBFile.cpp Fri Jul 29 16:38:00 2016
>> @@ -104,6 +104,7 @@ Error PDBFile::setBlockData(uint32_t Blo
>> Error PDBFile::parseFileHeaders() {
>> StreamReader Reader(*Buffer);
>>
>> + // Initialize SB.
>> const msf::SuperBlock *SB = nullptr;
>> if (auto EC = Reader.readObject(SB)) {
>> consumeError(std::move(EC));
>> @@ -119,6 +120,16 @@ Error PDBFile::parseFileHeaders() {
>> "File size is not a multiple of block
>> size");
>> ContainerLayout.SB = SB;
>>
>> + // Initialize Free Page Map.
>> + ContainerLayout.FreePageMap.resize(getBlockSize() * 8);
>> + uint64_t FPMOffset = SB->FreeBlockMapBlock * getBlockSize();
>> + ArrayRef<uint8_t> FPMBlock;
>> + if (auto EC = Buffer->readBytes(FPMOffset, getBlockSize(), FPMBlock))
>> + return EC;
>> + for (uint32_t I = 0, E = getBlockSize() * 8; I != E; ++I)
>> + if (FPMBlock[I / 8] & (1 << (I % 8)))
>> + ContainerLayout.FreePageMap[I] = true;
>> +
>> Reader.setOffset(getBlockMapOffset());
>> if (auto EC = Reader.readArray(ContainerLayout.DirectoryBlocks,
>> getNumDirectoryBlocks()))
>>
>> Modified: llvm/trunk/test/DebugInfo/PDB/pdbdump-headers.test
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/PDB/pdbdump-headers.test?rev=277216&r1=277215&r2=277216&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/test/DebugInfo/PDB/pdbdump-headers.test (original)
>> +++ llvm/trunk/test/DebugInfo/PDB/pdbdump-headers.test Fri Jul 29
>> 16:38:00 2016
>> @@ -2,7 +2,7 @@
>> ; RUN: -sym-record-bytes -publics -module-files
>> -stream-name=/names \
>> ; RUN: -stream-summary -stream-blocks -ipi-records
>> -ipi-record-bytes \
>> ; RUN: -section-contribs -section-map -section-headers
>> -line-info \
>> -; RUN: -tpi-hash -fpo %p/Inputs/empty.pdb | FileCheck
>> -check-prefix=EMPTY %s
>> +; RUN: -tpi-hash -fpo -fpm %p/Inputs/empty.pdb | FileCheck
>> -check-prefix=EMPTY %s
>> ; RUN: llvm-pdbdump raw -all %p/Inputs/empty.pdb | FileCheck
>> -check-prefix=ALL %s
>> ; RUN: llvm-pdbdump raw -headers -stream-name=/names -modules
>> -module-files \
>> ; RUN: %p/Inputs/big-read.pdb | FileCheck -check-prefix=BIG
>> %s
>> @@ -38,6 +38,7 @@
>> ; EMPTY-NEXT: Stream 15: [TPI Hash] (308 bytes)
>> ; EMPTY-NEXT: Stream 16: [IPI Hash] (68 bytes)
>> ; EMPTY-NEXT: ]
>> +; EMPTY-NEXT: Used Page Map: [0, 1, 2, 6, 7, 10, 11, 12, 13, 14, 15, 16,
>> 17, 18, 19, 20, 21, 22, 23, 24]
>> ; EMPTY-NEXT: StreamBlocks [
>> ; EMPTY-NEXT: Stream 0: [8]
>> ; EMPTY-NEXT: Stream 1: [19]
>> @@ -973,6 +974,7 @@
>> ; ALL: Stream 15: [TPI Hash] (308 bytes)
>> ; ALL: Stream 16: [IPI Hash] (68 bytes)
>> ; ALL: ]
>> +; ALL: Used Page Map: [0, 1, 2, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17,
>> 18, 19, 20, 21, 22, 23, 24]
>> ; ALL: StreamBlocks [
>> ; ALL: Stream 0: [8]
>> ; ALL: Stream 1: [19]
>>
>> Modified: llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp?rev=277216&r1=277215&r2=277216&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp (original)
>> +++ llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.cpp Fri Jul 29 16:38:00
>> 2016
>> @@ -50,6 +50,9 @@ Error LLVMOutputStyle::dump() {
>> if (auto EC = dumpStreamSummary())
>> return EC;
>>
>> + if (auto EC = dumpFreePageMap())
>> + return EC;
>> +
>> if (auto EC = dumpStreamBlocks())
>> return EC;
>>
>> @@ -234,6 +237,22 @@ Error LLVMOutputStyle::dumpStreamSummary
>> return Error::success();
>> }
>>
>> +Error LLVMOutputStyle::dumpFreePageMap() {
>> + if (!opts::raw::DumpFreePageMap)
>> + return Error::success();
>> + const BitVector &FPM = File.getMsfLayout().FreePageMap;
>> +
>> + std::vector<uint32_t> Vec;
>> + for (uint32_t I = 0, E = FPM.size(); I != E; ++I)
>> + if (!FPM[I])
>> + Vec.push_back(I);
>> +
>> + // Prints out used pages instead of free pages because
>> + // the number of free pages is far larger than used pages.
>> + P.printList("Used Page Map", Vec);
>> + return Error::success();
>> +}
>> +
>> Error LLVMOutputStyle::dumpStreamBlocks() {
>> if (!opts::raw::DumpStreamBlocks)
>> return Error::success();
>>
>> Modified: llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.h?rev=277216&r1=277215&r2=277216&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.h (original)
>> +++ llvm/trunk/tools/llvm-pdbdump/LLVMOutputStyle.h Fri Jul 29 16:38:00
>> 2016
>> @@ -26,6 +26,7 @@ public:
>> private:
>> Error dumpFileHeaders();
>> Error dumpStreamSummary();
>> + Error dumpFreePageMap();
>> Error dumpStreamBlocks();
>> Error dumpStreamData();
>> Error dumpInfoStream();
>>
>> Modified: llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp?rev=277216&r1=277215&r2=277216&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp (original)
>> +++ llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.cpp Fri Jul 29 16:38:00
>> 2016
>> @@ -167,6 +167,8 @@ cl::opt<bool> DumpStreamBlocks("stream-b
>> cl::opt<bool> DumpStreamSummary("stream-summary",
>> cl::desc("dump summary of the PDB
>> streams"),
>> cl::cat(MsfOptions),
>> cl::sub(RawSubcommand));
>> +cl::opt<bool> DumpFreePageMap("fpm", cl::desc("dump free page bitmap"),
>> + cl::cat(MsfOptions),
>> cl::sub(RawSubcommand));
>>
>> // TYPE OPTIONS
>> cl::opt<bool>
>> @@ -542,6 +544,7 @@ int main(int argc_, const char *argv_[])
>> opts::raw::DumpPublics = true;
>> opts::raw::DumpSectionHeaders = true;
>> opts::raw::DumpStreamSummary = true;
>> + opts::raw::DumpFreePageMap = true;
>> opts::raw::DumpStreamBlocks = true;
>> opts::raw::DumpTpiRecords = true;
>> opts::raw::DumpTpiHash = true;
>>
>> Modified: llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.h?rev=277216&r1=277215&r2=277216&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.h (original)
>> +++ llvm/trunk/tools/llvm-pdbdump/llvm-pdbdump.h Fri Jul 29 16:38:00 2016
>> @@ -37,6 +37,7 @@ namespace raw {
>> extern llvm::cl::opt<bool> DumpHeaders;
>> extern llvm::cl::opt<bool> DumpStreamBlocks;
>> extern llvm::cl::opt<bool> DumpStreamSummary;
>> +extern llvm::cl::opt<bool> DumpFreePageMap;
>> extern llvm::cl::opt<bool> DumpTpiHash;
>> extern llvm::cl::opt<bool> DumpTpiRecordBytes;
>> extern llvm::cl::opt<bool> DumpTpiRecords;
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160729/07cdf5cf/attachment.html>
More information about the llvm-commits
mailing list