QEMU user emulation gdbstub emits incorrect file descriptor and errno values
Hi,
There are two bugs in the QEMU user emulation gdbstub code that I co-developed (e282010b2e1):
- We render file descriptor and errno integers into GDB remote protocol using "%d" format which is incorrect as GDB expects those values encoded in hexadecimal format. A patch for this has been sent to qemu-devel here (with cc to trivial-devel here).
- The errno values should be mapped from host system errno value to a GDB fileio errno value. GDB maps those values with the
host_to_fileio_errorfunction called fromhostio_error. The values are mmaped via thefileio_errorenum defined in the GDB's gdbsupport/fileio.h file.
Additionally, we should probably implement a qGDBServerVersion packet which could be used by clients to detect the QEMU version and use workarounds for known bugs.
PS: Thanks to patryk4815 who found this bug and reported this initially on https://github.com/pwndbg/pwndbg/issues/2648.
Edited by Disconnect3d