[PATCH] D151353: [DebugInfo] Add error-handling to DWARFAbbreviationDeclarationSet

Alex Langford via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 24 10:45:11 PDT 2023


bulbazord created this revision.
bulbazord added reviewers: aprantl, JDevlieghere, fdeazeve, rastogishubham, jhenderson.
Herald added a subscriber: hiraditya.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, jplehr, sstefan1.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151353

Files:
  llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h
  llvm/lib/DebugInfo/DWARF/DWARFDebugAbbrev.cpp
  llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
  llvm/test/tools/dsymutil/Inputs/swift-interface.s
  llvm/unittests/DebugInfo/DWARF/DWARFDebugAbbrevTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151353.525259.patch
Type: text/x-patch
Size: 32026 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230524/633e0353/attachment-0001.bin>


More information about the llvm-commits mailing list