This is an archive of the discontinued LLVM Phabricator instance.

Verify that all references point to actual DIEs in "llvm-dwarfdump --verify"
ClosedPublic

Authored by clayborg on May 1 2017, 4:07 PM.

Details

Summary

LTO and other fancy linking previously led to DWARF that contained invalid references. We already validate that CU relative references fall into the CU, and the DW_FORM_ref_addr references fall inside the .debug_info section, but we didn't validate that the references pointed to correct DIE offsets. This new verification will ensure that all references refer to actual DIEs and not an offset in between.

This caught a bug in DWARFUnit::getDIEForOffset() where if you gave it any offset, it would match the DIE that mathes the offset _or_ the next DIE. This has been fixed.

Diff Detail

Repository
rL LLVM

Event Timeline

clayborg created this revision.May 1 2017, 4:07 PM

I also moved the verification code over into a Verifier class to prepare for future extra verification steps where we will need to persist data between two steps.

aprantl accepted this revision.May 2 2017, 12:48 PM
aprantl added inline comments.
lib/DebugInfo/DWARF/DWARFContext.cpp
309 ↗(On Diff #97356)

Do we need a sorted container here or would an llvm::DenseMap be sufficient (and faster)?

This revision is now accepted and ready to land.May 2 2017, 12:48 PM
This revision was automatically updated to reflect the committed changes.
clayborg added inline comments.May 2 2017, 1:42 PM
lib/DebugInfo/DWARF/DWARFContext.cpp
309 ↗(On Diff #97356)

We can change this if needed. std::unordered_set would work as well.