Skip to content

Commit

Permalink
gdbstub: Change gdbserver_fork() to accept cpu instead of env
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
  • Loading branch information
pcrost authored and afaerber committed Jul 9, 2015
1 parent bbd77c1 commit f7ec7f7
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bsd-user/main.c
Expand Up @@ -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);
}
}

Expand Down
3 changes: 1 addition & 2 deletions gdbstub.c
Expand Up @@ -1629,9 +1629,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) {
Expand Down
2 changes: 1 addition & 1 deletion include/exec/gdbstub.h
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion linux-user/main.c
Expand Up @@ -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);
Expand Down

0 comments on commit f7ec7f7

Please sign in to comment.