From patchwork Sun Apr 25 18:01: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: 50947 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 C0237B7D1D for ; Mon, 26 Apr 2010 04:02:42 +1000 (EST) Received: from localhost ([127.0.0.1]:59362 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O66AA-00044G-Qc for incoming@patchwork.ozlabs.org; Sun, 25 Apr 2010 14:02:38 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O669X-000448-Lj for qemu-devel@nongnu.org; Sun, 25 Apr 2010 14:01:59 -0400 Received: from [140.186.70.92] (port=34379 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O669T-00042X-5c for qemu-devel@nongnu.org; Sun, 25 Apr 2010 14:01:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O669R-0005Dd-UR for qemu-devel@nongnu.org; Sun, 25 Apr 2010 14:01:54 -0400 Received: from mail-pv0-f173.google.com ([74.125.83.173]:40678) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O669R-0005DX-Ok for qemu-devel@nongnu.org; Sun, 25 Apr 2010 14:01:53 -0400 Received: by pvg4 with SMTP id 4so206265pvg.4 for ; Sun, 25 Apr 2010 11:01:52 -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; bh=e0cKN2kBDmu9hK31yVrpfsEu8aYeYd8gy+cn2ukp778=; b=EEJQeUFjNGzXEqMmIkb6+1ognAGQqo+R7DfzNtbzv9l1o1vdQjSTY2Axi0S8p5httO ScXPPJ7RdMdYimZdqHSTgkFFd031AJHZoUw0noLmDmkHWnce3JDOIvuSM40iEUwQ6A/x Onux4dRTNHmpkQlhA7vFVxI30OYodwdmq2dZU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer; b=RFRfOnLmy+P3UEJTW/Cr4q4buu3Rf+sUv7dymrr3C/r3Ns/qjueFdR1aUF2chsyilE Lg3JXmGhzeXVwcjhR13BvOONHJftvEt7cfcSrcOzEMxscurL9nls7nGAleYk1OAZ9L8i oW5CGImfsaYwRSGtAiFvX8mb+XF/aZhqXlFis= Received: by 10.115.117.38 with SMTP id u38mr2930971wam.168.1272218512625; Sun, 25 Apr 2010 11:01:52 -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 b6sm16642335wam.21.2010.04.25.11.01.49 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 25 Apr 2010 11:01:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 25 Apr 2010 11:01:24 -0700 Message-Id: <1272218485-12465-1-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.6.6.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: blauwirbel@gmail.com Subject: [Qemu-devel] [PATCH 1/2] 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 | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/target-sparc/translate.c b/target-sparc/translate.c index b54c520..5162b87 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -81,6 +81,7 @@ typedef struct DisasContext { int address_mask_32bit; uint32_t cc_op; /* current CC operation */ struct TranslationBlock *tb; + CPUState *env; sparc_def_t *def; } DisasContext; @@ -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->env->singlestep_enabled || singlestep)) { /* jump to same page: we can use a direct jump */ tcg_gen_goto_tb(tb_num); tcg_gen_movi_tl(cpu_pc, pc); @@ -4680,6 +4682,7 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb, memset(dc, 0, sizeof(DisasContext)); dc->tb = tb; + dc->env = env; pc_start = tb->pc; dc->pc = pc_start; last_pc = dc->pc; @@ -4755,8 +4758,6 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb, /* 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); break; } } while ((gen_opc_ptr < gen_opc_end) &&