From nobody Thu Dec 18 13:17:23 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1492707228171728.7161126435998; Thu, 20 Apr 2017 09:53:48 -0700 (PDT) Received: from localhost ([::1]:55108 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1FL0-0001u3-7n for importer@patchew.org; Thu, 20 Apr 2017 12:53:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d1F93-0008QH-BX for qemu-devel@nongnu.org; Thu, 20 Apr 2017 12:41:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d1F90-00087T-NA for qemu-devel@nongnu.org; Thu, 20 Apr 2017 12:41:25 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:36885) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d1F90-0007wI-Dx for qemu-devel@nongnu.org; Thu, 20 Apr 2017 12:41:22 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1d1F8z-0006zi-G3 for qemu-devel@nongnu.org; Thu, 20 Apr 2017 17:41:21 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 20 Apr 2017 17:41:07 +0100 Message-Id: <1492706470-10921-22-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492706470-10921-1-git-send-email-peter.maydell@linaro.org> References: <1492706470-10921-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 21/24] arm: Abstract out "are we singlestepping" test to utility function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 We now test for "are we singlestepping" in several places and it's not a trivial check because we need to care about both architectural singlestep and QEMU gdbstub singlestep. We're also about to add another place that needs to make this check, so pull the condition out into a function. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 1491844419-12485-7-git-send-email-peter.maydell@linaro.org --- target/arm/translate.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index 87fd702..f28c4ca 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -309,6 +309,17 @@ static void gen_singlestep_exception(DisasContext *s) } } =20 +static inline bool is_singlestepping(DisasContext *s) +{ + /* Return true if we are singlestepping either because of + * architectural singlestep or QEMU gdbstub singlestep. This does + * not include the command line '-singlestep' mode which is rather + * misnamed as it only means "one instruction per TB" and doesn't + * affect the code we generate. + */ + return s->singlestep_enabled || s->ss_active; +} + static void gen_smul_dual(TCGv_i32 a, TCGv_i32 b) { TCGv_i32 tmp1 =3D tcg_temp_new_i32(); @@ -4104,7 +4115,7 @@ static inline void gen_goto_tb(DisasContext *s, int n= , target_ulong dest) =20 static inline void gen_jmp (DisasContext *s, uint32_t dest) { - if (unlikely(s->singlestep_enabled || s->ss_active)) { + if (unlikely(is_singlestepping(s))) { /* An indirect jump so that we still trigger the debug exception. = */ if (s->thumb) dest |=3D 1; @@ -11970,9 +11981,8 @@ void gen_intermediate_code(CPUARMState *env, Transl= ationBlock *tb) ((dc->pc >=3D next_page_start - 3) && insn_crosses_page(env, d= c)); =20 } while (!dc->is_jmp && !tcg_op_buf_full() && - !cs->singlestep_enabled && + !is_singlestepping(dc) && !singlestep && - !dc->ss_active && !end_of_page && num_insns < max_insns); =20 @@ -11989,7 +11999,7 @@ void gen_intermediate_code(CPUARMState *env, Transl= ationBlock *tb) instruction was a conditional branch or trap, and the PC has already been written. */ gen_set_condexec(dc); - if (unlikely(cs->singlestep_enabled || dc->ss_active)) { + if (unlikely(is_singlestepping(dc))) { /* Unconditional and "condition passed" instruction codepath. */ switch (dc->is_jmp) { case DISAS_SWI: @@ -12067,7 +12077,7 @@ void gen_intermediate_code(CPUARMState *env, Transl= ationBlock *tb) /* "Condition failed" instruction codepath for the branch/trap ins= n */ gen_set_label(dc->condlabel); gen_set_condexec(dc); - if (unlikely(cs->singlestep_enabled || dc->ss_active)) { + if (unlikely(is_singlestepping(dc))) { gen_set_pc_im(dc, dc->pc); gen_singlestep_exception(dc); } else { --=20 2.7.4