[PATCH] D48344: [DWARF] Improved error reporting for range lists

Wolfgang Pieb via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 19 17:33:19 PDT 2018


wolfgangp created this revision.
wolfgangp added reviewers: JDevlieghere, aprantl, dblaikie.

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().


https://reviews.llvm.org/D48344

Files:
  include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h
  include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h
  include/llvm/DebugInfo/DWARF/DWARFDie.h
  include/llvm/DebugInfo/DWARF/DWARFUnit.h
  lib/DebugInfo/DWARF/DWARFContext.cpp
  lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
  lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp
  lib/DebugInfo/DWARF/DWARFDie.cpp
  lib/DebugInfo/DWARF/DWARFUnit.cpp
  lib/DebugInfo/DWARF/DWARFVerifier.cpp
  test/DebugInfo/X86/dwarfdump-ranges-baseaddr.s
  test/DebugInfo/X86/dwarfdump-rnglists.s
  tools/dsymutil/DwarfLinker.cpp
  tools/llvm-dwarfdump/Statistics.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48344.152000.patch
Type: text/x-patch
Size: 22194 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180620/3fbe0eb5/attachment.bin>


More information about the llvm-commits mailing list