From: Matthieu Longo <matthieu.longo@arm.com>
To: <gdb-patches@sourceware.org>
Cc: Luis Machado <luis.machado@amd.com>,
Luis Machado <luis.machado.foss@gmail.com>,
Simon Marchi <simark@simark.ca>,
"Thiago Jung Bauermann" <thiago.bauermann@linaro.org>,
Matthieu Longo <matthieu.longo@arm.com>
Subject: [PATCH v1 1/2] gdb: rename any_thread_of_inferior to any_non_exited_thread_of_inferior
Date: Tue, 28 Jul 2026 15:33:16 +0100 [thread overview]
Message-ID: <20260728143317.245389-2-matthieu.longo@arm.com> (raw)
In-Reply-To: <20260728143317.245389-1-matthieu.longo@arm.com>
The name any_thread_of_inferior suggests that the function may return
any thread of the inferior. In practice, it only returns a non-exited
thread.
Rename it to any_non_exited_thread_of_inferior to better reflect its
behavior. This is a preparatory change for the following patch, which
adds another helper with similar semantics.
Suggested-by: Simon Marchi <simark@simark.ca>
[1]: https://inbox.sourceware.org/gdb-patches/590655c1-abed-4a16-b8cc
-762f1d8e6093@simark.ca/
---
gdb/gdbthread.h | 4 ++--
gdb/inferior.c | 6 +++---
gdb/linux-fork.c | 10 +++++-----
gdb/mi/mi-main.c | 4 ++--
gdb/remote.c | 4 ++--
gdb/thread.c | 2 +-
gdb/top.c | 2 +-
7 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h
index 1bdbf621982..6588ae0c6a7 100644
--- a/gdb/gdbthread.h
+++ b/gdb/gdbthread.h
@@ -779,9 +779,9 @@ struct thread_info *find_thread_by_handle
/* Finds the first thread of the specified inferior. */
extern struct thread_info *first_thread_of_inferior (inferior *inf);
-/* Returns any thread of inferior INF, giving preference to the
+/* Returns any non-exited thread of inferior INF, giving preference to the
current thread. */
-extern struct thread_info *any_thread_of_inferior (inferior *inf);
+extern struct thread_info *any_non_exited_thread_of_inferior (inferior *inf);
/* Returns any non-exited thread of inferior INF, giving preference to
the current thread, and to not executing threads. */
diff --git a/gdb/inferior.c b/gdb/inferior.c
index 1481f46cdd1..ac8c4354b71 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -663,7 +663,7 @@ detach_inferior_command (const char *args, int from_tty)
continue;
}
- thread_info *tp = any_thread_of_inferior (inf);
+ thread_info *tp = any_non_exited_thread_of_inferior (inf);
if (tp == NULL)
{
warning (_("Inferior ID %d has no threads."), num);
@@ -702,7 +702,7 @@ kill_inferior_command (const char *args, int from_tty)
continue;
}
- thread_info *tp = any_thread_of_inferior (inf);
+ thread_info *tp = any_non_exited_thread_of_inferior (inf);
if (tp == NULL)
{
warning (_("Inferior ID %d has no threads."), num);
@@ -771,7 +771,7 @@ inferior_command (const char *args, int from_tty)
{
if (inf != current_inferior ())
{
- thread_info *tp = any_thread_of_inferior (inf);
+ thread_info *tp = any_non_exited_thread_of_inferior (inf);
if (tp == NULL)
error (_("Inferior has no threads."));
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 92afa4dde6d..446d3284388 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -571,7 +571,7 @@ class scoped_switch_fork_info
if (oldinf != newinf)
{
- thread_info *tp = any_thread_of_inferior (newinf);
+ thread_info *tp = any_non_exited_thread_of_inferior (newinf);
switch_to_thread (tp);
m_oldinf = oldinf;
}
@@ -593,7 +593,7 @@ class scoped_switch_fork_info
remove_breakpoints ();
if (m_oldinf != nullptr)
{
- thread_info *tp = any_thread_of_inferior (m_oldinf);
+ thread_info *tp = any_non_exited_thread_of_inferior (m_oldinf);
switch_to_thread (tp);
}
fork_load_infrun_state (m_oldfp);
@@ -836,7 +836,7 @@ print_checkpoints (struct ui_out *uiout, inferior *req_inf, fork_info *req_fi)
if (req_fi != nullptr && req_fi != &fi)
continue;
- thread_info *t = any_thread_of_inferior (inf);
+ thread_info *t = any_non_exited_thread_of_inferior (inf);
bool is_current = fi.ptid.pid () == inf->pid;
ui_out_emit_tuple tuple_emitter (uiout, nullptr);
@@ -1063,7 +1063,7 @@ linux_fork_context (struct fork_info *newfp, int from_tty, inferior *newinf)
if (newinf != current_inferior ())
{
- thread_info *tp = any_thread_of_inferior (newinf);
+ thread_info *tp = any_non_exited_thread_of_inferior (newinf);
switch_to_thread (tp);
inferior_changed = true;
}
@@ -1100,7 +1100,7 @@ restart_command (const char *args, int from_tty)
/* Don't allow switching from a thread/fork that's running. */
inferior *curinf = current_inferior ();
if (curinf->pid != 0
- && any_thread_of_inferior (curinf)->state () == THREAD_RUNNING)
+ && any_non_exited_thread_of_inferior (curinf)->state () == THREAD_RUNNING)
error (_("Cannot execute this command while "
"the selected thread is running."));
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 73c64b82186..6a79805d75d 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -397,7 +397,7 @@ run_one_inferior (inferior *inf, bool start_p)
if (inf->pid != 0)
{
- thread_info *tp = any_thread_of_inferior (inf);
+ thread_info *tp = any_non_exited_thread_of_inferior (inf);
if (tp == NULL)
error (_("Inferior has no threads."));
@@ -1742,7 +1742,7 @@ mi_cmd_remove_inferior (const char *command, const char *const *argv, int argc)
set_current_inferior (new_inferior);
if (new_inferior->pid != 0)
- tp = any_thread_of_inferior (new_inferior);
+ tp = any_non_exited_thread_of_inferior (new_inferior);
if (tp != NULL)
switch_to_thread (tp);
else
diff --git a/gdb/remote.c b/gdb/remote.c
index 194c4cbd9bb..30d0d171d1f 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -5761,7 +5761,7 @@ remote_target::start_remote_1 (int from_tty, int extended_p)
/* Need to switch to a specific thread, because remote_check_symbols
uses INFERIOR_PTID to set the general thread. */
scoped_restore_current_thread restore_thread;
- thread_info *thread = any_thread_of_inferior (inf);
+ thread_info *thread = any_non_exited_thread_of_inferior (inf);
switch_to_thread (thread);
this->remote_check_symbols ();
}
@@ -16175,7 +16175,7 @@ remote_objfile_changed_check_symbols (program_space *pspace)
called very early in the connection process, while the inferior is
being set up, before threads are added. Just skip it, start_remote_1
also calls remote_check_symbols when it's done setting things up. */
- thread_info *thread = any_thread_of_inferior (inf);
+ thread_info *thread = any_non_exited_thread_of_inferior (inf);
if (thread != nullptr)
{
scoped_restore_current_thread restore_thread;
diff --git a/gdb/thread.c b/gdb/thread.c
index 96c733e0629..a7d0b8a45dc 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -675,7 +675,7 @@ first_thread_of_inferior (inferior *inf)
}
thread_info *
-any_thread_of_inferior (inferior *inf)
+any_non_exited_thread_of_inferior (inferior *inf)
{
gdb_assert (inf->pid != 0);
diff --git a/gdb/top.c b/gdb/top.c
index 477c385da61..308b5552fd5 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1862,7 +1862,7 @@ kill_or_detach (inferior *inf, int from_tty)
if (inf->pid == 0)
return;
- thread_info *thread = any_thread_of_inferior (inf);
+ thread_info *thread = any_non_exited_thread_of_inferior (inf);
if (thread != NULL)
{
switch_to_thread (thread);
--
2.55.0
next prev parent reply other threads:[~2026-07-28 14:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 14:33 [PATCH v1 0/2] gdb: fix for bug 31207 Matthieu Longo
2026-07-28 14:33 ` Matthieu Longo [this message]
2026-07-28 14:33 ` [PATCH v1 2/2] gdb: rely on the first non-exited thread TPID when reading Linux procfs files Matthieu Longo
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=20260728143317.245389-2-matthieu.longo@arm.com \
--to=matthieu.longo@arm.com \
--cc=gdb-patches@sourceware.org \
--cc=luis.machado.foss@gmail.com \
--cc=luis.machado@amd.com \
--cc=simark@simark.ca \
--cc=thiago.bauermann@linaro.org \
/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