From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [96.47.72.81]) by sourceware.org (Postfix) with ESMTPS id 801063858D3C; Thu, 24 Mar 2022 17:45:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 801063858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 3AC8A7A411; Thu, 24 Mar 2022 17:45:14 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KPXgG04svz3NPc; Thu, 24 Mar 2022 17:45:14 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648143914; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=grtrjgcuBeQD+uRc2fBU26SZOXL0U1kTOUc9NgrXvdU=; b=qAIeyAGz5jQbZNU38EufH8fikW7nAL6bg/mVeT7f5XQAQYOwIObah9ddy/Mpxiw/jYv/yr gUlHIwY+X3aMKigH9NlRaQB9t580wNm2Po0o3KJldU17IedxK1OWi7OLqtl9lZDHWNmBlE m+f9vbdYrSbXQVMn5qmfoRBnrerJMsTf7pMaJtIlcECBZfqJmSSADbTknoaIgvEH7/kSrp ZyPdbpqjta9VeQJIZzZwl0Kxr1JFLmBwJTUBwUFptgroOLs2IC094neJf0Z1Zmn/+OdPmq 7pS96t5Z2OkHaZayRouiyTDtzqNQ8Ik8520O4ZuYu4w0FQyPLClU20YbVVPHwA== Received: from [10.0.1.4] (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 7645532C1; Thu, 24 Mar 2022 17:45:13 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <71802c0a-ec75-6d2e-69f4-5ca0dc0bba7d@FreeBSD.org> Date: Thu, 24 Mar 2022 10:45:12 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH 02/12] fbsd-nat: Add helper routines for register sets using PT_[G]SETREGSET. Content-Language: en-US To: Luis Machado , binutils@sourceware.org, gdb-patches@sourceware.org References: <20220323210048.25525-1-jhb@FreeBSD.org> <20220323210048.25525-3-jhb@FreeBSD.org> From: John Baldwin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648143914; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=grtrjgcuBeQD+uRc2fBU26SZOXL0U1kTOUc9NgrXvdU=; b=pI1armqOmO29F2sUxig+UGGE3+In7jDYFNT1O6+0n2M2AsJD7keOjXZlIs1r2UkYyyJJfD LPhE+9I9axmagYXuhOX7A5SIrRNi8cl0L4tx9VngbnXtmxFWvN93Cys3L+l+VhMkUIwnjP 3kMRsL5PDzvLNuk3In3NNje50VvYXqLCOkPIxX241xIc/1HvEYs1lldwh93HRuFxIGDOEL z81uOYrGldkG90MVvbZ5+E2frhFzm4aFRfWyF41L12iH6s9D2zrMc90f1yTjWOuEYTXG1x SUv2fxOuDGXJG5XLKstGIxsn4iMcHLOUl/9SweF5Zh+UCmITmF4M6EsqDo6PXw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648143914; a=rsa-sha256; cv=none; b=XjDKgCgw6CCk/ucK8gDTOJ/NU6fhaSkSG2kVEm+4jQnkk1zTXFFkav1RRywof/iHEQI/1i HoHLBNm9oeN7zyPLRUh/Em4g8hOQa8I3tgBXGc5qqQ/hvRhiUGn6NDhj2YC/eE/Wx/3CKl H8fl5bFEPwpbtZm6Rj765gcYs4xulm4A0/TWQK687fYsS43QhKQo1juXAWZEJXzcRc0zyj onDGA22pRfgTqw6z/mHkpk+8sWRm5KRikEUHVE1tVyTKfVxKOfQfQB+bnlPRvJPcMHt7I2 Af7cHFOyM3IAkEqUXQhibMyyGo0bSk/PSYkUzIOiEDzA97YfzibQIZFXYqVWPA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Mar 2022 17:45:16 -0000 On 3/24/22 1:51 AM, Luis Machado wrote: > On 3/23/22 21:00, John Baldwin wrote: >> FreeBSD's kernel has recently added PT_GETREGSET and PT_SETREGSET >> operations to fetch a register set named by an ELF note type. These >> helper routines provide helpers to check for a register set's >> existence, fetch registers for a register set, and store registers to >> a register set. >> --- >> gdb/fbsd-nat.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ >> gdb/fbsd-nat.h | 42 +++++++++++++++++++++++++++++ >> 2 files changed, 114 insertions(+) >> >> diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c >> index 934fdbad6ef..84abdd9a322 100644 >> --- a/gdb/fbsd-nat.c >> +++ b/gdb/fbsd-nat.c >> @@ -1772,6 +1772,78 @@ fbsd_nat_target::store_register_set (struct regcache *regcache, int regnum, >> return false; >> } >> >> +#ifdef PT_GETREGSET > > Instead of ifdef-ing the entire block of code, wouldn't it be better to > conditionally define the constant and have the code do checks at runtime? > > If GDB is built on a machine without the proper headers and copied onto > a machine with support for PT_GETREGSET, it won't be able to use this > improvement. On the other hand, if we build GDB on a machine with the > headers, but copy it into a machine without support for PT_GETREGSET, > things will break, no? FreeBSD does not generally support forwards compatibility (the second case of a newer binary on an older kernel), only backwards compatibility. However, it is true that in the use cases for PT_GETREGSET for the foreseeable future, they will all be conditioned on a runtime check via the 'have_regset' function enabling an architecture feature, so I could add a fallback for the macro and always enable these functions. I will go ahead and make that change. -- John Baldwin