diff mbox

[2/4] gdbserver: _fork: Change fn to accept cpu instead of env

Message ID 08ddb7bd6de0b2ffa95f5d4e7b9e0082746e427e.1432534114.git.crosthwaite.peter@gmail.com
State New
Headers show

Commit Message

Peter Crosthwaite May 25, 2015, 6:22 a.m. UTC
All callsites to this function navigate the cpu->env_ptr only for the
function to take the env ptr back to the original cpu ptr. Change the
function to just pass in the CPU pointer instead. Removes a core code
usage of ENV_GET_CPU (in gdbstub.c).

Cc: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---
 bsd-user/main.c        | 2 +-
 gdbstub.c              | 3 +--
 include/exec/gdbstub.h | 2 +-
 linux-user/main.c      | 2 +-
 4 files changed, 4 insertions(+), 5 deletions(-)

Comments

Andreas Färber June 5, 2015, 2:44 p.m. UTC | #1
Am 25.05.2015 um 15:22 schrieb Peter Crosthwaite:
> All callsites to this function navigate the cpu->env_ptr only for the
> function to take the env ptr back to the original cpu ptr. Change the
> function to just pass in the CPU pointer instead. Removes a core code
> usage of ENV_GET_CPU (in gdbstub.c).
> 
> Cc: Riku Voipio <riku.voipio@iki.fi>
> Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
> ---
>  bsd-user/main.c        | 2 +-
>  gdbstub.c              | 3 +--
>  include/exec/gdbstub.h | 2 +-
>  linux-user/main.c      | 2 +-
>  4 files changed, 4 insertions(+), 5 deletions(-)

Great,

Reviewed-by: Andreas Färber <afaerber@suse.de>

Thanks,
Andreas
diff mbox

Patch

diff --git a/bsd-user/main.c b/bsd-user/main.c
index 5bfaf5c..1800b02 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -92,7 +92,7 @@  void fork_start(void)
 void fork_end(int child)
 {
     if (child) {
-        gdbserver_fork((CPUArchState *)thread_cpu->env_ptr);
+        gdbserver_fork(thread_cpu);
     }
 }
 
diff --git a/gdbstub.c b/gdbstub.c
index c1e9321..d37943a 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1613,9 +1613,8 @@  int gdbserver_start(int port)
 }
 
 /* Disable gdb stub for child processes.  */
-void gdbserver_fork(CPUArchState *env)
+void gdbserver_fork(CPUState *cpu)
 {
-    CPUState *cpu = ENV_GET_CPU(env);
     GDBState *s = gdbserver_state;
 
     if (gdbserver_fd < 0 || s->fd < 0) {
diff --git a/include/exec/gdbstub.h b/include/exec/gdbstub.h
index c633248..ab7ac33 100644
--- a/include/exec/gdbstub.h
+++ b/include/exec/gdbstub.h
@@ -22,7 +22,7 @@  void gdb_exit(CPUArchState *, int);
 int gdb_queuesig (void);
 int gdb_handlesig(CPUState *, int);
 void gdb_signalled(CPUArchState *, int);
-void gdbserver_fork(CPUArchState *);
+void gdbserver_fork(CPUState *);
 #endif
 /* Get or set a register.  Returns the size of the register.  */
 typedef int (*gdb_reg_cb)(CPUArchState *env, uint8_t *buf, int reg);
diff --git a/linux-user/main.c b/linux-user/main.c
index 3f32db0..48eff88 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -130,7 +130,7 @@  void fork_end(int child)
         pthread_cond_init(&exclusive_cond, NULL);
         pthread_cond_init(&exclusive_resume, NULL);
         pthread_mutex_init(&tcg_ctx.tb_ctx.tb_lock, NULL);
-        gdbserver_fork((CPUArchState *)thread_cpu->env_ptr);
+        gdbserver_fork(thread_cpu);
     } else {
         pthread_mutex_unlock(&exclusive_lock);
         pthread_mutex_unlock(&tcg_ctx.tb_ctx.tb_lock);