This is an archive of the discontinued LLVM Phabricator instance.

[llvm-pdbutil] Support PDBs without a DBI stream
ClosedPublic

Authored by aganea on Aug 3 2018, 8:35 AM.

Details

Summary

This change ensures llvm-pdb doesn't fail on start, when the DBI stream isn't present in the PDB.

This occurs when compiling a simple .cpp with /Zi (see attached test)

Also, normalized the formatting of the errors printed by llvm-pdbutil in that case.

Tested all commands with the provided PDB, only llvm-pdbutil dump ... and llvm-pdbutil pdb2yaml ... seemed to be previously affected by the issue.

Diff Detail

Repository
rL LLVM

Event Timeline

aganea created this revision.Aug 3 2018, 8:35 AM
zturner added inline comments.Aug 3 2018, 11:24 AM
lib/DebugInfo/PDB/Native/PDBFile.cpp
473–474 ↗(On Diff #159016)

This check looks incorrect to me. A 0-byte stream is still a stream.

test/tools/llvm-pdbdump/Inputs/TypeServerTest.cpp
1 ↗(On Diff #159016)

Instead of checking in source code and a binary object file, can we just check in a yaml file and run it through yaml2pdb? If you can't get pdb2yaml to produce this file (because it also crashes), then just run pdb2yaml on a good file, and delete the DBI stream. If it's possible to get pdb2yaml to produce a PDB with a 0-byte DBI stream, that should be sufficient to test this.

If all else fails and you really must check in binary files, then I think we only need the PDB and not the obj, and you will probably need to use /nodefaultlib /entry:main to keep the PDB binary small.

tools/llvm-pdbutil/DumpOutputStyle.cpp
71–73 ↗(On Diff #159016)

This looks odd? We shouldn't be printing anything inside of a predicate function.

79–81 ↗(On Diff #159016)

Same here.

87–89 ↗(On Diff #159016)

And here.

aganea updated this revision to Diff 159311.Aug 6 2018, 8:31 AM
aganea marked 5 inline comments as done.Aug 6 2018, 8:35 AM
aganea added inline comments.
lib/DebugInfo/PDB/Native/PDBFile.cpp
473–474 ↗(On Diff #159016)

Reverted this change - replaced by change in InputFile.cpp instead.

test/tools/llvm-pdbdump/Inputs/TypeServerTest.cpp
1 ↗(On Diff #159016)

Unfourtunately the pdb is needed, because yaml2pdb generates a default DBI stream if there's none in the yaml. Also, please note this is the pdb generated by cl.exe, not link.exe. The current size is 60kb.

zturner added a subscriber: aganea.Aug 6 2018, 8:38 AM

Ok 60kb is probably fine. Lgtm

aganea marked 2 inline comments as done.Aug 6 2018, 8:39 AM

Thank you for the review Zachary!

This revision was not accepted when it landed; it landed in state Needs Review.Aug 6 2018, 12:35 PM
This revision was automatically updated to reflect the committed changes.