All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] dump-guest-memory.py: fix python 2 support
@ 2018-01-19 16:25 Marc-André Lureau
  2018-01-19 19:18 ` Laszlo Ersek
  2018-01-19 20:31 ` Eric Blake
  0 siblings, 2 replies; 5+ messages in thread
From: Marc-André Lureau @ 2018-01-19 16:25 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, lersek, eblake, Marc-André Lureau,
	Eduardo Habkost, Cleber Rosa

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>
---
 scripts/dump-guest-memory.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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."""
-- 
2.16.0.rc1.1.gef27df75a1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-01-19 20:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-19 16:25 [Qemu-devel] [PATCH v2] dump-guest-memory.py: fix python 2 support Marc-André Lureau
2018-01-19 19:18 ` Laszlo Ersek
2018-01-19 19:48   ` Eric Blake
2018-01-19 20:29     ` Laszlo Ersek
2018-01-19 20:31 ` Eric Blake

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.