From 6ef881d2acc0165f441eb86f5067bcf903679258 Mon Sep 17 00:00:00 2001 Message-Id: <6ef881d2acc0165f441eb86f5067bcf903679258.1349774431.git.minovotn@redhat.com> In-Reply-To: References: From: Luiz Capitulino Date: Fri, 5 Oct 2012 17:46:26 +0200 Subject: [PATCH 14/21] make gdb_id() generally avialable and rename it to cpu_index() RH-Author: Luiz Capitulino Message-id: <1349459193-18226-13-git-send-email-lcapitulino@redhat.com> Patchwork-id: 42760 O-Subject: [RHEL6.4 qemu-kvm PATCH 12/19] make gdb_id() generally avialable and rename it to cpu_index() Bugzilla: 832458 RH-Acked-by: Marcelo Tosatti RH-Acked-by: Markus Armbruster RH-Acked-by: Paolo Bonzini From: Wen Congyang The following patch also needs this API, so make it generally avialable. The function gdb_id() will not be used in gdbstub.c now, so its name is not suitable, and rename it to cpu_index() Signed-off-by: Wen Congyang Signed-off-by: Luiz Capitulino (cherry picked from commit 68f4730c714b7c30ca912d7c03e199f181739da0) Conflicts: gdbstub.c gdbstub.h Signed-off-by: Luiz Capitulino --- gdbstub.c | 19 +++++-------------- gdbstub.h | 9 +++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) Signed-off-by: Michal Novotny --- gdbstub.c | 19 +++++-------------- gdbstub.h | 9 +++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 9c55403..7f1e361 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1672,21 +1672,12 @@ static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) #endif } -static inline int gdb_id(CPUState *env) -{ -#if defined(CONFIG_USER_ONLY) && defined(CONFIG_USE_NPTL) - return env->host_tid; -#else - return env->cpu_index + 1; -#endif -} - static CPUState *find_cpu(uint32_t thread_id) { CPUState *env; for (env = first_cpu; env != NULL; env = env->next_cpu) { - if (gdb_id(env) == thread_id) { + if (cpu_index(env) == thread_id) { return env; } } @@ -1714,7 +1705,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) case '?': /* TODO: Make this return the correct value for user-mode. */ snprintf(buf, sizeof(buf), "T%02xthread:%02x;", GDB_SIGNAL_TRAP, - gdb_id(s->c_cpu)); + cpu_index(s->c_cpu)); put_packet(s, buf); /* Remove all the breakpoints when this query is issued, * because gdb is doing and initial connect and the state @@ -2001,7 +1992,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf) } else if (strcmp(p,"sThreadInfo") == 0) { report_cpuinfo: if (s->query_cpu) { - snprintf(buf, sizeof(buf), "m%x", gdb_id(s->query_cpu)); + snprintf(buf, sizeof(buf), "m%x", cpu_index(s->query_cpu)); put_packet(s, buf); s->query_cpu = s->query_cpu->next_cpu; } else @@ -2147,7 +2138,7 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) } snprintf(buf, sizeof(buf), "T%02xthread:%02x;%swatch:" TARGET_FMT_lx ";", - GDB_SIGNAL_TRAP, gdb_id(env), type, + GDB_SIGNAL_TRAP, cpu_index(env), type, env->watchpoint_hit->vaddr); put_packet(s, buf); env->watchpoint_hit = NULL; @@ -2158,7 +2149,7 @@ static void gdb_vm_state_change(void *opaque, int running, RunState state) } else { ret = GDB_SIGNAL_INT; } - snprintf(buf, sizeof(buf), "T%02xthread:%02x;", ret, gdb_id(env)); + snprintf(buf, sizeof(buf), "T%02xthread:%02x;", ret, cpu_index(env)); put_packet(s, buf); } #endif diff --git a/gdbstub.h b/gdbstub.h index 5740041..7b20e8e 100644 --- a/gdbstub.h +++ b/gdbstub.h @@ -32,4 +32,13 @@ void gdb_register_coprocessor(CPUState *env, gdb_reg_cb get_reg, gdb_reg_cb set_reg, int num_regs, const char *xml, int g_pos); +static inline int cpu_index(CPUArchState *env) +{ +#if defined(CONFIG_USER_ONLY) && defined(CONFIG_USE_NPTL) + return env->host_tid; +#else + return env->cpu_index + 1; +#endif +} + #endif -- 1.7.11.4