From f8255c2a40ccc45f929b4ba2f20b74c52719b1a9 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Thu, 9 Feb 2012 17:29:34 +0000 Subject: [PATCH] [gdbserver] return ENOSYS if readlink not supported. This reproduces on the GDBserver side what GDB does when readlink is not supported. gdb/gdbserver/ChangeLog: * configure.ac: Add readlink to AC_CHECK_FUNCS list. * configure, config.in: Regenerate. * hostio.c: Provide an alternate implementation if HAVE_READLINK is not defined. --- gdb/gdbserver/ChangeLog | 7 +++++++ gdb/gdbserver/config.in | 3 +++ gdb/gdbserver/configure | 2 +- gdb/gdbserver/configure.ac | 2 +- gdb/gdbserver/hostio.c | 4 ++++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 690d2a68c3f..e0823091b50 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,10 @@ +2012-02-09 Joel Brobecker + + * configure.ac: Add readlink to AC_CHECK_FUNCS list. + * configure, config.in: Regenerate. + * hostio.c: Provide an alternate implementation if HAVE_READLINK + is not defined. + 2012-02-02 Pedro Alves Try SIGKILL first, then PTRACE_KILL. diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in index a9472eaa4fc..7fa3b5b21e3 100644 --- a/gdb/gdbserver/config.in +++ b/gdb/gdbserver/config.in @@ -128,6 +128,9 @@ /* Define to 1 if you have the `pwrite' function. */ #undef HAVE_PWRITE +/* Define to 1 if you have the `readlink' function. */ +#undef HAVE_READLINK + /* Define to 1 if you have the header file. */ #undef HAVE_SGTTY_H diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure index d92a00f3c0e..e251844bd4c 100755 --- a/gdb/gdbserver/configure +++ b/gdb/gdbserver/configure @@ -4163,7 +4163,7 @@ fi done -for ac_func in pread pwrite pread64 +for ac_func in pread pwrite pread64 readlink do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac index 30666ec4065..7c86cd45d14 100644 --- a/gdb/gdbserver/configure.ac +++ b/gdb/gdbserver/configure.ac @@ -43,7 +43,7 @@ AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl errno.h fcntl.h signal.h sys/file.h malloc.h dnl sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl netinet/tcp.h arpa/inet.h sys/wait.h) -AC_CHECK_FUNCS(pread pwrite pread64) +AC_CHECK_FUNCS(pread pwrite pread64 readlink) AC_REPLACE_FUNCS(memmem vasprintf vsnprintf) # Check for UST diff --git a/gdb/gdbserver/hostio.c b/gdb/gdbserver/hostio.c index 34e4fa8e09e..03aab587d98 100644 --- a/gdb/gdbserver/hostio.c +++ b/gdb/gdbserver/hostio.c @@ -459,6 +459,7 @@ handle_unlink (char *own_buf) static void handle_readlink (char *own_buf, int *new_packet_len) { +#if defined (HAVE_READLINK) char filename[PATH_MAX], linkname[PATH_MAX]; char *p; int ret, bytes_sent; @@ -485,6 +486,9 @@ handle_readlink (char *own_buf, int *new_packet_len) to return a partial response, but simply fail. */ if (bytes_sent < ret) sprintf (own_buf, "F-1,%x", FILEIO_ENAMETOOLONG); +#else /* ! HAVE_READLINK */ + sprintf (own_buf, "F-1,%x", FILEIO_ENOSYS); +#endif } /* Handle all the 'F' file transfer packets. */ -- 2.30.2