You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[lldb][swift] Evaluate entry_value(async_reg) in terms of CFA
Prior to this commit, evaluating the dwarf expression `entry_value(async_reg)`
is done by finding the value of the asynchronous register in the parent frame.
To enable the above, the unwinder must pretend there is a real function call
between the parent frame and the current frame, and that the async register is
set by the parent frame prior to making the 'call'. None of this is actually
true, and it creates a lot of work for the unwinder (see the amount of code
deleted there).
Here is further evidence of how awkward this is. Suppose you have this call
stack:
```
A <--- younger frame, top of the stack
B
C <--- older frame, bottom of the stack
```
When the unwinder is creating the frame of C from the register state of B, it
must know whether A was an indirect (Q) funclet or not, because that determined
how the frame of B was produced from the register state of A. This is very
unusual, in fact, the unwinder doesn't even have access to such information (we
had to use a "dummy" register for this).
This patch changes how `entry_value(async_reg)` (or
`entry_value(async_reg),deref` for Q_funclets) is evaluated: this expression is
equivalent to the CFA (the async context) of the current frame. Since we no
longer need to peek at the parent frame, the unwinder no longer needs to perform
the work described previously. The unwinder can instead provide the continuation
funclet with the register contents they will _actually_ have when the funclet
runs.
This patch also addresses a more subtle issue. In Q funclets, after a certain
instruction, `entry_value(async_reg)` produces a pointer to memory that has been
freed, as Q funclets free the async context of funclet that just finished
executing. If the debugger attempts to evaluate `entry_value(async_reg), deref`
as two separate operations, it will be accessing freed heap memory. By
converting that operation sequence into `DW_OP_call_frame_cfa`, we bypass the
issue.
0 commit comments