[PATCH v2] Add support for NetBSD threads in amd64-bsd-nat.c
Simon Marchi
simark@simark.ca
Wed Mar 18 00:53:25 GMT 2020
On 2020-03-17 7:03 p.m., Kamil Rytarowski wrote:
> NetBSD ptrace(2) accepts thread id (LWP) as the 4th argument for threads.
>
> Define gdb_ptrace() a wrapper function for ptrace(2) that properly passes
> the pid,lwp pair on NetBSD and the result of get_ptrace_pid() for others.
>
> gdb/ChangeLog:
>
> * amd64-bsd-nat.c (gdb_ptrace): New.
> * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers)
> (amd64bsd_store_inferior_registers) Switch from pid_t to ptid_t.
> * amd64-bsd-nat.c (amd64bsd_fetch_inferior_registers)
> (amd64bsd_store_inferior_registers) Use gdb_ptrace.
Note that you don't have to repeat the file name for the different entries in the same file:
* amd64-bsd-nat.c (gdb_ptrace): New.
(amd64bsd_fetch_inferior_registers,
amd64bsd_store_inferior_registers): Switch from pid_t to ptid_t.
(amd64bsd_fetch_inferior_registers,
amd64bsd_store_inferior_registers): Use gdb_ptrace.
> @@ -180,25 +195,25 @@ amd64bsd_store_inferior_registers (struct regcache *regcache, int regnum)
> if (x86bsd_xsave_len != 0)
> {
> xstateregs = alloca (x86bsd_xsave_len);
> - if (ptrace (PT_GETXSTATE, pid, (PTRACE_TYPE_ARG3) xstateregs, 0)
> + if (gdb_ptrace (PT_GETXSTATE, ptid, (PTRACE_TYPE_ARG3) xstateregs, 0)
> == -1)
> perror_with_name (_("Couldn't get extended state status"));
>
> amd64_collect_xsave (regcache, regnum, xstateregs, 0);
>
> - if (ptrace (PT_SETXSTATE, pid, (PTRACE_TYPE_ARG3) xstateregs,
> + if (gdb_ptrace (PT_SETXSTATE, ptid, (PTRACE_TYPE_ARG3) xstateregs,
> x86bsd_xsave_len) == -1)
Adjust the indentation of this last line.
The patch is ok with that fixed.
Simon
More information about the Gdb-patches
mailing list