diff options
author | Ulrich Weigand <uweigand@de.ibm.com> | 2012-08-02 15:52:27 +0000 |
---|---|---|
committer | Ulrich Weigand <uweigand@de.ibm.com> | 2012-08-02 15:52:27 +0000 |
commit | 7c3270aec11d401689c9b9cbd6b1c9d574385526 (patch) | |
tree | a87ae8ed68bfb99d6b7931941ec021e4fe7d3e40 /gdb/inf-child.c | |
parent | 399c99f739767af94870e8fde027f9f0473fad16 (diff) | |
download | gdb-7c3270aec11d401689c9b9cbd6b1c9d574385526.zip gdb-7c3270aec11d401689c9b9cbd6b1c9d574385526.tar.gz gdb-7c3270aec11d401689c9b9cbd6b1c9d574385526.tar.bz2 |
ChangeLog:
* inf-child.c (inf_child_fileio_pwrite): If pwrite fails, fall back
to attempting lseek/write.
(inf_child_fileio_pread): Likewise for pread.
gdbserver/ChangeLog:
* hostio.c (handle_pread): If pread fails, fall back to attempting
lseek/read.
(handle_pwrite): Likewise for pwrite.
Diffstat (limited to 'gdb/inf-child.c')
-rw-r--r-- | gdb/inf-child.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/gdb/inf-child.c b/gdb/inf-child.c index 54e65c5..ae2dd1e 100644 --- a/gdb/inf-child.c +++ b/gdb/inf-child.c @@ -265,10 +265,15 @@ inf_child_fileio_pwrite (int fd, const gdb_byte *write_buf, int len, #ifdef HAVE_PWRITE ret = pwrite (fd, write_buf, len, (long) offset); #else - ret = lseek (fd, (long) offset, SEEK_SET); - if (ret != -1) - ret = write (fd, write_buf, len); + ret = -1; #endif + /* If we have no pwrite or it failed for this file, use lseek/write. */ + if (ret == -1) + { + ret = lseek (fd, (long) offset, SEEK_SET); + if (ret != -1) + ret = write (fd, write_buf, len); + } if (ret == -1) *target_errno = inf_child_errno_to_fileio_error (errno); @@ -288,10 +293,15 @@ inf_child_fileio_pread (int fd, gdb_byte *read_buf, int len, #ifdef HAVE_PREAD ret = pread (fd, read_buf, len, (long) offset); #else - ret = lseek (fd, (long) offset, SEEK_SET); - if (ret != -1) - ret = read (fd, read_buf, len); + ret = -1; #endif + /* If we have no pread or it failed for this file, use lseek/read. */ + if (ret == -1) + { + ret = lseek (fd, (long) offset, SEEK_SET); + if (ret != -1) + ret = read (fd, read_buf, len); + } if (ret == -1) *target_errno = inf_child_errno_to_fileio_error (errno); |