aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2022-08-29 12:19:40 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2022-09-21 14:11:03 -0400
commit517a63c2c48e5aaabe57de079e2d7f0bea09429b (patch)
tree2042e8a1a578cf61c31a257ab71c5bdaea2c9f32 /gdb
parentb872057a63c53106e4bf6033a52d53b988f30dfd (diff)
downloadgdb-517a63c2c48e5aaabe57de079e2d7f0bea09429b.zip
gdb-517a63c2c48e5aaabe57de079e2d7f0bea09429b.tar.gz
gdb-517a63c2c48e5aaabe57de079e2d7f0bea09429b.tar.bz2
gdbsupport: move fileio_errno_to_host to fileio.{h,cc} and rename
gdb_bfd.c and remote.c contain identical implementations of a fileio_error -> errno function. Factor that out to gdbsupport/fileio.{h,cc}. Rename it fileio_error_to_host, for symmetry with host_to_fileio_error. Change-Id: Ib9b8807683de2f809c94a5303e708acc2251a0df
Diffstat (limited to 'gdb')
-rw-r--r--gdb/gdb_bfd.c59
-rw-r--r--gdb/remote.c53
2 files changed, 4 insertions, 108 deletions
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 1438815..7e74389 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -303,59 +303,6 @@ gdb_bfd_open_from_target_memory (CORE_ADDR addr, ULONGEST size,
mem_bfd_iovec_stat);
}
-/* Return the system error number corresponding to ERRNUM. */
-
-static int
-fileio_errno_to_host (fileio_error errnum)
-{
- switch (errnum)
- {
- case FILEIO_EPERM:
- return EPERM;
- case FILEIO_ENOENT:
- return ENOENT;
- case FILEIO_EINTR:
- return EINTR;
- case FILEIO_EIO:
- return EIO;
- case FILEIO_EBADF:
- return EBADF;
- case FILEIO_EACCES:
- return EACCES;
- case FILEIO_EFAULT:
- return EFAULT;
- case FILEIO_EBUSY:
- return EBUSY;
- case FILEIO_EEXIST:
- return EEXIST;
- case FILEIO_ENODEV:
- return ENODEV;
- case FILEIO_ENOTDIR:
- return ENOTDIR;
- case FILEIO_EISDIR:
- return EISDIR;
- case FILEIO_EINVAL:
- return EINVAL;
- case FILEIO_ENFILE:
- return ENFILE;
- case FILEIO_EMFILE:
- return EMFILE;
- case FILEIO_EFBIG:
- return EFBIG;
- case FILEIO_ENOSPC:
- return ENOSPC;
- case FILEIO_ESPIPE:
- return ESPIPE;
- case FILEIO_EROFS:
- return EROFS;
- case FILEIO_ENOSYS:
- return ENOSYS;
- case FILEIO_ENAMETOOLONG:
- return ENAMETOOLONG;
- }
- return -1;
-}
-
/* bfd_openr_iovec OPEN_CLOSURE data for gdb_bfd_open. */
struct gdb_bfd_open_closure
{
@@ -383,7 +330,7 @@ gdb_bfd_iovec_fileio_open (struct bfd *abfd, void *open_closure)
&target_errno);
if (fd == -1)
{
- errno = fileio_errno_to_host (target_errno);
+ errno = fileio_error_to_host (target_errno);
bfd_set_error (bfd_error_system_call);
return NULL;
}
@@ -417,7 +364,7 @@ gdb_bfd_iovec_fileio_pread (struct bfd *abfd, void *stream, void *buf,
break;
if (bytes == -1)
{
- errno = fileio_errno_to_host (target_errno);
+ errno = fileio_error_to_host (target_errno);
bfd_set_error (bfd_error_system_call);
return -1;
}
@@ -479,7 +426,7 @@ gdb_bfd_iovec_fileio_fstat (struct bfd *abfd, void *stream,
result = target_fileio_fstat (fd, sb, &target_errno);
if (result == -1)
{
- errno = fileio_errno_to_host (target_errno);
+ errno = fileio_error_to_host (target_errno);
bfd_set_error (bfd_error_system_call);
}
diff --git a/gdb/remote.c b/gdb/remote.c
index b57d26a..2f6cb2d 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -12715,61 +12715,10 @@ remote_target::filesystem_is_local ()
return false;
}
-static int
-remote_fileio_errno_to_host (fileio_error errnum)
-{
- switch (errnum)
- {
- case FILEIO_EPERM:
- return EPERM;
- case FILEIO_ENOENT:
- return ENOENT;
- case FILEIO_EINTR:
- return EINTR;
- case FILEIO_EIO:
- return EIO;
- case FILEIO_EBADF:
- return EBADF;
- case FILEIO_EACCES:
- return EACCES;
- case FILEIO_EFAULT:
- return EFAULT;
- case FILEIO_EBUSY:
- return EBUSY;
- case FILEIO_EEXIST:
- return EEXIST;
- case FILEIO_ENODEV:
- return ENODEV;
- case FILEIO_ENOTDIR:
- return ENOTDIR;
- case FILEIO_EISDIR:
- return EISDIR;
- case FILEIO_EINVAL:
- return EINVAL;
- case FILEIO_ENFILE:
- return ENFILE;
- case FILEIO_EMFILE:
- return EMFILE;
- case FILEIO_EFBIG:
- return EFBIG;
- case FILEIO_ENOSPC:
- return ENOSPC;
- case FILEIO_ESPIPE:
- return ESPIPE;
- case FILEIO_EROFS:
- return EROFS;
- case FILEIO_ENOSYS:
- return ENOSYS;
- case FILEIO_ENAMETOOLONG:
- return ENAMETOOLONG;
- }
- return -1;
-}
-
static char *
remote_hostio_error (fileio_error errnum)
{
- int host_error = remote_fileio_errno_to_host (errnum);
+ int host_error = fileio_error_to_host (errnum);
if (host_error == -1)
error (_("Unknown remote I/O error %d"), errnum);