public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: Alan Hayward <alan.hayward@arm.com>, <gdb-patches@sourceware.org>
Cc: <nd@arm.com>
Subject: Re: [PATCH v2 03/10] Add reg_buffer_common
Date: Thu, 07 Jun 2018 20:19:00 -0000	[thread overview]
Message-ID: <17367496-22c7-d61c-6800-cbdfd856f308@ericsson.com> (raw)
In-Reply-To: <20180606151629.36602-4-alan.hayward@arm.com>

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  <alan.hayward@arm.com>
> 
> 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

  reply	other threads:[~2018-06-07 20:19 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-06 15:16 [PATCH v2 00/10] gdb/gdbserver support for aarch64 SVE Alan Hayward
2018-06-06 15:17 ` [PATCH v2 01/10] Aarch64 SVE pseudo register support Alan Hayward
2018-06-06 22:17   ` Simon Marchi
2018-06-07  9:34     ` Alan Hayward
2018-06-06 15:17 ` [PATCH v2 02/10] Add Aarch64 SVE Linux headers Alan Hayward
2018-06-08 14:13   ` Alan Hayward
2018-06-08 14:37     ` Simon Marchi
2018-06-08 15:23       ` Simon Marchi
2018-06-12 14:37         ` Alan Hayward
2018-06-12 14:43           ` Pedro Alves
2018-06-12 15:06             ` Simon Marchi
2018-06-12 15:11               ` Pedro Alves
2018-06-12 15:21                 ` Simon Marchi
2018-06-12 15:09             ` Alan Hayward
2018-06-12 14:51           ` Simon Marchi
2018-06-12 16:34             ` Sergio Durigan Junior
2018-06-12 17:51               ` Alan Hayward
2018-06-12 20:29                 ` Sergio Durigan Junior
2018-06-15  9:45                   ` Ramana Radhakrishnan
2018-06-15 17:14                     ` Alan Hayward
2018-09-20 21:16                       ` Status of the AArch* builders (was: Re: [PATCH v2 02/10] Add Aarch64 SVE Linux headers) Sergio Durigan Junior
2018-09-24 14:16                         ` Alan Hayward
2018-09-24 14:42                           ` Status of the AArch* builders Sergio Durigan Junior
2018-10-11  9:23                             ` Alan Hayward
2018-10-12 19:06                               ` Sergio Durigan Junior
2018-10-15 10:16                                 ` Alan Hayward
2018-10-15 12:42                                   ` Sergio Durigan Junior
2018-10-15 14:02                                     ` Alan Hayward
2018-10-15 15:32                                       ` Sergio Durigan Junior
2018-10-17 18:46                                         ` Sergio Durigan Junior
2018-10-24  9:56                                           ` Alan Hayward
2018-10-25 16:26                                             ` Sergio Durigan Junior
2018-06-08 15:27       ` [PATCH v2 02/10] Add Aarch64 SVE Linux headers Alan Hayward
2018-06-06 15:17 ` [PATCH v2 09/10] Ptrace support for AArch64 SVE gdbsever Alan Hayward
2018-06-11  2:43   ` Simon Marchi
2018-06-11  2:44   ` Simon Marchi
2018-06-06 15:17 ` [PATCH v2 07/10] Increase gdbsever PBUFSIZ Alan Hayward
2018-06-11  0:46   ` Simon Marchi
2018-06-06 15:17 ` [PATCH v2 10/10] Remove reg2 section from Aarch64 SVE cores Alan Hayward
2018-06-11  2:47   ` Simon Marchi
2018-06-11 16:37     ` Alan Hayward
2018-06-06 15:17 ` [PATCH v2 05/10] Ptrace support for Aarch64 SVE Alan Hayward
2018-06-10 22:52   ` Simon Marchi
2018-06-06 15:17 ` [PATCH v2 08/10] Enable Aarch64 SVE for gdbserver Alan Hayward
2018-06-11  0:49   ` Simon Marchi
2018-06-06 15:17 ` [PATCH v2 06/10] Add Aarch64 SVE dwarf regnums Alan Hayward
2018-06-11  0:43   ` Simon Marchi
2018-06-06 15:17 ` [PATCH v2 04/10] Add regcache raw_compare method Alan Hayward
2018-06-07 20:56   ` Simon Marchi
2018-06-08 15:16     ` Alan Hayward
2018-06-10 22:26       ` Simon Marchi
2018-06-06 15:17 ` [PATCH v2 03/10] Add reg_buffer_common Alan Hayward
2018-06-07 20:19   ` Simon Marchi [this message]
2018-06-07 20:42     ` Simon Marchi
2018-06-08 14:14     ` Alan Hayward
2018-06-10 22:21       ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17367496-22c7-d61c-6800-cbdfd856f308@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=alan.hayward@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=nd@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).