coroutines: Expose implementation state to the debugger.
In the process of transforming a coroutine into the separate representation
as the ramp function and a state machine, we generate some variables that
are of interest to a user during debugging. Any variable that is persistent
for the execution of the coroutine is placed into the coroutine frame.
The promise object.
The function pointers for the resumer and destroyer.
The current resume index (suspend point).
The handle that represents this coroutine 'self handle'.
Any handle provided for a continuation coroutine.
Whether the coroutine frame is allocated and needs to be freed.
Visibility of some of these has already been requested by end users.
This patch ensures that such variables have names that are usable in a
debugger, but are in the reserved namespace for the implementation (they
all begin with _Coro_). The identifiers are generated lazily when the
first coroutine is encountered.
We place the variables into the outermost bind expression and then add a
DECL_VALUE_EXPR to each that points to the frame entry.
These changes simplify the handling of the variables in the body of the
function (in particular, the use of the DECL_VALUE_EXPR means that we now
no longer need to rewrite proxies for the promise and coroutine handles into
the frame->offset form).
Partial improvement to debugging (PR c++/99215).
Signed-off-by: Iain Sandoe <email@example.com>
* coroutines.cc (coro_resume_fn_id, coro_destroy_fn_id,
coro_promise_id, coro_frame_needs_free_id, coro_resume_index_id,
(coro_init_identifiers): Initialize new name identifiers.
(coro_promise_type_found_p): Use pre-built identifiers.
(struct await_xform_data): Remove unused fields.
(transform_await_expr): Delete code that is now unused.
(build_actor_fn): Simplify interface, use pre-built identifiers and
remove transforms that are no longer needed.
(build_destroy_fn): Use revised field names.
(register_local_var_uses): Use pre-built identifiers.
(coro_rewrite_function_body): Simplify interface, use pre-built
identifiers. Generate proxy vars in the outer bind expr scope for the
implementation state that we wish to expose.
(morph_fn_to_coro): Adjust comments for new variable names, use pre-
built identifiers. Remove unused code to generate frame entries for
the implementation state. Adjust call for build_actor_fn.
1 file changed