From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113736 invoked by alias); 7 Jun 2018 20:19:02 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 113699 invoked by uid 89); 7 Jun 2018 20:19:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 spammy=ideally, gdbserver, UD:regcache.h, UD:common-regcache.h X-HELO: sessmg23.ericsson.net Received: from sessmg23.ericsson.net (HELO sessmg23.ericsson.net) (193.180.251.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 07 Jun 2018 20:18:59 +0000 Received: from ESESSHC008.ericsson.se (Unknown_Domain [153.88.183.42]) by sessmg23.ericsson.net (Symantec Mail Security) with SMTP id 88.37.10459.033991B5; Thu, 7 Jun 2018 22:18:56 +0200 (CEST) Received: from ESESSMB501.ericsson.se (153.88.183.162) by ESESSHC008.ericsson.se (153.88.183.42) with Microsoft SMTP Server (TLS) id 14.3.382.0; Thu, 7 Jun 2018 22:18:56 +0200 Received: from ESESBMB505.ericsson.se (153.88.183.172) by ESESSMB501.ericsson.se (153.88.183.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Thu, 7 Jun 2018 22:18:55 +0200 Received: from NAM03-BY2-obe.outbound.protection.outlook.com (153.88.183.157) by ESESBMB505.ericsson.se (153.88.183.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3 via Frontend Transport; Thu, 7 Jun 2018 22:18:55 +0200 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from [142.133.60.240] (192.75.88.130) by DM6PR15MB2393.namprd15.prod.outlook.com (2603:10b6:5:8d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.841.14; Thu, 7 Jun 2018 20:18:51 +0000 Subject: Re: [PATCH v2 03/10] Add reg_buffer_common To: Alan Hayward , CC: References: <20180606151629.36602-1-alan.hayward@arm.com> <20180606151629.36602-4-alan.hayward@arm.com> From: Simon Marchi Message-ID: <17367496-22c7-d61c-6800-cbdfd856f308@ericsson.com> Date: Thu, 07 Jun 2018 20:19:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180606151629.36602-4-alan.hayward@arm.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: HE1PR0301CA0012.eurprd03.prod.outlook.com (2603:10a6:3:76::22) To DM6PR15MB2393.namprd15.prod.outlook.com (2603:10b6:5:8d::27) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR15MB2393: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-MS-Exchange-SenderADCheck: 1 X-Forefront-PRVS: 06968FD8C4 Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Office365-Filtering-Correlation-Id: 1ec3a941-6af6-466e-4af8-08d5ccb3e35b X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jun 2018 20:18:51.1745 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1ec3a941-6af6-466e-4af8-08d5ccb3e35b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR15MB2393 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes X-SW-Source: 2018-06/txt/msg00181.txt.bz2 Hi Alan, Just some quick comments. I get this when building on x86-64 with --enable-targets=all: CXX aarch64-tdep.o In file included from /home/emaisin/src/binutils-gdb/gdb/nat/aarch64-sve-linux-ptrace.h:29:0, from /home/emaisin/src/binutils-gdb/gdb/aarch64-tdep.c:61: /home/emaisin/src/binutils-gdb/gdb/nat/aarch64-linux-sigcontext.h:19:22: error: field ‘head’ has incomplete type ‘_aarch64_ctx’ struct _aarch64_ctx head; ^ /home/emaisin/src/binutils-gdb/gdb/nat/aarch64-linux-sigcontext.h:19:9: note: forward declaration of ‘struct _aarch64_ctx’ struct _aarch64_ctx head; ^ First, we should not include "nat/aarch64-sve-linux-ptrace.h" (a file that only makes sense when building on AArch64) in aarch64-tdep.c, a file built on all architecture when including the support for AArch64 debugging. It looks like aarch64-tdep.c needs sve_vq_from_vl. Maybe that definition could be moved to arch/, which can be included in aarch64-tdep.c. Then, is the _aarch64_ctx structure guaranteed to be defined on older AArch64 kernels or should we include it too? On 2018-06-06 11:16 AM, Alan Hayward wrote: > A purely virtual class containing functions from gdb/regcache.h > > Both the gdb regcache structures and gdbserver regcache inherit > directly from reg_buffer_common. This will allow for common > functions which require the use of a regcache. > > 2018-06-06 Alan Hayward > > gdb/ > * common/common-regcache.h (reg_buffer_common): New structure. > * regcache.h (reg_buffer_common:get_register_status) Add override. > (reg_buffer_common:raw_supply): Add dummy function. > reg_buffer_common:raw_collect): Likewise > (readable_regcache:raw_supply) Add override. > (detached_regcache:raw_collect) Likewise. > > gdbserver/ > * regcache.c (new_register_cache): Use new. > (free_register_cache): Use delete. > register_data): Use const. > (supply_register): Call member function. > (regcache::raw_supply): Replacement for supply_register. > (collect_register): Call member function. > (regcache::raw_collect): Replacement for collect_register. > (regcache::get_register_status): New function. > * regcache.h (regcache:raw_supply): Add dummy function. > (regcache:raw_collect): Likewise > (regcache:get_register_status) Likewise. > --- > gdb/common/common-regcache.h | 8 ++++++++ > gdb/gdbserver/regcache.c | 47 ++++++++++++++++++++++++++++++++------------ > gdb/gdbserver/regcache.h | 18 +++++++++++------ > gdb/regcache.h | 19 ++++++++++++++---- > 4 files changed, 69 insertions(+), 23 deletions(-) > > diff --git a/gdb/common/common-regcache.h b/gdb/common/common-regcache.h > index 696ba00955..487da0a7fb 100644 > --- a/gdb/common/common-regcache.h > +++ b/gdb/common/common-regcache.h > @@ -62,4 +62,12 @@ extern enum register_status regcache_raw_read_unsigned > > ULONGEST regcache_raw_get_unsigned (struct regcache *regcache, int regnum); > > +struct reg_buffer_common > +{ > + virtual ~reg_buffer_common () = default; > + virtual void raw_supply (int regnum, const void *buf) = 0; > + virtual void raw_collect (int regnum, void *buf) const = 0; > + virtual register_status get_register_status (int regnum) const = 0; > +}; Ideally, we would gather the documentation for these methods here. Where they are implemented/overriden, we can maybe add a reference such as /* See struct reg_buffer_common. */ ? > diff --git a/gdb/regcache.h b/gdb/regcache.h > index 3edddf47e1..b559a10752 100644 > --- a/gdb/regcache.h > +++ b/gdb/regcache.h > @@ -139,7 +139,7 @@ typedef struct cached_reg > > /* Buffer of registers. */ > > -class reg_buffer > +class reg_buffer : public reg_buffer_common > { > public: > reg_buffer (gdbarch *gdbarch, bool has_pseudo); > @@ -151,13 +151,24 @@ public: > > /* Get the availability status of the value of register REGNUM in this > buffer. */ > - enum register_status get_register_status (int regnum) const; > + enum register_status get_register_status (int regnum) const override; > > virtual ~reg_buffer () > { > xfree (m_registers); > xfree (m_register_status); > } > + > + virtual void raw_supply (int regnum, const void *buf) override > + { > + gdb_assert (false); > + } > + > + virtual void raw_collect (int regnum, void *buf) const override > + { > + gdb_assert (false); > + } Hmm, I understand why you need to do this right now. But what do you think of the idea of moving the supply and collect implementations up to reg_buffer? I think that the supply/collect operations are a good fit to go in reg_buffer. Essentially they just peek/poke in the buffer. The regcache layer's responsibility is then to use that register buffer to implement a cache in front of the target registers, and offer the API to properly read/write registers (including pseudo ones). For reference here's the patch in the regcache-for-alan branch that did this: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=0e04bb35765d2717818dddd88328cb975f417b2c;hp=ca9f66e37913be55abaea44813a768b40673a39a Simon