From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id DEA5E381DCF6 for ; Wed, 18 Mar 2020 21:15:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DEA5E381DCF6 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 1B7861E5F8; Wed, 18 Mar 2020 17:15:21 -0400 (EDT) Subject: Re: [PATCH] Disable get_ptrace_pid for NetBSD To: Kamil Rytarowski , gdb-patches@sourceware.org References: <20200318162915.15043-1-n54@gmx.com> From: Simon Marchi Cc: Tom Tromey Message-ID: <3ea12183-68f2-94c4-d7d0-504b88a79ed4@simark.ca> Date: Wed, 18 Mar 2020 17:15:20 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200318162915.15043-1-n54@gmx.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US-large Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-25.0 required=5.0 tests=GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS 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: Wed, 18 Mar 2020 21:15:23 -0000 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 > + > + * 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 > > * 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