From: Simon Marchi <simark@simark.ca>
To: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>,
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 12:58:17 -0400 [thread overview]
Message-ID: <ce8c5b0a-8553-4fb1-96d3-4d702b67721e@simark.ca> (raw)
In-Reply-To: <20260420134611.4009838-1-tankut.baris.aktemur@intel.com>
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.
> 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.
> 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
next prev parent reply other threads:[~2026-04-20 16:58 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 ` Simon Marchi [this message]
2026-04-20 17:21 ` [PATCH v2 1/3] gdb: parameterize all_threads_safe for the target and ptid Aktemur, Tankut Baris
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=ce8c5b0a-8553-4fb1-96d3-4d702b67721e@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=tankut.baris.aktemur@intel.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