public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Aktemur, Tankut Baris" <tankut.baris.aktemur@intel.com>
To: Pedro Alves <palves@redhat.com>
Cc: "Metzger, Markus T" <markus.t.metzger@intel.com>,
	gdb-patches <gdb-patches@sourceware.org>
Subject: RE: [PATCH v8 5/6] gdb/infrun: enable/disable thread events of all targets in stop_all_threads
Date: Thu, 14 May 2020 11:30:08 +0000	[thread overview]
Message-ID: <SN6PR11MB289345D80118C5CA2D30039FC4BC0@SN6PR11MB2893.namprd11.prod.outlook.com> (raw)
In-Reply-To: <060f84c1-4c08-6eb0-de76-bdfdb878c276@redhat.com>

On Thursday, May 14, 2020 1:17 PM, Pedro Alves wrote:
> On 5/14/20 9:44 AM, Aktemur, Tankut Baris wrote:
> > On Wednesday, May 13, 2020 10:54 PM, Pedro Alves wrote:
> >> diff --git a/gdb/infrun.c b/gdb/infrun.c
> >> index c5bf2d0ad74..6602bc28d5e 100644
> >> --- a/gdb/infrun.c
> >> +++ b/gdb/infrun.c
> >> @@ -4769,8 +4769,12 @@ stop_all_threads (void)
> >>
> >>    scoped_restore_current_thread restore_thread;
> >>
> >> -  target_thread_events (1);
> >> -  SCOPE_EXIT { target_thread_events (0); };
> >> +  /* Enable thread events of all targets.  */
> >> +  for (auto *target : all_non_exited_process_targets ())
> >> +    {
> >> +      switch_to_target_no_thread (target);
> >> +      target_thread_events (true);
> >> +    }
> >>
> >>    /* Request threads to stop, and then wait for the stops.  Because
> >>       threads we already know about can spawn more threads while we're
> >> @@ -4962,6 +4966,13 @@ stop_all_threads (void)
> >>  	}
> >>      }
> >>
> >> +  /* Disable thread events of all targets.  */
> >> +  for (auto *target : all_non_exited_process_targets ())
> >> +    {
> >> +      switch_to_target_no_thread (target);
> >> +      target_thread_events (false);
> >> +    }
> >> +
> >>    if (debug_infrun)
> >>      fprintf_unfiltered (gdb_stdlog, "infrun: stop_all_threads done\n");
> >>  }
> >
> > In internal communication, Markus pointed out that while the original
> > SCOPED_EXIT block would run also in the case of exceptions, the new code
> > does not.  Here is an update that uses SCOPED_EXIT for the thread event
> > disabling loop, too:
> >
> > diff --git a/gdb/infrun.c b/gdb/infrun.c
> > index c5bf2d0ad74..04fcc390d17 100644
> > --- a/gdb/infrun.c
> > +++ b/gdb/infrun.c
> > @@ -4769,8 +4769,22 @@ stop_all_threads (void)
> >
> >    scoped_restore_current_thread restore_thread;
> >
> > -  target_thread_events (1);
> > -  SCOPE_EXIT { target_thread_events (0); };
> > +  /* Enable thread events of all targets.  */
> > +  for (auto *target : all_non_exited_process_targets ())
> > +    {
> > +      switch_to_target_no_thread (target);
> > +      target_thread_events (true);
> > +    }
> > +
> > +  SCOPE_EXIT
> > +    {
> > +      /* Disable thread events of all targets.  */
> > +      for (auto *target : all_non_exited_process_targets ())
> > +       {
> > +         switch_to_target_no_thread (target);
> > +         target_thread_events (false);
> > +       }
> > +    };
> >
> 
> Yes, I noticed it too, but forgot to address it.  Thanks for bringing
> it up.
> 
> I think the:
> 
>   if (debug_infrun)
>     fprintf_unfiltered (gdb_stdlog, "infrun: stop_all_threads done\n");
> 
> bit should also move to within SCOPE_EXIT, since we currently
> print that before the destructors are run.  But that could be seen
> as an unrelated change.

OK, I'll move that piece into SCOPED_EXIT, too.

> 
> Thanks,
> Pedro Alves

-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

  reply	other threads:[~2020-05-14 11:30 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-13 20:53 [PATCH v8 0/6] Handle already-exited threads in 'stop_all_threads' Pedro Alves
2020-05-13 20:53 ` [PATCH v8 1/6] gdb: protect some 'regcache_read_pc' calls Pedro Alves
2020-05-13 20:53 ` [PATCH v8 2/6] gdb/infrun: move a 'regcache_read_pc' call down to first use Pedro Alves
2020-05-13 20:53 ` [PATCH v8 3/6] gdb/infrun: extract out a code piece into 'mark_non_executing_threads' function Pedro Alves
2020-05-13 20:53 ` [PATCH v8 4/6] gdb: introduce 'all_non_exited_process_targets' and 'switch_to_target_no_thread' Pedro Alves
2020-05-14  8:44   ` Aktemur, Tankut Baris
2020-05-14 11:12     ` Pedro Alves
2020-05-14 11:23       ` Aktemur, Tankut Baris
2020-05-13 20:53 ` [PATCH v8 5/6] gdb/infrun: enable/disable thread events of all targets in stop_all_threads Pedro Alves
2020-05-14  8:44   ` Aktemur, Tankut Baris
2020-05-14 11:16     ` Pedro Alves
2020-05-14 11:30       ` Aktemur, Tankut Baris [this message]
2020-05-13 20:53 ` [PATCH v8 6/6] gdb/infrun: handle already-exited threads when attempting to stop Pedro Alves
2020-05-14  8:47   ` Aktemur, Tankut Baris
2020-05-14 11:16     ` Pedro Alves
2020-05-14 11:40       ` Aktemur, Tankut Baris
2020-05-14 18:00   ` Tom de Vries
2020-05-14 18:54     ` Aktemur, Tankut Baris
2020-05-14 18:58       ` Pedro Alves
2020-05-15  7:53         ` Aktemur, Tankut Baris
2020-05-15 10:14           ` Pedro Alves
2020-05-15 10:17         ` Tom de Vries
2020-05-15 10:35           ` Pedro Alves
2020-05-15 11:53         ` Tom de Vries
2020-05-15 12:02           ` Pedro Alves
2020-05-15 14:16             ` Tom de Vries
2020-05-15 15:46               ` Pedro Alves
2020-05-15 17:17                 ` Tom de Vries
2020-05-18  6:18                   ` [PATCH][gdb/testsuite] Warn about leaked global array Tom de Vries
2020-05-18 10:41                     ` Pedro Alves
2020-05-19 16:34                       ` Tom de Vries

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=SN6PR11MB289345D80118C5CA2D30039FC4BC0@SN6PR11MB2893.namprd11.prod.outlook.com \
    --to=tankut.baris.aktemur@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=markus.t.metzger@intel.com \
    --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).