[PATCH 13/26] gdbserver: convert register_data into regcache::register_data

Tankut Baris Aktemur via Gdb-patches
2023-02-28T11:31:31Z

Convert the register_data function to a method of the regcache struct.
---
gdbserver/regcache.cc | 20 ++++++++++----------
gdbserver/regcache.h | 3 +++
2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc
index 31f1e7bb3dc..79835ef4ff1 100644
--- a/gdbserver/regcache.cc
+++ b/gdbserver/regcache.cc
@@ -314,11 +314,11 @@ regcache_register_size (const struct regcache *regcache, int n)
return register_size (regcache->tdesc, n);
}

-static unsigned char *
-register_data (const struct regcache *regcache, int n)
+unsigned char *
+regcache::register_data (int regnum) const
{
- return (regcache->registers
- + find_register_by_number (regcache->tdesc, n).offset / 8);
+ return (registers
+ + find_register_by_number (tdesc, regnum).offset / 8);
}

void
@@ -334,7 +334,7 @@ regcache::raw_supply (int n, const void *buf)
{
if (buf)
{
- memcpy (register_data (this, n), buf, register_size (tdesc, n));
+ memcpy (register_data (n), buf, register_size (tdesc, n));
#ifndef IN_PROCESS_AGENT
if (register_status != NULL)
register_status[n] = REG_VALID;
@@ -342,7 +342,7 @@ regcache::raw_supply (int n, const void *buf)
}
else
{
- memset (register_data (this, n), 0, register_size (tdesc, n));
+ memset (register_data (n), 0, register_size (tdesc, n));
#ifndef IN_PROCESS_AGENT
if (register_status != NULL)
register_status[n] = REG_UNAVAILABLE;
@@ -355,7 +355,7 @@ regcache::raw_supply (int n, const void *buf)
void
supply_register_zeroed (struct regcache *regcache, int n)
{
- memset (register_data (regcache, n), 0,
+ memset (regcache->register_data (n), 0,
register_size (regcache->tdesc, n));
#ifndef IN_PROCESS_AGENT
if (regcache->register_status != NULL)
@@ -419,7 +419,7 @@ collect_register (struct regcache *regcache, int n, void *buf)
void
regcache::raw_collect (int n, void *buf) const
{
- memcpy (buf, register_data (this, n), register_size (tdesc, n));
+ memcpy (buf, register_data (n), register_size (tdesc, n));
}

enum register_status
@@ -458,7 +458,7 @@ regcache_raw_get_unsigned_by_name (struct regcache *regcache,
void
collect_register_as_string (struct regcache *regcache, int n, char *buf)
{
- bin2hex (register_data (regcache, n), buf,
+ bin2hex (regcache->register_data (n), buf,
register_size (regcache->tdesc, n));
}

@@ -505,7 +505,7 @@ regcache::raw_compare (int regnum, const void *buf, int offset) const
{
gdb_assert (buf != NULL);

- const unsigned char *regbuf = register_data (this, regnum);
+ const unsigned char *regbuf = register_data (regnum);
int size = register_size (tdesc, regnum);
gdb_assert (size >= offset);

diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h
index 944718070b4..88e6ac32bae 100644
--- a/gdbserver/regcache.h
+++ b/gdbserver/regcache.h
@@ -96,6 +96,9 @@ struct regcache : public reg_buffer_common
to this regcache. If BUF is NULL, all the registers' values are
recorded as unavailable. */
void supply_regblock (const void *buf);
+
+ /* Return the pointer to the register with number REGNUM. */
+ unsigned char *register_data (int regnum) const;
};

regcache *get_thread_regcache (thread_info *thread, bool fetch = true);
--
2.25.1

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