public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Luis Machado <luis.machado@arm.com>,
	Simon Marchi <simon.marchi@efficios.com>,
	gdb-patches@sourceware.org
Cc: John Baldwin <jhb@freebsd.org>
Subject: Re: [PATCH 2/2] gdb: add missing regcache_map_entry array null terminators in aarch64-linux-tdep.c
Date: Fri, 1 Dec 2023 11:21:13 -0500	[thread overview]
Message-ID: <0674fb57-acde-4195-918f-5aa4090b3fa8@simark.ca> (raw)
In-Reply-To: <62a27fad-acaf-4d94-aa97-23cd751f4f2c@arm.com>

On 12/1/23 04:12, Luis Machado wrote:
> Hi Simon,
> 
> On 11/30/23 21:20, Simon Marchi wrote:
>> Fix two spots in aarch64-linux-tdep.c that build regcache_map_entry
>> arrays without a null terminator.  The null terminators are needed for
>> regcache::transfer_regset to work properly.
>>
>> Some shower thoughts: I'm wondering: if a caller uses
>> supply_regset/collect_regset with a regcache_map_entry array that
>> describes exactly X bytes, and passes a buffer of X bytes, should a null
>> terminator really be needed?  regcache::transfer_regset could be written
>> in a way that it exits as soon as the remaining buffer size reaches 0.
>> Right now, even when it has consumed exactly the X bytes of the buffer,
>> transfer_regset needs to read the following regcache_map_entry's count
>> (expected to be 0) to realize it's done.  If it exited its outer loop
>> when `offs == size`, it would remove the need for the null terminator in
>> this case.
>>
>> Shower thought #2: we could also bypass that by using array_view to pass
>> regcache_map_entry arrays, removing the need for null terminators
>> altogether, but that's a bigger change.
>>
>> Change-Id: I3224a314e1360b319438f32de8c81e70ab42e105
>> ---
>>  gdb/aarch64-linux-tdep.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
>> index cd99b33fed25..5be887a9c817 100644
>> --- a/gdb/aarch64-linux-tdep.c
>> +++ b/gdb/aarch64-linux-tdep.c
>> @@ -1497,7 +1497,9 @@ aarch64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
>>        /* Create this on the fly in order to handle the ZA register size.  */
>>        const struct regcache_map_entry za_regmap[] =
>>  	{
>> -	  { 1, tdep->sme_za_regnum, (int) std::pow (sve_vl_from_vq (tdep->sme_svq), 2) }
>> +	  { 1, tdep->sme_za_regnum,
>> +	    (int) std::pow (sve_vl_from_vq (tdep->sme_svq), 2) },
>> +	  { 0 }
>>  	};
>>  
>>        const struct regset aarch64_linux_za_regset =
>> @@ -1518,7 +1520,8 @@ aarch64_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
>>  	{
>>  	  const struct regcache_map_entry zt_regmap[] =
>>  	    {
>> -	      { 1, tdep->sme2_zt0_regnum, AARCH64_SME2_ZT0_SIZE }
>> +	      { 1, tdep->sme2_zt0_regnum, AARCH64_SME2_ZT0_SIZE },
>> +	      { 0 }
>>  	    };
>>  
>>  	  /* We set the register set size to REGSET_VARIABLE_SIZE here because
> 
> Yeah, that was a silly mistake. Glad it was spotted.
> 
> I failed to spot the missing terminators for these two regcache_map_entry's,
> as I see them in other regcache_map_entry's.
> 
> This is OK, thanks!
> 
> Approved-By: Luis Machado <luis.machado@arm.com>

Thanks, pushed both patches.

Simon

      reply	other threads:[~2023-12-01 16:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-30 21:20 [PATCH 0/2] Fix gdb.arch/aarch64-sme-core-*.exp failures Simon Marchi
2023-11-30 21:20 ` [PATCH 1/2] gdb: return when exceeding buffer size in regcache::transfer_regset Simon Marchi
2023-11-30 23:42   ` John Baldwin
2023-12-01  0:02     ` Simon Marchi
2023-12-01  9:13   ` Luis Machado
2023-11-30 21:20 ` [PATCH 2/2] gdb: add missing regcache_map_entry array null terminators in aarch64-linux-tdep.c Simon Marchi
2023-11-30 23:44   ` John Baldwin
2023-12-01  0:03     ` Simon Marchi
2023-12-01  9:12   ` Luis Machado
2023-12-01 16:21     ` 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=0674fb57-acde-4195-918f-5aa4090b3fa8@simark.ca \
    --to=simark@simark.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=jhb@freebsd.org \
    --cc=luis.machado@arm.com \
    --cc=simon.marchi@efficios.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).