From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ivMuFiczm2mUhAUAWB0awg (envelope-from ) for ; Sun, 22 Feb 2026 11:47:35 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gnu.org header.i=@gnu.org header.a=rsa-sha256 header.s=fencepost-gnu-org header.b=SepPKJi9; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 446351E089; Sun, 22 Feb 2026 11:47:35 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E28FB1E089 for ; Sun, 22 Feb 2026 11:47:33 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 538964BA2E1C for ; Sun, 22 Feb 2026 16:47:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 538964BA2E1C Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gnu.org header.i=@gnu.org header.a=rsa-sha256 header.s=fencepost-gnu-org header.b=SepPKJi9 Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 477E34BA2E11 for ; Sun, 22 Feb 2026 16:47:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 477E34BA2E11 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 477E34BA2E11 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:142:3::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771778829; cv=none; b=o9st1Ux1MsCv7UuQWDVdFB6bntFpQN6oyZ/zpVFEgul1APUub6OapI1XT6IOsvIY1hssoHoqxgdEZDy6GFb9E67W4DlJNMveWTkZb9mEXuBD4jNPxTbn2GsfUDu2I+ipZCiKLRcb7pKOyyPOEUx33jZMmuKf5ilNMZH4mJ8bMPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771778829; c=relaxed/simple; bh=KE7ViUBCWNcbHVeIERp6Y+Dy8L8/kTlmxqT9YzHikTU=; h=DKIM-Signature:Date:Message-Id:From:To:Subject; b=iTNAJmYe7nRsS48D28jPOid3EvXrBxIT0je4GhKLSxJvBYRxW9byGLUr4PZXAYHhtra0xMkIvrNcXzPZEaNwOGMr9U4dU8+P/3dN2JS2bFiq5IMODpF1T3QtKx/7RMfhu/L7M/5ZPEnry5QT3eqWmYC/YQrBV8rOMG8w8Sz63cw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 477E34BA2E11 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vuCbs-0004qo-Dd; Sun, 22 Feb 2026 11:47:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=33Wrjo0u8oMIlnlz6DDi4FwRpSUfN0Rn8OZ0y85N9/s=; b=SepPKJi94NJK kbHFw3P47TK64gMtIJtHn8lUo+yU+d2g+iOKkQLuCq9lsFtFggD1l7VKe2WMNDzKBAiUEQ4iy9SoM ZOAWEU5uC6df1OSd9DLE5gC9iz/NsEWGAQpQ0FIYYIyygWW7JgSxId3L5cxH8/bFK8TmUnOjW0vBt loTL9M1qfUAC9JkvL3vIBM4DFknRi745dZV9vNTouMUwbbW7Xt4ftrlucDyTVHwuOKLGcM98ocx0V HpuebQC9rA3CDL6PnO02eT9HBLeyvv02xLxc9mqz7jJ+RgEROQqQBNGwkn9vF38FLiq3/FkEr9N2f 5FrmMfAG28V7Cb3rc5WAHw==; Date: Sun, 22 Feb 2026 18:47:05 +0200 Message-Id: <86h5r8d8ty.fsf@gnu.org> From: Eli Zaretskii To: Andrew Burgess Cc: gdb-patches@sourceware.org In-Reply-To: <90f187ce8c819e25bdc49101f4579490cf267ded.1771776161.git.aburgess@redhat.com> (message from Andrew Burgess on Sun, 22 Feb 2026 16:02:58 +0000) Subject: Re: [PATCH] gdb/python: new selected_context event References: <90f187ce8c819e25bdc49101f4579490cf267ded.1771776161.git.aburgess@redhat.com> X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org > From: Andrew Burgess > Cc: Andrew Burgess > Date: Sun, 22 Feb 2026 16:02:58 +0000 > > This commit introduces a new Python event, selected_context. This > event is attached to the user_selected_context_changed observer, which > triggers when the user changes the currently selected inferior, > thread, or frame. > > Adding this event allows a Python extension to update in response to > user driven changes without having to poll the state from a > before_prompt hook, which is what I currently do to achieve the same > results. > > I did consider splitting the user_selected_context_changed observer > into 3 separate Python events, inferior_changed, thread_changed, and > frame_changed, but I couldn't see any significant advantage to doing > this, so in the end I went with just a single event, and the event > object contains the inferior, thread, and frame. > > Additionally, the user isn't informed about which aspect of the > context changed. That is, every event carries the inferior, thread, > and frame, so an event triggered when switching frames will looks > identical to an event triggered when switching inferiors. If the user > wants to know what changed then they will have to track the current > state themselves, and then compare the event state to the stored > current state. In many cases though I suspect that just being told > something changed, and then updating everything will be sufficient, > which is why I've not bothered trying to inform the user what changed. > --- > gdb/NEWS | 7 + > gdb/doc/python.texi | 35 +++++ > gdb/python/py-all-events.def | 1 + > gdb/python/py-event-types.def | 5 + > gdb/python/py-inferior.c | 54 ++++++++ > .../gdb.python/py-selected-context.c | 56 ++++++++ > .../gdb.python/py-selected-context.exp | 130 ++++++++++++++++++ > .../gdb.python/py-selected-context.py | 57 ++++++++ > 8 files changed, 345 insertions(+) > create mode 100644 gdb/testsuite/gdb.python/py-selected-context.c > create mode 100644 gdb/testsuite/gdb.python/py-selected-context.exp > create mode 100644 gdb/testsuite/gdb.python/py-selected-context.py The documentation parts are okay, thanks. Reviewed-By: Eli Zaretskii