public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Luis Machado <luis.machado@arm.com>
To: Simon Marchi <simon.marchi@polymtl.ca>, gdb-patches@sourceware.org
Subject: Re: [PATCH 00/24] Fix reading and writing pseudo registers in non-current frames
Date: Mon, 13 Nov 2023 13:10:53 +0000	[thread overview]
Message-ID: <b5deb915-0701-4303-9539-0d5c92c2a233@arm.com> (raw)
In-Reply-To: <4bc57dc1-67ee-45b7-9de5-3cdc85b6518e@polymtl.ca>

Simon,

On 11/9/23 19:04, Simon Marchi wrote:
> On 11/8/23 14:34, Simon Marchi wrote:
>> Ah, damn, probably because I switched to byte_vector,  which doesn't do
>> the zero-initialization we want to do.  Here's a new patch (that applies
>> on the series directly) that doesn't use byte_vector.
>>
>> diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
>> index 1815d78dec4..200e740e013 100644
>> --- a/gdb/aarch64-tdep.c
>> +++ b/gdb/aarch64-tdep.c
>> @@ -3300,7 +3300,7 @@ aarch64_pseudo_write_1 (gdbarch *gdbarch, frame_info_ptr next_frame,
>>                         int regnum_offset,
>>                         gdb::array_view<const gdb_byte> buf)
>>  {
>> -  unsigned v_regnum = AARCH64_V0_REGNUM + regnum_offset;
>> +  unsigned raw_regnum = AARCH64_V0_REGNUM + regnum_offset;
>>    gdb_static_assert (AARCH64_V0_REGNUM == AARCH64_SVE_Z0_REGNUM);
>>
>>    /* Enough space for a full vector register.
>> @@ -3309,11 +3309,11 @@ aarch64_pseudo_write_1 (gdbarch *gdbarch, frame_info_ptr next_frame,
>>       various 'scalar' pseudo registers to behavior like architectural
>>       writes, register width bytes are written the remainder are set to
>>       zero.  */
>> -  constexpr int raw_reg_size = 16;
>> +  int raw_reg_size = register_size (gdbarch, raw_regnum);
>>    gdb_byte raw_buf[raw_reg_size] {};
>> -  gdb::array_view<gdb_byte> raw_view (raw_buf);
>> +  gdb::array_view<gdb_byte> raw_view (raw_buf, raw_reg_size);
>>    copy (buf, raw_view.slice (0, buf.size ()));
>> -  put_frame_register (next_frame, v_regnum, raw_view);
>> +  put_frame_register (next_frame, raw_regnum, raw_view);
>>  }
>>
>>  /* Given REGNUM, a SME pseudo-register number, store the bytes from DATA to the
>>
>> Simon
> 
> I managed to run a Debian AArch64 image in qemu, with SVE support, so I
> was able to reproduce the failures you mentioned.  In the end, here's a
> version of aarch64_pseudo_write_1 that works for me (written as to
> minimize the number of unnecessary changes, since that seems to
> introduce unexpected bugs...).
> 
> static void
> aarch64_pseudo_write_1 (gdbarch *gdbarch, frame_info_ptr next_frame,
> 			int regnum_offset,
> 			gdb::array_view<const gdb_byte> buf)
> {
>   unsigned raw_regnum = AARCH64_V0_REGNUM + regnum_offset;
> 
>   /* Enough space for a full vector register.  */
>   int raw_reg_size = register_size (gdbarch, raw_regnum);
>   gdb_byte raw_buf[raw_reg_size];
>   gdb_static_assert (AARCH64_V0_REGNUM == AARCH64_SVE_Z0_REGNUM);
> 
>   /* Ensure the register buffer is zero, we want gdb writes of the
>      various 'scalar' pseudo registers to behavior like architectural
>      writes, register width bytes are written the remainder are set to
>      zero.  */
>   memset (raw_buf, 0, register_size (gdbarch, AARCH64_V0_REGNUM));
> 
>   gdb::array_view<gdb_byte> raw_view (raw_buf, raw_reg_size);
>   copy (buf, raw_view.slice (0, buf.size ()));
>   put_frame_register (next_frame, raw_regnum, raw_view);
> }
> 
> Simon

Sorry for the late reply. I was out a couple days last week.

The above seems to make gdb.arch/aarch64-fp.exp happy, but gdb.arch/aarch64-pseudo-unwind.exp is still slightly unhappy:

FAIL: gdb.arch/aarch64-pseudo-unwind.exp: caller, after change: p/x $v8.q.u
FAIL: gdb.arch/aarch64-pseudo-unwind.exp: caller, after change: p/x $s8.u
FAIL: gdb.arch/aarch64-pseudo-unwind.exp: continue to breakpoint: continue to break_here_c
FAIL: gdb.arch/aarch64-pseudo-unwind.exp: p/x value

