[PATCH] D89845: Add the ability to extract the unwind rows from DWARF Call Frame Information.

Greg Clayton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 20 20:17:04 PDT 2020


clayborg created this revision.
clayborg added reviewers: labath, aprantl, JDevlieghere, dblaikie, MaskRay.
Herald added subscribers: rupprecht, atanasyan, jrtc27, fedor.sergeev, hiraditya.
Herald added a reviewer: jhenderson.
Herald added a project: LLVM.
clayborg requested review of this revision.

This patch adds the ability to evaluate the state machine for CIE and FDE unwind objects and produce a UnwindTable with all UnwindRow objects needed to unwind registers. It will also dump the UnwindTable for each CIE and FDE when dumping DWARF .debug_frame or .eh_frame sections in llvm-dwarfdump or llvm-objdump. This allows users to see what the unwind rows actually look like for a given CIE or FDE instead of just seeing a list of opcodes.

This patch adds new classes: UnwindLocation, RegisterLocations, UnwindRow, and UnwindTable.

UnwindLocation is a class that describes how to unwind a register or Call Frame Address (CFA).

RegisterLocations is a class that tracks registers and their UnwindLocations. It gets populated when parsing the DWARF call frame instruction opcodes for a unwind row. The registers are mapped from their register numbers to the UnwindLocation in a map.

UnwindRow contains the result of evaluating a row of DWARF call frame instructions for the CIE, or a row from a FDE. The CIE can produce a set of initial instructions that each FDE that points to that CIE will use as the seed for the state machine when parsing FDE opcodes. A UnwindRow for a CIE will not have a valid address, whille a UnwindRow for a FDE will have a valid address.

The UnwindTable is a class that contains a sorted (by address) vector of UnwindRow objects and is the result of parsing all opcodes in a CIE, or FDE. Parsing a CIE should produce a UnwindTable with a single row. Parsing a FDE will produce a UnwindTable with one or more UnwindRow objects where all UnwindRow objects have valid addresses. The rows in the UnwindTable will be sorted from lowest Address to highest after parsing the state machine, or an error will be returned if the table isn't sorted. To parse a UnwindTable clients can use the following methods:

static Expected<UnwindTable> UnwindTable::create(const CIE *Cie);
static Expected<UnwindTable> UnwindTable::create(const FDE *Fde);

A valid table will be returned if the DWARF call frame instruction opcodes have no encoding errors. There are a few things that can go wrong during the evaluation of the state machine and these create functions will catch and return them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89845

Files:
  llvm/include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h
  llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h
  llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
  llvm/lib/DebugInfo/DWARF/DWARFExpression.cpp
  llvm/test/tools/llvm-objdump/eh_frame-mipsel.test
  llvm/unittests/DebugInfo/DWARF/DWARFDebugFrameTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89845.299546.patch
Type: text/x-patch
Size: 90941 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201021/52121cab/attachment.bin>


More information about the llvm-commits mailing list