Re: [PATCH 12/26] gdbserver: convert supply_regblock to regcache::supply_regblock

Simon Marchi
2023-12-21T21:23:18Z

On 2/28/23 06:28, Tankut Baris Aktemur via Gdb-patches wrote:
> Convert the supply_regblock function into a method of the regcache
> struct. Also do some minor code modernization.
> ---
> gdbserver/regcache.cc | 32 ++++++++------------------------
> gdbserver/regcache.h | 7 +++++--
> gdbserver/tracepoint.cc | 8 ++++----
> 3 files changed, 17 insertions(+), 30 deletions(-)
>
> diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc
> index 156fda7068d..31f1e7bb3dc 100644
> --- a/gdbserver/regcache.cc
> +++ b/gdbserver/regcache.cc
> @@ -376,39 +376,23 @@ supply_register_by_name_zeroed (struct regcache *regcache,
>
> #endif
>
> -/* Supply the whole register set whose contents are stored in BUF, to
> - REGCACHE. If BUF is NULL, all the registers' values are recorded
> - as unavailable. */
> -
> void
> -supply_regblock (struct regcache *regcache, const void *buf)
> +regcache::supply_regblock (const void *buf)

Add `/* See regcache.h. */`.

Can you investigate if the buf == nullptr case is really needed? It
seems to me like the only times we call supply_regblock with nullptr is
just after creating a fresh regcache. Since the regcache is created
with all registers in the REG_UNAVAILABLE state, perhaps those spots can
just omit calling supply_regblock, and supply_regblock can be
simplified?

Simon