Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Andrew Burgess <aburgess@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/python: new selected_context event
Date: Fri, 27 Feb 2026 11:56:44 -0700	[thread overview]
Message-ID: <87a4wut3pv.fsf@tromey.com> (raw)
In-Reply-To: <90f187ce8c819e25bdc49101f4579490cf267ded.1771776161.git.aburgess@redhat.com> (Andrew Burgess's message of "Sun, 22 Feb 2026 16:02:58 +0000")

>>>>> "Andrew" == Andrew Burgess <aburgess@redhat.com> writes:

Andrew> This commit introduces a new Python event, selected_context.  This
Andrew> event is attached to the user_selected_context_changed observer, which
Andrew> triggers when the user changes the currently selected inferior,
Andrew> thread, or frame.

Thanks.  I think this approach seems fine.

FWIW this is https://sourceware.org/bugzilla/show_bug.cgi?id=24482

Andrew> Adding this event allows a Python extension to update in response to
Andrew> user driven changes without having to poll the state from a
Andrew> before_prompt hook, which is what I currently do to achieve the same
Andrew> results.

Yeah, that approach is ok-ish but also problematic.

I think we have similar issues in the TUI, see

https://sourceware.org/bugzilla/show_bug.cgi?id=32865

Andrew> I did consider splitting the user_selected_context_changed observer
Andrew> into 3 separate Python events, inferior_changed, thread_changed, and
Andrew> frame_changed, but I couldn't see any significant advantage to doing
Andrew> this, so in the end I went with just a single event, and the event
Andrew> object contains the inferior, thread, and frame.

This seems totally fine to me.

Andrew> Additionally, the user isn't informed about which aspect of the
Andrew> context changed.

This too.

Andrew> +The event is of type @code{gdb.SelectedContext} and has the following
Andrew> +attributes:

There's been a convention that an event type name ends in "Event".

Andrew> +    frame_obj = gdbpy_ref<> (Py_None);

This has to be gdbpy_ref<>::new_reference (Py_None);

Unfortunately even the safety series I am working on won't prevent this
kind of problem :-(

I guess we could do it by forbidding the use of plain "Py_None" somehow,
and then having a gdb variant that is clearly a borrowed reference.

Tom

  parent reply	other threads:[~2026-02-27 18:57 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
2026-02-27 18:56 ` Tom Tromey [this message]
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=87a4wut3pv.fsf@tromey.com \
    --to=tom@tromey.com \
    --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