From: Kamil Rytarowski <n54@gmx.com>
To: gdb-patches@sourceware.org
Cc: tom@tromey.com,
"gdb-patches@sourceware.org >> gdb-patches"
<gdb-patches@sourceware.org>
Subject: Re: [PATCH] Disable get_ptrace_pid for NetBSD
Date: Wed, 18 Mar 2020 22:51:09 +0100 [thread overview]
Message-ID: <398c7dcf-03d5-52d3-c257-3ff4a4748389@gmx.com> (raw)
In-Reply-To: <20200318214934.24306-1-n54@gmx.com>
[-- Attachment #1.1: Type: text/plain, Size: 5060 bytes --]
On 18.03.2020 22:49, Kamil Rytarowski wrote:
> Unlike most other Operating Systems, NetBSD tracks both pid and lwp.
> The process id on NetBSD is stored always in the pid field of ptid.
>
There is is one bug.
I'm going to fix and submit a new version.
> gdb/ChangeLog:
>
> * inf-ptrace.h: Disable get_ptrace_pid on NetBSD.
> * inf-ptrace.c: Likewise.
> * (gdb_ptrace): Add.
> * (inf_ptrace_target::resume): Update.
> * (inf_ptrace_target::xfer_partial): Likewise.
> ---
> gdb/ChangeLog | 8 ++++++++
> gdb/inf-ptrace.c | 32 +++++++++++++++++++++++---------
> gdb/inf-ptrace.h | 2 ++
> 3 files changed, 33 insertions(+), 9 deletions(-)
>
> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
> index 84964dc00ac..406414cee76 100644
> --- a/gdb/ChangeLog
> +++ b/gdb/ChangeLog
> @@ -1,3 +1,11 @@
> +2020-03-18 Kamil Rytarowski <n54@gmx.com>
> +
> + * inf-ptrace.h: Disable get_ptrace_pid on NetBSD.
> + * inf-ptrace.c: Likewise.
> + * (gdb_ptrace): Add.
> + * (inf_ptrace_target::resume): Update.
> + * (inf_ptrace_target::xfer_partial): Likewise.
> +
> 2020-03-17 Kamil Rytarowski <n54@gmx.com>
>
> * regformats/regdef.h: Put reg in gdb namespace.
> diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
> index db17a76d946..304a749f3f3 100644
> --- a/gdb/inf-ptrace.c
> +++ b/gdb/inf-ptrace.c
> @@ -37,6 +37,18 @@
>
> \f
>
> +static int
> +gdb_ptrace (PTRACE_TYPE_ARG1 request, ptid_t ptid, PTRACE_TYPE_ARG3 addr,
> + PTRACE_TYPE_ARG4 data)
> +{
> +#ifdef __NetBSD__
> + return ptrace (request, ptid.pid (), addr, data);
> +#else
> + pid_t pid = get_ptrace_pid (ptid);
> + return ptrace (request, pid, addr, data);
> +#endif
> +}
> +
> /* A unique_ptr helper to unpush a target. */
>
> struct target_unpusher
> @@ -313,8 +325,12 @@ inf_ptrace_target::kill ()
> target_mourn_inferior (inferior_ptid);
> }
>
> +#ifndef __NetBSD__
> /* Return which PID to pass to ptrace in order to observe/control the
> - tracee identified by PTID. */
> + tracee identified by PTID.
> +
> + Unlike most other Operating Systems, NetBSD tracks both pid and lwp
> + and avoids this function. */
>
> pid_t
> get_ptrace_pid (ptid_t ptid)
> @@ -328,6 +344,7 @@ get_ptrace_pid (ptid_t ptid)
> pid = ptid.pid ();
> return pid;
> }
> +#endif
>
> /* Resume execution of thread PTID, or all threads if PTID is -1. If
> STEP is nonzero, single-step it. If SIGNAL is nonzero, give it
> @@ -336,15 +353,12 @@ get_ptrace_pid (ptid_t ptid)
> void
> inf_ptrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
> {
> - pid_t pid;
> int request;
>
> if (minus_one_ptid == ptid)
> /* Resume all threads. Traditionally ptrace() only supports
> single-threaded processes, so simply resume the inferior. */
> - pid = inferior_ptid.pid ();
> - else
> - pid = get_ptrace_pid (ptid);
> + ptid = inferior_ptid;
>
> if (catch_syscall_enabled () > 0)
> request = PT_SYSCALL;
> @@ -365,7 +379,7 @@ inf_ptrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
> where it was. If GDB wanted it to start some other way, we have
> already written a new program counter value to the child. */
> errno = 0;
> - ptrace (request, pid, (PTRACE_TYPE_ARG3)1, gdb_signal_to_host (signal));
> + gdb_ptrace (request, ptid, (PTRACE_TYPE_ARG3)1, gdb_signal_to_host (signal));
> if (errno != 0)
> perror_with_name (("ptrace"));
> }
> @@ -528,7 +542,7 @@ inf_ptrace_target::xfer_partial (enum target_object object,
> const gdb_byte *writebuf,
> ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
> {
> - pid_t pid = get_ptrace_pid (inferior_ptid);
> + ptid_t ptid = inferior_ptid;
>
> switch (object)
> {
> @@ -552,7 +566,7 @@ inf_ptrace_target::xfer_partial (enum target_object object,
> piod.piod_len = len;
>
> errno = 0;
> - if (ptrace (PT_IO, pid, (caddr_t)&piod, 0) == 0)
> + if (gdb_ptrace (PT_IO, ptid, (caddr_t)&piod, 0) == 0)
> {
> /* Return the actual number of bytes read or written. */
> *xfered_len = piod.piod_len;
> @@ -588,7 +602,7 @@ inf_ptrace_target::xfer_partial (enum target_object object,
> piod.piod_len = len;
>
> errno = 0;
> - if (ptrace (PT_IO, pid, (caddr_t)&piod, 0) == 0)
> + if (gdb_ptrace (PT_IO, ptid, (caddr_t)&piod, 0) == 0)
> {
> /* Return the actual number of bytes read or written. */
> *xfered_len = piod.piod_len;
> diff --git a/gdb/inf-ptrace.h b/gdb/inf-ptrace.h
> index dd0733736f2..340d41d8beb 100644
> --- a/gdb/inf-ptrace.h
> +++ b/gdb/inf-ptrace.h
> @@ -78,9 +78,11 @@ struct inf_ptrace_target : public inf_child_target
> void detach_success (inferior *inf);
> };
>
> +#ifndef __NetBSD__
> /* Return which PID to pass to ptrace in order to observe/control the
> tracee identified by PTID. */
>
> extern pid_t get_ptrace_pid (ptid_t);
> +#endif
>
> #endif
> --
> 2.25.0
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-03-18 21:52 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-18 21:49 Kamil Rytarowski
2020-03-18 21:51 ` Kamil Rytarowski [this message]
2020-03-18 21:55 ` [PATCH v2] " Kamil Rytarowski
2020-03-18 22:21 ` Simon Marchi
2020-03-18 23:30 ` Kamil Rytarowski
2020-03-18 23:16 ` [PATCH v3] " Kamil Rytarowski
2020-03-19 1:13 ` Simon Marchi
2020-03-19 12:01 ` Kamil Rytarowski
2020-03-19 12:28 ` [PATCH v4] " Kamil Rytarowski
2020-03-19 12:55 ` Simon Marchi
2020-03-19 15:30 ` Simon Marchi
2020-03-19 15:51 ` Kamil Rytarowski
2020-03-20 15:50 ` Tom Tromey
2020-03-19 15:45 ` [PATCH v5] " Kamil Rytarowski
2020-03-19 19:27 ` Simon Marchi
-- strict thread matches above, loose matches on Subject: below --
2020-03-18 16:29 [PATCH] " Kamil Rytarowski
2020-03-18 20:48 ` Tom Tromey
2020-03-18 20:54 ` Tom Tromey
2020-03-18 21:22 ` Simon Marchi
2020-03-18 21:15 ` Simon Marchi
2020-03-18 21:40 ` Kamil Rytarowski
2020-03-18 21:43 ` Simon Marchi
2020-03-18 21:45 ` Kamil Rytarowski
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=398c7dcf-03d5-52d3-c257-3ff4a4748389@gmx.com \
--to=n54@gmx.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.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