Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Matthieu Longo <matthieu.longo@arm.com>
To: Simon Marchi <simon.marchi@efficios.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] gdb: don't return an exited thread from any_non_exited_thread_of_inferior
Date: Fri, 2 Oct 2026 12:12:08 +0100	[thread overview]
Message-ID: <294f46b7-a6c8-4f5e-9a26-8454910d6c21@arm.com> (raw)
In-Reply-To: <20260917201755.589524-1-simon.marchi@efficios.com>

On 17/09/2026 21:16, Simon Marchi wrote:
> any_non_exited_thread_of_inferior prefers to return the selected thread:
> 
>   /* Prefer the current thread, if there's one.  */
>   if (inf == current_inferior () && inferior_ptid != null_ptid)
>     return inferior_thread ();
> 
> ... but the selected thread can be an exited thread.  This can happen in
> non-stop when the selected thread exits, in which case it is kept around
> but marked as exited (see thread_info::deletable).
> 
> Check the current thread's state before returning it, and fall through
> to the existing loop otherwise.
> 
> Note that we also have any_live_thread_of_inferior, which is similar but
> differs in subtle ways.  We should probably check if we can merge them
> at some point.
> 
> Change-Id: I620ee200037c6a3fd3d59b96f16750d6b962c724
> ---
>  gdb/thread.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/thread.c b/gdb/thread.c
> index 0f86f6efe380..e14254619e34 100644
> --- a/gdb/thread.c
> +++ b/gdb/thread.c
> @@ -670,9 +670,13 @@ any_non_exited_thread_of_inferior (inferior *inf)
>  {
>    gdb_assert (inf->pid != 0);
>  
> -  /* Prefer the current thread, if there's one.  */
> +  /* Prefer the current thread, if there's one and it hasn't exited.  */
>    if (inf == current_inferior () && inferior_ptid != null_ptid)
> -    return inferior_thread ();
> +    {
> +      if (thread_info *curr_thr = inferior_thread ();
> +	  curr_thr->state () != THREAD_EXITED)
> +	return curr_thr;
> +    }
>  
>    for (thread_info &tp : inf->non_exited_threads ())
>      return &tp;
> 
> base-commit: 0595410d007e5f628e14717cd268e557e166675f

Hi Simon,

Given that there was no further feedback, would it be possible to merge this patch and the following
one ? Or is it required to get an approval from another maintainer ?

Matthieu

  parent reply	other threads:[~2026-10-02 11:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17 20:16 Simon Marchi
2026-09-17 20:16 ` [PATCH 2/2] gdb: use the selected thread's LWP ID when reading Linux procfs files Simon Marchi
2026-09-21 10:22 ` [PATCH 1/2] gdb: don't return an exited thread from any_non_exited_thread_of_inferior Matthieu Longo
2026-09-21 13:46   ` Simon Marchi
     [not found] ` <20260917201755.589524-2-simon.marchi@efficios.com_5b6b04a9_release>
2026-09-21 14:26   ` [PATCH 2/2] gdb: use the selected thread's LWP ID when reading Linux procfs files Matthieu Longo
2026-09-21 14:57     ` Simon Marchi
2026-10-02 11:12 ` Matthieu Longo [this message]
2026-10-02 14:54   ` [PATCH 1/2] gdb: don't return an exited thread from any_non_exited_thread_of_inferior Simon Marchi

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=294f46b7-a6c8-4f5e-9a26-8454910d6c21@arm.com \
    --to=matthieu.longo@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    /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