From: Markus Metzger <markus.t.metzger@intel.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simark@simark.ca>
Subject: [PATCH v2] gdb: use correct target in notify_thread_exited()
Date: Tue, 5 May 2026 07:57:44 +0000 [thread overview]
Message-ID: <20260505075744.936344-1-markus.t.metzger@intel.com> (raw)
clean_up_just_stopped_threads_fsms() may call notify_thread_exited() in
the context of a thread from a different target.
Switch to the thread we're notifying about to get the inferior and target
right.
CC: Simon Marchi <simark@simark.ca>
---
gdb/thread.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/gdb/thread.c b/gdb/thread.c
index c156f16377b..02ea62d524c 100644
--- a/gdb/thread.c
+++ b/gdb/thread.c
@@ -203,6 +203,9 @@ notify_thread_exited (thread_info *t, std::optional<ULONGEST> exit_code,
{
if (!silent && print_thread_events)
{
+ scoped_restore_current_thread restore_thread;
+ switch_to_thread (t);
+
if (exit_code.has_value ())
gdb_printf (_("[%s (id %s) exited with code %s]\n"),
target_pid_to_str (t->ptid).c_str (),
--
2.34.1
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
next reply other threads:[~2026-05-05 7:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-05 7:57 Markus Metzger [this message]
2026-05-05 16:20 ` 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=20260505075744.936344-1-markus.t.metzger@intel.com \
--to=markus.t.metzger@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