This was tested on hardware (AWS's Graviton 3). Let me play with it a bit to understand what's up. I also see a
SIGSEGV in the test that shouldn't be there. I'm guessing some sort of raw register corruption, as it leads to
pc == 0x0.

  reply	other threads:[~2023-11-13 13:11 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-08  5:00 Simon Marchi
2023-11-08  5:00 ` [PATCH 01/24] gdb: don't handle i386 k registers as pseudo registers Simon Marchi
2023-11-11 19:29   ` John Baldwin
2023-11-08  5:00 ` [PATCH 02/24] gdb: use reg_buffer_common throughout gdbsupport/common-regcache.h Simon Marchi
2023-11-11 19:42   ` John Baldwin
2023-11-08  5:00 ` [PATCH 03/24] gdb: make store_integer take an array_view Simon Marchi
2023-11-08  5:00 ` [PATCH 04/24] gdb: simplify conditions in regcache::{read,write,raw_collect,raw_supply}_part Simon Marchi
2023-11-08  5:00 ` [PATCH 05/24] gdb: change regcache interface to use array_view Simon Marchi
2023-11-13 13:43   ` Andrew Burgess
2023-11-13 14:00     ` Andrew Burgess
2023-11-13 16:47       ` Simon Marchi
2023-11-08  5:00 ` [PATCH 06/24] gdb: fix bugs in {get,put}_frame_register_bytes Simon Marchi
2023-11-13 15:00   ` Andrew Burgess
2023-11-13 19:51     ` Simon Marchi
2023-11-08  5:00 ` [PATCH 07/24] gdb: make put_frame_register take an array_view Simon Marchi
2023-11-08  5:00 ` [PATCH 08/24] gdb: change value_of_register and value_of_register_lazy to take the next frame Simon Marchi
2023-11-08  5:00 ` [PATCH 09/24] gdb: remove frame_register Simon Marchi
2023-11-08  5:00 ` [PATCH 10/24] gdb: make put_frame_register take the next frame Simon Marchi
2023-11-08  5:00 ` [PATCH 11/24] gdb: make put_frame_register_bytes " Simon Marchi
2023-11-08  5:00 ` [PATCH 12/24] gdb: make get_frame_register_bytes " Simon Marchi
2023-11-08  5:00 ` [PATCH 13/24] gdb: add value::allocate_register Simon Marchi
2023-11-08  5:00 ` [PATCH 14/24] gdb: read pseudo register through frame Simon Marchi
2023-11-11 20:11   ` John Baldwin
2023-11-08  5:00 ` [PATCH 15/24] gdb: change parameter name in frame_unwind_register_unsigned declaration Simon Marchi
2023-11-08  5:01 ` [PATCH 16/24] gdb: rename gdbarch_pseudo_register_write to gdbarch_deprecated_pseudo_register_write Simon Marchi
2023-11-14 12:12   ` Andrew Burgess
2023-11-14 15:16     ` Simon Marchi
2023-11-08  5:01 ` [PATCH 17/24] gdb: add gdbarch_pseudo_register_write that takes a frame Simon Marchi
2023-11-14 12:20   ` Andrew Burgess
2023-11-14 15:20     ` Simon Marchi
2023-11-08  5:01 ` [PATCH 18/24] gdb: migrate i386 and amd64 to the new gdbarch_pseudo_register_write Simon Marchi
2023-11-11 20:16   ` John Baldwin
2023-11-13  2:59     ` Simon Marchi
2023-11-08  5:01 ` [PATCH 19/24] gdb: make aarch64_za_offsets_from_regnum return za_offsets Simon Marchi
2023-11-08  5:01 ` [PATCH 20/24] gdb: add missing raw register read in aarch64_sme_pseudo_register_write Simon Marchi
2023-11-08  5:01 ` [PATCH 21/24] gdb: migrate aarch64 to new gdbarch_pseudo_register_write Simon Marchi
2023-11-08  5:01 ` [PATCH 22/24] gdb: migrate arm to gdbarch_pseudo_register_read_value Simon Marchi
2023-11-08  5:01 ` [PATCH 23/24] gdb: migrate arm to new gdbarch_pseudo_register_write Simon Marchi
2023-11-08  5:01 ` [PATCH 24/24] gdb/testsuite: add tests for unwinding of pseudo registers Simon Marchi
2023-11-08  5:16 ` [PATCH 00/24] Fix reading and writing pseudo registers in non-current frames Simon Marchi
2023-11-09  3:05   ` Simon Marchi
2023-11-08 11:57 ` Luis Machado
2023-11-08 15:47   ` Simon Marchi
2023-11-08 17:08     ` Luis Machado
2023-11-08 19:34       ` Simon Marchi
2023-11-09 19:04         ` Simon Marchi
2023-11-13 13:10           ` Luis Machado [this message]
2023-11-13 15:08             ` Luis Machado
2023-11-11 20:26 ` John Baldwin
2023-11-13  3:03   ` Simon Marchi
2023-12-01 16:27 Simon Marchi
2023-12-01 16:56 ` Simon Marchi
2023-12-14 14:51 ` Luis Machado
2023-12-14 16:20   ` 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=b5deb915-0701-4303-9539-0d5c92c2a233@arm.com \
    --to=luis.machado@arm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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).