Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@mips.com>
To: John Baldwin <jhb@FreeBSD.org>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Workaround a FreeBSD ptrace() bug with clearing thread events.
Date: Fri, 02 Mar 2018 00:51:00 -0000	[thread overview]
Message-ID: <alpine.DEB.2.00.1803020009130.10166@tp.orcam.me.uk> (raw)
In-Reply-To: <20180224000935.43344-1-jhb@FreeBSD.org>

On Fri, 23 Feb 2018, John Baldwin wrote:

> diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
> index d44950618c..9c87bfed33 100644
> --- a/gdb/fbsd-nat.c
> +++ b/gdb/fbsd-nat.c
> @@ -1163,6 +1163,39 @@ fbsd_resume (struct target_ops *ops,
>  	}
>        ptid = inferior_ptid;
>      }
> +
> +#if __FreeBSD_version < 1200052
> +  /*
> +   * When multiple threads within a process wish to report STOPPED
> +   * events from wait(), the kernel picks one thread event as the
> +   * thread event to report.  The chosen thread event is retrieved via
> +   * PT_LWPINFO by passing the process ID as the request pid.  If
> +   * multiple events are pending, then the subsequent wait() after
> +   * resuming a process will report another STOPPED event after
> +   * resuming the process to handle the next thread event and so on.
> +   *
> +   * A single thread event is cleared as a side effect of resuming the
> +   * process with PT_CONTINUE, PT_STEP, etc.  In older kernels,
> +   * however, the request pid was used to select which thread's event
> +   * was cleared rather than always clearing the event that was just
> +   * reported.  To avoid clearing the event of the wrong LWP, always
> +   * pass the process ID instead of an LWP ID to PT_CONTINUE or
> +   * PT_SYSCALL.

 Hmm, doesn't it have to be a run-time check then?  Otherwise you're 
basing your decision on the host system GDB has been built for and not one 
it will be run on, which I suppose does not necessarily have to be of the 
same version.  Or am I missing anything here?

  Maciej


  parent reply	other threads:[~2018-03-02  0:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-24  0:10 John Baldwin
2018-02-26  4:28 ` Joel Brobecker
2018-02-26 17:25   ` John Baldwin
2018-03-02  0:51 ` Maciej W. Rozycki [this message]
2018-03-02 18:32   ` John Baldwin
2018-03-02 20:09     ` Maciej W. Rozycki
2018-03-02 22:48       ` John Baldwin
2018-03-03 17:45         ` Maciej W. Rozycki

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=alpine.DEB.2.00.1803020009130.10166@tp.orcam.me.uk \
    --to=macro@mips.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jhb@FreeBSD.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