Received: from eggs.gnu.org ([208.118.235.92]:57001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TduuA-0005qh-E7 for qemu-devel@nongnu.org; Wed, 28 Nov 2012 22:35:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tduu9-0001A7-F1 for qemu-devel@nongnu.org; Wed, 28 Nov 2012 22:35:14 -0500 Received: from [222.73.24.84] (port=29128 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tduu9-00018F-62 for qemu-devel@nongnu.org; Wed, 28 Nov 2012 22:35:13 -0500 From: liguang Date: Thu, 29 Nov 2012 11:32:51 +0800 Message-Id: <1354159971-6720-3-git-send-email-lig.fnst@cn.fujitsu.com> In-Reply-To: <1354159971-6720-1-git-send-email-lig.fnst@cn.fujitsu.com> References: <1354159971-6720-1-git-send-email-lig.fnst@cn.fujitsu.com> Subject: [Qemu-devel] [PATCH 3/3] target-i386:refactor check_hw_breakpoints function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: ehabkost@redhat.com, imammedo@redhat.com, afaerber@suse.de, qemu-devel@nongnu.org Cc: liguang Signed-off-by: liguang --- target-i386/helper.c | 28 ++++++++++++++++++++-------- 1 files changed, 20 insertions(+), 8 deletions(-) diff --git a/target-i386/helper.c b/target-i386/helper.c index 9ca52a7..a506df0 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -1012,22 +1012,34 @@ void hw_breakpoint_remove(CPUX86State *env, int index) int check_hw_breakpoints(CPUX86State *env, int force_dr6_update) { target_ulong dr6; - int reg, type; + int index; int hit_enabled = 0; dr6 = env->dr[6] & ~0xf; - for (reg = 0; reg < MAX_BP; reg++) { - type = hw_breakpoint_type(env->dr[7], reg); - if ((type == 0 && env->dr[reg] == env->eip) || - ((type & 1) && env->cpu_watchpoint[reg] && - (env->cpu_watchpoint[reg]->flags & BP_WATCHPOINT_HIT))) { - dr6 |= 1 << reg; - if (hw_breakpoint_enabled(env->dr[7], reg)) + for (index = 0; index < MAX_BP; index++) { + switch (hw_breakpoint_type(env->dr[7], index)){ + case BP_INST: + if (env->dr[index] != env->eip) + break; + goto enable_hit; + case BP_DATA_WR: + case BP_DATA_RW: + if (!env->cpu_watchpoint[index]) + break; + if (!(env->cpu_watchpoint[index]->flags & BP_WATCHPOINT_HIT)) + break; + enable_hit: + dr6 |= 1 << index; + if (hw_breakpoint_enabled(env->dr[7], index)) hit_enabled = 1; + break; + case BP_IO_RW: + break; } } if (hit_enabled || force_dr6_update) env->dr[6] = dr6; + return hit_enabled; } -- 1.7.2.5