From: Kamil Rytarowski <n54@gmx.com>
To: Simon Marchi <simark@simark.ca>, gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: Re: [PATCH] Disable get_ptrace_pid for NetBSD
Date: Wed, 18 Mar 2020 22:40:15 +0100 [thread overview]
Message-ID: <11c3372f-256b-6c92-ef45-fbb351ed0693@gmx.com> (raw)
In-Reply-To: <3ea12183-68f2-94c4-d7d0-504b88a79ed4@simark.ca>
[-- Attachment #1.1: Type: text/plain, Size: 3092 bytes --]
On 18.03.2020 22:15, Simon Marchi wrote:
> On 2020-03-18 12:29 p.m., 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.
>>
>> gdb/ChangeLog:
>>
>> * inf-ptrace.h: Disable get_ptrace_pid on NetBSD.
>> * inf-ptrace.c: Likewise.
>> * (inf_ptrace_target::resume): Update.
>> * (inf_ptrace_target::xfer_partial): Likewise.
>> ---
>> gdb/ChangeLog | 7 +++++++
>> gdb/inf-ptrace.c | 19 +++++++++++++++++--
>> gdb/inf-ptrace.h | 2 ++
>> 3 files changed, 26 insertions(+), 2 deletions(-)
>>
>> diff --git a/gdb/ChangeLog b/gdb/ChangeLog
>> index 84964dc00ac..36e333ec8ba 100644
>> --- a/gdb/ChangeLog
>> +++ b/gdb/ChangeLog
>> @@ -1,3 +1,10 @@
>> +2020-03-18 Kamil Rytarowski <n54@gmx.com>
>> +
>> + * inf-ptrace.h: Disable get_ptrace_pid on NetBSD.
>> + * inf-ptrace.c: Likewise.
>> + * (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..e8bf66ed45f 100644
>> --- a/gdb/inf-ptrace.c
>> +++ b/gdb/inf-ptrace.c
>> @@ -313,8 +313,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 +332,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
>> @@ -344,7 +349,13 @@ inf_ptrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal)
>> single-threaded processes, so simply resume the inferior. */
>> pid = inferior_ptid.pid ();
>> else
>> - pid = get_ptrace_pid (ptid);
>> + {
>> +#ifdef __NetBSD__
>> + pid = ptid. pid();
>> +#else
>> + pid = get_ptrace_pid (ptid);
>> +#endif
>> + }
>
> To avoid the ifdefs in this more complex code, can't you use a gdb_ptrace function like in
> the other patches? This time, it would look like:
>
> 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
> }
>
> Simon
>
I will go for it, but only for a selection of ptrace () calls in this file.
In certain places there would need to be need to compose ptid_t out of
plain pid. Another case is PT_TRACE_ME.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-03-18 21:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-18 16:29 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 [this message]
2020-03-18 21:43 ` Simon Marchi
2020-03-18 21:45 ` Kamil Rytarowski
2020-03-18 21:49 Kamil Rytarowski
2020-03-18 21:51 ` 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=11c3372f-256b-6c92-ef45-fbb351ed0693@gmx.com \
--to=n54@gmx.com \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
--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