[{"id":1778926,"web_url":"http://patchwork.ozlabs.org/comment/1778926/","msgid":"<CABdb734VfemLf6BuASDYEBbHuErEubmcFZ_pN5NCuG76xwjOmQ@mail.gmail.com>","list_archive_url":null,"date":"2017-10-03T12:58:10","subject":"Re: [Qemu-devel] [PATCH 33/43] windbg: implemented\n\twindbg_hw_breakpoint_insert and windbg_hw_breakpoint_remove","submitter":{"id":68164,"url":"http://patchwork.ozlabs.org/api/people/68164/","name":"Ladi Prosek","email":"lprosek@redhat.com"},"content":"On Tue, Sep 26, 2017 at 1:07 PM, Mihail Abakumov\n<mikhail.abakumov@ispras.ru> wrote:\n> Signed-off-by: Mihail Abakumov <mikhail.abakumov@ispras.ru>\n> Signed-off-by: Pavel Dovgalyuk <dovgaluk@ispras.ru>\n> Signed-off-by: Dmitriy Koltunov <koltunov@ispras.ru>\n> ---\n>  windbgstub-utils.c |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++++\n>  1 file changed, 60 insertions(+)\n>\n> diff --git a/windbgstub-utils.c b/windbgstub-utils.c\n> index e33789725e..05caf98c0c 100755\n> --- a/windbgstub-utils.c\n> +++ b/windbgstub-utils.c\n> @@ -294,11 +294,71 @@ static KDData *kd;\n>\n>  static int windbg_hw_breakpoint_insert(CPUState *cpu, int index)\n>  {\n> +    CPUArchState *env = cpu->env_ptr;\n> +\n> +    if (!IS_BP_ENABLED(env->dr[7], index)) {\n\nnit: This is already checked by both callers.\n\n> +        return 0;\n> +    }\n> +\n> +    target_ulong addr = env->dr[index];\n> +    int type = BP_TYPE(env->dr[7], index);\n> +    int len = BP_LEN(env->dr[7], index);\n> +    int err = 0;\n> +\n> +    switch (type) {\n> +    case DR7_TYPE_DATA_WR:\n> +        err = cpu_watchpoint_insert(cpu, addr, len, BP_MEM_WRITE | BP_GDB,\n> +                                    &env->cpu_watchpoint[index]);\n> +        break;\n> +    case DR7_TYPE_DATA_RW:\n> +        err = cpu_watchpoint_insert(cpu, addr, len, BP_MEM_ACCESS | BP_GDB,\n> +                                    &env->cpu_watchpoint[index]);\n> +        break;\n> +    case DR7_TYPE_BP_INST:\n> +        err = cpu_breakpoint_insert(cpu, addr, BP_GDB,\n> +                                    &env->cpu_breakpoint[index]);\n> +        break;\n> +    case DR7_TYPE_IO_RW:\n> +        return HF_IOBPT_MASK;\n> +    default:\n> +        return 0;\n> +    }\n> +\n> +    if (!err) {\n> +        WINDBG_DEBUG(\"hw_breakpoint_insert: index(%d), \" FMT_ADDR,\n> +                     index, addr);\n> +    } else {\n> +        env->cpu_breakpoint[index] = NULL;\n> +        WINDBG_ERROR(\"hw_breakpoint_insert: index(%d), \" FMT_ADDR \", \" FMT_ERR,\n> +                     index, addr, err);\n> +    }\n>      return 0;\n>  }\n>\n>  static int windbg_hw_breakpoint_remove(CPUState *cpu, int index)\n>  {\n> +    CPUArchState *env = cpu->env_ptr;\n> +    int type = BP_TYPE(env->dr[7], index);\n> +\n> +    switch (type) {\n> +    case DR7_TYPE_BP_INST:\n> +        if (env->cpu_breakpoint[index]) {\n> +            cpu_breakpoint_remove_by_ref(cpu, env->cpu_breakpoint[index]);\n> +        }\n> +        break;\n> +    case DR7_TYPE_DATA_WR:\n> +    case DR7_TYPE_DATA_RW:\n> +        if (env->cpu_watchpoint[index]) {\n> +            cpu_watchpoint_remove_by_ref(cpu, env->cpu_watchpoint[index]);\n> +        }\n> +        break;\n> +    default:\n> +        return 0;\n> +    }\n> +\n> +    env->cpu_breakpoint[index] = NULL;\n> +    WINDBG_DEBUG(\"hw_breakpoint_remove: index(%d), \" FMT_ADDR,\n> +                 index, env->dr[index]);\n>      return 0;\n>  }\n>\n>","headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3y5zcK66Txz9sBW\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue,  3 Oct 2017 23:58:40 +1100 (AEDT)","from localhost ([::1]:58464 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dzMmS-0000kK-HL\n\tfor incoming@patchwork.ozlabs.org; Tue, 03 Oct 2017 08:58:36 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:54353)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <lprosek@redhat.com>) id 1dzMm9-0000k2-4L\n\tfor qemu-devel@nongnu.org; Tue, 03 Oct 2017 08:58:18 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <lprosek@redhat.com>) id 1dzMm4-0001Bv-9r\n\tfor qemu-devel@nongnu.org; Tue, 03 Oct 2017 08:58:17 -0400","from mail-vk0-f52.google.com ([209.85.213.52]:52412)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <lprosek@redhat.com>) id 1dzMm4-0001B3-5a\n\tfor qemu-devel@nongnu.org; Tue, 03 Oct 2017 08:58:12 -0400","by mail-vk0-f52.google.com with SMTP id 126so4490527vkj.9\n\tfor <qemu-devel@nongnu.org>; Tue, 03 Oct 2017 05:58:12 -0700 (PDT)","by 10.103.60.26 with HTTP; Tue, 3 Oct 2017 05:58:10 -0700 (PDT)"],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=vwxg7pK811WixfCgLeOOMIxCRwSo8KikvHEJ5nQcOMI=;\n\tb=nePlTY56D/iT9uiejfdQ7ac9JJ5UzCRI41WhF2hukB3pSDMeIEyVcja3lIybjUIcj0\n\trhFEuwGYsxIwVu2l89trcJ2rk6OYJTRVUDh4i7rKhOX62EcysBhZUh5M/yAr0bmyrs3W\n\tCKfsnqzws4dlPz400BGwhd9LVdSPfY55pneVbTTOSME8v+ibJtpFO+Ba7EXQQkG2aQVb\n\tD/Tyr/E0c0iBgPm3cTxIRSltXEvVGHqjtCPYJ6Li8K5hQ/Mf8QP3L8R2uBy2FKnFT7dN\n\tNZXvV5JMRJdW/Urzvl33oaGbnBYSKVaA2+Mcu4UfzZhKKmvj46VFclF16PxkJ76xLUGT\n\t0lgg==","X-Gm-Message-State":"AMCzsaWoEqcC1UDtlvjlbajNIAp+Q4rqMQMeLMrwvK5nvcvZDDBEk7c5\n\t4yBLER6yV7/TCbgeAFgR57/6Pf6vsGa7WkRFPXWvLw==","X-Google-Smtp-Source":"AOwi7QDlHR0OPL8IJkvy2e9KkxSuZdr8ddg4LSlvMwv4cwL8SyHvasj/b4VcSxooULvJnVz9foGagG4krensa3axIzQ=","X-Received":"by 10.31.95.70 with SMTP id t67mr1375352vkb.168.1507035491310;\n\tTue, 03 Oct 2017 05:58:11 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<150642403148.3900.7920017116044093005.stgit@Misha-PC.lan02.inno>","References":"<150642384156.3900.3326424823772221077.stgit@Misha-PC.lan02.inno>\n\t<150642403148.3900.7920017116044093005.stgit@Misha-PC.lan02.inno>","From":"Ladi Prosek <lprosek@redhat.com>","Date":"Tue, 3 Oct 2017 14:58:10 +0200","Message-ID":"<CABdb734VfemLf6BuASDYEBbHuErEubmcFZ_pN5NCuG76xwjOmQ@mail.gmail.com>","To":"Mihail Abakumov <mikhail.abakumov@ispras.ru>","Content-Type":"text/plain; charset=\"UTF-8\"","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.85.213.52","Subject":"Re: [Qemu-devel] [PATCH 33/43] windbg: implemented\n\twindbg_hw_breakpoint_insert and windbg_hw_breakpoint_remove","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"sw@weilnetz.de, qemu-devel <qemu-devel@nongnu.org>,\n\tPavel Dovgalyuk <dovgaluk@ispras.ru>,\n\tRoman Kagan <rkagan@virtuozzo.com>, \n\tPaolo Bonzini <pbonzini@redhat.com>, \"Denis V. Lunev\" <den@openvz.org>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"}}]