From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33146) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UwvTU-0008By-Vw for qemu-devel@nongnu.org; Wed, 10 Jul 2013 10:34:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UwvTT-0003YA-Pb for qemu-devel@nongnu.org; Wed, 10 Jul 2013 10:34:32 -0400 Received: from cantor2.suse.de ([195.135.220.15]:60932 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UwvTT-0003Xr-Hk for qemu-devel@nongnu.org; Wed, 10 Jul 2013 10:34:31 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C7A54A51BB for ; Wed, 10 Jul 2013 16:34:30 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Wed, 10 Jul 2013 16:33:39 +0200 Message-Id: <1373466860-32732-3-git-send-email-afaerber@suse.de> In-Reply-To: <1373466860-32732-1-git-send-email-afaerber@suse.de> References: <1373466860-32732-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 02/43] Revert "gdbstub: Simplify find_cpu()" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= This reverts commit c52a6b67c1d7c6fc9fb2e3ba988d7b978e1487d3, 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 Signed-off-by: Andreas F=C3=A4rber --- gdbstub.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 3101a43..9ae6576 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -2071,13 +2071,17 @@ static void gdb_set_cpu_pc(GDBState *s, target_ul= ong pc) =20 static CPUArchState *find_cpu(uint32_t thread_id) { + CPUArchState *env; CPUState *cpu; =20 - cpu =3D qemu_get_cpu(thread_id); - if (cpu =3D=3D NULL) { - return NULL; + for (env =3D first_cpu; env !=3D NULL; env =3D env->next_cpu) { + cpu =3D ENV_GET_CPU(env); + if (cpu_index(cpu) =3D=3D thread_id) { + return env; + } } - return cpu->env_ptr; + + return NULL; } =20 static int gdb_handle_packet(GDBState *s, const char *line_buf) --=20 1.8.1.4