[DebugInfo] Add error-handling to DWARFAbbreviationDeclarationSet
authorAlex Langford <alangford@apple.com>
Wed, 24 May 2023 00:13:31 +0000 (17:13 -0700)
committerAlex Langford <alangford@apple.com>
Thu, 8 Jun 2023 18:16:42 +0000 (11:16 -0700)
commit715726429ec4fc4f0f5f0f2e3dc6c3c31ce8f3a6
treef1492dc45a6a70c334bc4f8419a69a6aa62e6415
parentf10f7b0dcafec3913cfe4bcff41cd5a2697ddd46
[DebugInfo] Add error-handling to DWARFAbbreviationDeclarationSet

This commit aims to improve error handling in the
DWARFAbbreviationDeclarationSet class. Specifically, we change the return type
of DWARFAbbreviationDeclarationSet::extract to an llvm::Error. In doing
so, we propagate the error from DWARFAbbreviationDeclaration::extract
another layer upward.

I have built on the previous unittest for DWARFDebugAbbrev that I
wrote a few days prior.
Namely, I am verifying that the following should give an error:
- An invalid tag following a non-null code
- An invalid attribute with a valid form
- A valid attribute with an invalid form
- An incorrectly terminated DWARFAbbreviationDeclaration

Additionally, I uncovered some invalid DWARF in an unrelated dsymutil
test. Namely the last Abbreviation Decl was missing a code.
This test has been updated accordingly. However, this commit does
not fix the underlying issue: llvm-dwarfdump does not correctly
verify the debug abbreviation section to catch these kinds of
mistakes. I have updated DWARFVerifier to not dereference a
pointer without first checking it and left a FIXME for future
contributors.

Differential Revision: https://reviews.llvm.org/D151353
15 files changed:
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp
llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
llvm/test/DebugInfo/ARM/dwarfdump-rela.yaml
llvm/test/DebugInfo/X86/dwarfdump-header-64.s
llvm/test/DebugInfo/X86/dwarfdump-rela-dwo.s
llvm/test/tools/dsymutil/Inputs/empty-CU.o [deleted file]
llvm/test/tools/dsymutil/Inputs/empty-CU.s
llvm/test/tools/dsymutil/Inputs/swift-interface.s
llvm/test/tools/dsymutil/X86/empty-CU.test
llvm/test/tools/llvm-dwarfdump/X86/debug-abbrev.s
llvm/test/tools/llvm-dwarfdump/X86/no_debug_addr.s
llvm/test/tools/llvm-dwarfdump/X86/verify_strings.s
llvm/test/tools/llvm-dwarfdump/X86/verify_unit_header_chain.s
llvm/unittests/DebugInfo/DWARF/DWARFDebugAbbrevTest.cpp