This is an archive of the discontinued LLVM Phabricator instance.

[llvm-pdbdump] Display padding bytes on record layout
ClosedPublic

Authored by zturner on Apr 6 2017, 6:42 PM.

Details

Summary

When dumping classes, show where padding occurs, and at the end of the class print statistics about how many bytes total of padding exist in a class.

Since PDB doesn't specifically contain information about padding, we have to mimic this by sort of reversing a small portion of the record layout algorithm (e.g. looking at offsets and sizes and trying to determine whether something is part of the same field or a new field).

Diff Detail

Event Timeline

zturner created this revision.Apr 6 2017, 6:42 PM
zturner updated this revision to Diff 94481.Apr 6 2017, 10:33 PM

Use a better method for detecting padding. This is less error prone and more efficient. It also allows us to analyze the padding one time up front, which allows us to filter record display based on whether or not the record has padding (e.g. only dump those records that have padding).

amccarth accepted this revision.Apr 7 2017, 7:42 AM

LGTM

With this, it seems llvm-pdbdump is becoming a more sophisticated analysis tool rather than just a dumper. It makes me wonder whether this is the best tool to do this kind of analysis. On the one hand, it works for any binary with a PDB, whether it's built by clang or MSVC. On the other hand, it's not useful for clang-built binaries targeting other platforms. It almost seems like it should be done looking at the IR rather than the final debug info.

llvm/tools/llvm-pdbdump/PrettyClassDefinitionDumper.cpp
109

Below, you explicitly test the results of BitVector::find_first by comparing to -1, but here it's >= 0.

This revision is now accepted and ready to land.Apr 7 2017, 7:42 AM
rnk edited edge metadata.Apr 7 2017, 8:23 AM

Is it possible to write a test with an existing PDB in Inputs?

llvm/tools/llvm-pdbdump/PrettyClassDefinitionDumper.cpp
81

Why fall through to break? Seems less special to break.

This revision was automatically updated to reflect the committed changes.