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 3/3] Parse SVE registers in aarch64 core file reading/writing
Date: Mon, 06 Aug 2018 18:29:00 -0000	[thread overview]
Message-ID: <dd0d4e70-b346-21d5-ef32-e2f92c540b52@ericsson.com> (raw)
In-Reply-To: <20180730092528.98739-4-alan.hayward@arm.com>

On 2018-07-30 05:25 AM, Alan Hayward wrote:
> sve_regmap cannot be global static as the size is dependant on the current
> vector length.
> 
> 2018-07-30  Alan Hayward  <alan.hayward@arm.com>
> 
> 	* aarch64-linux-tdep.c (aarch64_linux_supply_sve_regset): New function.
> 	(aarch64_linux_collect_sve_regset): Likewise.
> 	(aarch64_linux_iterate_over_regset_sections): Check for SVE.
> 	* regcache.h (regcache_map_entry_size): New function.
> ---
>  gdb/aarch64-linux-tdep.c | 112 ++++++++++++++++++++++++++++++++++++++++++++++-
>  gdb/regcache.h           |   8 ++++
>  2 files changed, 118 insertions(+), 2 deletions(-)
> 
> diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
> index f9a95950da..bd61a2d722 100644
> --- a/gdb/aarch64-linux-tdep.c
> +++ b/gdb/aarch64-linux-tdep.c
> @@ -288,6 +288,85 @@ aarch64_linux_core_read_vq (struct gdbarch *gdbarch, bfd *abfd)
>    return vq;
>  }
>  
> +/* Supply register REGNUM from BUF to REGCACHE, using the register map
> +   in REGSET.  If REGNUM is -1, do this for all registers in REGSET.
> +   If BUF is NULL, set the registers to "unavailable" status.  */
> +
> +static void
> +aarch64_linux_supply_sve_regset (const struct regset *regset,
> +				 struct regcache *regcache,
> +				 int regnum, const void *buf, size_t size)
> +{
> +  struct gdbarch *gdbarch = regcache->arch ();
> +  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
> +
> +  if (buf == nullptr)
> +    return regcache->supply_regset (regset, regnum, nullptr, size);
> +  gdb_assert (size > SVE_HEADER_SIZE);
> +
> +  /* BUF contains an SVE header followed by a register dump of either the
> +     passed in SVE regset or a NEON fpregset.  */
> +
> +  /* Extract required fields from the header.  */
> +  uint64_t vg = sve_vg_from_vl (SVE_HEADER_READ (buf, 2, byte_order));
> +  uint16_t flags = SVE_HEADER_READ (buf, 4, byte_order);
> +
> +  if (regnum == -1 || regnum == AARCH64_SVE_VG_REGNUM)
> +    regcache->raw_supply (AARCH64_SVE_VG_REGNUM, &vg);

I think this raw_supply is wrong.  The vg local variable is in host byte order,
but the data in the buffer passed to raw_supply should be in target.  So you
may need to do a store_unsigned_integer in a buffer and supply that.  If this
is a pattern that happens often enough, maybe it would be worth having a
raw_supply that does this conversion from integer to register buffer, a bit
like "regcache::raw_write (int regnum, T val)" does.

> +
> +  if (flags & 1)
> +    {
> +      /* Register dump is a SVE structure.  */
> +      regcache->supply_regset (regset, regnum,
> +			       (gdb_byte *) buf + SVE_HEADER_SIZE,
> +			       size - SVE_HEADER_SIZE);
> +    }
> +  else
> +    {
> +      /* Register dump is a fpsimd structure.  First clear the SVE
> +	 registers.  */
> +      for (int i = 0; i < AARCH64_SVE_Z_REGS_NUM; i++)
> +	regcache->raw_supply_zeroed (AARCH64_SVE_Z0_REGNUM + i);
> +      for (int i = 0; i < AARCH64_SVE_P_REGS_NUM; i++)
> +	regcache->raw_supply_zeroed (AARCH64_SVE_P0_REGNUM + i);
> +      regcache->raw_supply_zeroed (AARCH64_SVE_FFR_REGNUM);

Just wondering, should they be made unavailable instead of cleared?

Simon

  reply	other threads:[~2018-08-06 18:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-30  9:26 [PATCH v2 0/3] Core file support for Aarch64 SVE Alan Hayward
2018-07-30  9:25 ` [PATCH v2 2/3] Detect SVE when reading aarch64 core files Alan Hayward
2018-08-06 18:28   ` Simon Marchi
2018-07-30  9:26 ` [PATCH v2 1/3] Add min size to regset section iterations Alan Hayward
2018-08-06 18:27   ` Simon Marchi
2018-08-07 11:01     ` Alan Hayward
2018-08-07 16:05       ` Simon Marchi
2018-08-08  8:19         ` Alan Hayward
2018-08-08 13:34           ` Simon Marchi
2018-08-09 18:29             ` Simon Marchi
2018-08-09 18:53               ` Simon Marchi
2018-07-30  9:26 ` [PATCH v2 3/3] Parse SVE registers in aarch64 core file reading/writing Alan Hayward
2018-08-06 18:29   ` Simon Marchi [this message]
2018-08-07 11:20     ` Alan Hayward
2018-08-06 10:10 ` [PING][PATCH v2 0/3] Core file support for Aarch64 SVE Alan Hayward

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=dd0d4e70-b346-21d5-ef32-e2f92c540b52@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).