diff options
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 29 | ||||
-rw-r--r-- | gdb/gdbserver/Makefile.in | 4 | ||||
-rwxr-xr-x | gdb/gdbserver/configure | 2 | ||||
-rw-r--r-- | gdb/gdbserver/configure.ac | 2 | ||||
-rw-r--r-- | gdb/gdbserver/configure.srv | 7 | ||||
-rw-r--r-- | gdb/gdbserver/hostio-errno.c | 88 | ||||
-rw-r--r-- | gdb/gdbserver/hostio.c | 72 | ||||
-rw-r--r-- | gdb/gdbserver/linux-low.c | 2 | ||||
-rw-r--r-- | gdb/gdbserver/server.h | 3 | ||||
-rw-r--r-- | gdb/gdbserver/spu-low.c | 1 | ||||
-rw-r--r-- | gdb/gdbserver/target.h | 4 | ||||
-rw-r--r-- | gdb/gdbserver/win32-low.c | 68 |
12 files changed, 216 insertions, 66 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 5a6e7b9e920..07f0a447c56 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,32 @@ +2008-02-01 Pedro Alves <pedro_alves@portugalmail.pt> + + * 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. + 2008-01-29 Daniel Jacobowitz <dan@codesourcery.com> * linux-low.c (linux_attach_lwp): Do not _exit after errors. diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in index 91e5c1f6f5f..d643bdf379c 100644 --- a/gdb/gdbserver/Makefile.in +++ b/gdb/gdbserver/Makefile.in @@ -130,7 +130,8 @@ SFILES= $(srcdir)/gdbreplay.c $(srcdir)/inferiors.c \ $(srcdir)/linux-s390-low.c \ $(srcdir)/linux-sh-low.c $(srcdir)/linux-x86-64-low.c \ $(srcdir)/win32-arm-low.c $(srcdir)/win32-i386-low.c \ - $(srcdir)/win32-low.c $(srcdir)/wincecompat.c + $(srcdir)/win32-low.c $(srcdir)/wincecompat.c \ + $(srcdir)/hostio.c $(srcdir)/hostio-errno.c DEPFILES = @GDBSERVER_DEPFILES@ @@ -278,6 +279,7 @@ server_h = $(srcdir)/server.h $(regcache_h) config.h $(srcdir)/target.h \ $(srcdir)/mem-break.h hostio.o: hostio.c $(server_h) +hostio-errno.o: hostio-errno.c $(server_h) inferiors.o: inferiors.c $(server_h) mem-break.o: mem-break.c $(server_h) proc-service.o: proc-service.c $(server_h) $(gdb_proc_service_h) diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure index b8b28790826..5dad21c15f8 100755 --- a/gdb/gdbserver/configure +++ b/gdb/gdbserver/configure @@ -4403,7 +4403,7 @@ _ACEOF done fi -GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_thread_depfiles" +GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles" GDBSERVER_LIBS="$srv_libs" diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac index 819feade83a..979c92530ed 100644 --- a/gdb/gdbserver/configure.ac +++ b/gdb/gdbserver/configure.ac @@ -214,7 +214,7 @@ if test "$srv_xmltarget" != ""; then done fi -GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_thread_depfiles" +GDBSERVER_DEPFILES="$srv_regobj $srv_tgtobj $srv_hostio_err_objs $srv_thread_depfiles" GDBSERVER_LIBS="$srv_libs" AC_SUBST(GDBSERVER_DEPFILES) diff --git a/gdb/gdbserver/configure.srv b/gdb/gdbserver/configure.srv index 24ee3089776..b57c8a50ce1 100644 --- a/gdb/gdbserver/configure.srv +++ b/gdb/gdbserver/configure.srv @@ -6,6 +6,8 @@ # srv_regobj The register protocol appropriate for this target. # srv_tgtobj Any other target-specific modules appropriate # for this target. +# srv_hostio_err The object implementing the hostio_last_error +# target method. # srv_xmltarget The XML source file to use for target.xml, if any. # srv_xmlfiles Any other XML files which should be available for # gdbserver in this configuration. @@ -18,6 +20,9 @@ # srv_linux_usrregs Set to "yes" if we can get at registers via # PTRACE_PEEKUSR / PTRACE_POKEUSR. +# Default hostio_last_error implementation +srv_hostio_err_objs="hostio-errno.o" + # Input is taken from the "${target}" variable. case "${target}" in @@ -36,6 +41,8 @@ case "${target}" in arm*-*-mingw32ce*) srv_regobj=reg-arm.o srv_tgtobj="win32-low.o win32-arm-low.o" srv_tgtobj="${srv_tgtobj} wincecompat.o" + # hostio_last_error implementation is in win32-low.c + srv_hostio_err_objs="" srv_mingw=yes srv_mingwce=yes ;; diff --git a/gdb/gdbserver/hostio-errno.c b/gdb/gdbserver/hostio-errno.c new file mode 100644 index 00000000000..140cc64e63a --- /dev/null +++ b/gdb/gdbserver/hostio-errno.c @@ -0,0 +1,88 @@ +/* Host file transfer support for gdbserver. + Copyright (C) 2007, 2008 Free Software Foundation, Inc. + + Contributed by CodeSourcery. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* This file implements the hostio_last_error target callback + on top of errno. */ + +#include <errno.h> +#include "server.h" +#include "gdb/fileio.h" + +static int +errno_to_fileio_error (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; +} + +void +hostio_last_error_from_errno (char *buf) +{ + int error = errno; + int fileio_error = errno_to_fileio_error (error); + sprintf (buf, "F-1,%x", fileio_error); +} diff --git a/gdb/gdbserver/hostio.c b/gdb/gdbserver/hostio.c index 3ace72538b2..712deb487e2 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; } diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index f5bf5dce472..c2b66c34227 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -2053,6 +2053,8 @@ static struct target_ops linux_target_ops = { NULL, #endif linux_arch_string, + NULL, + hostio_last_error_from_errno, }; static void diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h index 745d7b63f4b..107813b8398 100644 --- a/gdb/gdbserver/server.h +++ b/gdb/gdbserver/server.h @@ -159,6 +159,9 @@ extern jmp_buf toplevel; /* Functions from hostio.c. */ extern int handle_vFile (char *, int, int *); +/* Functions from hostio-errno.c. */ +extern void hostio_last_error_from_errno (char *own_buf); + /* From remote-utils.c */ extern int remote_debug; diff --git a/gdb/gdbserver/spu-low.c b/gdb/gdbserver/spu-low.c index 8579e8be46c..bba7c193be6 100644 --- a/gdb/gdbserver/spu-low.c +++ b/gdb/gdbserver/spu-low.c @@ -590,6 +590,7 @@ static struct target_ops spu_target_ops = { NULL, spu_arch_string, spu_proc_xfer_spu, + hostio_last_error_from_errno, }; void diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h index 4f6377d6fe0..8bb7a07b3d7 100644 --- a/gdb/gdbserver/target.h +++ b/gdb/gdbserver/target.h @@ -188,6 +188,10 @@ struct target_ops /* Read/Write from/to spufs using qXfer packets. */ int (*qxfer_spu) (const char *annex, unsigned char *readbuf, unsigned const char *writebuf, CORE_ADDR offset, int len); + + /* Fill BUF with an hostio error packet representing the last hostio + error. */ + void (*hostio_last_error) (char *buf); }; extern struct target_ops *the_target; diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c index a47ba89f826..141403d81f1 100644 --- a/gdb/gdbserver/win32-low.c +++ b/gdb/gdbserver/win32-low.c @@ -21,6 +21,7 @@ #include "server.h" #include "regcache.h" #include "gdb/signals.h" +#include "gdb/fileio.h" #include "mem-break.h" #include "win32-low.h" @@ -1653,6 +1654,65 @@ win32_arch_string (void) return the_low_target.arch_string; } +#ifdef _WIN32_WCE +int +win32_error_to_fileio_error (DWORD err) +{ + switch (err) + { + case ERROR_BAD_PATHNAME: + case ERROR_FILE_NOT_FOUND: + case ERROR_INVALID_NAME: + case ERROR_PATH_NOT_FOUND: + return FILEIO_ENOENT; + case ERROR_CRC: + case ERROR_IO_DEVICE: + case ERROR_OPEN_FAILED: + return FILEIO_EIO; + case ERROR_INVALID_HANDLE: + return FILEIO_EBADF; + case ERROR_ACCESS_DENIED: + case ERROR_SHARING_VIOLATION: + return FILEIO_EACCES; + case ERROR_NOACCESS: + return FILEIO_EFAULT; + case ERROR_BUSY: + return FILEIO_EBUSY; + case ERROR_ALREADY_EXISTS: + case ERROR_FILE_EXISTS: + return FILEIO_EEXIST; + case ERROR_BAD_DEVICE: + return FILEIO_ENODEV; + case ERROR_DIRECTORY: + return FILEIO_ENOTDIR; + case ERROR_FILENAME_EXCED_RANGE: + case ERROR_INVALID_DATA: + case ERROR_INVALID_PARAMETER: + case ERROR_NEGATIVE_SEEK: + return FILEIO_EINVAL; + case ERROR_TOO_MANY_OPEN_FILES: + return FILEIO_EMFILE; + case ERROR_HANDLE_DISK_FULL: + case ERROR_DISK_FULL: + return FILEIO_ENOSPC; + case ERROR_WRITE_PROTECT: + return FILEIO_EROFS; + case ERROR_NOT_SUPPORTED: + return FILEIO_ENOSYS; + } + + return FILEIO_EUNKNOWN; +} + +static void +wince_hostio_last_error (char *buf) +{ + DWORD winerr = GetLastError (); + int fileio_err = win32_error_to_fileio_error (winerr); + sprintf (buf, "F-1,%x", fileio_err); +} +#endif + static struct target_ops win32_target_ops = { win32_create_inferior, win32_attach, @@ -1675,7 +1735,13 @@ static struct target_ops win32_target_ops = { NULL, NULL, NULL, - win32_arch_string + win32_arch_string, + NULL, +#ifdef _WIN32_WCE + wince_hostio_last_error, +#else + hostio_last_error_from_errno, +#endif }; /* Initialize the Win32 backend. */ |