summary refs log tree commit diff stats
path: root/scripts/dump-guest-memory.py
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2018-01-17 12:13:00 +0100
committerMarc-André Lureau <marcandre.lureau@redhat.com>2018-01-20 20:59:00 +0100
commit6f49ec4034e55dfb675a56a62c9579384f7fb8cc (patch)
treecbf5eacebacc430809c66d62cf125637845e48c6 /scripts/dump-guest-memory.py
parentb384cd95eb9c6f73ad84ed1bb0717a26e29cc78f (diff)
downloadfocaccia-qemu-6f49ec4034e55dfb675a56a62c9579384f7fb8cc.tar.gz
focaccia-qemu-6f49ec4034e55dfb675a56a62c9579384f7fb8cc.zip
dump-guest-memory.py: fix python 2 support
Python GDB support may use Python 2 or 3.

Inferior.read_memory() may return a 'buffer' with Python 2 or a
'memoryview' with Python 3 (see also
https://sourceware.org/gdb/onlinedocs/gdb/Inferiors-In-Python.html)

The elf.add_vmcoreinfo_note() method expects a "bytes" object. Wrap
the returned memory with bytes(), which works with both 'memoryview'
and 'buffer'.

Fixes a regression introduced with commit
d23bfa91b7789534d16ede6cb7d925bfac3f3c4c ("add vmcoreinfo").

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'scripts/dump-guest-memory.py')
-rw-r--r--scripts/dump-guest-memory.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/scripts/dump-guest-memory.py b/scripts/dump-guest-memory.py
index 09bec92b50..03fbf69f8a 100644
--- a/scripts/dump-guest-memory.py
+++ b/scripts/dump-guest-memory.py
@@ -564,7 +564,7 @@ shape and this command should mostly work."""
 
         vmcoreinfo = self.phys_memory_read(addr, size)
         if vmcoreinfo:
-            self.elf.add_vmcoreinfo_note(vmcoreinfo.tobytes())
+            self.elf.add_vmcoreinfo_note(bytes(vmcoreinfo))
 
     def invoke(self, args, from_tty):
         """Handles command invocation from gdb."""