| Message ID | 20260505075744.936344-1-markus.t.metzger@intel.com |
|---|---|
| State | New |
| Headers |
Return-Path: <gdb-patches-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 9A7174B9DB73 for <patchwork@sourceware.org>; Tue, 5 May 2026 07:58:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A7174B9DB73 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=A5LrvewT X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) by sourceware.org (Postfix) with ESMTPS id 464A94BA7980 for <gdb-patches@sourceware.org>; Tue, 5 May 2026 07:57:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 464A94BA7980 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 464A94BA7980 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777967868; cv=none; b=Czh5FyPYRPm6KR5q+mSn8J9pqKs92shosJno1TqU4sfSBlMpSaCqpKIyJojSptDC9O797Pi5PBeHLlpmG83IimCctWKMzmphCS+dQ+aRUUTVd+YhFEAOj82sUes+1mueLRIfXdYFq0ZA7lygiU5VsfSDoEdGvg4FmrBGhxYsQZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1777967868; c=relaxed/simple; bh=2GWSIkL9Uuzxs/7TRFozMV+GnR7ar69r9OWVwxCNf90=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=pMNjJjb81emYUSKGvXv4z7bwMiplTxS2obYj7nUSh3kHEXRaRQjmzMAPHdvE4hSyLwgQ2+EoGct2hJFCu+v8pETxKWpH5ZABz+/R+4hlrMB3sXFGvP9gyC3vOeUOZREjtFreE7DUkjyMl+o53o6Z3Bo2BcjgMWZ7FDtHuXqp/KQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 464A94BA7980 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1777967869; x=1809503869; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=2GWSIkL9Uuzxs/7TRFozMV+GnR7ar69r9OWVwxCNf90=; b=A5LrvewTkBA4EttWUsBkhGsnVaAb9Ajkp+D8SeDujV9Vng2JuMHVmQxS XZ1LGGzigVPa8hOFWoUvIVip1QyCwWSIWToqqGOK5bwSdCS6PDSi/XiZQ 2UPFcxzlgCKbROqNM7cy8IBitj/HBvgMPGju9UcXZ+r91cryS7+Z0o0pX hBNidv9IAWMgPaajmxZz72XKk4kL6/rcgzoJLGvmSltZNvRsIGM6G9vc9 WrV2prDQk/9Qg3sQTmQyup/G6nQapc9VZE2g0gav6iXuaWAuL04fYSpK6 XtQQkbVdl/r1Uzbpf7SERlAlBL+2LgtaO/kxIu5UE0kXj54TsspZi/DLz w==; X-CSE-ConnectionGUID: LnueubvBRZm3OhCmR7oZLA== X-CSE-MsgGUID: PZ2MN8LQSKeaY01XGLUaWg== X-IronPort-AV: E=McAfee;i="6800,10657,11776"; a="66359141" X-IronPort-AV: E=Sophos;i="6.23,217,1770624000"; d="scan'208";a="66359141" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2026 00:57:47 -0700 X-CSE-ConnectionGUID: blB47hA1RzWYRGb+xEedQA== X-CSE-MsgGUID: RN+63hnoQ1yS7AuedaAspQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,217,1770624000"; d="scan'208";a="259420965" Received: from gkldtt-dev-004.igk.intel.com (HELO localhost) ([10.123.221.202]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 May 2026 00:57:46 -0700 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 Message-Id: <20260505075744.936344-1-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
[v2] gdb: use correct target in notify_thread_exited()
|
|
Commit Message
Metzger, Markus T
May 5, 2026, 7:57 a.m. UTC
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(+)
Comments
On 2026-05-05 03:57, Markus Metzger wrote: > 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); Let's use: /* 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 (), I checked if any callee of the observable cared whether THREAD is the current thread, or if THREAD's inferior is the current inferior, and I don't think so. remove_threaded_breakpoints recurses into a bunch of breakpoint functions so it's difficult to be sure, but at first glance it seems fine. With the above fixed: Approved-By: Simon Marchi <simon.marchi@efficios.com> Simon
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 (),