[PATCH] D43313: [DebugInfo] Support parsing DWARF expressions

Rafael Auler via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 1 10:38:02 PST 2018


rafauler added inline comments.


================
Comment at: include/llvm/DebugInfo/DWARF/DWARFDebugFrame.h:50
+  /// sequence of operations and operands handled separately by DWARFExpression.
+  struct Instruction {
+    Instruction(uint8_t Opcode) : Opcode(Opcode) {}
----------------
JDevlieghere wrote:
> Doesn't this represent the same thing as the `DWARFExpression::Operation`? 
Well, not exactly.  So the DWARF expression is a sequence of operations too, but they manipulate this evaluation stack whose topmost value will be considered the result of the expression after all operations have been processed. It is written in postfix notation.
It's a bit different with CFI (call frame information) instructions, which is represented in this struct. These instructions establish the frame status at each program counter inside a function (in my copy of the DWARF4 manual, this is explained in more detail on pg.127 in "Sec6. Other debugging information"). For example, the most important information about the frame is the one that tells where the frame starts, so the unwinder knows at least how to find the return address, jump to the caller and adjust the stack pointer accordingly. The address where the frame starts is called a "canonical frame address" (CFA), so one of the instructions that can set this is called  "DW_CFA_def_cfa_expression", where the operand is a DWARF expression teaching the unwinder how to get to the frame start. In this case, DW_CFA_def_cfa_expression is the CFIProgram::Instruction here, and the expression is just an operand. The expression itself will be entirely interpreted in the DWARFExpression class.


Repository:
  rL LLVM

https://reviews.llvm.org/D43313





More information about the llvm-commits mailing list