]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: use correct target in notify_thread_exited()
authorMarkus Metzger <markus.t.metzger@intel.com>
Fri, 24 Apr 2026 13:11:07 +0000 (13:11 +0000)
committerMarkus Metzger <markus.t.metzger@intel.com>
Mon, 11 May 2026 07:00:19 +0000 (07:00 +0000)
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 <simon.marchi@efficios.com>
gdb/thread.c

index c156f16377bdf8912cad79b1f2b90ad1a2391c93..4f62ca280cdb1f527dc224a0c6232bc039e8fda3 100644 (file)
@@ -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 (),