Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Aktemur, Tankut Baris" <tankut.baris.aktemur@intel.com>
To: Simon Marchi <simark@simark.ca>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH v2 1/3] gdb: parameterize all_threads_safe for the target and ptid
Date: Mon, 20 Apr 2026 17:21:23 +0000	[thread overview]
Message-ID: <DM4PR11MB7303C25CD67A5C27983FD540C42F2@DM4PR11MB7303.namprd11.prod.outlook.com> (raw)
In-Reply-To: <ce8c5b0a-8553-4fb1-96d3-4d702b67721e@simark.ca>

On Monday, April 20, 2026 6:58 PM, Simon Marchi wrote:
> On 4/20/26 9:46 AM, Tankut Baris Aktemur wrote:
> > diff --git a/gdb/infrun.c b/gdb/infrun.c
> > index b295956f8ea..46d6b684ebc 100644
> > --- a/gdb/infrun.c
> > +++ b/gdb/infrun.c
> > @@ -1239,7 +1239,7 @@ static void
> >  follow_exec (ptid_t ptid, const char *exec_file_target)
> >  {
> >    int pid = ptid.pid ();
> > -  ptid_t process_ptid;
> > +  ptid_t process_ptid = ptid_t (pid);
> 
> ptid_t process_ptid (pid);
> 
> >    /* Switch terminal for any messages produced e.g. by
> >       breakpoint_re_set.  */
> > @@ -1285,8 +1285,9 @@ follow_exec (ptid_t ptid, const char *exec_file_target)
> >       them.  Deleting them now rather than at the next user-visible
> >       stop provides a nicer sequence of events for user and MI
> >       notifications.  */
> > -  for (thread_info &th : all_threads_safe ())
> > -    if (th.ptid.pid () == pid && th.ptid != ptid)
> > +  process_stratum_target *target = current_inferior ()->process_target ();
> > +  for (thread_info &th : all_threads_safe (target, process_ptid))
> > +    if (th.ptid != ptid)
> 
> Just noting that this is a behavior change, the previous code iterated
> threads of all targets, while the new code only iterates the threads of
> the current process target.  You could have passed nullptr to preserve
> existing behavior.  But I think this is a good change, it's the same
> spirit as your other patches.

Ack.

> > diff --git a/gdb/remote.c b/gdb/remote.c
> > index 88668b2748e..7c8aed481f2 100644
> > --- a/gdb/remote.c
> > +++ b/gdb/remote.c
> > @@ -4584,11 +4584,8 @@ remote_target::update_thread_list ()
> >        /* CONTEXT now holds the current thread list on the remote
> >  	 target end.  Delete GDB-side threads no longer found on the
> >  	 target.  */
> > -      for (thread_info &tp : all_threads_safe ())
> > +      for (thread_info &tp : all_threads_safe (this))
> >  	{
> > -	  if (tp.inf->process_target () != this)
> > -	    continue;
> > -
> 
> You could now remove the braces for the `for`, to reduce indentation a
> bit.

There is another loop right after this one where we can apply
the same rule.  Shall I remove braces there, too, in another
obvious patch?  Otherwise, we will have inconsistency within
the function.

> >  	  if (!context.contains_thread (tp.ptid))
> >  	    {
> >  	      /* Do not remove the thread if it is the last thread in
> > diff --git a/gdb/thread-iter.h b/gdb/thread-iter.h
> > index 3c15ada1cbb..32bc6475ebe 100644
> > --- a/gdb/thread-iter.h
> > +++ b/gdb/thread-iter.h
> > @@ -165,7 +165,7 @@ using inf_non_exited_threads_iterator
> >  /* Iterate over all threads of all inferiors, safely.  */
> >
> >  using all_threads_safe_iterator
> > -  = basic_safe_iterator<all_threads_iterator>;
> > +  = basic_safe_iterator<all_matching_threads_iterator>;
> 
> I'd rename all_threads_safe_iterator to
> all_matching_threads_safe_iterator, to try to preserve the logic in how
> these are named.
> 
> all_threads_safe_range would also be renamed to
> all_matching_threads_safe_range.
> 
> With those fixed:
> 
> Approved-By: Simon Marchi <simon.marchi@efficios.com>
> 
> Simon

Thank you.
-Baris

Intel Deutschland GmbH
Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany
Tel: +49 89 991 430, www.intel.de
Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell
Chairperson of the Supervisory Board: Nicole Lau
Registered Seat: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

  reply	other threads:[~2026-04-20 17:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-20 13:46 Tankut Baris Aktemur
2026-04-20 13:46 ` [PATCH v2 2/3] gdb, multi-target: pass a target argument to prune_threads Tankut Baris Aktemur
2026-04-20 17:02   ` Simon Marchi
2026-04-20 13:46 ` [PATCH v2 3/3] gdb, multi-target: pass a target argument to delete_exited_threads Tankut Baris Aktemur
2026-04-20 17:20   ` Simon Marchi
2026-04-21  7:48     ` Aktemur, Tankut Baris
2026-04-20 16:58 ` [PATCH v2 1/3] gdb: parameterize all_threads_safe for the target and ptid Simon Marchi
2026-04-20 17:21   ` Aktemur, Tankut Baris [this message]
2026-04-20 17:49     ` Simon Marchi

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=DM4PR11MB7303C25CD67A5C27983FD540C42F2@DM4PR11MB7303.namprd11.prod.outlook.com \
    --to=tankut.baris.aktemur@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simark@simark.ca \
    /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