Adds initial llvm-dwarfdump --verify support with unit tests.
authorGreg Clayton <gclayton@apple.com>
Mon, 1 May 2017 22:07:02 +0000 (22:07 +0000)
committerGreg Clayton <gclayton@apple.com>
Mon, 1 May 2017 22:07:02 +0000 (22:07 +0000)
commit48432cfbeb1c7193a9ef1c2d24dc6c5c06f2bda8
tree7f0cccb534326994954637b8d539bd451d3528f4
parent74d22dd7dc608675486f166918b4d4369d79c88b
Adds initial llvm-dwarfdump --verify support with unit tests.

lldb-dwarfdump gets a new "--verify" option that will verify a single file's DWARF debug info and will print out any errors that it finds. It will return an non-zero exit status if verification fails, and a zero exit status if verification succeeds. Adding the --quiet option will suppress any output the STDOUT or STDERR.

The first part of the verify does the following:

- verifies that all CU relative references (DW_FORM_ref1, DW_FORM_ref2, DW_FORM_ref4, DW_FORM_ref8, DW_FORM_ref_udata) have valid CU offsets
- verifies that all DW_FORM_ref_addr references have valid .debug_info offsets
- verifies that all DW_AT_ranges attributes have valid .debug_ranges offsets
- verifies that all DW_AT_stmt_list attributes have valid .debug_line offsets
- verifies that all DW_FORM_strp attributes have valid .debug_str offsets

Unit tests were added for each of the above cases.

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

llvm-svn: 301844
llvm/include/llvm/DebugInfo/DIContext.h
llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
llvm/include/llvm/DebugInfo/DWARF/DWARFFormValue.h
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/lib/DebugInfo/DWARF/DWARFFormValue.cpp
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp