[DebugInfo/DWARF] - Test invalid CFI opcodes properly and refine related `CFIProgram...
authorGeorgii Rymar <grimar@accesssoftek.com>
Tue, 30 Jun 2020 12:02:28 +0000 (15:02 +0300)
committerGeorgii Rymar <grimar@accesssoftek.com>
Wed, 8 Jul 2020 09:10:23 +0000 (12:10 +0300)
commitbee8cdcabd2b3931be3f240e70b0b04e766ea4fe
treeb465eb85c329a66d8716a08ebc74382827ca637f
parent1f84ace3c7266564801d79185ebb05eb451205f1
[DebugInfo/DWARF] - Test invalid CFI opcodes properly and refine related `CFIProgram::parse` code.

There are following issues with `CFIProgram::parse` code:

1) Invalid CFI opcodes were never tested. And currently a test would fail
when the `LLVM_ENABLE_ABI_BREAKING_CHECKS` is enabled. It happens because
the `DataExtractor::Cursor C` remains unchecked when the
"Invalid extended CFI opcode" error is reported:

```
.eh_frame section at offset 0x1128 address 0x0:
Program aborted due to an unhandled Error:
Error value was Success. (Note: Success values must still be checked prior to being destroyed).
```

2) It is impossible to reach the "Invalid primary CFI opcode" error with the current code.
There are 3 possible primary opcode values and all of them are handled. Hence this error
should be replaced with llvm_unreachable.

3) Errors currently reported are upper-case.

This patch refines the code in the `CFIProgram::parse` method to fix all issues mentioned
and adds unit tests for all possible invalid extended CFI opcodes.

Differential revision: https://reviews.llvm.org/D82868
llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
llvm/unittests/DebugInfo/DWARF/DWARFDebugFrameTest.cpp