diff options
author | Zachary Turner <zturner@google.com> | 2018-03-29 17:45:34 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2018-03-29 17:45:34 +0000 |
commit | f4b6dcf6af9d1ef38f60f112c8ccbf2521e07e88 (patch) | |
tree | 3a56ccb2377f67382f77c651d42f89dcd017b0e4 /llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp | |
parent | 7d89ce97ecab86c0b48bce46ab51535ec9950c68 (diff) | |
download | bcm5719-llvm-f4b6dcf6af9d1ef38f60f112c8ccbf2521e07e88.tar.gz bcm5719-llvm-f4b6dcf6af9d1ef38f60f112c8ccbf2521e07e88.zip |
[PDB] Print some more details when explaining MSF fields.
When we determine that a field belongs to an MSF super block or
the free page map, we wouldn't print any additional information.
With this patch, we now print the value of the field (for super
block fields) or the allocation status of the specified byte (in
the case of offsets in the FPM).
llvm-svn: 328808
Diffstat (limited to 'llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp')
-rw-r--r-- | llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp b/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp index 229cf9f9ffb..c4fbde22e75 100644 --- a/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp +++ b/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp @@ -103,25 +103,47 @@ void ExplainOutputStyle::explainSuperBlockOffset() { OffsetInBlock); if (OffsetInBlock < endof(SuperBlock, MagicBytes)) P.printLine("which is part of the MSF file magic."); - else if (OffsetInBlock < endof(SuperBlock, BlockSize)) + else if (OffsetInBlock < endof(SuperBlock, BlockSize)) { P.printLine("which contains the block size of the file."); - else if (OffsetInBlock < endof(SuperBlock, FreeBlockMapBlock)) + P.formatLine("The current value is {0}.", + uint32_t(File.getMsfLayout().SB->BlockSize)); + } else if (OffsetInBlock < endof(SuperBlock, FreeBlockMapBlock)) { P.printLine("which contains the index of the FPM block (e.g. 1 or 2)."); - else if (OffsetInBlock < endof(SuperBlock, NumBlocks)) + P.formatLine("The current value is {0}.", + uint32_t(File.getMsfLayout().SB->FreeBlockMapBlock)); + } else if (OffsetInBlock < endof(SuperBlock, NumBlocks)) { P.printLine("which contains the number of blocks in the file."); - else if (OffsetInBlock < endof(SuperBlock, NumDirectoryBytes)) + P.formatLine("The current value is {0}.", + uint32_t(File.getMsfLayout().SB->NumBlocks)); + } else if (OffsetInBlock < endof(SuperBlock, NumDirectoryBytes)) { P.printLine("which contains the number of bytes in the stream directory."); - else if (OffsetInBlock < endof(SuperBlock, Unknown1)) + P.formatLine("The current value is {0}.", + uint32_t(File.getMsfLayout().SB->NumDirectoryBytes)); + } else if (OffsetInBlock < endof(SuperBlock, Unknown1)) { P.printLine("whose purpose is unknown."); - else if (OffsetInBlock < endof(SuperBlock, BlockMapAddr)) + P.formatLine("The current value is {0}.", + uint32_t(File.getMsfLayout().SB->Unknown1)); + } else if (OffsetInBlock < endof(SuperBlock, BlockMapAddr)) { P.printLine("which contains the file offset of the block map."); - else { + P.formatLine("The current value is {0}.", + uint32_t(File.getMsfLayout().SB->BlockMapAddr)); + } else { assert(OffsetInBlock > sizeof(SuperBlock)); P.printLine( "which is outside the range of valid data for the super block."); } } +static std::string toBinaryString(uint8_t Byte) { + char Result[9] = {0}; + for (int I = 0; I < 8; ++I) { + char C = (Byte & 1) ? '1' : '0'; + Result[I] = C; + Byte >>= 1; + } + return std::string(Result); +} + void ExplainOutputStyle::explainFpmBlockOffset() { const MSFLayout &Layout = File.getMsfLayout(); uint32_t MainFpm = Layout.mainFpmBlock(); @@ -143,6 +165,10 @@ void ExplainOutputStyle::explainFpmBlockOffset() { P.formatLine("Address describes the allocation status of blocks [{0},{1})", DescribedBlockStart, DescribedBlockStart + 8); + ArrayRef<uint8_t> Bytes; + cantFail(File.getMsfBuffer().readBytes(FileOffset, 1, Bytes)); + P.formatLine("Status = {0} (Note: 0 = allocated, 1 = free)", + toBinaryString(Bytes[0])); } void ExplainOutputStyle::explainBlockMapOffset() { |