From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by sourceware.org (Postfix) with ESMTPS id 7852E3877024 for ; Mon, 16 Mar 2020 21:36:36 +0000 (GMT) Received: by mail-ot1-x343.google.com with SMTP id 66so19489172otd.9 for ; Mon, 16 Mar 2020 14:36:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/6as0fC9euArPYLl+rVMwGZHRvgZ4SdHyDwj+SJuM+A=; b=fQVf3zTxdB2eZLBphHChQgshvwSeRvQvQpPeaEckUy7Za1PxRx9nF9IO5jz3Xg9h/N 6xF0vvjj7DG44omVbW9uEAyMBKt8bUNlwVO41gUCha+I7VS0lVZKJrQY77XNygq07mCn YA0GsTLXNOG89ogAmXTiH18XPDhKCAdqWBUjAI4tpC/GPqg8nvdzOYw2WW0xzgL2pO7z 6iZqpIgY+OQyY1MDCh7wQJcHk3kwfG4AqF8Krupl2HXJZyg8OhpWkJEHSe6+e79LOZ66 SYXH4B9IgR7NnDmxSqGcrnDLcuVjffbfkYNE84xMjJY/W2lpO/CpTMmHNWyhB7CMM4ft yOzA== X-Gm-Message-State: ANhLgQ0xHVvixNTU6h5EhH4ysYZSpy4iyz5uJlqav+zRN/vjxSm0ikff vw7rbKLFCEJKsoBo2ASUre3ehJ0h3t7TNpu/pQ5c3g== X-Google-Smtp-Source: ADFU+vvR2uq8iCy50NKnqZgawP0qG2o9FZs4RzeYmbxYSgeF2wzlsnyPWtDY10N14yp7dXxQHgZyEeqf2is+ijkwUeY= X-Received: by 2002:a9d:6b1a:: with SMTP id g26mr1073119otp.2.1584394595559; Mon, 16 Mar 2020 14:36:35 -0700 (PDT) MIME-Version: 1.0 References: <20200314182710.11396-1-n54@gmx.com> In-Reply-To: <20200314182710.11396-1-n54@gmx.com> From: Christian Biesinger Date: Mon, 16 Mar 2020 16:35:59 -0500 Message-ID: Subject: Re: [PATCH] Add support for NetBSD threads in sparc-nat.c To: Kamil Rytarowski Cc: gdb-patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-40.7 required=5.0 tests=DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Mar 2020 21:36:37 -0000 On Sat, Mar 14, 2020 at 1:28 PM 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. I wonder if it would be less ugly to have a function that handles this: inline int gdb_ptrace (...) { #ifdef __NetBSD__ return ptrace (..., lwp); #else return ptrace (..., (PTRACE_TYPE_ARG4) 0); #endif } Then call gdb_ptrace in this file. Thoughts? Christian > --- > gdb/sparc-nat.c | 19 +++++++++++++++++-- > 1 file changed, 17 insertions(+), 2 deletions(-) > > diff --git a/gdb/sparc-nat.c b/gdb/sparc-nat.c > index dff0f521565..1e890bd8613 100644 > --- a/gdb/sparc-nat.c > +++ b/gdb/sparc-nat.c > @@ -154,6 +154,12 @@ sparc_fetch_inferior_registers (struct regcache *regcache, int regnum) > registers can be written. */ > pid = get_ptrace_pid (regcache->ptid ()); > > +#ifdef __NetBSD__ > +# define lwp regcache->ptid ().lwp () > +#else > +# define lwp (PTRACE_TYPE_ARG4) 0 > +#endif > + > if (regnum == SPARC_G0_REGNUM) > { > gdb_byte zero[8] = { 0 }; > @@ -166,7 +172,7 @@ sparc_fetch_inferior_registers (struct regcache *regcache, int regnum) > { > gregset_t regs; > > - if (ptrace (PTRACE_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, 0) == -1) > + if (ptrace (PTRACE_GETREGS, pid, (PTRACE_TYPE_ARG3) ®s, lwp) == -1) > perror_with_name (_("Couldn't get registers")); > > sparc_supply_gregset (sparc_gregmap, regcache, -1, ®s); > @@ -178,11 +184,13 @@ sparc_fetch_inferior_registers (struct regcache *regcache, int regnum) > { > fpregset_t fpregs; > > - if (ptrace (PTRACE_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, 0) == -1) > + if (ptrace (PTRACE_GETFPREGS, pid, (PTRACE_TYPE_ARG3) &fpregs, lwp) == -1) > perror_with_name (_("Couldn't get floating point status")); > > sparc_supply_fpregset (sparc_fpregmap, regcache, -1, &fpregs); > } > + > +#undef lwp > } > > void > @@ -195,6 +203,12 @@ sparc_store_inferior_registers (struct regcache *regcache, int regnum) > about threaded assumptions. */ > pid = get_ptrace_pid (regcache->ptid ()); > > +#ifdef __NetBSD__ > +# define lwp regcache->ptid ().lwp () > +#else > +# define lwp (PTRACE_TYPE_ARG4) 0 > +#endif > + > if (regnum == -1 || sparc_gregset_supplies_p (gdbarch, regnum)) > { > gregset_t regs; > @@ -245,6 +259,7 @@ sparc_store_inferior_registers (struct regcache *regcache, int regnum) > if (regnum != -1) > return; > } > +#undef lwp > } > > > -- > 2.25.0 >