From: Kamil Rytarowski <n54@gmx.com>
To: Simon Marchi <simark@simark.ca>, gdb-patches@sourceware.org
Subject: Re: [PATCH v4] Add support for NetBSD threads in sparc-nat.c
Date: Tue, 17 Mar 2020 18:07:35 +0100 [thread overview]
Message-ID: <c7323a64-384d-61c3-c46a-ba47c9234597@gmx.com> (raw)
In-Reply-To: <10f3399c-84ee-4cc8-b9fe-a3057fc070eb@simark.ca>
[-- Attachment #1.1: Type: text/plain, Size: 2493 bytes --]
On 17.03.2020 17:59, Simon Marchi wrote:
> On 2020-03-17 12:51 p.m., Simon Marchi wrote:
>> On 2020-03-17 12:46 p.m., Kamil Rytarowski wrote:
>>> NetBSD ptrace(2) accepts thread id (LWP) as the 4th argument for threads.
>>>
>>> This file is still shared with other targets that use different 4th argument
>>> type, that is always unused.
>>> ---
>>> gdb/sparc-nat.c | 50 ++++++++++++++++++++++---------------------------
>>> 1 file changed, 22 insertions(+), 28 deletions(-)
>>>
>>> diff --git a/gdb/sparc-nat.c b/gdb/sparc-nat.c
>>> index dff0f521565..10cc01375ed 100644
>>> --- a/gdb/sparc-nat.c
>>> +++ b/gdb/sparc-nat.c
>>> @@ -78,6 +78,19 @@ typedef struct fp_status fpregset_t;
>>> #define PTRACE_SETFPREGS PT_SETFPREGS
>>> #endif
>>>
>>> +static int
>>> +gdb_ptrace (int request, ptid_t pid, void *addr)
>>> +{
>>> +#ifdef __NetBSD__
>>> + /* Support for NetBSD threads: unlike other ptrace implementations in this
>>> + file, NetBSD requires that we pass both the pid and lwp. */
>>> + return ptrace (request, ptid (). pid (), addr, ptid ().lwp ());
>>
>> Does that even build? ptid isn't the name of a parameter, and the parenthesis after
>> "ptid" should not be there. Rename the pid parameter to ptid, and replace the above
>> with "ptid.pid ()" and "ptid.lwp ()".
>>
>> Simon
>>
>
> I tried to build this using a sparc-linux cross-compiler, and I think we need
> to adjust gdb_ptrace to account for the various possible arguments types. The
> following version of the function builds fine with sparc64-linux-gnu-gcc, can you
> try it with NetBSD?
>
> static PTRACE_TYPE_RET
> gdb_ptrace (PTRACE_TYPE_ARG1 request, ptid_t ptid, PTRACE_TYPE_ARG4 addr)
Does it work for you if you use PTRACE_TYPE_ARG3? addr is the 3rd argument.
PTRACE_TYPE_ARG4 is int on BSDs.
> {
> #ifdef __NetBSD__
> /* Support for NetBSD threads: unlike other ptrace implementations in this
> file, NetBSD requires that we pass both the pid and lwp. */
> return ptrace (request, ptid.pid (), addr, ptid.lwp ());
> #else
> pid_t pid = get_ptrace_pid (ptid);
> return ptrace (request, pid, addr, 0);
> #endif
> }
>
> Alternatively, we could keep address as a "void *", and cast the value inside gdb_ptrace:
>
> return ptrace (request, ptid.pid (), (PTRACE_TYPE_ARG4) addr, ptid.lwp ());
>
> All the callers of gdb_ptrace wouldn't have to cast that themselves, which is perhaps
> a bit nicer.
>
> Simon
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-03-17 17:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-17 9:40 [PATCH] " Kamil Rytarowski
2020-03-17 15:10 ` [PATCH v3] " Kamil Rytarowski
2020-03-17 16:03 ` Simon Marchi
2020-03-17 16:46 ` [PATCH v4] " Kamil Rytarowski
2020-03-17 16:51 ` Simon Marchi
2020-03-17 16:59 ` Simon Marchi
2020-03-17 17:07 ` Kamil Rytarowski [this message]
2020-03-17 17:10 ` Simon Marchi
2020-03-17 18:14 ` Kamil Rytarowski
2020-03-17 18:18 ` [PATCH v5] " Kamil Rytarowski
2020-03-17 19:07 ` Simon Marchi
2020-03-17 19:09 ` 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=c7323a64-384d-61c3-c46a-ba47c9234597@gmx.com \
--to=n54@gmx.com \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
/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