From patchwork Fri Mar 10 10:54:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 9616003 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 562FF60417 for ; Fri, 10 Mar 2017 10:56:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 450B1286FC for ; Fri, 10 Mar 2017 10:56:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35CCE28709; Fri, 10 Mar 2017 10:56:11 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 CF240286FC for ; Fri, 10 Mar 2017 10:56:10 +0000 (UTC) Received: from localhost ([::1]:38453 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cmIDR-0004mq-VI for patchwork-qemu-devel@patchwork.kernel.org; Fri, 10 Mar 2017 05:56:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cmICS-0004Jn-5c for qemu-devel@nongnu.org; Fri, 10 Mar 2017 05:55:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cmICQ-0001ly-QU for qemu-devel@nongnu.org; Fri, 10 Mar 2017 05:55:08 -0500 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]:35091) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cmICQ-0001lC-F5 for qemu-devel@nongnu.org; Fri, 10 Mar 2017 05:55:06 -0500 Received: by mail-lf0-x244.google.com with SMTP id v2so6582456lfi.2 for ; Fri, 10 Mar 2017 02:55:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kQD7FJdaurXyOO30itc1iYwy3a8s/vqnI7csdx5u8wg=; b=jR8J5VSsnjEfdpOCv0J/qbi6S27pQZuhInM6xA1RTZ9eBua3K+BDT7PkQZyycKMshe EAuyjNCCzEq9h6lgOrL2sf41KKbHQs+45lbJtOsyZ/QzNRtXujiRjmQG/T3iwJPf6mZx Kh6QEMfVKEWmGCEGyVpciPCECiv52io1zw0jo9ProPMnM/PIfGXpH30mogQ6TS9Y0pWq 1/58Tyu42ErbUGoma3eRlFxgXUPoMNJhMv/UFnldNn7y8E2QqcupFAiiklF/00+szFAF V2OHfoHI2VGPc3gSMSwbmipnDfXf5t0D5Af72V64oaBOPZ4R33L+VnYhaWX4uNvNMW6g zBqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kQD7FJdaurXyOO30itc1iYwy3a8s/vqnI7csdx5u8wg=; b=mpuvda59pf3iy343U809kqCdrKiV+SwhGwMIoWTh3ax5gV0mJzTx0rLdTUVbq3vLAm D4JEMV9E1YCM7YwbqZrisJ4tWxCs9ZOfD1DNpZ6k0F5sAwaheeiDZREmcr5IgOrCD0hd OSaNg7qDTQ55E0edD0lXG/KJ7qrft4OtZP6llAVwFKOaeIzobLp24QGrGvk1VC6MwZ/Z ak9IeqvG31NtD7ohdlSDoVP4jCLYlvADnWUinq4bhpwvx/GwkA5DcY2T03U6gP1TgvL0 KT8g/in6lZD7Ts6k2KcoTA8g7TZu2/r5YVva6uJOlCbMLryd1fGNa8TTKGSvymTetwqx 1s7w== X-Gm-Message-State: AMke39liDhM3X6Ta0pe3Bm2QTJRlfSGZ3A0SrDkNZSVacBNnmVwPeHpzuiAWHeOqJTV4+TfyaiMn6GMx/J83Ag== X-Received: by 10.46.19.25 with SMTP id 25mr5855275ljt.103.1489143303456; Fri, 10 Mar 2017 02:55:03 -0800 (PST) MIME-Version: 1.0 References: <20170310085331.17916-1-marcandre.lureau@redhat.com> <479b756e-b808-eee7-7780-69d2b2669cdf@redhat.com> In-Reply-To: <479b756e-b808-eee7-7780-69d2b2669cdf@redhat.com> From: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Date: Fri, 10 Mar 2017 10:54:52 +0000 Message-ID: To: Paolo Bonzini , qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::244 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: Re: [Qemu-devel] [PATCH] scripts/dump-guest-memory.py: fix int128_get64 on recent gcc 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: lersek@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Hi On Fri, Mar 10, 2017 at 2:00 PM Paolo Bonzini wrote: > > > On 10/03/2017 09:53, Marc-André Lureau wrote: > > The Int128 is no longer a struct, reaching a python exception: > > Python Exception Attempt to extract a component of a > value that is not a (null).: > > > > Replace struct access with a cast to uint64 instead. > > > > Fixes: > > https://bugzilla.redhat.com/show_bug.cgi?id=1427466 > > > > Signed-off-by: Marc-André Lureau > > --- > > scripts/dump-guest-memory.py | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py > > index 9956fc036c..bbe1c14ba2 100644 > > --- a/scripts/dump-guest-memory.py > > +++ b/scripts/dump-guest-memory.py > > @@ -314,8 +314,10 @@ def get_arch_phdr(endianness, elfclass): > > def int128_get64(val): > > """Returns low 64bit part of Int128 struct.""" > > > > - assert val["hi"] == 0 > > - return val["lo"] > > + u64t = gdb.lookup_type('uint64_t').array(2) > > + u64 = val.cast(u64t) > > + assert u64[1] == 0 > > + return u64[0] > > > > > > def qlist_foreach(head, field_str): > > > > I'm afraid this is not big-endian-friendly (Python lets you check that > with "sys.byteorder == 'little'"). > > Also when building on a 32-bit machine the old code should be used; I > think you need to use try/except to choose between the two. > Do you think that would be enough? diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py index 9956fc036c..f7c6635f15 100644 > Paolo > > -- Marc-André Lureau --- a/scripts/dump-guest-memory.py +++ b/scripts/dump-guest-memory.py @@ -314,8 +314,18 @@ def get_arch_phdr(endianness, elfclass): def int128_get64(val): """Returns low 64bit part of Int128 struct.""" - assert val["hi"] == 0 - return val["lo"] + try: + assert val["hi"] == 0 + return val["lo"] + except gdb.error: + u64t = gdb.lookup_type('uint64_t').array(2) + u64 = val.cast(u64t) + if sys.byteorder == 'little': + assert u64[1] == 0 + return u64[0] + else: + assert u64[0] == 0 + return u64[1] (I don't have a 32-bit system handy to check it, and cross-compilation with m32 etc is tricky to get right, I am trying though)