Verify that all references point to actual DIEs in "llvm-dwarfdump --verify"
authorGreg Clayton <gclayton@apple.com>
Tue, 2 May 2017 20:28:33 +0000 (20:28 +0000)
committerGreg Clayton <gclayton@apple.com>
Tue, 2 May 2017 20:28:33 +0000 (20:28 +0000)
commitc7695a8e4565afb256aad1a705ef292bc3625a36
treec385982e9cd7f5f5e80007c584c19e8f82ebdada
parent7e7007d1c6ba8f302c6c63c5149c72f4ca627a45
Verify that all references point to actual DIEs in "llvm-dwarfdump --verify"

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.

Differential Revision: https://reviews.llvm.org/D32722

llvm-svn: 301971
llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp