From patchwork Tue Oct 17 13:11:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikhail Abakumov X-Patchwork-Id: 826992 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yGbXv1tNzz9s8J for ; Wed, 18 Oct 2017 00:25:35 +1100 (AEDT) Received: from localhost ([::1]:39235 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4RsD-0007Zr-AE for incoming@patchwork.ozlabs.org; Tue, 17 Oct 2017 09:25:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4Rez-0004zU-Tx for qemu-devel@nongnu.org; Tue, 17 Oct 2017 09:11:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4Rev-0006bC-SY for qemu-devel@nongnu.org; Tue, 17 Oct 2017 09:11:53 -0400 Received: from mail.ispras.ru ([83.149.199.45]:57142) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4Rev-0006aT-Jh for qemu-devel@nongnu.org; Tue, 17 Oct 2017 09:11:49 -0400 Received: from Misha-PC.lan02.inno (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id E398F54006C; Tue, 17 Oct 2017 16:11:48 +0300 (MSK) From: Mihail Abakumov To: qemu-devel@nongnu.org Date: Tue, 17 Oct 2017 16:11:46 +0300 Message-ID: <150824590636.6816.17152155223503474492.stgit@Misha-PC.lan02.inno> In-Reply-To: <150824572545.6816.5099701189660002212.stgit@Misha-PC.lan02.inno> References: <150824572545.6816.5099701189660002212.stgit@Misha-PC.lan02.inno> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [PATCH v2 31/43] windbg: implemented windbg_set_dr 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: , Cc: sw@weilnetz.de, lprosek@redhat.com, dovgaluk@ispras.ru, rkagan@virtuozzo.com, pbonzini@redhat.com, den@openvz.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Defined useful macros for breakpoints. Signed-off-by: Mihail Abakumov Signed-off-by: Pavel Dovgalyuk Signed-off-by: Dmitriy Koltunov --- target/i386/windbgstub.c | 50 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/target/i386/windbgstub.c b/target/i386/windbgstub.c index d67ad8cf0c..7dff5e6c1b 100755 --- a/target/i386/windbgstub.c +++ b/target/i386/windbgstub.c @@ -12,6 +12,21 @@ #include "qemu/osdep.h" #include "exec/windbgstub-utils.h" +#define IS_LOCAL_BP_ENABLED(dr7, index) (((dr7) >> ((index) * 2)) & 1) + +#define IS_GLOBAL_BP_ENABLED(dr7, index) (((dr7) >> ((index) * 2)) & 2) + +#define IS_BP_ENABLED(dr7, index) \ + (IS_LOCAL_BP_ENABLED(dr7, index) | IS_GLOBAL_BP_ENABLED(dr7, index)) + +#define BP_TYPE(dr7, index) \ + ((int) ((dr7) >> (DR7_TYPE_SHIFT + ((index) * 4))) & 3) + +#define BP_LEN(dr7, index) ({ \ + int _len = (((dr7) >> (DR7_LEN_SHIFT + ((index) * 4))) & 3); \ + (_len == 2) ? 8 : _len + 1; \ +}) + #ifdef TARGET_X86_64 # define OFFSET_SELF_PCR 0x18 # define OFFSET_VERS 0x108 @@ -271,9 +286,42 @@ typedef struct _CPU_KPROCESSOR_STATE { #endif -static void windbg_set_dr(CPUState *cpu, int index, target_ulong value) +static int windbg_hw_breakpoint_insert(CPUState *cpu, int index) +{ + return 0; +} + +static int windbg_hw_breakpoint_remove(CPUState *cpu, int index) +{ + return 0; +} + +static void windbg_set_dr7(CPUState *cpu, target_ulong new_dr7) {} +static void windbg_set_dr(CPUState *cpu, int index, target_ulong value) +{ + CPUArchState *env = cpu->env_ptr; + + switch (index) { + case 0 ... 3: + if (IS_BP_ENABLED(env->dr[7], index) && env->dr[index] != value) { + windbg_hw_breakpoint_remove(cpu, index); + env->dr[index] = value; + windbg_hw_breakpoint_insert(cpu, index); + } else { + env->dr[index] = value; + } + return; + case 6: + env->dr[6] = value | DR6_FIXED_1; + return; + case 7: + windbg_set_dr7(cpu, value); + return; + } +} + static void windbg_set_sr(CPUState *cpu, int sr, uint16_t selector) { CPUArchState *env = cpu->env_ptr;