llvm.org GIT mirror llvm / 103f6b6
[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). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328808 91177308-0d34-0410-b5e6-96231b3b80d8 Zachary Turner 1 year, 5 months ago
2 changed file(s) with 36 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
3939 FORTY-NEXT: Address is in block 0 (allocated).
4040 FORTY-NEXT: This corresponds to offset 40 of the MSF super block,
4141 FORTY-NEXT: which contains the number of blocks in the file.
42 FORTY-NEXT: The current value is 29.
4243
4344 SIXTY: Block:Offset = 0:003C.
4445 SIXTY-NEXT: Address is in block 0 (allocated).
4950 FPM1-NEXT: Address is in block 1 (allocated).
5051 FPM1-NEXT: Address is in FPM1 (Alt FPM)
5152 FPM1-NEXT: Address describes the allocation status of blocks [0,8)
53 FPM1-NEXT: Status = 00000011 (Note: 0 = allocated, 1 = free)
5254
5355 EXTRANEOUSFPM: Block:Offset = 1:0100.
5456 EXTRANEOUSFPM-NEXT: Address is in block 1 (allocated).
5961 FPM2-NEXT: Address is in block 2 (allocated).
6062 FPM2-NEXT: Address is in FPM2 (Main FPM)
6163 FPM2-NEXT: Address describes the allocation status of blocks [0,8)
64 FPM2-NEXT: Status = 00011100 (Note: 0 = allocated, 1 = free)
6265
6366 UNALLOCATED: Block:Offset = 3:0000.
6467 UNALLOCATED-NEXT: Address is in block 3 (unallocated).
102102 OffsetInBlock);
103103 if (OffsetInBlock < endof(SuperBlock, MagicBytes))
104104 P.printLine("which is part of the MSF file magic.");
105 else if (OffsetInBlock < endof(SuperBlock, BlockSize))
105 else if (OffsetInBlock < endof(SuperBlock, BlockSize)) {
106106 P.printLine("which contains the block size of the file.");
107 else if (OffsetInBlock < endof(SuperBlock, FreeBlockMapBlock))
107 P.formatLine("The current value is {0}.",
108 uint32_t(File.getMsfLayout().SB->BlockSize));
109 } else if (OffsetInBlock < endof(SuperBlock, FreeBlockMapBlock)) {
108110 P.printLine("which contains the index of the FPM block (e.g. 1 or 2).");
109 else if (OffsetInBlock < endof(SuperBlock, NumBlocks))
111 P.formatLine("The current value is {0}.",
112 uint32_t(File.getMsfLayout().SB->FreeBlockMapBlock));
113 } else if (OffsetInBlock < endof(SuperBlock, NumBlocks)) {
110114 P.printLine("which contains the number of blocks in the file.");
111 else if (OffsetInBlock < endof(SuperBlock, NumDirectoryBytes))
115 P.formatLine("The current value is {0}.",
116 uint32_t(File.getMsfLayout().SB->NumBlocks));
117 } else if (OffsetInBlock < endof(SuperBlock, NumDirectoryBytes)) {
112118 P.printLine("which contains the number of bytes in the stream directory.");
113 else if (OffsetInBlock < endof(SuperBlock, Unknown1))
119 P.formatLine("The current value is {0}.",
120 uint32_t(File.getMsfLayout().SB->NumDirectoryBytes));
121 } else if (OffsetInBlock < endof(SuperBlock, Unknown1)) {
114122 P.printLine("whose purpose is unknown.");
115 else if (OffsetInBlock < endof(SuperBlock, BlockMapAddr))
123 P.formatLine("The current value is {0}.",
124 uint32_t(File.getMsfLayout().SB->Unknown1));
125 } else if (OffsetInBlock < endof(SuperBlock, BlockMapAddr)) {
116126 P.printLine("which contains the file offset of the block map.");
117 else {
127 P.formatLine("The current value is {0}.",
128 uint32_t(File.getMsfLayout().SB->BlockMapAddr));
129 } else {
118130 assert(OffsetInBlock > sizeof(SuperBlock));
119131 P.printLine(
120132 "which is outside the range of valid data for the super block.");
121133 }
134 }
135
136 static std::string toBinaryString(uint8_t Byte) {
137 char Result[9] = {0};
138 for (int I = 0; I < 8; ++I) {
139 char C = (Byte & 1) ? '1' : '0';
140 Result[I] = C;
141 Byte >>= 1;
142 }
143 return std::string(Result);
122144 }
123145
124146 void ExplainOutputStyle::explainFpmBlockOffset() {
142164
143165 P.formatLine("Address describes the allocation status of blocks [{0},{1})",
144166 DescribedBlockStart, DescribedBlockStart + 8);
167 ArrayRef Bytes;
168 cantFail(File.getMsfBuffer().readBytes(FileOffset, 1, Bytes));
169 P.formatLine("Status = {0} (Note: 0 = allocated, 1 = free)",
170 toBinaryString(Bytes[0]));
145171 }
146172
147173 void ExplainOutputStyle::explainBlockMapOffset() {