Patchwork [qom-cpu,12/59] gdbstub: Simplify find_cpu()

login
register
mail settings
Submitter Andreas Färber
Date June 9, 2013, 7:12 p.m.
Message ID <1370805206-26574-13-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/250136/
State New
Headers show

Comments

Andreas Färber - June 9, 2013, 7:12 p.m.
Use qemu_get_cpu() and CPUState::env_ptr.

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

Patch

diff --git a/gdbstub.c b/gdbstub.c
index fb6c6a5..92ecdcb 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -2068,17 +2068,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)