Convert the `new_register_cache` function into a constructor of the
regcache struct. Also define a default ctor because it is used in
other places, in particular, tracepoint.cc.
---
gdbserver/regcache.cc | 11 +++--------
gdbserver/regcache.h | 8 ++++----
gdbserver/server.cc | 2 +-
3 files changed, 8 insertions(+), 13 deletions(-)
@@ -43,7 +43,7 @@ get_thread_regcache (struct thread_info *thread, int fetch)
gdb_assert (proc->tdesc != NULL);
- regcache = new_register_cache (proc->tdesc);
+ regcache = new struct regcache (proc->tdesc);
set_thread_regcache_data (thread, regcache);
}
@@ -151,15 +151,10 @@ regcache::initialize (const target_desc *tdesc,
#ifndef IN_PROCESS_AGENT
-struct regcache *
-new_register_cache (const struct target_desc *tdesc)
+regcache::regcache (const target_desc *tdesc)
{
- struct regcache *regcache = new struct regcache;
-
gdb_assert (tdesc->registers_size != 0);
- regcache->initialize (tdesc, nullptr);
-
- return regcache;
+ initialize (tdesc, nullptr);
}
void
@@ -44,6 +44,10 @@ struct regcache : public reg_buffer_common
#ifndef IN_PROCESS_AGENT
/* One of REG_UNAVAILABLE or REG_VALID. */
unsigned char *register_status = nullptr;
+
+ /* Constructors. */
+ regcache () = default;
+ regcache (const target_desc *tdesc);
#endif
/* Init the regcache data. */
@@ -64,10 +68,6 @@ struct regcache : public reg_buffer_common
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);
-
struct regcache *get_thread_regcache (struct thread_info *thread, int fetch);
/* Release all memory associated with the register cache for INFERIOR. */
@@ -4238,7 +4238,7 @@ process_serial_event (void)
if (cs.current_traceframe >= 0)
{
struct regcache *regcache
- = new_register_cache (current_target_desc ());
+ = new struct regcache (current_target_desc ());
if (fetch_traceframe_registers (cs.current_traceframe,
regcache, -1) == 0)