[{"id":1775708,"web_url":"http://patchwork.ozlabs.org/comment/1775708/","msgid":"<CAKmqyKMrFGWDctvuPMFyEGqBm6QMF2VTArqV6v2rONVeUa8SrA@mail.gmail.com>","list_archive_url":null,"date":"2017-09-26T17:13:00","subject":"Re: [Qemu-devel] [PATCH 05/43] windbg: added helper features","submitter":{"id":64571,"url":"http://patchwork.ozlabs.org/api/people/64571/","name":"Alistair Francis","email":"alistair23@gmail.com"},"content":"On Tue, Sep 26, 2017 at 4:04 AM, Mihail Abakumov\n<mikhail.abakumov@ispras.ru> wrote:\n> Added some helper features for windbgstub.\n>\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>  include/exec/windbgstub-utils.h |   46 +++++++++++++++++++++++++++++++++++++++\n>  include/exec/windbgstub.h       |    3 +++\n>  windbgstub.c                    |    1 +\n>  3 files changed, 50 insertions(+)\n>\n> diff --git a/include/exec/windbgstub-utils.h b/include/exec/windbgstub-utils.h\n> index 2390597f1f..65f336e4bf 100755\n> --- a/include/exec/windbgstub-utils.h\n> +++ b/include/exec/windbgstub-utils.h\n> @@ -13,7 +13,53 @@\n>  #define WINDBGSTUB_UTILS_H\n>\n>  #include \"qemu/osdep.h\"\n> +#include \"qemu/error-report.h\"\n> +#include \"cpu.h\"\n>  #include \"exec/windbgstub.h\"\n>  #include \"exec/windbgkd.h\"\n>\n> +#ifndef TARGET_I386\n> +#error Unsupported Architecture\n> +#endif\n> +#ifdef TARGET_X86_64 /* Unimplemented yet */\n> +#error Unsupported Architecture\n> +#endif\n> +\n> +#if (WINDBG_DEBUG_ON)\n> +\n> +# define WINDBG_DEBUG(...) do {    \\\n> +    printf(\"Debug: \" __VA_ARGS__); \\\n> +    printf(\"\\n\");                  \\\n> +} while (false)\n> +\n> +# define WINDBG_ERROR(...) do {    \\\n> +    printf(\"Error: \" __VA_ARGS__); \\\n> +    printf(\"\\n\");                  \\\n> +} while (false)\n\nUse qemu_log() instead of printf().\n\nHave a look as some other files for the usual way we handle debug printing.\n\n> +\n> +#else\n> +\n> +# define WINDBG_DEBUG(...)\n> +# define WINDBG_ERROR(...) error_report(WINDBG \": \" __VA_ARGS__)\n> +\n> +#endif\n> +\n> +#define FMT_ADDR \"addr:0x\" TARGET_FMT_lx\n> +#define FMT_ERR  \"Error:%d\"\n> +\n> +#define UINT8_P(ptr) ((uint8_t *) (ptr))\n> +#define UINT32_P(ptr) ((uint32_t *) (ptr))\n> +#define FIELD_P(type, field, ptr) ((typeof_field(type, field) *) (ptr))\n> +#define PTR(var) UINT8_P(&var)\n> +\n> +#define M64_SIZE sizeof(DBGKD_MANIPULATE_STATE64)\n> +\n> +#define sizeof_field(type, field) sizeof(((type *) NULL)->field)\n> +\n> +#define READ_VMEM(cpu, addr, type) ({                         \\\n> +    type _t;                                                  \\\n> +    cpu_memory_rw_debug(cpu, addr, PTR(_t), sizeof(type), 0); \\\n> +    _t;                                                       \\\n> +})\n> +\n>  #endif\n> diff --git a/include/exec/windbgstub.h b/include/exec/windbgstub.h\n> index 1a6e1cc6e5..703fc26b8f 100755\n> --- a/include/exec/windbgstub.h\n> +++ b/include/exec/windbgstub.h\n> @@ -12,6 +12,9 @@\n>  #ifndef WINDBGSTUB_H\n>  #define WINDBGSTUB_H\n>\n> +#define WINDBG \"windbg\"\n> +#define WINDBG_DEBUG_ON false\n\nYou should have a check here to see if the user has already set\nWINDBG_DEBUG_ON to allow people to set it during build time.\n\nThanks,\nAlistair\n\n> +\n>  int windbg_server_start(const char *device);\n>\n>  #endif\n> diff --git a/windbgstub.c b/windbgstub.c\n> index 4951f59203..3830446988 100755\n> --- a/windbgstub.c\n> +++ b/windbgstub.c\n> @@ -11,6 +11,7 @@\n>\n>  #include \"qemu/osdep.h\"\n>  #include \"exec/windbgstub.h\"\n> +#include \"exec/windbgstub-utils.h\"\n>\n>  int windbg_server_start(const char *device)\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>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"gLZ5Fmqk\"; dkim-atps=neutral"],"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 3y1nc02r5Lz9t3Z\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 27 Sep 2017 03:13:52 +1000 (AEST)","from localhost ([::1]:50395 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 1dwtQc-0002JE-I5\n\tfor incoming@patchwork.ozlabs.org; Tue, 26 Sep 2017 13:13:50 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:51921)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <alistair23@gmail.com>) id 1dwtQK-0002J9-M8\n\tfor qemu-devel@nongnu.org; Tue, 26 Sep 2017 13:13:33 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <alistair23@gmail.com>) id 1dwtQJ-0004JA-Lt\n\tfor qemu-devel@nongnu.org; Tue, 26 Sep 2017 13:13:32 -0400","from mail-it0-x230.google.com ([2607:f8b0:4001:c0b::230]:46859)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <alistair23@gmail.com>)\n\tid 1dwtQJ-0004Ix-HK\n\tfor qemu-devel@nongnu.org; Tue, 26 Sep 2017 13:13:31 -0400","by mail-it0-x230.google.com with SMTP id d192so3997079itd.1\n\tfor <qemu-devel@nongnu.org>; Tue, 26 Sep 2017 10:13:31 -0700 (PDT)","by 10.79.14.209 with HTTP; Tue, 26 Sep 2017 10:13:00 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=nIkB9lJebW5YbuBNW1rQ+iqhpmDfv5rmBACA9x0Fo98=;\n\tb=gLZ5FmqksSqLldCtmC4/PnPL4IJQUie5LlkMwFRemJaP7DSS/fgZG8qb/TJivtRnGo\n\t2+LDtq5T8vCyjryOy0LUdN2uRRzH005oqPvx1I+Rc588Kzt7hNjML9RSXbpiv6+OdZSi\n\t7buoHRx6S+bBdoO3Tc5iMYENo80kvNVfi18tLz0iE7F/51IHnDXvpX3OuCl+KFDR0k0l\n\tJt8GZSqVLl3svUhpyITlAWobPARs+6vRD/7MdY1MRQPElf/OnNTn/xN2FulLmfRrEf1s\n\tqjx4eR9r4IpDsdc58UjNbT7sxr9hEMuW9sZ/3Ugh1selb0HkEktZ40x5I8Ut612i6SfD\n\t/KXA==","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=nIkB9lJebW5YbuBNW1rQ+iqhpmDfv5rmBACA9x0Fo98=;\n\tb=MyEHFzqOcrYWPIeOnRPf79/Am5URgoV9CKaV8oY0DRTOmPPOiLXdPVFCgwJxYtCslA\n\tKnrxoMMaPXwJVZSN2eMzyNamsQVPMMSK1Ez7df5oSMT9kspovL3ez4QYtI/RD0XA1k5E\n\tanhqRgcEciEjMFYGEeXdDYlCaJHz3q/vjmG5Wl08e8SS1FLFflfOauX5NKRq1hlQoh0n\n\t2i3zkPUJMOE50MRG79zwK9i4OzZTORZy46DJy+4I6ll3ntLNL8UxAHmO48I1ohVPkZbT\n\tIxNAkXuaJgzuA+JoXvnTvBNJeh3gb1SEKoTsp3IGZfHdLz/EWhbkbC3u0q3HSmtyGnXw\n\tqXbQ==","X-Gm-Message-State":"AHPjjUjtQd58w5dxrFRdNQJaGg3G6fCt2Uuqg+lv1dqwK7STbnCrJnsu\n\tkK5disHrlmkdWbLlBtC9r0M5Ou0i8BNTvPY61/E=","X-Google-Smtp-Source":"AOwi7QBaTPioyPHJFGfbk40EU9srKmVrm1N6fbf9nrnhP3Hk2Ii6OX1lbwNyMrwrqZupB25WySMzhsx5NnIEMjEl4Ss=","X-Received":"by 10.36.141.67 with SMTP id w64mr6688509itd.8.1506446010898;\n\tTue, 26 Sep 2017 10:13:30 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<150642387446.3900.8629683985208127854.stgit@Misha-PC.lan02.inno>","References":"<150642384156.3900.3326424823772221077.stgit@Misha-PC.lan02.inno>\n\t<150642387446.3900.8629683985208127854.stgit@Misha-PC.lan02.inno>","From":"Alistair Francis <alistair23@gmail.com>","Date":"Tue, 26 Sep 2017 10:13:00 -0700","Message-ID":"<CAKmqyKMrFGWDctvuPMFyEGqBm6QMF2VTArqV6v2rONVeUa8SrA@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: Genre and OS details not\n\trecognized.","X-Received-From":"2607:f8b0:4001:c0b::230","Subject":"Re: [Qemu-devel] [PATCH 05/43] windbg: added helper features","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":"Stefan Weil <sw@weilnetz.de>, lprosek@redhat.com,\n\t\"qemu-devel@nongnu.org Developers\" <qemu-devel@nongnu.org>,\n\tdovgaluk@ispras.ru, rkagan@virtuozzo.com, den@openvz.org,\n\tPaolo Bonzini <pbonzini@redhat.com>","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>"}},{"id":1775730,"web_url":"http://patchwork.ozlabs.org/comment/1775730/","msgid":"<7db986e7-3cec-f606-530d-f442b7562be3@redhat.com>","list_archive_url":null,"date":"2017-09-26T17:27:29","subject":"Re: [Qemu-devel] [PATCH 05/43] windbg: added helper features","submitter":{"id":6591,"url":"http://patchwork.ozlabs.org/api/people/6591/","name":"Eric Blake","email":"eblake@redhat.com"},"content":"On 09/26/2017 12:13 PM, Alistair Francis wrote:\n\n>> +#if (WINDBG_DEBUG_ON)\n>> +\n>> +# define WINDBG_DEBUG(...) do {    \\\n>> +    printf(\"Debug: \" __VA_ARGS__); \\\n>> +    printf(\"\\n\");                  \\\n>> +} while (false)\n>> +\n>> +# define WINDBG_ERROR(...) do {    \\\n>> +    printf(\"Error: \" __VA_ARGS__); \\\n>> +    printf(\"\\n\");                  \\\n>> +} while (false)\n> \n> Use qemu_log() instead of printf().\n> \n> Have a look as some other files for the usual way we handle debug printing.\n> \n>> +\n>> +#else\n>> +\n>> +# define WINDBG_DEBUG(...)\n>> +# define WINDBG_ERROR(...) error_report(WINDBG \": \" __VA_ARGS__)\n\nWhat's more - as written, your approach is prone to bit-rot: the\ndebug/error statements are not compared against -Werror except for the\nrare person that enables debugging.  Better is go make the macro\nunconditionally expand to something that triggers -Wformat checking, but\nguarded by an if(0) for normal use.  Or even switch to trace points\nrather than debugging statements, so that you can control at runtime how\nmuch debugging information you want, rather than having to recompile to\nturn it on and off.","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>)","ext-mx10.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx10.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=eblake@redhat.com"],"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 3y1nyp6vl8z9t1G\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 27 Sep 2017 03:30:10 +1000 (AEST)","from localhost ([::1]:50448 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 1dwtgP-00006B-2A\n\tfor incoming@patchwork.ozlabs.org; Tue, 26 Sep 2017 13:30:09 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:56363)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dwtdv-0006qk-JD\n\tfor qemu-devel@nongnu.org; Tue, 26 Sep 2017 13:27:36 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <eblake@redhat.com>) id 1dwtdt-0004NI-9p\n\tfor qemu-devel@nongnu.org; Tue, 26 Sep 2017 13:27:35 -0400","from mx1.redhat.com ([209.132.183.28]:37456)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <eblake@redhat.com>) id 1dwtdt-0004Mm-0Q\n\tfor qemu-devel@nongnu.org; Tue, 26 Sep 2017 13:27:33 -0400","from smtp.corp.redhat.com\n\t(int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id E05505F7BD;\n\tTue, 26 Sep 2017 17:27:31 +0000 (UTC)","from [10.10.124.97] (ovpn-124-97.rdu2.redhat.com [10.10.124.97])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id E3C98784BF;\n\tTue, 26 Sep 2017 17:27:29 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com E05505F7BD","To":"Alistair Francis <alistair23@gmail.com>,\n\tMihail Abakumov <mikhail.abakumov@ispras.ru>","References":"<150642384156.3900.3326424823772221077.stgit@Misha-PC.lan02.inno>\n\t<150642387446.3900.8629683985208127854.stgit@Misha-PC.lan02.inno>\n\t<CAKmqyKMrFGWDctvuPMFyEGqBm6QMF2VTArqV6v2rONVeUa8SrA@mail.gmail.com>","From":"Eric Blake <eblake@redhat.com>","Openpgp":"url=http://people.redhat.com/eblake/eblake.gpg","Organization":"Red Hat, Inc.","Message-ID":"<7db986e7-3cec-f606-530d-f442b7562be3@redhat.com>","Date":"Tue, 26 Sep 2017 12:27:29 -0500","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<CAKmqyKMrFGWDctvuPMFyEGqBm6QMF2VTArqV6v2rONVeUa8SrA@mail.gmail.com>","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\";\n\tboundary=\"Dj6jexTIOPGCAJDF1hOiqgvX4hA40reIn\"","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.12","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.39]);\n\tTue, 26 Sep 2017 17:27:32 +0000 (UTC)","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]","X-Received-From":"209.132.183.28","X-Content-Filtered-By":"Mailman/MimeDel 2.1.21","Subject":"Re: [Qemu-devel] [PATCH 05/43] windbg: added helper features","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":"Stefan Weil <sw@weilnetz.de>, lprosek@redhat.com,\n\t\"qemu-devel@nongnu.org Developers\" <qemu-devel@nongnu.org>,\n\tdovgaluk@ispras.ru, rkagan@virtuozzo.com,\n\tPaolo Bonzini <pbonzini@redhat.com>, 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>"}},{"id":1793129,"web_url":"http://patchwork.ozlabs.org/comment/1793129/","msgid":"<c23218e7b44a0f2f2616bd83f5328cd0@ispras.ru>","list_archive_url":null,"date":"2017-10-24T10:59:41","subject":"Re: [Qemu-devel] [PATCH 05/43] windbg: added helper features","submitter":{"id":71645,"url":"http://patchwork.ozlabs.org/api/people/71645/","name":"Mikhail Abakumov","email":"mikhail.abakumov@ispras.ru"},"content":"Alistair Francis писал 2017-09-26 20:13:\n> On Tue, Sep 26, 2017 at 4:04 AM, Mihail Abakumov\n> <mikhail.abakumov@ispras.ru> wrote:\n>> Added some helper features for windbgstub.\n>> \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>>  include/exec/windbgstub-utils.h |   46 \n>> +++++++++++++++++++++++++++++++++++++++\n>>  include/exec/windbgstub.h       |    3 +++\n>>  windbgstub.c                    |    1 +\n>>  3 files changed, 50 insertions(+)\n>> \n>> diff --git a/include/exec/windbgstub-utils.h \n>> b/include/exec/windbgstub-utils.h\n>> index 2390597f1f..65f336e4bf 100755\n>> --- a/include/exec/windbgstub-utils.h\n>> +++ b/include/exec/windbgstub-utils.h\n>> @@ -13,7 +13,53 @@\n>>  #define WINDBGSTUB_UTILS_H\n>> \n>>  #include \"qemu/osdep.h\"\n>> +#include \"qemu/error-report.h\"\n>> +#include \"cpu.h\"\n>>  #include \"exec/windbgstub.h\"\n>>  #include \"exec/windbgkd.h\"\n>> \n>> +#ifndef TARGET_I386\n>> +#error Unsupported Architecture\n>> +#endif\n>> +#ifdef TARGET_X86_64 /* Unimplemented yet */\n>> +#error Unsupported Architecture\n>> +#endif\n>> +\n>> +#if (WINDBG_DEBUG_ON)\n>> +\n>> +# define WINDBG_DEBUG(...) do {    \\\n>> +    printf(\"Debug: \" __VA_ARGS__); \\\n>> +    printf(\"\\n\");                  \\\n>> +} while (false)\n>> +\n>> +# define WINDBG_ERROR(...) do {    \\\n>> +    printf(\"Error: \" __VA_ARGS__); \\\n>> +    printf(\"\\n\");                  \\\n>> +} while (false)\n> \n> Use qemu_log() instead of printf().\n> \n> Have a look as some other files for the usual way we handle debug \n> printing.\n> \n\nThanks for your feedback. I'm replaced printf() with qemu_log().\n\nYou can find new version here:\n     \nhttps://lists.nongnu.org/archive/html/qemu-devel/2017-10/msg03912.html\n\n>> +\n>> +#else\n>> +\n>> +# define WINDBG_DEBUG(...)\n>> +# define WINDBG_ERROR(...) error_report(WINDBG \": \" __VA_ARGS__)\n>> +\n>> +#endif\n>> +\n>> +#define FMT_ADDR \"addr:0x\" TARGET_FMT_lx\n>> +#define FMT_ERR  \"Error:%d\"\n>> +\n>> +#define UINT8_P(ptr) ((uint8_t *) (ptr))\n>> +#define UINT32_P(ptr) ((uint32_t *) (ptr))\n>> +#define FIELD_P(type, field, ptr) ((typeof_field(type, field) *) \n>> (ptr))\n>> +#define PTR(var) UINT8_P(&var)\n>> +\n>> +#define M64_SIZE sizeof(DBGKD_MANIPULATE_STATE64)\n>> +\n>> +#define sizeof_field(type, field) sizeof(((type *) NULL)->field)\n>> +\n>> +#define READ_VMEM(cpu, addr, type) ({                         \\\n>> +    type _t;                                                  \\\n>> +    cpu_memory_rw_debug(cpu, addr, PTR(_t), sizeof(type), 0); \\\n>> +    _t;                                                       \\\n>> +})\n>> +\n>>  #endif\n>> diff --git a/include/exec/windbgstub.h b/include/exec/windbgstub.h\n>> index 1a6e1cc6e5..703fc26b8f 100755\n>> --- a/include/exec/windbgstub.h\n>> +++ b/include/exec/windbgstub.h\n>> @@ -12,6 +12,9 @@\n>>  #ifndef WINDBGSTUB_H\n>>  #define WINDBGSTUB_H\n>> \n>> +#define WINDBG \"windbg\"\n>> +#define WINDBG_DEBUG_ON false\n> \n> You should have a check here to see if the user has already set\n> WINDBG_DEBUG_ON to allow people to set it during build time.\n> \n> Thanks,\n> Alistair\n> \n\nYes, you're right. I done it.\n\n>> +\n>>  int windbg_server_start(const char *device);\n>> \n>>  #endif\n>> diff --git a/windbgstub.c b/windbgstub.c\n>> index 4951f59203..3830446988 100755\n>> --- a/windbgstub.c\n>> +++ b/windbgstub.c\n>> @@ -11,6 +11,7 @@\n>> \n>>  #include \"qemu/osdep.h\"\n>>  #include \"exec/windbgstub.h\"\n>> +#include \"exec/windbgstub-utils.h\"\n>> \n>>  int windbg_server_start(const char *device)\n>>  {\n>> \n>> \n\n--\nThanks,\nMihail Abakumov","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 3yLr045MYSz9t2h\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 24 Oct 2017 22:00:17 +1100 (AEDT)","from localhost ([::1]:43140 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 1e6wwQ-0005Fz-0Z\n\tfor incoming@patchwork.ozlabs.org; Tue, 24 Oct 2017 07:00:14 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:54584)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <mikhail.abakumov@ispras.ru>) id 1e6ww2-0005Fd-Dr\n\tfor qemu-devel@nongnu.org; Tue, 24 Oct 2017 06:59:51 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <mikhail.abakumov@ispras.ru>) id 1e6wvz-0006Eh-BU\n\tfor qemu-devel@nongnu.org; Tue, 24 Oct 2017 06:59:50 -0400","from mail.ispras.ru ([83.149.199.45]:41860)\n\tby eggs.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <mikhail.abakumov@ispras.ru>) id 1e6wvy-0006CK-VB\n\tfor qemu-devel@nongnu.org; Tue, 24 Oct 2017 06:59:47 -0400","from mail.ispras.ru (localhost [127.0.0.1])\n\tby mail.ispras.ru (Postfix) with ESMTPSA id E53C954006C;\n\tTue, 24 Oct 2017 13:59:41 +0300 (MSK)"],"MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8;\n format=flowed","Date":"Tue, 24 Oct 2017 13:59:41 +0300","From":"Mihail Abakumov <mikhail.abakumov@ispras.ru>","To":"Alistair Francis <alistair23@gmail.com>","In-Reply-To":"<CAKmqyKMrFGWDctvuPMFyEGqBm6QMF2VTArqV6v2rONVeUa8SrA@mail.gmail.com>","References":"<150642384156.3900.3326424823772221077.stgit@Misha-PC.lan02.inno>\n\t<150642387446.3900.8629683985208127854.stgit@Misha-PC.lan02.inno>\n\t<CAKmqyKMrFGWDctvuPMFyEGqBm6QMF2VTArqV6v2rONVeUa8SrA@mail.gmail.com>","Message-ID":"<c23218e7b44a0f2f2616bd83f5328cd0@ispras.ru>","X-Sender":"mikhail.abakumov@ispras.ru","User-Agent":"Roundcube Webmail/1.1.2","Content-Transfer-Encoding":"quoted-printable","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 3.x [fuzzy]","X-Received-From":"83.149.199.45","Subject":"Re: [Qemu-devel] [PATCH 05/43] windbg: added helper features","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":"Stefan Weil <sw@weilnetz.de>, lprosek@redhat.com,\n\t\"qemu-devel@nongnu.org Developers\" <qemu-devel@nongnu.org>,\n\tdovgaluk@ispras.ru, rkagan@virtuozzo.com, den@openvz.org,\n\tPaolo Bonzini <pbonzini@redhat.com>","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>"}},{"id":1793137,"web_url":"http://patchwork.ozlabs.org/comment/1793137/","msgid":"<09bbb5c0ed85330e0828fbc9cc34583b@ispras.ru>","list_archive_url":null,"date":"2017-10-24T11:34:14","subject":"Re: [Qemu-devel] [PATCH 05/43] windbg: added helper features","submitter":{"id":71645,"url":"http://patchwork.ozlabs.org/api/people/71645/","name":"Mikhail Abakumov","email":"mikhail.abakumov@ispras.ru"},"content":"Eric Blake писал 2017-09-26 20:27:\n> On 09/26/2017 12:13 PM, Alistair Francis wrote:\n> \n>>> +#if (WINDBG_DEBUG_ON)\n>>> +\n>>> +# define WINDBG_DEBUG(...) do {    \\\n>>> +    printf(\"Debug: \" __VA_ARGS__); \\\n>>> +    printf(\"\\n\");                  \\\n>>> +} while (false)\n>>> +\n>>> +# define WINDBG_ERROR(...) do {    \\\n>>> +    printf(\"Error: \" __VA_ARGS__); \\\n>>> +    printf(\"\\n\");                  \\\n>>> +} while (false)\n>> \n>> Use qemu_log() instead of printf().\n>> \n>> Have a look as some other files for the usual way we handle debug \n>> printing.\n>> \n>>> +\n>>> +#else\n>>> +\n>>> +# define WINDBG_DEBUG(...)\n>>> +# define WINDBG_ERROR(...) error_report(WINDBG \": \" __VA_ARGS__)\n> \n> What's more - as written, your approach is prone to bit-rot: the\n> debug/error statements are not compared against -Werror except for the\n> rare person that enables debugging.  Better is go make the macro\n> unconditionally expand to something that triggers -Wformat checking, \n> but\n> guarded by an if(0) for normal use.  Or even switch to trace points\n> rather than debugging statements, so that you can control at runtime \n> how\n> much debugging information you want, rather than having to recompile to\n> turn it on and off.\n\nThank you for your feedback.\n\nI corrected it like this\n#define WINDBG_DEBUG(...) do {             \\\n     if (WINDBG_DEBUG_ON) {                 \\\n         qemu_log(WINDBG \": \" __VA_ARGS__); \\\n         qemu_log(\"\\n\");                    \\\n     }                                      \\\n} while (false)\n\nYou can find a new version here:\n     \nhttps://lists.nongnu.org/archive/html/qemu-devel/2017-10/msg03912.html\n\n--\nThanks,\nMihail Abakumov","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 3yLrlr6zh7z9t3Z\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 24 Oct 2017 22:34:48 +1100 (AEDT)","from localhost ([::1]:43258 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 1e6xTp-0002sQ-7f\n\tfor incoming@patchwork.ozlabs.org; Tue, 24 Oct 2017 07:34:45 -0400","from eggs.gnu.org ([2001:4830:134:3::10]:33696)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <mikhail.abakumov@ispras.ru>) id 1e6xTR-0002s8-VD\n\tfor qemu-devel@nongnu.org; Tue, 24 Oct 2017 07:34:22 -0400","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <mikhail.abakumov@ispras.ru>) id 1e6xTO-0005XI-TQ\n\tfor qemu-devel@nongnu.org; Tue, 24 Oct 2017 07:34:22 -0400","from mail.ispras.ru ([83.149.199.45]:46678)\n\tby eggs.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <mikhail.abakumov@ispras.ru>) id 1e6xTO-0005WV-N5\n\tfor qemu-devel@nongnu.org; Tue, 24 Oct 2017 07:34:18 -0400","from mail.ispras.ru (localhost [127.0.0.1])\n\tby mail.ispras.ru (Postfix) with ESMTPSA id DA32B54006C;\n\tTue, 24 Oct 2017 14:34:14 +0300 (MSK)"],"MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8;\n format=flowed","Date":"Tue, 24 Oct 2017 14:34:14 +0300","From":"Mihail Abakumov <mikhail.abakumov@ispras.ru>","To":"Eric Blake <eblake@redhat.com>, Alistair Francis <alistair23@gmail.com>","In-Reply-To":"<7db986e7-3cec-f606-530d-f442b7562be3@redhat.com>","References":"<150642384156.3900.3326424823772221077.stgit@Misha-PC.lan02.inno>\n\t<150642387446.3900.8629683985208127854.stgit@Misha-PC.lan02.inno>\n\t<CAKmqyKMrFGWDctvuPMFyEGqBm6QMF2VTArqV6v2rONVeUa8SrA@mail.gmail.com>\n\t<7db986e7-3cec-f606-530d-f442b7562be3@redhat.com>","Message-ID":"<09bbb5c0ed85330e0828fbc9cc34583b@ispras.ru>","X-Sender":"mikhail.abakumov@ispras.ru","User-Agent":"Roundcube Webmail/1.1.2","Content-Transfer-Encoding":"quoted-printable","X-detected-operating-system":"by eggs.gnu.org: GNU/Linux 3.x [fuzzy]","X-Received-From":"83.149.199.45","Subject":"Re: [Qemu-devel] [PATCH 05/43] windbg: added helper features","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":"Stefan Weil <sw@weilnetz.de>, lprosek@redhat.com, \"qemu-devel@nongnu.org\n\tDevelopers\" <qemu-devel@nongnu.org>, dovgaluk@ispras.ru,\n\trkagan@virtuozzo.com, Paolo Bonzini <pbonzini@redhat.com>, 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>"}}]