This is an archive of the discontinued LLVM Phabricator instance.

[pdb] handle missing pdb streams more gracefully
ClosedPublic

Authored by inglorion on Dec 1 2016, 5:08 PM.

Details

Summary

The code we use to read PDBs assumed that streams we ask it to read exist, and would read memory outside a vector and crash if this wasn't the case. This would, for example, cause llvm-pdbdump to crash on PDBs generated by lld. This patch handles such cases more gracefully: the PDB reading code in LLVM now reports errors when asked to get a stream that is not present, and llvm-pdbdump will report missing streams and continue processing streams that are present.

Diff Detail

Repository
rL LLVM

Event Timeline

inglorion updated this revision to Diff 80000.Dec 1 2016, 5:08 PM
inglorion retitled this revision from to [pdb] handle missing pdb streams more gracefully.
inglorion updated this object.
inglorion added reviewers: ruiu, zturner.
inglorion added subscribers: amccarth, thakis.
ruiu added inline comments.Dec 1 2016, 5:18 PM
include/llvm/DebugInfo/PDB/Raw/PDBFile.h
99–105 ↗(On Diff #80000)

Why some are const and some are not?

lib/DebugInfo/PDB/Raw/PDBFile.cpp
233 ↗(On Diff #80000)

Please run clang-format-diff.

inglorion added inline comments.Dec 1 2016, 6:18 PM
include/llvm/DebugInfo/PDB/Raw/PDBFile.h
99–105 ↗(On Diff #80000)

The various get* methods above are not const, so when the has* method has to call a get* method, it can't be const. The common case is when a has* method needs to look at the DBI stream to determine the index of the stream whose existence is being tested.

inglorion updated this revision to Diff 80014.Dec 1 2016, 6:25 PM

clang-format

@ruiu, is this good to go now?

ruiu accepted this revision.Dec 5 2016, 10:33 AM
ruiu edited edge metadata.

LGTM

This revision is now accepted and ready to land.Dec 5 2016, 10:33 AM
This revision was automatically updated to reflect the committed changes.