From patchwork Mon Apr 26 17:17:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 50981 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F1EEAB7D2D for ; Tue, 27 Apr 2010 03:25:27 +1000 (EST) Received: from localhost ([127.0.0.1]:39812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O6Rxl-0005JW-19 for incoming@patchwork.ozlabs.org; Mon, 26 Apr 2010 13:19:17 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O6RwO-0005JI-2z for qemu-devel@nongnu.org; Mon, 26 Apr 2010 13:17:52 -0400 Received: from [140.186.70.92] (port=58724 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O6RwM-0005J7-Mg for qemu-devel@nongnu.org; Mon, 26 Apr 2010 13:17:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O6RwL-0006u9-5y for qemu-devel@nongnu.org; Mon, 26 Apr 2010 13:17:50 -0400 Received: from mail-pw0-f45.google.com ([209.85.160.45]:43646) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O6RwL-0006tu-0k for qemu-devel@nongnu.org; Mon, 26 Apr 2010 13:17:49 -0400 Received: by pwi6 with SMTP id 6so7824462pwi.4 for ; Mon, 26 Apr 2010 10:17:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:from:to:cc:subject :date:message-id:x-mailer:in-reply-to:references; bh=ROCVQyJ0lPmShsTFzW/2ZYs9YGU03eLx3Dtvrjt8KjQ=; b=eQlULJf1D9vggoGKGSY0AXCAn+SdpANJG87fBGlNRl2kR0atWUBp+rNrLYPFiuTxGa swg02S9iyB85lwFrkoT/gEq/ZmRzV1mvGlzKdhaCTqgn7v/QXgwuYdj6awdG/k6aiinE Gj/gypPEBf8XhkW90UO3FGoHWaAHO5us5k3o4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; b=Qx2CTPyXT7oShosPLv4gzSg14tIucX2tw+LKcwnCK6nwKbgUhCixrdzAjVdHitKEts F0wN3TxIl0BdDytBApCRIuFNkuyXnloJQ7lWimKJEkLNoWvTHpAgaXqFv4U+/xQ1Q1Sx /VUgWI9MscwvCHNVG4opA9FlfcBrweOatPujw= Received: by 10.115.113.22 with SMTP id q22mr4780398wam.62.1272302265409; Mon, 26 Apr 2010 10:17:45 -0700 (PDT) Received: from localhost.localdomain (cpe-98-150-193-136.hawaii.res.rr.com [98.150.193.136]) by mx.google.com with ESMTPS id v13sm21664003wav.2.2010.04.26.10.17.42 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 26 Apr 2010 10:17:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 26 Apr 2010 10:17:24 -0700 Message-Id: <1272302244-7501-1-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.6.6.1 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: Blue Swirl Subject: [Qemu-devel] [PATCH] target-sparc: Fix -singlestep. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Single-stepping was not properly updating npc, resulting in some instructions being executed twice. In addition, we were emitting dead code at the end of the TB. Fix both by teaching gen_goto_tb to avoid goto_tb for single-step and removing the special-case code in gen_intermediate_code_internal. Signed-off-by: Richard Henderson --- target-sparc/translate.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/target-sparc/translate.c b/target-sparc/translate.c index b54c520..be2a116 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -79,6 +79,7 @@ typedef struct DisasContext { int mem_idx; int fpu_enabled; int address_mask_32bit; + int singlestep; uint32_t cc_op; /* current CC operation */ struct TranslationBlock *tb; sparc_def_t *def; @@ -234,7 +235,8 @@ static inline void gen_goto_tb(DisasContext *s, int tb_num, tb = s->tb; if ((pc & TARGET_PAGE_MASK) == (tb->pc & TARGET_PAGE_MASK) && - (npc & TARGET_PAGE_MASK) == (tb->pc & TARGET_PAGE_MASK)) { + (npc & TARGET_PAGE_MASK) == (tb->pc & TARGET_PAGE_MASK) && + !s->singlestep) { /* jump to same page: we can use a direct jump */ tcg_gen_goto_tb(tb_num); tcg_gen_movi_tl(cpu_pc, pc); @@ -4694,6 +4696,7 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb, #ifdef TARGET_SPARC64 dc->address_mask_32bit = env->pstate & PS_AM; #endif + dc->singlestep = (env->singlestep_enabled || singlestep); gen_opc_end = gen_opc_buf + OPC_MAX_SIZE; cpu_tmp0 = tcg_temp_new(); @@ -4754,9 +4757,7 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb, break; /* if single step mode, we generate only one instruction and generate an exception */ - if (env->singlestep_enabled || singlestep) { - tcg_gen_movi_tl(cpu_pc, dc->pc); - tcg_gen_exit_tb(0); + if (dc->singlestep) { break; } } while ((gen_opc_ptr < gen_opc_end) &&