diff options
author | Ulrich Weigand <uweigand@de.ibm.com> | 2012-01-20 09:47:32 +0000 |
---|---|---|
committer | Ulrich Weigand <uweigand@de.ibm.com> | 2012-01-20 09:47:32 +0000 |
commit | b9e7b9c3de60f6aef716ac169d82418ea27d4331 (patch) | |
tree | d50dcabd991b1b7fa639b51eba142bd39db2f4b8 /gdb/gdbserver | |
parent | 7313baad7c73664bed62b87481cbb078d71e84f4 (diff) | |
download | gdb-b9e7b9c3de60f6aef716ac169d82418ea27d4331.zip gdb-b9e7b9c3de60f6aef716ac169d82418ea27d4331.tar.gz gdb-b9e7b9c3de60f6aef716ac169d82418ea27d4331.tar.bz2 |
ChangeLog:
* configure.ac [AC_CHECK_FUNCS]: Check for readlink.
* config.in, configure: Regenerate.
* target.h (struct target_ops): Add to_fileio_readlink.
(target_fileio_readlink): Add prototype.
* target.c (target_fileio_readlink): New function.
* inf-child.c: Conditionally include <sys/param.h>.
(inf_child_fileio_readlink): New function.
(inf_child_target): Install it.
* remote.c (PACKET_vFile_readlink): New enum value.
(remote_hostio_readlink): New function.
(init_remote_ops): Install it.
(_initialize_remote): Handle vFile:readlink packet type.
doc/ChangeLog:
* gdb.texinfo (Remote Configuration): Document
"set remote hostio-readlink-packet" command.
(General Query Packets): Document vFile:readlink packet.
gdbserver/ChangeLog:
* hostio.c (handle_readlink): New function.
(handle_vFile): Call it to handle "vFile:readlink" packets.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/gdbserver/hostio.c | 33 |
2 files changed, 38 insertions, 0 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 72f0286..0cb67da 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,8 @@ +2012-01-20 Ulrich Weigand <ulrich.weigand@linaro.org> + + * hostio.c (handle_readlink): New function. + (handle_vFile): Call it to handle "vFile:readlink" packets. + 2012-01-20 Pedro Alves <palves@redhat.com> Ulrich Weigand <ulrich.weigand@linaro.org> diff --git a/gdb/gdbserver/hostio.c b/gdb/gdbserver/hostio.c index b1508ec..34e4fa8 100644 --- a/gdb/gdbserver/hostio.c +++ b/gdb/gdbserver/hostio.c @@ -456,6 +456,37 @@ handle_unlink (char *own_buf) hostio_reply (own_buf, ret); } +static void +handle_readlink (char *own_buf, int *new_packet_len) +{ + char filename[PATH_MAX], linkname[PATH_MAX]; + char *p; + int ret, bytes_sent; + + p = own_buf + strlen ("vFile:readlink:"); + + if (require_filename (&p, filename) + || require_end (p)) + { + hostio_packet_error (own_buf); + return; + } + + ret = readlink (filename, linkname, sizeof linkname); + if (ret == -1) + { + hostio_error (own_buf); + return; + } + + bytes_sent = hostio_reply_with_data (own_buf, linkname, ret, new_packet_len); + + /* If the response does not fit into a single packet, do not attempt + to return a partial response, but simply fail. */ + if (bytes_sent < ret) + sprintf (own_buf, "F-1,%x", FILEIO_ENAMETOOLONG); +} + /* Handle all the 'F' file transfer packets. */ int @@ -471,6 +502,8 @@ handle_vFile (char *own_buf, int packet_len, int *new_packet_len) handle_close (own_buf); else if (strncmp (own_buf, "vFile:unlink:", 13) == 0) handle_unlink (own_buf); + else if (strncmp (own_buf, "vFile:readlink:", 15) == 0) + handle_readlink (own_buf, new_packet_len); else return 0; |