public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Aktemur, Tankut Baris" <tankut.baris.aktemur@intel.com>
To: Simon Marchi <simon.marchi@efficios.com>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: Luis Machado <luis.machado@arm.com>,
	John Baldwin <jhb@freebsd.org>,
	Andrew Burgess <aburgess@redhat.com>,
	John Baldwin <jhb@FreeBSD.org>
Subject: RE: [PATCH v2 05/24] gdb: change regcache interface to use array_view
Date: Thu, 30 Nov 2023 17:58:59 +0000	[thread overview]
Message-ID: <DM4PR11MB730373DC2E72D250CE2D4684C482A@DM4PR11MB7303.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20231124212656.96801-6-simon.marchi@efficios.com>

On Friday, November 24, 2023 10:26 PM, Simon Marchi wrote:
> New in v2:
> 
>  - remove dummy float parameters
> 
> Change most of regcache (and base classes) to use array_view when
> possible, instead of raw pointers.  By propagating the use of array_view
> further, it enables having some runtime checks to make sure the what we
> read from or write to regcaches has the expected length (such as the one
> in the `copy(array_view, array_view)` function.  It also integrates well
> when connecting with other APIs already using gdb::array_view.
> 
> Add some overloads of the methods using raw pointers to avoid having to
> change all call sites at once (which is both a lot of work and risky).
> 
> I tried to do this change in small increments, but since many of these
> functions use each other, it ended up simpler to do it in one shot than
> having a lot of intermediary / transient changes.
> 
> This change extends into gdbserver as well, because there is some part
> of the regcache interface that is shared.
> 
> Changing the reg_buffer_common interface to use array_view caused some
> build failures in nat/aarch64-scalable-linux-ptrace.c.  That file
> currently "takes advantage" of the fact that
> reg_buffer_common::{raw_supply,raw_collect} operates on `void *`, which
> IMO is dangerous.  It uses raw_supply/raw_collect directly on
> uint64_t's, which I guess is fine because it is expected that native
> code will have the same endianness as the debugged process.  To
> accomodate that, add some overloads of raw_collect and raw_supply that
> work on uint64_t.
> 
> This file also uses raw_collect and raw_supply on `char` pointers.
> Change it to use `gdb_byte` pointers instead.  Add overloads of
> raw_collect and raw_supply that work on `gdb_byte *` and make an
> array_view on the fly using the register's size.  Those call sites could
> be converted to use array_view with not much work, in which case these
> overloads could be removed, but I didn't want to do it in this patch, to
> avoid starting to dig in arch-specific code.
> 
> Change-Id: I9005f04114543ddff738949e12d85a31855304c2
> Reviewed-By: John Baldwin <jhb@FreeBSD.org>
> ---
...
> @@ -650,13 +677,13 @@ template<typename T, typename>
>  void
>  regcache::raw_write (int regnum, T val)
>  {
> -  gdb_byte *buf;
> -
>    assert_regnum (regnum);
> -  buf = (gdb_byte *) alloca (m_descr->sizeof_register[regnum]);
> -  store_integer (buf, m_descr->sizeof_register[regnum],
> -		 gdbarch_byte_order (m_descr->gdbarch), val);
> -  raw_write (regnum, buf);
> +
> +  int len = m_descr->sizeof_register[regnum];
> +  gdb_byte *buf = (gdb_byte *) alloca (m_descr->sizeof_register[regnum]);

We could use `len` as the argument to `alloca`.  Could you also consider naming
the variable `size` instead of `len`?  It seems to be used more often than `len`
in this patch, and also fits better to array_view's `size` method.

Regards
-Baris


Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


  reply	other threads:[~2023-11-30 17:59 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-24 21:26 [PATCH v2 00/24] Fix reading and writing pseudo registers in non-current frames Simon Marchi
2023-11-24 21:26 ` [PATCH v2 01/24] gdb: don't handle i386 k registers as pseudo registers Simon Marchi
2023-11-24 21:26 ` [PATCH v2 02/24] gdb: use reg_buffer_common throughout gdbsupport/common-regcache.h Simon Marchi
2023-11-30 11:45   ` Aktemur, Tankut Baris
2023-11-30 21:02     ` Simon Marchi
2023-11-30 16:11   ` Aktemur, Tankut Baris
2023-11-30 18:01     ` Simon Marchi
2023-11-24 21:26 ` [PATCH v2 03/24] gdb: make store_integer take an array_view Simon Marchi
2023-11-30 11:40   ` Aktemur, Tankut Baris
2023-11-30 17:51     ` Simon Marchi
2023-11-24 21:26 ` [PATCH v2 04/24] gdb: simplify conditions in regcache::{read,write,raw_collect,raw_supply}_part Simon Marchi
2023-11-24 21:26 ` [PATCH v2 05/24] gdb: change regcache interface to use array_view Simon Marchi
2023-11-30 17:58   ` Aktemur, Tankut Baris [this message]
2023-11-30 20:09     ` Simon Marchi
2023-11-24 21:26 ` [PATCH v2 06/24] gdb: fix bugs in {get,put}_frame_register_bytes Simon Marchi
2023-11-24 21:26 ` [PATCH v2 07/24] gdb: make put_frame_register take an array_view Simon Marchi
2023-11-24 21:26 ` [PATCH v2 08/24] gdb: change value_of_register and value_of_register_lazy to take the next frame Simon Marchi
2023-11-24 21:26 ` [PATCH v2 09/24] gdb: remove frame_register Simon Marchi
2023-11-24 21:26 ` [PATCH v2 10/24] gdb: make put_frame_register take the next frame Simon Marchi
2023-11-24 21:26 ` [PATCH v2 11/24] gdb: make put_frame_register_bytes " Simon Marchi
2023-11-24 21:26 ` [PATCH v2 12/24] gdb: make get_frame_register_bytes " Simon Marchi
2023-11-24 21:26 ` [PATCH v2 13/24] gdb: add value::allocate_register Simon Marchi
2023-11-24 21:26 ` [PATCH v2 14/24] gdb: read pseudo register through frame Simon Marchi
2023-11-24 21:26 ` [PATCH v2 15/24] gdb: change parameter name in frame_unwind_register_unsigned declaration Simon Marchi
2023-11-24 21:26 ` [PATCH v2 16/24] gdb: rename gdbarch_pseudo_register_write to gdbarch_deprecated_pseudo_register_write Simon Marchi
2023-11-24 21:26 ` [PATCH v2 17/24] gdb: add gdbarch_pseudo_register_write that takes a frame Simon Marchi
2023-11-24 21:26 ` [PATCH v2 18/24] gdb: migrate i386 and amd64 to the new gdbarch_pseudo_register_write Simon Marchi
2023-11-24 21:26 ` [PATCH v2 19/24] gdb: make aarch64_za_offsets_from_regnum return za_offsets Simon Marchi
2023-11-27 11:42   ` Luis Machado
2023-11-27 15:56     ` Simon Marchi
2023-11-24 21:26 ` [PATCH v2 20/24] gdb: add missing raw register read in aarch64_sme_pseudo_register_write Simon Marchi
2023-11-27 11:43   ` Luis Machado
2023-11-27 15:57     ` Simon Marchi
2023-11-24 21:26 ` [PATCH v2 21/24] gdb: migrate aarch64 to new gdbarch_pseudo_register_write Simon Marchi
2023-11-28 12:35   ` Luis Machado
2023-11-24 21:26 ` [PATCH v2 22/24] gdb: migrate arm to gdbarch_pseudo_register_read_value Simon Marchi
2023-11-27 16:42   ` Luis Machado
2023-11-24 21:26 ` [PATCH v2 23/24] gdb: migrate arm to new gdbarch_pseudo_register_write Simon Marchi
2023-11-27 16:42   ` Luis Machado
2023-11-24 21:26 ` [PATCH v2 24/24] gdb/testsuite: add tests for unwinding of pseudo registers Simon Marchi
2023-11-27 11:53   ` Luis Machado
2023-11-27 15:59     ` 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=DM4PR11MB730373DC2E72D250CE2D4684C482A@DM4PR11MB7303.namprd11.prod.outlook.com \
    --to=tankut.baris.aktemur@intel.com \
    --cc=aburgess@redhat.com \
    --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).