Mirror of the gdb-patches mailing list
 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 2/3] Avoid memcpys in regcache read_part/write_part for full registers.
Date: Thu, 21 Jun 2018 14:00:00 -0000	[thread overview]
Message-ID: <59b4e783-0cc5-5f75-61bf-56c9fe640ffa@ericsson.com> (raw)
In-Reply-To: <20180621093802.79342-3-alan.hayward@arm.com>

On 2018-06-21 05:38 AM, Alan Hayward wrote:
> Additionally, tidy up the functions: Remove asserts, use gdb_byte,
> update comments.

Thanks, that's a nice cleanup.

Just two nits, the patch LGTM with those fixed.

> diff --git a/gdb/regcache.c b/gdb/regcache.c
> index 6276b149a2..fe4742c2ee 100644
> --- a/gdb/regcache.c
> +++ b/gdb/regcache.c
> @@ -775,77 +775,75 @@ regcache::cooked_write (int regnum, const gdb_byte *buf)
>  				   regnum, buf);
>  }
>  
> -/* Perform a partial register transfer using a read, modify, write
> -   operation.  */
> +/* See regcache.h.  */
>  
>  enum register_status
> -readable_regcache::read_part (int regnum, int offset, int len, void *in,
> -			      bool is_raw)
> +readable_regcache::read_part (int regnum, int offset, int len,
> +			      gdb_byte *out, bool is_raw)
>  {
> -  struct gdbarch *gdbarch = arch ();
> -  gdb_byte *reg = (gdb_byte *) alloca (register_size (gdbarch, regnum));
> +  int reg_size = register_size (arch (), regnum);
>  
> -  gdb_assert (in != NULL);
> -  gdb_assert (offset >= 0 && offset <= m_descr->sizeof_register[regnum]);
> -  gdb_assert (len >= 0 && offset + len <= m_descr->sizeof_register[regnum]);
> -  /* Something to do?  */
> -  if (offset + len == 0)
> +  gdb_assert (out != NULL);
> +  gdb_assert (offset >= 0 && len >= 0 && offset + len <= reg_size);
> +
> +  if (offset == 0 && len == 0)
>      return REG_VALID;
> -  /* Read (when needed) ...  */
> +
> +  if (offset == 0 && len == reg_size)
> +    return (is_raw) ? raw_read (regnum, out) : cooked_read (regnum, out);

Could you add some comments to help the reader quickly know what's
going on?  Something like:

  if (offset == 0 && len == 0)
    {
      /* We don't read anything at all.  */
      return REG_VALID;
    }

  if (offset == 0 && len == reg_size)
    {
      /* We read the whole register.  */
      return (is_raw) ? raw_read (regnum, out) : cooked_read (regnum, out);
    }

  /* We read only part of the register.  */

Same for write_part.

> @@ -355,9 +358,10 @@ private:
>  			int regnum, const void *in_buf,
>  			void *out_buf, size_t size) const;
>  
> +  /* Perform a partial register transfer using a read, modify, write
> +     operation.  */
>    enum register_status write_part (int regnum, int offset, int len,
> -				   const void *out, bool is_raw);
> -
> +				   const gdb_byte *out, bool is_raw);

Rename out to in?

Thanks,

Simon


      reply	other threads:[~2018-06-21 14:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-21  9:39 [PATCH v2 0/3] Support large registers in regcache transfer_regset Alan Hayward
2018-06-21  9:38 ` [PATCH v2 1/3] Use unsigned ints in regcache_map_entry Alan Hayward
2018-06-21 13:27   ` Simon Marchi
2018-06-21 13:52     ` Simon Marchi
2018-06-21 15:19       ` Alan Hayward
     [not found]         ` <3e13b55d-5283-eb61-c018-880ff0e92ab1@ericsson.com>
2018-06-21 17:32           ` Simon Marchi
2018-06-21 19:52             ` Alan Hayward
2018-06-21  9:39 ` [PATCH v2 3/3] Use partial register read/writes in transfer_regset Alan Hayward
2018-06-21 14:16   ` Simon Marchi
2018-06-21 19:56     ` Alan Hayward
2018-06-21 15:02   ` Simon Marchi
2018-06-21  9:39 ` [PATCH v2 2/3] Avoid memcpys in regcache read_part/write_part for full registers Alan Hayward
2018-06-21 14:00   ` Simon Marchi [this message]

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=59b4e783-0cc5-5f75-61bf-56c9fe640ffa@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