[binutils-gdb] gdb: use correct target in notify_thread_exited()
Markus Metzger via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=aca091c462db54e7b9fe96eded8ccc2d2eaf83cf commit aca091c462db54e7b9fe96eded8ccc2d2eaf83cf Author: Markus Metzger <[email protected]> Date: Fri Apr 24 13:11:07 2026 +0000 gdb: use correct target in notify_thread_exited() 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's inferior to get the target right. Approved-By: Simon Marchi <[email protected]> Diff: --- gdb/thread.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gdb/thread.c b/gdb/thread.c index c156f16377b..4f62ca280cd 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) { + /* Switch inferior before the target calls below. */ + auto restore_inf = maybe_switch_inferior (t->inf); + if (exit_code.has_value ()) gdb_printf (_("[%s (id %s) exited with code %s]\n"), target_pid_to_str (t->ptid).c_str (),