This is an archive of the discontinued LLVM Phabricator instance.

[DWARF] Improved error reporting for range lists
ClosedPublic

Authored by wolfgangp on Jun 19 2018, 5:33 PM.

Details

Summary

This is a primarily a refactor of the routines that are used to find individual range lists based on offsets or indices found as values of the DW_AT_ranges attribute.
Particularly DWARFUnit::findRnglistFromOffset() and DWARFUnit::findRnglistFromIndex() now return an Expected<> instead of a plain DWARFAddressRangesVector. This allows propagation of errors that occur during handling of the attribute, in particular invalid offsets and indices that are values of the DW_AT_ranges attribute. We did not report errors for this prior to this change.
As a result, a few routines that use the 2 mentioned above also return an Expected<>, which in turn means that their callers have to handle an error in some way if it occurs, e.g. DWARFDie::getAddressRanges() returns an Expected<> which means that their callers have to report the error, or ignore them.

This patch reports the error in the following contexts:

dumpAttribute() in DWARFDie.cpp
DWARFDie::collectAddressRanges()

In the following contexts it's ignored (for now):

DWARFDie::collectChildrenAddressRanges()
DWARFUnit::updateAddressDieMap()
DWARFVerifier::verifyDieRanges()
getLowPC() in llvm-dwarfdump/Statistics.cpp
DWARFDie::addressRangeContainsAddress()

In these contexts I added FIXME comments, because we want to eventually report the error, but they either require support for .debug_aranges or more complex tests with child DIEs. I'd like to add them in a follow-on patch.

In the case of the verifier, it needs to handle DWARF v5 rnglists before we can report errors meaningfully.

The extraction of v4 range lists (DebugRangeLists.extract()) now also returns an Error instead of a boolean, which is reported in DWARFContext::dump().

Diff Detail

Repository
rL LLVM

Event Timeline

wolfgangp created this revision.Jun 19 2018, 5:33 PM
JDevlieghere accepted this revision.Jun 20 2018, 3:19 AM

Thanks Wolfgang, I'm always excited to see improved error handling! LGTM modulo inline comment.

lib/DebugInfo/DWARF/DWARFUnit.cpp
417 ↗(On Diff #152000)

Did you capitalize this on purpose or should it be lowercase like the other error messages? Same question below.

This revision is now accepted and ready to land.Jun 20 2018, 3:19 AM
wolfgangp marked an inline comment as done.Jun 20 2018, 12:44 PM
wolfgangp added inline comments.
lib/DebugInfo/DWARF/DWARFUnit.cpp
417 ↗(On Diff #152000)

Thanks for finding this. Should have all been lowercase.

This revision was automatically updated to reflect the committed changes.
wolfgangp marked an inline comment as done.