gdbstub/user-target: Convert host errno to GDB File-I/O errno
Use host_to_gdb_errno to convert host-supplied errnos to their GDB File-I/O remote protocol values, and use them in F reply packets. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2751 Reported-by: Dominik 'Disconnect3d' Czarnota <dominik.b.czarnota@gmail.com> Signed-off-by: Yodel Eldar <yodel.eldar@yodel.dev> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20260116014612.226183-4-yodel.eldar@yodel.dev> Message-ID: <20260203115201.2387721-10-alex.bennee@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "exec/gdbstub.h"
|
#include "exec/gdbstub.h"
|
||||||
#include "gdbstub/commands.h"
|
#include "gdbstub/commands.h"
|
||||||
|
#include "gdbstub/syscalls.h"
|
||||||
#include "qemu.h"
|
#include "qemu.h"
|
||||||
#include "internals.h"
|
#include "internals.h"
|
||||||
#ifdef CONFIG_LINUX
|
#ifdef CONFIG_LINUX
|
||||||
@@ -315,7 +316,8 @@ void gdb_handle_v_file_open(GArray *params, void *user_ctx)
|
|||||||
int fd = open(filename, flags, mode);
|
int fd = open(filename, flags, mode);
|
||||||
#endif
|
#endif
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
g_string_printf(gdbserver_state.str_buf, "F-1,%x", errno);
|
int gdb_errno = host_to_gdb_errno(errno);
|
||||||
|
g_string_printf(gdbserver_state.str_buf, "F-1,%x", gdb_errno);
|
||||||
} else {
|
} else {
|
||||||
g_string_printf(gdbserver_state.str_buf, "F%x", fd);
|
g_string_printf(gdbserver_state.str_buf, "F%x", fd);
|
||||||
}
|
}
|
||||||
@@ -327,7 +329,8 @@ void gdb_handle_v_file_close(GArray *params, void *user_ctx)
|
|||||||
int fd = gdb_get_cmd_param(params, 0)->val_ul;
|
int fd = gdb_get_cmd_param(params, 0)->val_ul;
|
||||||
|
|
||||||
if (close(fd) == -1) {
|
if (close(fd) == -1) {
|
||||||
g_string_printf(gdbserver_state.str_buf, "F-1,%x", errno);
|
int gdb_errno = host_to_gdb_errno(errno);
|
||||||
|
g_string_printf(gdbserver_state.str_buf, "F-1,%x", gdb_errno);
|
||||||
gdb_put_strbuf();
|
gdb_put_strbuf();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -350,7 +353,8 @@ void gdb_handle_v_file_pread(GArray *params, void *user_ctx)
|
|||||||
|
|
||||||
ssize_t n = pread(fd, buf, bufsiz, offset);
|
ssize_t n = pread(fd, buf, bufsiz, offset);
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
g_string_printf(gdbserver_state.str_buf, "F-1,%x", errno);
|
int gdb_errno = host_to_gdb_errno(errno);
|
||||||
|
g_string_printf(gdbserver_state.str_buf, "F-1,%x", gdb_errno);
|
||||||
gdb_put_strbuf();
|
gdb_put_strbuf();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -373,7 +377,8 @@ void gdb_handle_v_file_readlink(GArray *params, void *user_ctx)
|
|||||||
ssize_t n = readlink(filename, buf, BUFSIZ);
|
ssize_t n = readlink(filename, buf, BUFSIZ);
|
||||||
#endif
|
#endif
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
g_string_printf(gdbserver_state.str_buf, "F-1,%x", errno);
|
int gdb_errno = host_to_gdb_errno(errno);
|
||||||
|
g_string_printf(gdbserver_state.str_buf, "F-1,%x", gdb_errno);
|
||||||
gdb_put_strbuf();
|
gdb_put_strbuf();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user