From patchwork Sun Jun 16 15:57:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 251694 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 63DDC2C00B1 for ; Mon, 17 Jun 2013 01:58:44 +1000 (EST) Received: from localhost ([::1]:34373 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UoFLm-0006qc-9f for incoming@patchwork.ozlabs.org; Sun, 16 Jun 2013 11:58:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UoFL9-0006kf-DW for qemu-devel@nongnu.org; Sun, 16 Jun 2013 11:58:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UoFL8-0006je-Bi for qemu-devel@nongnu.org; Sun, 16 Jun 2013 11:58:03 -0400 Received: from cantor2.suse.de ([195.135.220.15]:59948 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UoFL8-0006jN-6A for qemu-devel@nongnu.org; Sun, 16 Jun 2013 11:58:02 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9D35AA50DD for ; Sun, 16 Jun 2013 17:58:01 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Sun, 16 Jun 2013 17:57:23 +0200 Message-Id: <1371398269-6213-4-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1371398269-6213-1-git-send-email-afaerber@suse.de> References: <1371398269-6213-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH qom-cpu v2 03/29] gdbstub: Simplify find_cpu() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use qemu_get_cpu() and CPUState::env_ptr. Signed-off-by: Andreas Färber Reviewed-by: Richard Henderson --- gdbstub.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index bbae06d..663549c 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)