From: Andreas Färber Date: Fri, 17 May 2013 15:49:10 +0000 (+0200) Subject: gdbstub: Simplify find_cpu() X-Git-Tag: v1.6.0-rc0~173^2~17 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=c52a6b67c1d7c6fc9fb2e3ba988d7b978e1487d3;p=qemu.git gdbstub: Simplify find_cpu() Use qemu_get_cpu() and CPUState::env_ptr. Reviewed-by: Richard Henderson Signed-off-by: Andreas Färber --- diff --git a/gdbstub.c b/gdbstub.c index 94c78ced5..9ffb376eb 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2071,17 +2071,13 @@ static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) static CPUArchState *find_cpu(uint32_t thread_id) { - CPUArchState *env; CPUState *cpu; - for (env = first_cpu; env != NULL; env = env->next_cpu) { - cpu = ENV_GET_CPU(env); - if (cpu_index(cpu) == thread_id) { - return env; - } + cpu = qemu_get_cpu(thread_id); + if (cpu == NULL) { + return NULL; } - - return NULL; + return cpu->env_ptr; } static int gdb_handle_packet(GDBState *s, const char *line_buf)