public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: John Baldwin <jhb@FreeBSD.org>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2 4/5] obsd-nat: Various fixes for fork following.
Date: Thu, 29 Jul 2021 15:14:25 -0400	[thread overview]
Message-ID: <2af9f23d-86e5-a84c-b579-a9dba5e9e9ff@polymtl.ca> (raw)
In-Reply-To: <20210727174110.62480-5-jhb@FreeBSD.org>



On 2021-07-27 1:41 p.m., John Baldwin wrote:
> - Don't use #ifdef's on ptrace ops.  obsd-nat.h didn't include
>   <sys/ptrace.h>, so the virtual methods weren't always overridden
>   causing the fork following to not work.  In addition, the thread and
>   fork code is intertwined in ::wait and and the lack of #ifdef's
>   there already assumed both were present.

In any case, PT_GET_PROCESS_STATE was added here, 16 years ago:

  https://github.com/openbsd/src/commit/f38bed7f869bd3503530c554b4860228ea4e8641

So it's reasonable to assume it's there (especially for a port with no
maintainer).

> 
> - Move duplicated code to enable PTRACE_FORK event reporting to a
>   single function and invoke it on new child processes reported via
>   PTRACE_FORK.
> 
> - Don't return early from PTRACE_FORK handling, but instead reset
>   wptid to the correct ptid if the child reports its event before the
>   parent.  This allows the ptid fixup code to add thread IDs if the
>   first event for a process is a PTRACE_FORK event.  This also
>   properly returns ptid's with thread IDs when reporting PTRACE_FORK
>   events.
> 
> - Handle detach_fork by skipping the PT_DETACH.
> ---
>  gdb/obsd-nat.c | 51 +++++++++++++++++++++++---------------------------
>  gdb/obsd-nat.h |  2 --
>  2 files changed, 23 insertions(+), 30 deletions(-)
> 
> diff --git a/gdb/obsd-nat.c b/gdb/obsd-nat.c
> index 8549c6ea66b..0edaa66cf1b 100644
> --- a/gdb/obsd-nat.c
> +++ b/gdb/obsd-nat.c
> @@ -33,8 +33,6 @@
>     that maps userland threads directly onto kernel threads in a 1:1
>     fashion.  */
>  
> -#ifdef PT_GET_THREAD_FIRST

10 years ago for this one.  Still long enough, and removing it makes the
code much simpler to understand.

> -
>  std::string
>  obsd_nat_target::pid_to_str (ptid_t ptid)
>  {
> @@ -72,6 +70,19 @@ obsd_nat_target::update_thread_list ()
>      }
>  }
>  
> +static void
> +obsd_enable_proc_events (pid_t pid)

Could you please write a small, oneliner comment for this one?

Simon

  reply	other threads:[~2021-07-29 19:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-27 17:41 [PATCH v2 0/5] A few fixes to OpenBSD's native target John Baldwin
2021-07-27 17:41 ` [PATCH v2 1/5] Don't compile x86 debug register support on OpenBSD John Baldwin
2021-07-27 17:41 ` [PATCH v2 2/5] x86-bsd-nat: Only define gdb_ptrace when using debug registers John Baldwin
2021-07-27 17:41 ` [PATCH v2 3/5] obsd-nat: Various fixes to obsd_nat_target::wait John Baldwin
2021-07-29 19:05   ` Simon Marchi
2021-07-29 19:11     ` Simon Marchi
2021-07-29 20:11       ` John Baldwin
2021-07-30  1:27         ` Simon Marchi
2021-07-27 17:41 ` [PATCH v2 4/5] obsd-nat: Various fixes for fork following John Baldwin
2021-07-29 19:14   ` Simon Marchi [this message]
2021-07-27 17:41 ` [PATCH v2 5/5] obsd-nat: Report both thread and PID in ::pid_to_str John Baldwin
2021-07-29 19:15 ` [PATCH v2 0/5] A few fixes to OpenBSD's native target 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=2af9f23d-86e5-a84c-b579-a9dba5e9e9ff@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).