Commit 6f49ec40 authored by Marc-André Lureau's avatar Marc-André Lureau
Browse files

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
d23bfa91 ("add vmcoreinfo").

Suggested-by: default avatarPeter Maydell <peter.maydell@linaro.org>
Signed-off-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: default avatarLaszlo Ersek <lersek@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
parent b384cd95
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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."""