Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Gerlicher, Klaus" <klaus.gerlicher@intel.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: RE: [PATCH v2] gdb: remember previously selected thread per inferior
Date: Tue, 28 Apr 2026 09:26:35 +0000	[thread overview]
Message-ID: <DM3PPFD7E67F036AA2B5F34FAF7B3E5D4F6E8372@DM3PPFD7E67F036.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20260325122321.315910-1-klaus.gerlicher@intel.com>

Kindly pinging.

Thanks
Klaus

> -----Original Message-----
> From: Klaus Gerlicher <klaus.gerlicher@intel.com>
> Sent: Wednesday, March 25, 2026 1:23 PM
> To: gdb-patches@sourceware.org
> Subject: [PATCH v2] gdb: remember previously selected thread per inferior
> 
> Hi,
> 
> This is V2 of my patch to add thread memory when switching inferiors.
> 
> Thanks for the feedback, @Andrew, @Pedro, addressing it here:
> 
> Changes since V1:
> * made the feature switchable with 'set remember-threads-per-inferior
> [on|off]'
> * added full documentation (gdb.texinfo)
> * Added NEWS entry
> * Added test for disabled behavior (test_disabled_behavior)
> * default is ON (enabled by default)
> 
> 1. Switchable Feature:
>    I've made this controllable. The default is ON because I think most users
>    would want this behavior but users who prefer the old "first available
>    thread" behavior can easily disable it. Pedro's concern in the V1 thread was
>    that not everyone might find this natural, so now everyone can choose.
> 
> 2. Documentation:
>    Added full texinfo documentation with examples showing both enabled and
>    disabled modes. Also added NEWS entry as requested.
> 
> 3. Observer arch:
>    You asked why we need the manual call in infrun.c and can't rely solely
>    on the observer.
> 
>    The user_selected_context_changed observer only fires for explicit user
>    commands (thread, inferior, frame), not for event switches.
> 
>    Example that breaks w/o infrun.c saving:
> 
>    (gdb) set schedule-multiple on
>    (gdb) thread 1.1
>    (gdb) continue
>    # Breakpoint hits in inferior 2, thread 2.2 (automatic switch)
>    # Observer does NOT fire (not a user command!)
>    # Without infrun.c save: thread 2.2 never gets recorded
>    (gdb) inferior 1
>    (gdb) inferior 2
>    # BUG: Would switch to thread 2.1 instead of 2.2
> 
>    My test_implicit scenario explicitly tests this and fails without the
>    infrun.c call.
> 
>    Alternative would be creating a new observer that fires for ALL context
>    switches (user + automatic)?
> 
> I've kept the default as ON rather than OFF. If you prefer defaulting to OFF,
> I can change it.
> 
> Tested on x86_64.
> 
> Thanks,
> Klaus
> 
> Klaus Gerlicher (1):
>   gdb: remember previously selected thread per inferior
> 
>  gdb/NEWS                                      |   7 +
>  gdb/doc/gdb.texinfo                           |  19 ++
>  gdb/gdbthread.h                               |   4 +
>  gdb/inferior.c                                |  58 +++++-
>  gdb/inferior.h                                |  14 ++
>  gdb/infrun.c                                  |   6 +-
>  gdb/testsuite/gdb.base/inferior-switch.c      |  42 +++++
>  gdb/testsuite/gdb.base/inferior-switch.exp    | 172 ++++++++++++++++++
>  .../gdb.mi/user-selected-context-sync.exp     |  14 ++
>  gdb/thread.c                                  |   8 +
>  10 files changed, 341 insertions(+), 3 deletions(-)
>  create mode 100644 gdb/testsuite/gdb.base/inferior-switch.c
>  create mode 100644 gdb/testsuite/gdb.base/inferior-switch.exp
> 
> --
> 2.34.1
> 
> Intel Deutschland GmbH
> Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany
> Tel: +49 89 991 430, www.intel.de
> Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell
> Chairperson of the Supervisory Board: Nicole Lau
> Registered Seat: Munich
> Commercial Register: Amtsgericht Muenchen HRB 186928
> 

Intel Deutschland GmbH
Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany
Tel: +49 89 991 430, www.intel.de
Managing Directors: Harry Demas, Jeffrey Schneiderman, Yin Chong Sorrell
Chairperson of the Supervisory Board: Nicole Lau
Registered Seat: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


      parent reply	other threads:[~2026-04-28  9:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-25 12:23 Klaus Gerlicher
2026-03-25 12:23 ` [PATCH v2 1/1] " Klaus Gerlicher
2026-03-25 14:34   ` Eli Zaretskii
2026-04-28  9:26 ` Gerlicher, Klaus [this message]

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=DM3PPFD7E67F036AA2B5F34FAF7B3E5D4F6E8372@DM3PPFD7E67F036.namprd11.prod.outlook.com \
    --to=klaus.gerlicher@intel.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