* [Qemu-devel] [PATCH] scripts/dump-guest-memory.py: fix int128_get64 on recent gcc
@ 2017-03-10 8:53 Marc-André Lureau
2017-03-10 9:59 ` Paolo Bonzini
0 siblings, 1 reply; 4+ messages in thread
From: Marc-André Lureau @ 2017-03-10 8:53 UTC (permalink / raw)
To: qemu-devel; +Cc: lersek, Marc-André Lureau
The Int128 is no longer a struct, reaching a python exception:
Python Exception <class 'gdb.error'> 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 <marcandre.lureau@redhat.com>
---
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):
--
2.12.0.rc2.3.gc93709801
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] scripts/dump-guest-memory.py: fix int128_get64 on recent gcc
2017-03-10 8:53 [Qemu-devel] [PATCH] scripts/dump-guest-memory.py: fix int128_get64 on recent gcc Marc-André Lureau
@ 2017-03-10 9:59 ` Paolo Bonzini
2017-03-10 10:54 ` Marc-André Lureau
0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2017-03-10 9:59 UTC (permalink / raw)
To: Marc-André Lureau, qemu-devel; +Cc: lersek
On 10/03/2017 09:53, Marc-André Lureau wrote:
> The Int128 is no longer a struct, reaching a python exception:
> Python Exception <class 'gdb.error'> 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 <marcandre.lureau@redhat.com>
> ---
> 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.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] scripts/dump-guest-memory.py: fix int128_get64 on recent gcc
2017-03-10 9:59 ` Paolo Bonzini
@ 2017-03-10 10:54 ` Marc-André Lureau
2017-03-10 10:58 ` Paolo Bonzini
0 siblings, 1 reply; 4+ messages in thread
From: Marc-André Lureau @ 2017-03-10 10:54 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: lersek
Hi
On Fri, Mar 10, 2017 at 2:00 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>
> On 10/03/2017 09:53, Marc-André Lureau wrote:
> > The Int128 is no longer a struct, reaching a python exception:
> > Python Exception <class 'gdb.error'> 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 <marcandre.lureau@redhat.com>
> > ---
> > 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
--- 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)
> Paolo
>
> --
Marc-André Lureau
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] scripts/dump-guest-memory.py: fix int128_get64 on recent gcc
2017-03-10 10:54 ` Marc-André Lureau
@ 2017-03-10 10:58 ` Paolo Bonzini
0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2017-03-10 10:58 UTC (permalink / raw)
To: Marc-André Lureau, qemu-devel; +Cc: lersek
On 10/03/2017 11:54, Marc-André Lureau wrote:
> Hi
>
> On Fri, Mar 10, 2017 at 2:00 PM Paolo Bonzini <pbonzini@redhat.com
> <mailto:pbonzini@redhat.com>> wrote:
>
>
>
> On 10/03/2017 09:53, Marc-André Lureau wrote:
> > The Int128 is no longer a struct, reaching a python exception:
> > Python Exception <class 'gdb.error'> 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 <marcandre.lureau@redhat.com
> <mailto:marcandre.lureau@redhat.com>>
> > ---
> > 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
> --- 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)
Yes, this should work.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-03-10 10:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-10 8:53 [Qemu-devel] [PATCH] scripts/dump-guest-memory.py: fix int128_get64 on recent gcc Marc-André Lureau
2017-03-10 9:59 ` Paolo Bonzini
2017-03-10 10:54 ` Marc-André Lureau
2017-03-10 10:58 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).