From patchwork Tue Nov 28 08:18:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ladi Prosek X-Patchwork-Id: 10078973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D993A60353 for ; Tue, 28 Nov 2017 08:19:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3D5A291AA for ; Tue, 28 Nov 2017 08:19:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B88EB291C1; Tue, 28 Nov 2017 08:19:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 05F4D291B0 for ; Tue, 28 Nov 2017 08:19:16 +0000 (UTC) Received: from localhost ([::1]:36498 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJb6o-0003aP-2K for patchwork-qemu-devel@patchwork.kernel.org; Tue, 28 Nov 2017 03:19:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJb6C-0003aG-NP for qemu-devel@nongnu.org; Tue, 28 Nov 2017 03:18:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJb68-00022r-Js for qemu-devel@nongnu.org; Tue, 28 Nov 2017 03:18:36 -0500 Received: from mail-ua0-f193.google.com ([209.85.217.193]:45495) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eJb68-00022d-Fi for qemu-devel@nongnu.org; Tue, 28 Nov 2017 03:18:32 -0500 Received: by mail-ua0-f193.google.com with SMTP id r11so20920387uah.12 for ; Tue, 28 Nov 2017 00:18:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=GLvurhKDYWLkVMQr2aCMXYgXY1Jg3SmqdpMe02E+cOo=; b=s4lKqpYBimYcgFSgV3nuPdK6Ej2Vx3L6ReIPgRkrfGBfGalefZUTFwiwxvvcFPqleH VXoGNLuAkjfM9knTkZkbKTvLL+esQUX79BCoEuiJryawBLdIWOQ7QxRtTEkjfPdNZDWI dxAPW7I3JE9/IFxx+B9bTA+oj7PQ0ZJz1UAj6+CkJzXf23w1r412I+4Mj6l2wuVqBN1+ LTuxIUDXMgXxyLOH1dAyXCrmADAyT3Gw4FJtsDYhvCv8aNXO3ZqQb59r/gDGt4aw9s4a /WTJzOR2U+z9322tCm399fVR1EKsqWZmfO57Wi6mgsWRuL42rb697GK4H+ptfC7mkR7B 2zAA== X-Gm-Message-State: AJaThX7Ep0PzDJl6H/5PRRb9fgXOwaET+16BycH6iBg3EzfRuZP+Xarc QY9NMhi3BRp1yApFGFm8Qez103VGuMhuegQ7Wapbrg== X-Google-Smtp-Source: AGs4zMZxzgLB8Wx62r6Zi2yf07XkEPTBFvDNGRSgYivY8wTNQ9P1AdLe2HEiPAsJxz3VEF0+tvn37k3R7nwa0n61t4s= X-Received: by 10.176.20.143 with SMTP id d15mr26117575uae.52.1511857111056; Tue, 28 Nov 2017 00:18:31 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.52.199 with HTTP; Tue, 28 Nov 2017 00:18:30 -0800 (PST) In-Reply-To: <151127326409.6888.9209413226035587910.stgit@Misha-PC.lan02.inno> References: <151127322955.6888.16198535123422076171.stgit@Misha-PC.lan02.inno> <151127326409.6888.9209413226035587910.stgit@Misha-PC.lan02.inno> From: Ladi Prosek Date: Tue, 28 Nov 2017 09:18:30 +0100 Message-ID: To: Mihail Abakumov X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.217.193 Subject: Re: [Qemu-devel] [PATCH v3 05/45] windbg: added helper features 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, qemu-devel , Pavel Dovgalyuk , Roman Kagan , Paolo Bonzini , "Denis V. Lunev" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Nov 21, 2017 at 3:07 PM, Mihail Abakumov wrote: > Added some helper features for windbgstub. > > Signed-off-by: Mihail Abakumov > Signed-off-by: Pavel Dovgalyuk > Signed-off-by: Dmitriy Koltunov > --- > include/exec/windbgstub-utils.h | 27 +++++++++++++++++++++++++++ > include/exec/windbgstub.h | 6 ++++++ > 2 files changed, 33 insertions(+) > > diff --git a/include/exec/windbgstub-utils.h b/include/exec/windbgstub-utils.h > index 2390597f1f..e9f5223e94 100755 > --- a/include/exec/windbgstub-utils.h > +++ b/include/exec/windbgstub-utils.h > @@ -13,7 +13,34 @@ > #define WINDBGSTUB_UTILS_H > > #include "qemu/osdep.h" > +#include "qemu/error-report.h" > +#include "log.h" > +#include "cpu.h" > #include "exec/windbgstub.h" > #include "exec/windbgkd.h" > > +#define WINDBG_DEBUG(...) do { \ > + if (WINDBG_DEBUG_ON) { \ > + qemu_log(WINDBG ": " __VA_ARGS__); \ > + qemu_log("\n"); \ > + } \ > +} while (false) > + > +#define WINDBG_ERROR(...) error_report(WINDBG ": " __VA_ARGS__) > + > +#define FMT_ADDR "addr:0x" TARGET_FMT_lx > +#define FMT_ERR "Error:%d" > + > +#define UINT8_P(ptr) ((uint8_t *) (ptr)) > +#define UINT32_P(ptr) ((uint32_t *) (ptr)) This doesn't cross-compile on Linux: In file included from /home/lprosek/qemu/target/i386/windbgstub.c:15:0: /home/lprosek/qemu/target/i386/windbgstub.c: In function 'kd_api_read_msr': /home/lprosek/qemu/include/exec/windbgstub-utils.h:35:24: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] #define UINT32_P(ptr) ((uint32_t *) (ptr)) ^ /home/lprosek/qemu/target/i386/windbgstub.c:1210:27: note: in expansion of macro 'UINT32_P' m64c->DataValueLow = UINT32_P(val)[0]; ^~~~~~~~ /home/lprosek/qemu/include/exec/windbgstub-utils.h:35:24: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] #define UINT32_P(ptr) ((uint32_t *) (ptr)) ^ /home/lprosek/qemu/target/i386/windbgstub.c:1211:27: note: in expansion of macro 'UINT32_P' m64c->DataValueHigh = UINT32_P(val)[1]; ^~~~~~~~ The macro or the places where it's used need to make sure that the argument is of the right size. I hacked around it by doing: > +#define PTR(var) UINT8_P(&var) > + > +#define sizeof_field(type, field) sizeof(((type *) NULL)->field) > + > +#define READ_VMEM(cpu, addr, type) ({ \ > + type _t; \ > + cpu_memory_rw_debug(cpu, addr, PTR(_t), sizeof(type), 0); \ > + _t; \ > +}) > + > #endif > diff --git a/include/exec/windbgstub.h b/include/exec/windbgstub.h > index 1a6e1cc6e5..21bc552e58 100755 > --- a/include/exec/windbgstub.h > +++ b/include/exec/windbgstub.h > @@ -12,6 +12,12 @@ > #ifndef WINDBGSTUB_H > #define WINDBGSTUB_H > > +#define WINDBG "windbg" > + > +#ifndef WINDBG_DEBUG_ON > +#define WINDBG_DEBUG_ON false > +#endif > + > int windbg_server_start(const char *device); > > #endif > --- a/include/exec/windbgstub-utils.h +++ b/include/exec/windbgstub-utils.h @@ -32,7 +32,7 @@ #define FMT_ERR "Error:%d" #define UINT8_P(ptr) ((uint8_t *) (ptr)) -#define UINT32_P(ptr) ((uint32_t *) (ptr)) +#define UINT32_P(ptr) ((uint32_t *) (size_t) (ptr)) #define PTR(var) UINT8_P(&var)