[PATCH 07/26] gdbserver: convert regcache_cpy into regcache::copy_from

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

Convert the free `regcache_cpy` function to a method of the
regcache struct.
---
gdbserver/regcache.cc | 16 ++++++++--------
gdbserver/regcache.h | 5 +++--
gdbserver/tracepoint.cc | 2 +-
3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc
index 89ecdfec6f3..be01df342bb 100644
--- a/gdbserver/regcache.cc
+++ b/gdbserver/regcache.cc
@@ -180,19 +180,19 @@ free_register_cache (struct regcache *regcache)
#endif

void
-regcache_cpy (struct regcache *dst, struct regcache *src)
+regcache::copy_from (regcache *src)
{
- gdb_assert (src != NULL && dst != NULL);
- gdb_assert (src->tdesc == dst->tdesc);
- gdb_assert (src != dst);
+ gdb_assert (src != nullptr);
+ gdb_assert (src->tdesc == this->tdesc);
+ gdb_assert (src != this);

- memcpy (dst->registers, src->registers, src->tdesc->registers_size);
+ memcpy (this->registers, src->registers, src->tdesc->registers_size);
#ifndef IN_PROCESS_AGENT
- if (dst->register_status != NULL && src->register_status != NULL)
- memcpy (dst->register_status, src->register_status,
+ if (this->register_status != nullptr && src->register_status != nullptr)
+ memcpy (this->register_status, src->register_status,
src->tdesc->reg_defs.size ());
#endif
- dst->registers_valid = src->registers_valid;
+ this->registers_valid = src->registers_valid;
}

/* Return a reference to the description of register N. */
diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h
index 7eae6cb724a..32b3a8dccfc 100644
--- a/gdbserver/regcache.h
+++ b/gdbserver/regcache.h
@@ -70,9 +70,10 @@ struct regcache : public reg_buffer_common

/* Fetch the registers from the target, if not done already. */
void fetch ();
-};

-void regcache_cpy (struct regcache *dst, struct regcache *src);
+ /* Copy the contents of SRC into this regcache. */
+ void copy_from (regcache *src);
+};

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

diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index 82bb74addd1..26003422a70 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -4802,7 +4802,7 @@ do_action_at_tracepoint (struct tracepoint_hit_ctx *ctx,
tregcache.initialize (context_regcache->tdesc, regspace + 1);

/* Copy the register data to the regblock. */
- regcache_cpy (&tregcache, context_regcache);
+ tregcache.copy_from (context_regcache);

#ifndef IN_PROCESS_AGENT
/* On some platforms, trap-based tracepoints will have the PC
--
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