Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Andrew Burgess <aburgess@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/python: new selected_context event
Date: Sun, 22 Feb 2026 18:47:05 +0200	[thread overview]
Message-ID: <86h5r8d8ty.fsf@gnu.org> (raw)
In-Reply-To: <90f187ce8c819e25bdc49101f4579490cf267ded.1771776161.git.aburgess@redhat.com> (message from Andrew Burgess on Sun, 22 Feb 2026 16:02:58 +0000)

> From: Andrew Burgess <aburgess@redhat.com>
> Cc: Andrew Burgess <aburgess@redhat.com>
> 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 <eliz@gnu.org>

  reply	other threads:[~2026-02-22 16:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-22 16:02 Andrew Burgess
2026-02-22 16:47 ` Eli Zaretskii [this message]
2026-02-27 18:56 ` Tom Tromey
2026-03-04 20:28 ` [PATCHv2] " Andrew Burgess
2026-03-04 20:42   ` Tom Tromey
2026-03-05  9:49     ` Andrew Burgess

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=86h5r8d8ty.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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