Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/3] Pass inferior down to target_detach and to_detach
Date: Thu, 18 Jan 2018 16:41:00 -0000	[thread overview]
Message-ID: <71c999db-f10c-ca2b-911e-4d6968121a3f@redhat.com> (raw)
In-Reply-To: <1514699454-18587-2-git-send-email-simon.marchi@ericsson.com>

On 12/31/2017 05:50 AM, Simon Marchi wrote:
> The to_detach target_ops method implementations are currently expected
> to work on current_inferior/inferior_ptid.  In order to make things more
> explicit, and remove some "shadow" parameter passing through globals,
> this patch adds an "inferior" parameter to to_detach.  Implementations
> will be expected to use this instead of relying on the global.  However,
> to keep things simple, this patch only does the minimum that is
> necessary to add the parameter.  The following patch gives an example of
> how one such implementation would be adapted.  If the approach is deemed
> good, we can then look into adapting more implementations.  Until then,
> they'll continue to work as they do currently.

On the multi-target work/branch, I ended up hanging the current
target stack to the current inferior.  Which means that in practice
we have to switch the current inferior/thread before calling any target
method.  I can't see any other practical way.  I've pondered making
every target method take an inferior or some kind of "execution
context" object as parameter, but that's a massive undertaking.
The result is still better for relying more on thread pointers
instead of inferior_ptid / ptid_t, though, IMO.

Note that in practice, even with your patch (in master) we still have
to switch the current inferior before calling target_detach anyway,
for making sure things like the current program space is set correctly,
target_gdbarch(), target description, removing breakpoints, accessing memory,
registers, etc., like here:

>        /* Note that the detach above makes PARENT_INF dangling.  */
> @@ -976,7 +976,7 @@ handle_vfork_child_exec_or_exit (int exec)
>  		}
>  	    }
>  
> -	  target_detach (0);
> +	  target_detach (inf->vfork_parent, 0);

... this still relies on the switch_to_thread call a bit above.

Or look at the prepare_to_detach call in target_detach.

All that said, I'm totally fine with incremental progress.  Actually,
it's probably the only way to go!

So I'm fine with the patch, though, I think we should add a
temporary assertion in target_detach, like:

  gdb_assert (inf == current_inferior ());

until everything beneath either uses an explicit inferior,
or switches the current inferior temporarily.

Thanks,
Pedro Alves


  reply	other threads:[~2018-01-18 16:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-31  5:56 [PATCH 1/3] Remove args from target detach Simon Marchi
2017-12-31  5:58 ` [PATCH 2/3] Pass inferior down to target_detach and to_detach Simon Marchi
2018-01-18 16:41   ` Pedro Alves [this message]
2018-01-19  3:17     ` Simon Marchi
2017-12-31  6:01 ` [PATCH 3/3] Make linux_nat_detach/thread_db_detach use the inferior parameter Simon Marchi
2018-01-18 17:06   ` Pedro Alves
2018-01-19  3:26     ` Simon Marchi
2018-01-18 15:57 ` [PATCH 1/3] Remove args from target detach Pedro Alves

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=71c999db-f10c-ca2b-911e-4d6968121a3f@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@ericsson.com \
    /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