forked from swiftlang/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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. (cherry picked from commit bbc1484)
- Loading branch information
1 parent
3911c0e
commit b45de43
Showing
3 changed files
with
111 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters