diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2022-06-07 12:38:26 -0700 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2022-06-28 04:35:07 +0530 |
commit | c805e118754a2c90c29219985ba389829d4a53a4 (patch) | |
tree | 7aacb825b8c96218f3b81af10c4cc631d5aa30dc /gdbstub.c | |
parent | 9814483d6346fb697c9f852f3a1edab0b6910486 (diff) |
gdbstub: Convert GDB error numbers to host error numbers
Provide the callback with consistent state -- always use
host error numbers. The individual callback can then
decide if the errno requires conversion for the guest.
Reviewed-by: Luc Michel <lmichel@kalray.eu>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'gdbstub.c')
-rw-r--r-- | gdbstub.c | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -1886,6 +1886,37 @@ static void handle_file_io(GArray *params, void *user_ctx) } else { err = 0; } + + /* Convert GDB error numbers back to host error numbers. */ +#define E(X) case GDB_E##X: err = E##X; break + switch (err) { + case 0: + break; + E(PERM); + E(NOENT); + E(INTR); + E(BADF); + E(ACCES); + E(FAULT); + E(BUSY); + E(EXIST); + E(NODEV); + E(NOTDIR); + E(ISDIR); + E(INVAL); + E(NFILE); + E(MFILE); + E(FBIG); + E(NOSPC); + E(SPIPE); + E(ROFS); + E(NAMETOOLONG); + default: + err = EINVAL; + break; + } +#undef E + gdbserver_state.current_syscall_cb(gdbserver_state.c_cpu, ret, err); gdbserver_state.current_syscall_cb = NULL; } |