[PATCH v2] Add support for NetBSD threads in i386-bsd-nat.c

Simon Marchi simark@simark.ca
Wed Mar 18 00:57:59 GMT 2020


On 2020-03-17 7:44 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:
> 
> 	* i386-bsd-nat.c (gdb_ptrace): New.
> 	* i386-bsd-nat.c (i386bsd_fetch_inferior_registers)
> 	(i386bsd_store_inferior_registers) Switch from pid_t to ptid_t.
> 	* i386-bsd-nat.c (i386bsd_fetch_inferior_registers)
> 	(i386bsd_store_inferior_registers) Use gdb_ptrace.
> ---
>  gdb/i386-bsd-nat.c | 63 ++++++++++++++++++++++++++++++----------------
>  1 file changed, 42 insertions(+), 21 deletions(-)
> 
> diff --git a/gdb/i386-bsd-nat.c b/gdb/i386-bsd-nat.c
> index 4e22013a7a8..9f4a7bd388d 100644
> --- a/gdb/i386-bsd-nat.c
> +++ b/gdb/i386-bsd-nat.c
> @@ -34,6 +34,21 @@
>  #include "inf-ptrace.h"
>  

> 
> +static int
> +gdb_ptrace (PTRACE_TYPE_ARG1 request, ptid_t ptid, PTRACE_TYPE_ARG3 addr,
> +	    PTRACE_TYPE_ARG4 data)
> +{
> +#ifdef __NetBSD__
> +  gdb_assert(data == 0);

Space before parenthesis.

The patch LGTM with that fixed.

Simon


More information about the Gdb-patches mailing list