diff options
| author | Zachary Turner <zturner@google.com> | 2018-03-29 17:11:14 +0000 |
|---|---|---|
| committer | Zachary Turner <zturner@google.com> | 2018-03-29 17:11:14 +0000 |
| commit | 1b20416bfa4ed906d5b5f289aa8a4430b9620132 (patch) | |
| tree | be0f346326ab83b46a4cb5fcf3c180d417e4ee5a | |
| parent | b458329327978b40f2f166a5a637fd4ef12c3883 (diff) | |
| download | bcm5719-llvm-1b20416bfa4ed906d5b5f289aa8a4430b9620132.tar.gz bcm5719-llvm-1b20416bfa4ed906d5b5f289aa8a4430b9620132.zip | |
[PDB] Fix a bug in the explain subcommand.
We were trying to dig into the super block fields and print a
description of the field at the specified offset, but we were
printing the wrong field due to an off-by-one-field-error.
llvm-svn: 328804
| -rw-r--r-- | llvm/test/tools/llvm-pdbdump/explain.test | 8 | ||||
| -rw-r--r-- | llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp | 18 |
2 files changed, 14 insertions, 12 deletions
diff --git a/llvm/test/tools/llvm-pdbdump/explain.test b/llvm/test/tools/llvm-pdbdump/explain.test index 9926eb01e35..e65027bdabb 100644 --- a/llvm/test/tools/llvm-pdbdump/explain.test +++ b/llvm/test/tools/llvm-pdbdump/explain.test @@ -33,17 +33,17 @@ ZERO: Block:Offset = 0:0000. ZERO-NEXT: Address is in block 0 (allocated). -ZERO-NEXT: This corresponds to offset 0 of MSF super block, +ZERO-NEXT: This corresponds to offset 0 of the MSF super block, ZERO-NEXT: which is part of the MSF file magic. FORTY: Block:Offset = 0:0028. FORTY-NEXT: Address is in block 0 (allocated). -FORTY-NEXT: This corresponds to offset 40 of MSF super block, -FORTY-NEXT: which contains the number of bytes in the stream directory. +FORTY-NEXT: This corresponds to offset 40 of the MSF super block, +FORTY-NEXT: which contains the number of blocks in the file. SIXTY: Block:Offset = 0:003C. SIXTY-NEXT: Address is in block 0 (allocated). -SIXTY-NEXT: This corresponds to offset 60 of MSF super block, +SIXTY-NEXT: This corresponds to offset 60 of the MSF super block, SIXTY-NEXT: which is outside the range of valid data for the super block. FPM1: Block:Offset = 1:0000. diff --git a/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp b/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp index 48e8e1ee374..229cf9f9ffb 100644 --- a/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp +++ b/llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp @@ -96,22 +96,24 @@ bool ExplainOutputStyle::explainBlockStatus() { return !IsFree; } +#define endof(Class, Field) (offsetof(Class, Field) + sizeof(Class::Field)) + void ExplainOutputStyle::explainSuperBlockOffset() { - P.formatLine("This corresponds to offset {0} of MSF super block, ", + P.formatLine("This corresponds to offset {0} of the MSF super block, ", OffsetInBlock); - if (OffsetInBlock < sizeof(msf::Magic)) + if (OffsetInBlock < endof(SuperBlock, MagicBytes)) P.printLine("which is part of the MSF file magic."); - else if (OffsetInBlock < offsetof(SuperBlock, BlockSize)) + else if (OffsetInBlock < endof(SuperBlock, BlockSize)) P.printLine("which contains the block size of the file."); - else if (OffsetInBlock < offsetof(SuperBlock, FreeBlockMapBlock)) + else if (OffsetInBlock < endof(SuperBlock, FreeBlockMapBlock)) P.printLine("which contains the index of the FPM block (e.g. 1 or 2)."); - else if (OffsetInBlock < offsetof(SuperBlock, NumBlocks)) + else if (OffsetInBlock < endof(SuperBlock, NumBlocks)) P.printLine("which contains the number of blocks in the file."); - else if (OffsetInBlock < offsetof(SuperBlock, NumDirectoryBytes)) + else if (OffsetInBlock < endof(SuperBlock, NumDirectoryBytes)) P.printLine("which contains the number of bytes in the stream directory."); - else if (OffsetInBlock < offsetof(SuperBlock, Unknown1)) + else if (OffsetInBlock < endof(SuperBlock, Unknown1)) P.printLine("whose purpose is unknown."); - else if (OffsetInBlock < offsetof(SuperBlock, BlockMapAddr)) + else if (OffsetInBlock < endof(SuperBlock, BlockMapAddr)) P.printLine("which contains the file offset of the block map."); else { assert(OffsetInBlock > sizeof(SuperBlock)); |

