Received: from eggs.gnu.org ([208.118.235.92]:43699) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tv1uP-0002pp-FA for qemu-devel@nongnu.org; Tue, 15 Jan 2013 03:30:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tv1uO-00015A-49 for qemu-devel@nongnu.org; Tue, 15 Jan 2013 03:30:13 -0500 Received: from cantor2.suse.de ([195.135.220.15]:38332 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tv1uN-00014w-Qn for qemu-devel@nongnu.org; Tue, 15 Jan 2013 03:30:12 -0500 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 15 Jan 2013 09:29:56 +0100 Message-Id: <1358238598-31451-3-git-send-email-afaerber@suse.de> In-Reply-To: <1358238598-31451-1-git-send-email-afaerber@suse.de> References: <1358238598-31451-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH qom-cpu v6 2/4] target-i386: Introduce hw_{local, global}_breakpoint_enabled() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , lig.fnst@cn.fujitsu.com From: liguang hw_breakpoint_enabled() returned a bit field indicating whether a local breakpoint and/or global breakpoint was enabled. Avoid this number magic by using explicit boolean helper functions hw_local_breakpoint_enabled() and hw_global_breakpoint_enabled(), to aid readability. Reuse them for the hw_breakpoint_enabled() implementation and change its return type to bool. While at it, fix Coding Style issues (missing braces). Signed-off-by: liguang Signed-off-by: Andreas F=C3=A4rber --- target-i386/cpu.h | 15 +++++++++++++-- target-i386/helper.c | 9 ++++++--- target-i386/seg_helper.c | 3 ++- 3 Dateien ge=C3=A4ndert, 21 Zeilen hinzugef=C3=BCgt(+), 6 Zeilen entfern= t(-) diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 6682022..1e850a7 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -1014,9 +1014,20 @@ int cpu_x86_handle_mmu_fault(CPUX86State *env, tar= get_ulong addr, #define cpu_handle_mmu_fault cpu_x86_handle_mmu_fault void cpu_x86_set_a20(CPUX86State *env, int a20_state); =20 -static inline int hw_breakpoint_enabled(unsigned long dr7, int index) +static inline bool hw_local_breakpoint_enabled(unsigned long dr7, int in= dex) { - return (dr7 >> (index * 2)) & 3; + return (dr7 >> (index * 2)) & 1; +} + +static inline bool hw_global_breakpoint_enabled(unsigned long dr7, int i= ndex) +{ + return (dr7 >> (index * 2)) & 2; + +} +static inline bool hw_breakpoint_enabled(unsigned long dr7, int index) +{ + return hw_global_breakpoint_enabled(dr7, index) || + hw_local_breakpoint_enabled(dr7, index); } =20 static inline int hw_breakpoint_type(unsigned long dr7, int index) diff --git a/target-i386/helper.c b/target-i386/helper.c index 1fceb91..ebdd6a5 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -970,9 +970,10 @@ void hw_breakpoint_insert(CPUX86State *env, int inde= x) =20 switch (hw_breakpoint_type(env->dr[7], index)) { case DR7_TYPE_BP_INST: - if (hw_breakpoint_enabled(env->dr[7], index)) + if (hw_breakpoint_enabled(env->dr[7], index)) { err =3D cpu_breakpoint_insert(env, env->dr[index], BP_CPU, &env->cpu_breakpoint[index]); + } break; case DR7_TYPE_DATA_WR: type =3D BP_CPU | BP_MEM_WRITE; @@ -998,8 +999,9 @@ void hw_breakpoint_remove(CPUX86State *env, int index= ) return; switch (hw_breakpoint_type(env->dr[7], index)) { case DR7_TYPE_BP_INST: - if (hw_breakpoint_enabled(env->dr[7], index)) + if (hw_breakpoint_enabled(env->dr[7], index)) { cpu_breakpoint_remove_by_ref(env, env->cpu_breakpoint[index]= ); + } break; case DR7_TYPE_DATA_WR: case DR7_TYPE_DATA_RW: @@ -1024,8 +1026,9 @@ int check_hw_breakpoints(CPUX86State *env, int forc= e_dr6_update) ((type & 1) && env->cpu_watchpoint[reg] && (env->cpu_watchpoint[reg]->flags & BP_WATCHPOINT_HIT))) { dr6 |=3D 1 << reg; - if (hw_breakpoint_enabled(env->dr[7], reg)) + if (hw_breakpoint_enabled(env->dr[7], reg)) { hit_enabled =3D 1; + } } } if (hit_enabled || force_dr6_update) diff --git a/target-i386/seg_helper.c b/target-i386/seg_helper.c index c40bd96..3247dee 100644 --- a/target-i386/seg_helper.c +++ b/target-i386/seg_helper.c @@ -467,7 +467,8 @@ static void switch_tss(CPUX86State *env, int tss_sele= ctor, /* reset local breakpoints */ if (env->dr[7] & DR7_LOCAL_BP_MASK) { for (i =3D 0; i < DR7_MAX_BP; i++) { - if (hw_breakpoint_enabled(env->dr[7], i) =3D=3D 0x1) { + if (hw_local_breakpoint_enabled(env->dr[7], i) && + !hw_global_breakpoint_enabled(env->dr[7], i)) { hw_breakpoint_remove(env, i); } } --=20 1.7.10.4