From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O66Iz-0000J1-Bt for qemu-devel@nongnu.org; Sun, 25 Apr 2010 14:11:45 -0400 Received: from [140.186.70.92] (port=54403 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O66Ix-0000I6-6G for qemu-devel@nongnu.org; Sun, 25 Apr 2010 14:11:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O66Iv-0006Ji-JX for qemu-devel@nongnu.org; Sun, 25 Apr 2010 14:11:43 -0400 Received: from mail-pz0-f204.google.com ([209.85.222.204]:38838) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O66Iv-0006Ja-Cs for qemu-devel@nongnu.org; Sun, 25 Apr 2010 14:11:41 -0400 Received: by pzk42 with SMTP id 42so7490215pzk.4 for ; Sun, 25 Apr 2010 11:11:40 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1272218485-12465-1-git-send-email-rth@twiddle.net> References: <1272218485-12465-1-git-send-email-rth@twiddle.net> Date: Sun, 25 Apr 2010 21:11:40 +0300 Message-ID: From: Blue Swirl Content-Type: text/plain; charset=UTF-8 Subject: [Qemu-devel] Re: [PATCH 1/2] target-sparc: Fix -singlestep. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Richard Henderson Cc: qemu-devel@nongnu.org On 4/25/10, Richard Henderson wrote: > 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. Nice work! > 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; Instead of CPUState pointer, please create a flag which combines env->singlestep_enabled || singlestep. > 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) && > > -- > 1.6.6.1 > >