public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: Iain Sandoe <iain@sandoe.co.uk>, GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: PATCH 3/8] coroutines: Support for debugging implementation state.
Date: Fri, 3 Sep 2021 09:31:39 -0400	[thread overview]
Message-ID: <84eca7df-d2ef-a2a0-3dc8-0a09d5cda91d@redhat.com> (raw)
In-Reply-To: <C9F65FED-7179-4744-812C-79A8400128BB@sandoe.co.uk>

On 9/1/21 6:53 AM, Iain Sandoe wrote:
> 
> Some of the state that is associated with the implementation
> is of interest to a user debugging a coroutine.  In particular
> items such as the suspend point, promise object, and current
> suspend point.
> 
> These variables live in the coroutine frame, but we can inject
> proxies for them into the outermost bind expression of the
> coroutine.  Such variables are automatically moved into the
> coroutine frame (if they need to persist across a suspend
> expression).  PLacing the proxies thus allows the user to
> inspect them by name in the debugger.
> 
> To implement this, we ensure that (at the outermost scope) the
> frame entries are not mangled (coroutine frame variables are
> usually mangled with scope nesting information so that they do
> not clash).  We can safely avoid doing this for the outermost
> scope so that we can map frame entries directly to the variables.
> 
> This is partial contribution to debug support (PR 99215).

OK.

> Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
> 
> gcc/cp/ChangeLog:
> 
> 	* coroutines.cc (register_local_var_uses): Do not mangle
> 	frame entries for the outermost scope.  Record the outer
> 	scope as nesting depth 0.
> ---
>   gcc/cp/coroutines.cc | 16 +++++++++++-----
>   1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
> index b8501032969..a12714ea67e 100644
> --- a/gcc/cp/coroutines.cc
> +++ b/gcc/cp/coroutines.cc
> @@ -3885,8 +3885,6 @@ register_local_var_uses (tree *stmt, int *do_subtree, void *d)
>   
>     if (TREE_CODE (*stmt) == BIND_EXPR)
>       {
> -      lvd->bind_indx++;
> -      lvd->nest_depth++;
>         tree lvar;
>         for (lvar = BIND_EXPR_VARS (*stmt); lvar != NULL;
>   	   lvar = DECL_CHAIN (lvar))
> @@ -3925,11 +3923,17 @@ register_local_var_uses (tree *stmt, int *do_subtree, void *d)
>   	    continue;
>   
>   	  /* Make names depth+index unique, so that we can support nested
> -	     scopes with identically named locals.  */
> +	     scopes with identically named locals and still be able to
> +	     identify them in the coroutine frame.  */
>   	  tree lvname = DECL_NAME (lvar);
>   	  char *buf;
> -	  if (lvname != NULL_TREE)
> -	    buf = xasprintf ("__%s.%u.%u", IDENTIFIER_POINTER (lvname),
> +	  /* The outermost bind scope contains the artificial variables that
> +	     we inject to implement the coro state machine.  We want to be able
> +	     to inspect these in debugging.  */
> +	  if (lvname != NULL_TREE && lvd->nest_depth == 0)
> +	    buf = xasprintf ("%s", IDENTIFIER_POINTER (lvname));
> +	  else if (lvname != NULL_TREE)
> +	    buf = xasprintf ("%s_%u_%u", IDENTIFIER_POINTER (lvname),
>   			     lvd->nest_depth, lvd->bind_indx);
>   	  else
>   	    buf = xasprintf ("_D%u.%u.%u", DECL_UID (lvar), lvd->nest_depth,
> @@ -3942,6 +3946,8 @@ register_local_var_uses (tree *stmt, int *do_subtree, void *d)
>   	  /* We don't walk any of the local var sub-trees, they won't contain
>   	     any bind exprs.  */
>   	}
> +      lvd->bind_indx++;
> +      lvd->nest_depth++;
>         cp_walk_tree (&BIND_EXPR_BODY (*stmt), register_local_var_uses, d, NULL);
>         *do_subtree = 0; /* We've done this.  */
>         lvd->nest_depth--;
> 


  parent reply	other threads:[~2021-09-03 13:31 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-01 10:51 [PATCH 0/8] coroutines: Use DECL_VALUE_EXPRs to assist in debug [PR99215] Iain Sandoe
2021-09-01 10:52 ` [PATCH 1/8] coroutines : Use DECL_VALUE_EXPR instead of rewriting vars Iain Sandoe
2021-09-01 10:53   ` [PATCH 2/8] coroutines: Add a helper for creating local vars Iain Sandoe
2021-09-01 10:53     ` PATCH 3/8] coroutines: Support for debugging implementation state Iain Sandoe
2021-09-01 10:54       ` [PATCH 4/8] coroutines: Make some of the artificial names more debugger-friendly Iain Sandoe
2021-09-01 10:54         ` [PATCH 5/8] coroutines: Define and populate accessors for debug state Iain Sandoe
2021-09-01 10:55           ` [PATCH 6/8] coroutines: Convert implementation variables to debug-friendly form Iain Sandoe
2021-09-01 10:56             ` [PATCH 7/8] coroutines: Make proxy vars for the function arg copies Iain Sandoe
2021-09-01 10:56               ` [PATCH 8/8] coroutines: Make the continue handle visible to debug Iain Sandoe
2021-09-03 14:25                 ` Jason Merrill
2021-09-03 14:07               ` [PATCH 7/8] coroutines: Make proxy vars for the function arg copies Jason Merrill
2021-09-03 14:23                 ` Iain Sandoe
2021-09-05 19:50                   ` [PATCH 7/8 v2] " Iain Sandoe
2021-09-07 17:26                     ` Jason Merrill
2021-09-03 13:52             ` [PATCH 6/8] coroutines: Convert implementation variables to debug-friendly form Jason Merrill
2021-09-03 13:56               ` Iain Sandoe
2021-09-03 14:12                 ` Jason Merrill
2021-09-03 14:21                   ` Iain Sandoe
2021-09-05 19:47                     ` Iain Sandoe
2021-09-07 17:23                       ` Jason Merrill
2021-09-03 13:39           ` [PATCH 5/8] coroutines: Define and populate accessors for debug state Jason Merrill
2021-09-03 13:41             ` Iain Sandoe
2021-09-03 13:42             ` Iain Sandoe
2021-09-03 13:44               ` Jason Merrill
2021-09-03 13:35         ` [PATCH 4/8] coroutines: Make some of the artificial names more debugger-friendly Jason Merrill
2021-09-03 13:31       ` Jason Merrill [this message]
2021-09-02 21:52     ` [PATCH 2/8] coroutines: Add a helper for creating local vars Jason Merrill
2021-09-02 21:51   ` [PATCH 1/8] coroutines : Use DECL_VALUE_EXPR instead of rewriting vars Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=84eca7df-d2ef-a2a0-3dc8-0a09d5cda91d@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=iain@sandoe.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).