[PATCH 11/26] gdbserver: convert registers_from_string into regcache::registers_from_string

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

Convert the registers_from_string function into a method of the regcache
struct. Also constify the buffer argument.
---
gdbserver/regcache.cc | 4 +---
gdbserver/regcache.h | 7 +++----
gdbserver/server.cc | 2 +-
3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc
index 92dc6fc921c..156fda7068d 100644
--- a/gdbserver/regcache.cc
+++ b/gdbserver/regcache.cc
@@ -235,11 +235,9 @@ regcache::registers_to_string (char *buf)
}

void
-registers_from_string (struct regcache *regcache, char *buf)
+regcache::registers_from_string (const char *buf)
{
int len = strlen (buf);
- unsigned char *registers = regcache->registers;
- const struct target_desc *tdesc = regcache->tdesc;

if (len != tdesc->registers_size * 2)
{
diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h
index bed3151dcad..6aa03a70352 100644
--- a/gdbserver/regcache.h
+++ b/gdbserver/regcache.h
@@ -88,6 +88,9 @@ struct regcache : public reg_buffer_common
/* Convert all registers to a string in the currently specified remote
format. */
void registers_to_string (char *buf);
+
+ /* Convert a string to register values and fill our register cache. */
+ void registers_from_string (const char *buf);
};

regcache *get_thread_regcache (thread_info *thread, bool fetch = true);
@@ -110,10 +113,6 @@ void regcache_invalidate (void);

void regcache_release (void);

-/* Convert a string to register values and fill our register cache. */
-
-void registers_from_string (struct regcache *regcache, char *buf);
-
/* For regcache_read_pc see gdbsupport/common-regcache.h. */

void regcache_write_pc (struct regcache *regcache, CORE_ADDR pc);
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index f540cc86f7b..5e639d6ac57 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -4271,7 +4271,7 @@ process_serial_event (void)
else
{
regcache = get_thread_regcache (current_thread);
- registers_from_string (regcache, &cs.own_buf[1]);
+ regcache->registers_from_string (&cs.own_buf[1]);
write_ok (cs.own_buf);
}
}
--
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