This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo/DWARF] - Test invalid CFI opcodes properly and refine related `CFIProgram::parse` code.
ClosedPublic

Authored by grimar on Jun 30 2020, 5:12 AM.

Details

Summary

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).
  1. 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.

  1. 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.

Diff Detail

Event Timeline

grimar created this revision.Jun 30 2020, 5:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 30 2020, 5:13 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
jhenderson accepted this revision.Jul 8 2020, 1:12 AM

LGTM, with nit.

llvm/unittests/DebugInfo/DWARF/DWARFDebugFrameTest.cpp
124

parseCFI

This revision is now accepted and ready to land.Jul 8 2020, 1:12 AM
This revision was automatically updated to reflect the committed changes.