diff options
author | Pedro Alves <palves@redhat.com> | 2008-02-01 00:08:25 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2008-02-01 00:08:25 +0000 |
commit | 59a016f09f0e9a33e822fb0b79c608e582755dfd (patch) | |
tree | 199af344e15fcc1783d23bf7134efcc9326aad5d /gdb/gdbserver/hostio.c | |
parent | a279d1ff82b6dd3a2d64b236364669d88dedcc45 (diff) | |
download | gdb-59a016f09f0e9a33e822fb0b79c608e582755dfd.zip gdb-59a016f09f0e9a33e822fb0b79c608e582755dfd.tar.gz gdb-59a016f09f0e9a33e822fb0b79c608e582755dfd.tar.bz2 |
* hostio.c: Don't include errno.h.
(errno_to_fileio_errno): Move to hostio-errno.
* hostio.c: (hostio_error): Remove the error parameter. Defer the
error number outputting to the target->hostio_last_error callback.
(hostio_packet_error): Use FILEIO_EINVAL directly.
(handle_open, handle_pread, hostio_error, handle_unlink): Update
calls to hostio_error.
* hostio-errno.c: New.
* server.h (hostio_last_error_from_errno): Declare.
* target.h (target_ops): Add hostio_last_error member.
* linux-low.c (linux_target_op): Register hostio_last_error_from_errno
as hostio_last_error handler.
* spu-low.c (spu_target_ops): Likewise.
* win32-low.c [_WIN32_WCE] (win32_error_to_fileio_error)
(wince_hostio_last_error): New functions.
(win32_target_ops) [_WIN32_WCE]: Register wince_hostio_last_error
as hostio_last_error handler.
(win32_target_ops) [!_WIN32_WCE]: Register
hostio_last_error_from_errno as hostio_last_error handler.
* Makefile.in (SFILES): Add hostio.c and hostio-errno.c.
(hostio-errno.o): New rule.
* configure.ac (GDBSERVER_DEPFILES): Add $srv_hostio_err_objs.
* configure.srv (srv_hostio_err_objs): New variable. Default to
hostio-errno.o.
(arm*-*-mingw32ce*): Set srv_hostio_err_objs to "".
* configure: Regenerate.
Diffstat (limited to 'gdb/gdbserver/hostio.c')
-rw-r--r-- | gdb/gdbserver/hostio.c | 72 |
1 files changed, 10 insertions, 62 deletions
diff --git a/gdb/gdbserver/hostio.c b/gdb/gdbserver/hostio.c index 3ace725..712deb4 100644 --- a/gdb/gdbserver/hostio.c +++ b/gdb/gdbserver/hostio.c @@ -23,7 +23,6 @@ #include "server.h" #include "gdb/fileio.h" -#include <errno.h> #include <fcntl.h> #include <limits.h> #include <unistd.h> @@ -176,69 +175,18 @@ require_valid_fd (int fd) return -1; } -static int -errno_to_fileio_errno (int error) -{ - switch (error) - { - case EPERM: - return FILEIO_EPERM; - case ENOENT: - return FILEIO_ENOENT; - case EINTR: - return FILEIO_EINTR; - case EIO: - return FILEIO_EIO; - case EBADF: - return FILEIO_EBADF; - case EACCES: - return FILEIO_EACCES; - case EFAULT: - return FILEIO_EFAULT; - case EBUSY: - return FILEIO_EBUSY; - case EEXIST: - return FILEIO_EEXIST; - case ENODEV: - return FILEIO_ENODEV; - case ENOTDIR: - return FILEIO_ENOTDIR; - case EISDIR: - return FILEIO_EISDIR; - case EINVAL: - return FILEIO_EINVAL; - case ENFILE: - return FILEIO_ENFILE; - case EMFILE: - return FILEIO_EMFILE; - case EFBIG: - return FILEIO_EFBIG; - case ENOSPC: - return FILEIO_ENOSPC; - case ESPIPE: - return FILEIO_ESPIPE; - case EROFS: - return FILEIO_EROFS; - case ENOSYS: - return FILEIO_ENOSYS; - case ENAMETOOLONG: - return FILEIO_ENAMETOOLONG; - } - return FILEIO_EUNKNOWN; -} - +/* Fill in own_buf with the last hostio error packet, however it + suitable for the target. */ static void -hostio_error (char *own_buf, int error) +hostio_error (char *own_buf) { - int fileio_error = errno_to_fileio_errno (error); - - sprintf (own_buf, "F-1,%x", fileio_error); + the_target->hostio_last_error (own_buf); } static void hostio_packet_error (char *own_buf) { - hostio_error (own_buf, EINVAL); + sprintf (own_buf, "F-1,%x", FILEIO_EINVAL); } static void @@ -342,7 +290,7 @@ handle_open (char *own_buf) if (fd == -1) { - hostio_error (own_buf, errno); + hostio_error (own_buf); return; } @@ -386,7 +334,7 @@ handle_pread (char *own_buf, int *new_packet_len) if (ret == -1) { - hostio_error (own_buf, errno); + hostio_error (own_buf); free (data); return; } @@ -434,7 +382,7 @@ handle_pwrite (char *own_buf, int packet_len) if (ret == -1) { - hostio_error (own_buf, errno); + hostio_error (own_buf); free (data); return; } @@ -464,7 +412,7 @@ handle_close (char *own_buf) if (ret == -1) { - hostio_error (own_buf, errno); + hostio_error (own_buf); return; } @@ -499,7 +447,7 @@ handle_unlink (char *own_buf) if (ret == -1) { - hostio_error (own_buf, errno); + hostio_error (own_buf); return; } |