This is an archive of the discontinued LLVM Phabricator instance.

[dwarfdump] Verify line table prologue
ClosedPublic

Authored by JDevlieghere on Sep 6 2017, 5:04 AM.

Details

Summary

This patch adds prologue verification, which is already present in Apple's dwarfdump. It checks for invalid directory indices and warns about duplicate file paths.

Diff Detail

Repository
rL LLVM

Event Timeline

JDevlieghere created this revision.Sep 6 2017, 5:04 AM
dblaikie added inline comments.Sep 6 2017, 10:12 AM
lib/DebugInfo/DWARF/DWARFVerifier.cpp
455 ↗(On Diff #113991)

Don't branch-to-unreachable. Use an assert instead.

Is the false return from getFileNameByIndex really impossible? (has the FileIndex been checked for validity? What other error paths does getFileNameByIndex have, if any?)

JDevlieghere added inline comments.Sep 6 2017, 10:39 AM
lib/DebugInfo/DWARF/DWARFVerifier.cpp
455 ↗(On Diff #113991)

Thanks, an assert definitely better expresses the intent. The only path that returns false is this:

if (Kind == FileLineInfoKind::None || !hasFileAtIndex(FileIndex))
  return false;

The FileLineInfoKind is hard-coded so that can't trigger it. The index can't really be invalid either as we're iterating over the list of indices. If this returns false here it must be a programmer error.

JDevlieghere added inline comments.Sep 6 2017, 10:46 AM
lib/DebugInfo/DWARF/DWARFVerifier.cpp
455 ↗(On Diff #113991)

What about the unused variable though? I need the function call to populate the string, so I'd have to assign it to a bool that's only used in the assert.

dblaikie accepted this revision.Sep 6 2017, 10:49 AM

Looks good (with the change to the unreachable -> assert)

This revision is now accepted and ready to land.Sep 6 2017, 10:49 AM
clayborg edited edge metadata.Sep 6 2017, 11:10 AM

Why assert and not emit an error???

lib/DebugInfo/DWARF/DWARFVerifier.cpp
455 ↗(On Diff #113991)

This is a verifier that is trying to validate that the DWARF is valid. A bad file index is quite possible. Why not emit an appropriate error message here?

Use assert instead of unreachable.

aprantl accepted this revision.Sep 7 2017, 2:13 PM
This revision was automatically updated to reflect the committed changes.
aprantl added inline comments.Sep 8 2017, 2:49 PM
llvm/trunk/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
2072

Porlogue? :-)