From 0b58a8391587b88eef3762b8f89aa5d00c88edbf Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Sun, 29 Jun 2003 04:01:39 +0000 Subject: * configure.in: Check whether we need to prototype strerror. * server.h: Optionally prototype strerror. * gdbreplay.c (perror_with_name): Use strerror. * linux-low.c (linux_attach_lwp): Use strerror. * utils.c (perror_with_name): Use strerror. * config.in, configure: Regenerated. --- gdb/gdbserver/ChangeLog | 9 ++++ gdb/gdbserver/config.in | 3 ++ gdb/gdbserver/configure | 106 ++++++++++++++++++++++++++++++++------------- gdb/gdbserver/configure.in | 2 + gdb/gdbserver/gdbreplay.c | 7 +-- gdb/gdbserver/linux-low.c | 3 +- gdb/gdbserver/server.h | 6 +++ gdb/gdbserver/utils.c | 7 +-- 8 files changed, 104 insertions(+), 39 deletions(-) (limited to 'gdb/gdbserver') diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index e2efaa277cd..80a328b81b0 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,12 @@ +2003-06-28 Daniel Jacobowitz + + * configure.in: Check whether we need to prototype strerror. + * server.h: Optionally prototype strerror. + * gdbreplay.c (perror_with_name): Use strerror. + * linux-low.c (linux_attach_lwp): Use strerror. + * utils.c (perror_with_name): Use strerror. + * config.in, configure: Regenerated. + 2003-06-28 Daniel Jacobowitz * linux-sh-low.c (sh_regmap): Fix FP register offsets, reported by diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in index 5141263f4c6..e9d21c81039 100644 --- a/gdb/gdbserver/config.in +++ b/gdb/gdbserver/config.in @@ -49,6 +49,9 @@ /* Define if you have the header file. */ #undef HAVE_UNISTD_H +/* Define if strerror is not declared in system header files. */ +#undef NEED_DECLARATION_STRERROR + /* Define if has lwpid_t. */ #undef HAVE_LWPID_T diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure index 0b9bee47a3c..62d3785f4ab 100755 --- a/gdb/gdbserver/configure +++ b/gdb/gdbserver/configure @@ -1146,6 +1146,54 @@ fi done +echo $ac_n "checking whether strerror must be declared""... $ac_c" 1>&6 +echo "configure:1151: checking whether strerror must be declared" >&5 +if eval "test \"`echo '$''{'bfd_cv_decl_needed_strerror'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#ifdef HAVE_STRING_H +#include +#else +#ifdef HAVE_STRINGS_H +#include +#endif +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +int main() { +char *(*pfn) = (char *(*)) strerror +; return 0; } +EOF +if { (eval echo configure:1177: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + bfd_cv_decl_needed_strerror=no +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + bfd_cv_decl_needed_strerror=yes +fi +rm -f conftest* +fi + +echo "$ac_t""$bfd_cv_decl_needed_strerror" 1>&6 +if test $bfd_cv_decl_needed_strerror = yes; then + cat >> confdefs.h <<\EOF +#define NEED_DECLARATION_STRERROR 1 +EOF + +fi + + . ${srcdir}/configure.srv if test "${srv_linux_usrregs}" = "yes"; then @@ -1157,19 +1205,19 @@ fi if test "${srv_linux_regsets}" = "yes"; then echo $ac_n "checking for PTRACE_GETREGS""... $ac_c" 1>&6 -echo "configure:1161: checking for PTRACE_GETREGS" >&5 +echo "configure:1209: checking for PTRACE_GETREGS" >&5 if eval "test \"`echo '$''{'gdbsrv_cv_have_ptrace_getregs'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { PTRACE_GETREGS; ; return 0; } EOF -if { (eval echo configure:1173: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1221: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* gdbsrv_cv_have_ptrace_getregs=yes else @@ -1190,19 +1238,19 @@ EOF fi echo $ac_n "checking for PTRACE_GETFPXREGS""... $ac_c" 1>&6 -echo "configure:1194: checking for PTRACE_GETFPXREGS" >&5 +echo "configure:1242: checking for PTRACE_GETFPXREGS" >&5 if eval "test \"`echo '$''{'gdbsrv_cv_have_ptrace_getfpxregs'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { PTRACE_GETFPXREGS; ; return 0; } EOF -if { (eval echo configure:1206: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1254: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* gdbsrv_cv_have_ptrace_getfpxregs=yes else @@ -1225,12 +1273,12 @@ fi if test "$ac_cv_header_sys_procfs_h" = yes; then echo $ac_n "checking for lwpid_t in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:1229: checking for lwpid_t in sys/procfs.h" >&5 +echo "configure:1277: checking for lwpid_t in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_lwpid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1291: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_lwpid_t=yes else @@ -1261,12 +1309,12 @@ EOF echo "$ac_t""$bfd_cv_have_sys_procfs_type_lwpid_t" 1>&6 echo $ac_n "checking for psaddr_t in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:1265: checking for psaddr_t in sys/procfs.h" >&5 +echo "configure:1313: checking for psaddr_t in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_psaddr_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1327: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_psaddr_t=yes else @@ -1297,12 +1345,12 @@ EOF echo "$ac_t""$bfd_cv_have_sys_procfs_type_psaddr_t" 1>&6 echo $ac_n "checking for prgregset_t in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:1301: checking for prgregset_t in sys/procfs.h" >&5 +echo "configure:1349: checking for prgregset_t in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prgregset_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1363: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_prgregset_t=yes else @@ -1333,12 +1381,12 @@ EOF echo "$ac_t""$bfd_cv_have_sys_procfs_type_prgregset_t" 1>&6 echo $ac_n "checking for prfpregset_t in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:1337: checking for prfpregset_t in sys/procfs.h" >&5 +echo "configure:1385: checking for prfpregset_t in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_prfpregset_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1399: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_prfpregset_t=yes else @@ -1373,7 +1421,7 @@ EOF if test $bfd_cv_have_sys_procfs_type_prfpregset_t = yes; then echo $ac_n "checking whether prfpregset_t type is broken""... $ac_c" 1>&6 -echo "configure:1377: checking whether prfpregset_t type is broken" >&5 +echo "configure:1425: checking whether prfpregset_t type is broken" >&5 if eval "test \"`echo '$''{'gdb_cv_prfpregset_t_broken'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1381,7 +1429,7 @@ else gdb_cv_prfpregset_t_broken=yes else cat > conftest.$ac_ext < int main () @@ -1391,7 +1439,7 @@ else return 0; } EOF -if { (eval echo configure:1395: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1443: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then gdb_cv_prfpregset_t_broken=no else @@ -1415,12 +1463,12 @@ EOF fi echo $ac_n "checking for elf_fpregset_t in sys/procfs.h""... $ac_c" 1>&6 -echo "configure:1419: checking for elf_fpregset_t in sys/procfs.h" >&5 +echo "configure:1467: checking for elf_fpregset_t in sys/procfs.h" >&5 if eval "test \"`echo '$''{'bfd_cv_have_sys_procfs_type_elf_fpregset_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1481: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* bfd_cv_have_sys_procfs_type_elf_fpregset_t=yes else @@ -1458,14 +1506,14 @@ USE_THREAD_DB= if test "$srv_linux_thread_db" = "yes"; then echo $ac_n "checking for libthread_db""... $ac_c" 1>&6 -echo "configure:1462: checking for libthread_db" >&5 +echo "configure:1510: checking for libthread_db" >&5 if eval "test \"`echo '$''{'srv_cv_thread_db'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else old_LIBS="$LIBS" LIBS="$LIBS -lthread_db" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1531: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* srv_cv_thread_db="-lthread_db" else @@ -1495,7 +1543,7 @@ else fi LIBS="$old_LIBS `eval echo "$thread_db"`" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1561: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* srv_cv_thread_db="$thread_db" else diff --git a/gdb/gdbserver/configure.in b/gdb/gdbserver/configure.in index 9c3106da616..a5a34dfbda0 100644 --- a/gdb/gdbserver/configure.in +++ b/gdb/gdbserver/configure.in @@ -34,6 +34,8 @@ AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl proc_service.h sys/procfs.h thread_db.h linux/elf.h dnl stdlib.h unistd.h) +BFD_NEED_DECLARATION(strerror) + . ${srcdir}/configure.srv if test "${srv_linux_usrregs}" = "yes"; then diff --git a/gdb/gdbserver/gdbreplay.c b/gdb/gdbserver/gdbreplay.c index 45242749a97..ec7a2b851fa 100644 --- a/gdb/gdbserver/gdbreplay.c +++ b/gdb/gdbserver/gdbreplay.c @@ -54,14 +54,15 @@ static void perror_with_name (char *string) { #ifndef STDC_HEADERS - extern int sys_nerr; - extern char *sys_errlist[]; extern int errno; #endif const char *err; char *combined; - err = (errno < sys_nerr) ? sys_errlist[errno] : "unknown error"; + err = strerror (errno); + if (err == NULL) + err = "unknown error"; + combined = (char *) alloca (strlen (err) + strlen (string) + 3); strcpy (combined, string); strcat (combined, ": "); diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index c700d40ba3a..55c187c1bd5 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -175,8 +175,7 @@ linux_attach_lwp (int pid, int tid) if (ptrace (PTRACE_ATTACH, pid, 0, 0) != 0) { fprintf (stderr, "Cannot attach to process %d: %s (%d)\n", pid, - errno < sys_nerr ? sys_errlist[errno] : "unknown error", - errno); + strerror (errno), errno); fflush (stderr); /* If we fail to attach to an LWP, just return. */ diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h index 746502b3d63..5212deb2c4a 100644 --- a/gdb/gdbserver/server.h +++ b/gdb/gdbserver/server.h @@ -34,6 +34,12 @@ #include #endif +#ifdef NEED_DECLARATION_STRERROR +#ifndef strerror +extern char *strerror (int); /* X3.159-1989 4.11.6.2 */ +#endif +#endif + #ifndef ATTR_NORETURN #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) #define ATTR_NORETURN __attribute__ ((noreturn)) diff --git a/gdb/gdbserver/utils.c b/gdb/gdbserver/utils.c index e13eda80d46..20244d6cf83 100644 --- a/gdb/gdbserver/utils.c +++ b/gdb/gdbserver/utils.c @@ -33,16 +33,13 @@ void perror_with_name (char *string) { #ifndef STDC_HEADERS - extern int sys_nerr; - extern char *sys_errlist[]; extern int errno; #endif const char *err; char *combined; - if (errno < sys_nerr) - err = sys_errlist[errno]; - else + err = strerror (errno); + if (err == NULL) err = "unknown error"; combined = (char *) alloca (strlen (err) + strlen (string) + 3); -- cgit v1.2.1