public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Pedro Alves <pedro@palves.net>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb/linux-nat: Fix mem access ptrace fallback (PR threads/31579)
Date: Fri, 12 Apr 2024 17:05:25 +0100	[thread overview]
Message-ID: <8734rq5zy2.fsf@redhat.com> (raw)
In-Reply-To: <20240411113941.204268-1-pedro@palves.net>

Pedro Alves <pedro@palves.net> writes:

>
> diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
> index 2602e1f240d..d2b9aea724d 100644
> --- a/gdb/linux-nat.c
> +++ b/gdb/linux-nat.c

> @@ -2199,6 +2199,21 @@ mark_lwp_dead (lwp_info *lp, int status)
>    lp->stopped = 1;
>  }
>  
> +/* Return true if LP is dead, with a pending exit/signalled event.  */
> +
> +static bool
> +is_lwp_marked_dead (lwp_info *lp)
> +{
> +  switch (lp->waitstatus.kind ())
> +    {
> +    case TARGET_WAITKIND_EXITED:
> +    case TARGET_WAITKIND_THREAD_EXITED:
> +    case TARGET_WAITKIND_SIGNALLED:
> +      return true;
> +    }
> +  return false;
> +}

I wonder if this would be better as a method on waitstatus?  There's at
least one place in infrun.c (in handle_one) where we check for these
three statuses, and there's a few places where we check
TARGET_WAITKIND_EXITED and TARGET_WAITKIND_SIGNALLED ... and I suspect
we either _should_ be checking for TARGET_WAITKIND_THREAD_EXITED, or it
wouldn't matter if we did.

Not that I'm suggesting you should look at all those ... just I'm
wondering if it would be better to make is_lwp_marked_dead a waitstatus
method now, and we can then clean up other users later?

Consider this an optional suggestion, we can always make this a method
later if needed.

> +
>  /* Wait for LP to stop.  Returns the wait status, or 0 if the LWP has
>     exited.  */
>  
> @@ -3879,6 +3894,20 @@ linux_proc_xfer_memory_partial (int pid, gdb_byte *readbuf,
>  				const gdb_byte *writebuf, ULONGEST offset,
>  				LONGEST len, ULONGEST *xfered_len);
>  
> +/* Look for an LWP of PID that we know is ptrace-stopped.  Returns
> +   NULL if none is found.  */

s/NULL/nullptr/ ?

Approved-By: Andrew Burgess <aburgess@redhat.com>

Thanks,
Andrew


  parent reply	other threads:[~2024-04-12 16:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11 11:39 Pedro Alves
2024-04-12 10:44 ` Hannes Domani
2024-04-12 16:05 ` Andrew Burgess [this message]
2024-04-12 17:02   ` Pedro Alves
2024-04-15 16:05     ` Tom Tromey

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=8734rq5zy2.fsf@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).