Patchwork [RFC,qom-cpu,32/41] gdbstub: Change gdb_{read, write}_register() argument to CPUState

login
register
mail settings
Submitter Andreas Färber
Date June 29, 2013, 8:01 p.m.
Message ID <1372536117-28167-33-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/255785/
State New
Headers show

Comments

Andreas Färber - June 29, 2013, 8:01 p.m.
Use CPUState::env_ptr for now.

Prepares for changing GDBState::g_cpu to CPUState.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 gdbstub.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

Patch

diff --git a/gdbstub.c b/gdbstub.c
index a8fafe2..cee9c13 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1866,8 +1866,9 @@  static const char *get_feature_xml(const char *p, const char **newp)
 }
 #endif
 
-static int gdb_read_register(CPUArchState *env, uint8_t *mem_buf, int reg)
+static int gdb_read_register(CPUState *cpu, uint8_t *mem_buf, int reg)
 {
+    CPUArchState *env = cpu->env_ptr;
     GDBRegisterState *r;
 
     if (reg < NUM_CORE_REGS)
@@ -1881,8 +1882,9 @@  static int gdb_read_register(CPUArchState *env, uint8_t *mem_buf, int reg)
     return 0;
 }
 
-static int gdb_write_register(CPUArchState *env, uint8_t *mem_buf, int reg)
+static int gdb_write_register(CPUState *cpu, uint8_t *mem_buf, int reg)
 {
+    CPUArchState *env = cpu->env_ptr;
     GDBRegisterState *r;
 
     if (reg < NUM_CORE_REGS)
@@ -2210,7 +2212,8 @@  static int gdb_handle_packet(GDBState *s, const char *line_buf)
 #endif
         len = 0;
         for (addr = 0; addr < num_g_regs; addr++) {
-            reg_size = gdb_read_register(s->g_cpu, mem_buf + len, addr);
+            reg_size = gdb_read_register(ENV_GET_CPU(s->g_cpu),
+                                         mem_buf + len, addr);
             len += reg_size;
         }
         memtohex(buf, mem_buf, len);
@@ -2225,7 +2228,8 @@  static int gdb_handle_packet(GDBState *s, const char *line_buf)
         len = strlen(p) / 2;
         hextomem((uint8_t *)registers, p, len);
         for (addr = 0; addr < num_g_regs && len > 0; addr++) {
-            reg_size = gdb_write_register(s->g_cpu, registers, addr);
+            reg_size = gdb_write_register(ENV_GET_CPU(s->g_cpu), registers,
+                                          addr);
             len -= reg_size;
             registers += reg_size;
         }
@@ -2264,7 +2268,7 @@  static int gdb_handle_packet(GDBState *s, const char *line_buf)
         if (!gdb_has_xml)
             goto unknown_command;
         addr = strtoull(p, (char **)&p, 16);
-        reg_size = gdb_read_register(s->g_cpu, mem_buf, addr);
+        reg_size = gdb_read_register(ENV_GET_CPU(s->g_cpu), mem_buf, addr);
         if (reg_size) {
             memtohex(buf, mem_buf, reg_size);
             put_packet(s, buf);
@@ -2280,7 +2284,7 @@  static int gdb_handle_packet(GDBState *s, const char *line_buf)
             p++;
         reg_size = strlen(p) / 2;
         hextomem(mem_buf, p, reg_size);
-        gdb_write_register(s->g_cpu, mem_buf, addr);
+        gdb_write_register(ENV_GET_CPU(s->g_cpu), mem_buf, addr);
         put_packet(s, "OK");
         break;
     case 'Z':