public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Aktemur, Tankut Baris" <tankut.baris.aktemur@intel.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: "palves@redhat.com" <palves@redhat.com>
Subject: RE: [PATCH v7 5/5] gdb/infrun: handle already-exited threads when attempting to stop
Date: Sun, 3 May 2020 15:38:48 +0000	[thread overview]
Message-ID: <SN6PR11MB289337E4261B7CFFA1DBD431C4A90@SN6PR11MB2893.namprd11.prod.outlook.com> (raw)
In-Reply-To: <e540fa513347a44c1ae4fc4aa41b506098ad97d8.1587563226.git.tankut.baris.aktemur@intel.com>

On Wednesday, April 22, 2020 5:01 PM, Tankut Baris Aktemur wrote:
> In stop_all_threads, GDB sends signals to other threads in an attempt
> to stop them.  While in a typical scenario the expected wait status is
> TARGET_WAITKIND_STOPPED, it is possible that the thread GDB attempted
> to stop has already terminated.  If so, a waitstatus other than
> TARGET_WAITKIND_STOPPED would be received.  Handle this case
> appropriately.

I noticed that at the beginning of stop_all_threads, we have this:

  scoped_restore_current_thread restore_thread;

  target_thread_events (1);
  SCOPE_EXIT { target_thread_events (0); };

This is not quite right, because the current top target at the scope exit
time is not necessarily the same as the current top target at the function
start.  The 'scoped_restore_current_thread' should have come after 'SCOPE_EXIT
 { target_thread_events (0); };'.  Yet, this re-ordering of the statements
would still not be sufficient, because that would enable/disable the thread
events for only the current top target.  I think this has to be done for all
targets.

So, I've just emailed a two-patch series where the first one defines a convenience
method, 'all_non_exited_process_targets', to get a collection of targets:

  https://sourceware.org/pipermail/gdb-patches/2020-May/168172.html
  https://sourceware.org/pipermail/gdb-patches/2020-May/168173.html 

During the review period of the multi-target patches, Tom Tromey had commented
that such a method to allow for-each iteration over the targets would be useful.
For instance, a place where 'all_non_exited_process_targets' could be used is...

> diff --git a/gdb/infrun.c b/gdb/infrun.c
> index 167d50ff3ab..93169269553 100644
> --- a/gdb/infrun.c
> +++ b/gdb/infrun.c
> @@ -4781,7 +4781,47 @@ stop_all_threads (void)
>  	{
>  	  int need_wait = 0;
> 
> -	  update_thread_list ();
> +	  for (inferior *inf : all_non_exited_inferiors ())
> +	    {
> +	      update_thread_list ();

... this iteration, to avoid calling 'update_thread_list' multiple times on
a particular target.  I can submit a revision, if you think that's appropriate.

Regards.
-Baris


Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

  parent reply	other threads:[~2020-05-03 15:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1587563226.git.tankut.baris.aktemur@intel.com>
2020-04-22 15:00 ` [PATCH v7 3/5] gdb/remote: do not delete a thread if it has a pending exit event Tankut Baris Aktemur
2020-05-04 14:43   ` Pedro Alves
2020-05-04 15:33     ` Aktemur, Tankut Baris
2020-05-13 14:20       ` Pedro Alves
2020-04-22 15:00 ` [PATCH v7 5/5] gdb/infrun: handle already-exited threads when attempting to stop Tankut Baris Aktemur
2020-04-22 16:07   ` Aktemur, Tankut Baris
2020-05-03 15:38   ` Aktemur, Tankut Baris [this message]
2020-05-13 21:15   ` Pedro Alves
2020-05-14  8:50     ` Aktemur, Tankut Baris
2020-05-14 11:32       ` Pedro Alves
2020-05-14 11:42         ` Aktemur, Tankut Baris
2020-05-14 11:25     ` 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=SN6PR11MB289337E4261B7CFFA1DBD431C4A90@SN6PR11MB2893.namprd11.prod.outlook.com \
    --to=tankut.baris.aktemur@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).