[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 4/7] gdbstub/user-target: fix gdbserver int format (%d -> %x)
From: |
Michael Tokarev |
Subject: |
[PULL 4/7] gdbstub/user-target: fix gdbserver int format (%d -> %x) |
Date: |
Thu, 30 Jan 2025 16:34:44 +0300 |
From: Dominik 'Disconnect3d' Czarnota <dominik.b.czarnota@gmail.com>
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 <dominik.b.czarnota@gmail.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Fixes: e282010b2e1e ("gdbstub: Add support for info proc mappings")
Cc: qemu-stable@nongnu.org
Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
gdbstub/user-target.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/gdbstub/user-target.c b/gdbstub/user-target.c
index 22bf4008c0..4bfcf78aaa 100644
--- a/gdbstub/user-target.c
+++ b/gdbstub/user-target.c
@@ -317,9 +317,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();
}
@@ -329,7 +329,7 @@ void gdb_handle_v_file_close(GArray *params, void *user_ctx)
int fd = gdb_get_cmd_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;
}
@@ -352,7 +352,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;
}
@@ -375,7 +375,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
- [PULL 0/7] Trivial patches for 2025-01-30, Michael Tokarev, 2025/01/30
- [PULL 1/7] net: Fix announce_self, Michael Tokarev, 2025/01/30
- [PULL 2/7] net/dump: Correctly compute Ethernet packet offset, Michael Tokarev, 2025/01/30
- [PULL 3/7] vvfat: create_long_filename: fix out-of-bounds array access, Michael Tokarev, 2025/01/30
- [PULL 4/7] gdbstub/user-target: fix gdbserver int format (%d -> %x),
Michael Tokarev <=
- [PULL 5/7] tests/functional/test_mips_malta: Fix comment about endianness of the test, Michael Tokarev, 2025/01/30
- [PULL 6/7] licenses: Remove SPDX tags not being license identifier for Linaro, Michael Tokarev, 2025/01/30
- [PULL 7/7] hw/i386/pc: Remove unused pc_compat_2_3 declarations, Michael Tokarev, 2025/01/30