Skip to content

Commit

Permalink
Revert "gdbstub: Simplify find_cpu()"
Browse files Browse the repository at this point in the history
This reverts commit c52a6b6, which
replaced cpu_index() with cpu_index field, leading to deviation from
thread ID for NTPL and off-by-one otherwise.

Reported-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
  • Loading branch information
afaerber committed Jul 9, 2013
1 parent 071b336 commit aa48dd9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions gdbstub.c
Original file line number Diff line number Diff line change
Expand Up @@ -2071,13 +2071,17 @@ static void gdb_set_cpu_pc(GDBState *s, target_ulong pc)

static CPUArchState *find_cpu(uint32_t thread_id)
{
CPUArchState *env;
CPUState *cpu;

cpu = qemu_get_cpu(thread_id);
if (cpu == NULL) {
return NULL;
for (env = first_cpu; env != NULL; env = env->next_cpu) {
cpu = ENV_GET_CPU(env);
if (cpu_index(cpu) == thread_id) {
return env;
}
}
return cpu->env_ptr;

return NULL;
}

static int gdb_handle_packet(GDBState *s, const char *line_buf)
Expand Down

0 comments on commit aa48dd9

Please sign in to comment.