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 327BD394441B for ; Tue, 17 Mar 2020 16:39:09 +0000 (GMT) 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)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id BECCB1E5FD; Tue, 17 Mar 2020 12:39:08 -0400 (EDT) Subject: Re: [PATCH] Return unconditionally ptid.pid () in get_ptrace_pid() for NetBSD To: Kamil Rytarowski , gdb-patches@sourceware.org References: <20200317163020.28790-1-n54@gmx.com> From: Simon Marchi Message-ID: <597c7d5f-dfd5-53a8-3369-4042d4cd653a@simark.ca> Date: Tue, 17 Mar 2020 12:39:08 -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: <20200317163020.28790-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: Tue, 17 Mar 2020 16:39:10 -0000 On 2020-03-17 12:30 p.m., Kamil Rytarowski wrote: > NetBSD tracks the PID and LWP pair separately and both values are > needed and meaningful. > --- > gdb/inf-ptrace.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c > index db17a76d946..6a6cb554ba7 100644 > --- a/gdb/inf-ptrace.c > +++ b/gdb/inf-ptrace.c > @@ -321,10 +321,14 @@ get_ptrace_pid (ptid_t ptid) > { > pid_t pid; > > +#if !defined(__NetBSD__) > /* If we have an LWPID to work with, use it. Otherwise, we're > - dealing with a non-threaded program/target. */ > + dealing with a non-threaded program/target. > + > + NetBSD tracks the PID and LWP pair separately. */ > pid = ptid.lwp (); > if (pid == 0) > +#endif > pid = ptid.pid (); > return pid; > } > -- > 2.25.0 > I think you should just avoid using get_ptrace_pid on NetBSD altogether, since it is meant for OSes that require passing a single thread identifier to ptrace (whereas NetBSD requires the (pid, lwp) pair). Even with this modification in get_ptrace_pid, you need to change all the ptrace call sites to pass the lwp on top of it. I would suggest to instead #ifdef out get_ptrace_pid entirely on NetBSD, to avoid using it by mistake, and just replace all ptrace call sites possibly used on BSD to be ptrace (request, ptid.pid (), addr, ptid.lwp ()); This matches what I suggested in: https://sourceware.org/pipermail/gdb-patches/2020-March/166735.html Simon