From: Dominik 'Disconnect3d' Czarnota <[email protected]> This commit fixes an incorrect format string for formatting integers provided to GDB when debugging a target run in QEMU user mode.
The correct format is hexadecimal for both success and errno values, some of which can be seen here [0]. [0] https://github.com/bminor/binutils-gdb/blob/e65a355022d0dc6b5707310876a72b5693ec0aa5/gdbserver/hostio.cc#L196-L213 Signed-off-by: Dominik 'Disconnect3d' Czarnota <[email protected]> Reviewed-by: Alex Bennée <[email protected]> Fixes: e282010b2e1e ("gdbstub: Add support for info proc mappings") Cc: [email protected] Reviewed-by: Ilya Leoshkevich <[email protected]> Reviewed-by: Michael Tokarev <[email protected]> Signed-off-by: Michael Tokarev <[email protected]> (cherry picked from commit 8b647bd352505234cab2acd2422aba183a1aa1fd) Signed-off-by: Michael Tokarev <[email protected]> diff --git a/gdbstub/user-target.c b/gdbstub/user-target.c index c4bba4c72c..b760beb0fc 100644 --- a/gdbstub/user-target.c +++ b/gdbstub/user-target.c @@ -316,9 +316,9 @@ void gdb_handle_v_file_open(GArray *params, void *user_ctx) int fd = open(filename, flags, mode); #endif if (fd < 0) { - g_string_printf(gdbserver_state.str_buf, "F-1,%d", errno); + g_string_printf(gdbserver_state.str_buf, "F-1,%x", errno); } else { - g_string_printf(gdbserver_state.str_buf, "F%d", fd); + g_string_printf(gdbserver_state.str_buf, "F%x", fd); } gdb_put_strbuf(); } @@ -328,7 +328,7 @@ void gdb_handle_v_file_close(GArray *params, void *user_ctx) int fd = get_param(params, 0)->val_ul; if (close(fd) == -1) { - g_string_printf(gdbserver_state.str_buf, "F-1,%d", errno); + g_string_printf(gdbserver_state.str_buf, "F-1,%x", errno); gdb_put_strbuf(); return; } @@ -351,7 +351,7 @@ void gdb_handle_v_file_pread(GArray *params, void *user_ctx) ssize_t n = pread(fd, buf, bufsiz, offset); if (n < 0) { - g_string_printf(gdbserver_state.str_buf, "F-1,%d", errno); + g_string_printf(gdbserver_state.str_buf, "F-1,%x", errno); gdb_put_strbuf(); return; } @@ -374,7 +374,7 @@ void gdb_handle_v_file_readlink(GArray *params, void *user_ctx) ssize_t n = readlink(filename, buf, BUFSIZ); #endif if (n < 0) { - g_string_printf(gdbserver_state.str_buf, "F-1,%d", errno); + g_string_printf(gdbserver_state.str_buf, "F-1,%x", errno); gdb_put_strbuf(); return; } -- 2.39.5
