From: Tankut Baris Aktemur Date: Tue, 17 Dec 2024 07:48:03 +0000 (+0100) Subject: gdbserver: convert regcache_cpy into regcache::copy_from X-Git-Tag: gdb-16-branchpoint~75 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ccdddcac51d41d4c2adaf79d5db4d0eefa5a682b;p=thirdparty%2Fbinutils-gdb.git gdbserver: convert regcache_cpy into regcache::copy_from Convert the free `regcache_cpy` function to a method of the regcache struct. Approved-By: Simon Marchi --- diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc index 5ae922ec0be..583b5624333 100644 --- a/gdbserver/regcache.cc +++ b/gdbserver/regcache.cc @@ -178,19 +178,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 068f9e8df3d..db3b2425de6 100644 --- a/gdbserver/regcache.h +++ b/gdbserver/regcache.h @@ -60,14 +60,15 @@ struct regcache : public reg_buffer_common /* See gdbsupport/common-regcache.h. */ bool raw_compare (int regnum, const void *buf, int offset) const override; + + /* Copy the contents of SRC into this regcache. */ + void copy_from (regcache *src); }; struct regcache *init_register_cache (struct regcache *regcache, const struct target_desc *tdesc, unsigned char *regbuf); -void regcache_cpy (struct regcache *dst, struct regcache *src); - /* Create a new register cache for INFERIOR. */ struct regcache *new_register_cache (const struct target_desc *tdesc); diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc index 6b5541b5fbf..81104b02c83 100644 --- a/gdbserver/tracepoint.cc +++ b/gdbserver/tracepoint.cc @@ -4797,7 +4797,7 @@ do_action_at_tracepoint (struct tracepoint_hit_ctx *ctx, 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