From 9c232dda88ade649e92be7a6c9917e0a80ea54c8 Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Fri, 21 Nov 2014 22:05:41 +0800 Subject: [PATCH] Include alloca.h unconditionally Since gnulib alloca module was imported, we can include alloca.h in both gdb and gdbserver unconditionally, so this patch adds inclusion of alloca.h in common-defs.h. This patch also removes AC_FUNC_ALLOCA in configure.ac because we don't need to check alloca any more. This patch below is removed in fact. [RFA/commit] include alloca.h if available. https://www.sourceware.org/ml/gdb-patches/2010-08/msg00566.html Since alloca.h is from gnulib now, we don't have to check malloc.h in configure and include malloc.h in code. This patch also remove them too. gdb: 2014-11-21 Yao Qi * common/common-defs.h: Include alloca.h * configure.ac: Don't invoke AC_FUNC_ALLOCA. * configure: Re-generated. * defs.h: Remove code handling alloca. * utils.c (gdb_realpath): Don't check HAVE_ALLOCA is defined or not. gdb/gdbserver: 2014-11-21 Yao Qi * configure.ac: Don't invoke AC_FUNC_ALLOCA. (AC_CHECK_HEADERS): Remove malloc.h. * configure: Re-generated. * config.in: Re-generated. * server.h: Don't include alloca.h and malloc.h. * gdbreplay.c: Don't check HAVE_ALLOCA_H is defined. Don't include malloc.h. --- gdb/ChangeLog | 9 ++ gdb/common/common-defs.h | 1 + gdb/configure | 190 ------------------------------------ gdb/configure.ac | 1 - gdb/defs.h | 21 ---- gdb/gdbserver/ChangeLog | 10 ++ gdb/gdbserver/config.in | 3 - gdb/gdbserver/configure | 195 +------------------------------------ gdb/gdbserver/configure.ac | 4 +- gdb/gdbserver/gdbreplay.c | 7 +- gdb/gdbserver/server.h | 9 -- gdb/utils.c | 2 +- 12 files changed, 26 insertions(+), 426 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c0b6199cb9..c35fe5e7e6 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2014-11-21 Yao Qi + + * common/common-defs.h: Include alloca.h + * configure.ac: Don't invoke AC_FUNC_ALLOCA. + * configure: Re-generated. + * defs.h: Remove code handling alloca. + * utils.c (gdb_realpath): Don't check HAVE_ALLOCA is defined + or not. + 2014-11-21 Yao Qi * gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULE): Add diff --git a/gdb/common/common-defs.h b/gdb/common/common-defs.h index 4d2e8a73bb..0a5256a617 100644 --- a/gdb/common/common-defs.h +++ b/gdb/common/common-defs.h @@ -33,6 +33,7 @@ #include #include #include +#include #include "ansidecl.h" #include "libiberty.h" #include "pathmax.h" diff --git a/gdb/configure b/gdb/configure index 1d6d88be76..ade1755030 100755 --- a/gdb/configure +++ b/gdb/configure @@ -10072,196 +10072,6 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h # Checks for library functions. # # ------------------------------ # -# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works -# for constant arguments. Useless! -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 -$as_echo_n "checking for working alloca.h... " >&6; } -if test "${ac_cv_working_alloca_h+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -char *p = (char *) alloca (2 * sizeof (int)); - if (p) return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_working_alloca_h=yes -else - ac_cv_working_alloca_h=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 -$as_echo "$ac_cv_working_alloca_h" >&6; } -if test $ac_cv_working_alloca_h = yes; then - -$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 -$as_echo_n "checking for alloca... " >&6; } -if test "${ac_cv_func_alloca_works+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __GNUC__ -# define alloca __builtin_alloca -#else -# ifdef _MSC_VER -# include -# define alloca _alloca -# else -# ifdef HAVE_ALLOCA_H -# include -# else -# ifdef _AIX - #pragma alloca -# else -# ifndef alloca /* predefined by HP cc +Olibcalls */ -char *alloca (); -# endif -# endif -# endif -# endif -#endif - -int -main () -{ -char *p = (char *) alloca (1); - if (p) return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_func_alloca_works=yes -else - ac_cv_func_alloca_works=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 -$as_echo "$ac_cv_func_alloca_works" >&6; } - -if test $ac_cv_func_alloca_works = yes; then - -$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h - -else - # The SVR3 libPW and SVR4 libucb both contain incompatible functions -# that cause trouble. Some versions do not even contain alloca or -# contain a buggy version. If you still want to use their alloca, -# use ar to extract alloca.o from them instead of compiling alloca.c. - -ALLOCA=\${LIBOBJDIR}alloca.$ac_objext - -$as_echo "#define C_ALLOCA 1" >>confdefs.h - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 -$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } -if test "${ac_cv_os_cray+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#if defined CRAY && ! defined CRAY2 -webecray -#else -wenotbecray -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "webecray" >/dev/null 2>&1; then : - ac_cv_os_cray=yes -else - ac_cv_os_cray=no -fi -rm -f conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 -$as_echo "$ac_cv_os_cray" >&6; } -if test $ac_cv_os_cray = yes; then - for ac_func in _getb67 GETB67 getb67; 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" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : - -cat >>confdefs.h <<_ACEOF -#define CRAY_STACKSEG_END $ac_func -_ACEOF - - break -fi - - done -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 -$as_echo_n "checking stack direction for C alloca... " >&6; } -if test "${ac_cv_c_stack_direction+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_c_stack_direction=0 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -find_stack_direction () -{ - static char *addr = 0; - auto char dummy; - if (addr == 0) - { - addr = &dummy; - return find_stack_direction (); - } - else - return (&dummy > addr) ? 1 : -1; -} - -int -main () -{ - return find_stack_direction () < 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_c_stack_direction=1 -else - ac_cv_c_stack_direction=-1 -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 -$as_echo "$ac_cv_c_stack_direction" >&6; } -cat >>confdefs.h <<_ACEOF -#define STACK_DIRECTION $ac_cv_c_stack_direction -_ACEOF - - -fi - for ac_header in stdlib.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` diff --git a/gdb/configure.ac b/gdb/configure.ac index 2d736691c2..98eb57b5b5 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -1302,7 +1302,6 @@ AC_C_BIGENDIAN # Checks for library functions. # # ------------------------------ # -AC_FUNC_ALLOCA AC_FUNC_MMAP AC_FUNC_VFORK AC_CHECK_FUNCS([canonicalize_file_name realpath getrusage getuid getgid \ diff --git a/gdb/defs.h b/gdb/defs.h index 1eb43ebce4..6b63b6ad78 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -548,27 +548,6 @@ enum gdb_osabi extern double atof (const char *); /* X3.159-1989 4.10.1.1 */ #endif -/* Various possibilities for alloca. */ -#ifndef alloca -#ifdef __GNUC__ -#define alloca __builtin_alloca -#else /* Not GNU C */ -#ifdef HAVE_ALLOCA_H -#include -#else -#ifdef _AIX -#pragma alloca -#else - -/* We need to be careful not to declare this in a way which conflicts with - bison. Bison never declares it as char *, but under various circumstances - (like __hpux) we need to use void *. */ -extern void *alloca (); -#endif /* Not _AIX */ -#endif /* Not HAVE_ALLOCA_H */ -#endif /* Not GNU C */ -#endif /* alloca not defined */ - /* Dynamic target-system-dependent parameters for GDB. */ #include "gdbarch.h" diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 0c25069e0c..141947089f 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,13 @@ +2014-11-21 Yao Qi + + * configure.ac: Don't invoke AC_FUNC_ALLOCA. + (AC_CHECK_HEADERS): Remove malloc.h. + * configure: Re-generated. + * config.in: Re-generated. + * server.h: Don't include alloca.h and malloc.h. + * gdbreplay.c: Don't check HAVE_ALLOCA_H is defined. + Don't include malloc.h. + 2014-11-17 Joel Brobecker * lynx-low.c (lynx_write_memory): Put lynx_read_memory and diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in index 7828bf9ce0..8cac20538e 100644 --- a/gdb/gdbserver/config.in +++ b/gdb/gdbserver/config.in @@ -96,9 +96,6 @@ /* Define if has lwpid_t. */ #undef HAVE_LWPID_T -/* Define to 1 if you have the header file. */ -#undef HAVE_MALLOC_H - /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure index 9495905c66..22666178a0 100755 --- a/gdb/gdbserver/configure +++ b/gdb/gdbserver/configure @@ -605,6 +605,7 @@ WERROR_CFLAGS WARN_CFLAGS ustinc ustlibs +ALLOCA SET_MAKE GMAKE_FALSE GMAKE_TRUE @@ -614,7 +615,6 @@ DEPDIR am__leading_dot host_noncanonical target_noncanonical -ALLOCA RANLIB AR INSTALL_DATA @@ -4225,197 +4225,6 @@ $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi -# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works -# for constant arguments. Useless! -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 -$as_echo_n "checking for working alloca.h... " >&6; } -if test "${ac_cv_working_alloca_h+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ -char *p = (char *) alloca (2 * sizeof (int)); - if (p) return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_working_alloca_h=yes -else - ac_cv_working_alloca_h=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 -$as_echo "$ac_cv_working_alloca_h" >&6; } -if test $ac_cv_working_alloca_h = yes; then - -$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 -$as_echo_n "checking for alloca... " >&6; } -if test "${ac_cv_func_alloca_works+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#ifdef __GNUC__ -# define alloca __builtin_alloca -#else -# ifdef _MSC_VER -# include -# define alloca _alloca -# else -# ifdef HAVE_ALLOCA_H -# include -# else -# ifdef _AIX - #pragma alloca -# else -# ifndef alloca /* predefined by HP cc +Olibcalls */ -char *alloca (); -# endif -# endif -# endif -# endif -#endif - -int -main () -{ -char *p = (char *) alloca (1); - if (p) return 0; - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_func_alloca_works=yes -else - ac_cv_func_alloca_works=no -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 -$as_echo "$ac_cv_func_alloca_works" >&6; } - -if test $ac_cv_func_alloca_works = yes; then - -$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h - -else - # The SVR3 libPW and SVR4 libucb both contain incompatible functions -# that cause trouble. Some versions do not even contain alloca or -# contain a buggy version. If you still want to use their alloca, -# use ar to extract alloca.o from them instead of compiling alloca.c. - -ALLOCA=\${LIBOBJDIR}alloca.$ac_objext - -$as_echo "#define C_ALLOCA 1" >>confdefs.h - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 -$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } -if test "${ac_cv_os_cray+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#if defined CRAY && ! defined CRAY2 -webecray -#else -wenotbecray -#endif - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "webecray" >/dev/null 2>&1; then : - ac_cv_os_cray=yes -else - ac_cv_os_cray=no -fi -rm -f conftest* - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 -$as_echo "$ac_cv_os_cray" >&6; } -if test $ac_cv_os_cray = yes; then - for ac_func in _getb67 GETB67 getb67; 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" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : - -cat >>confdefs.h <<_ACEOF -#define CRAY_STACKSEG_END $ac_func -_ACEOF - - break -fi - - done -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 -$as_echo_n "checking stack direction for C alloca... " >&6; } -if test "${ac_cv_c_stack_direction+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - if test "$cross_compiling" = yes; then : - ac_cv_c_stack_direction=0 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -find_stack_direction () -{ - static char *addr = 0; - auto char dummy; - if (addr == 0) - { - addr = &dummy; - return find_stack_direction (); - } - else - return (&dummy > addr) ? 1 : -1; -} - -int -main () -{ - return find_stack_direction () < 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ac_cv_c_stack_direction=1 -else - ac_cv_c_stack_direction=-1 -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 -$as_echo "$ac_cv_c_stack_direction" >&6; } -cat >>confdefs.h <<_ACEOF -#define STACK_DIRECTION $ac_cv_c_stack_direction -_ACEOF - - -fi - - # Set the 'development' global. . $srcdir/../../bfd/development.sh @@ -4904,7 +4713,7 @@ $as_echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cach cd "$ac_popdir" -for ac_header in sgtty.h termio.h termios.h sys/reg.h string.h proc_service.h sys/procfs.h linux/elf.h fcntl.h signal.h sys/file.h malloc.h sys/ioctl.h netinet/in.h sys/socket.h netdb.h netinet/tcp.h arpa/inet.h +for ac_header in sgtty.h termio.h termios.h sys/reg.h string.h proc_service.h sys/procfs.h linux/elf.h fcntl.h signal.h sys/file.h sys/ioctl.h netinet/in.h sys/socket.h netdb.h netinet/tcp.h arpa/inet.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac index 8e5d74fb72..3864ff469d 100644 --- a/gdb/gdbserver/configure.ac +++ b/gdb/gdbserver/configure.ac @@ -39,8 +39,6 @@ AC_ARG_PROGRAM AC_HEADER_STDC -AC_FUNC_ALLOCA - # Set the 'development' global. . $srcdir/../../bfd/development.sh @@ -82,7 +80,7 @@ ACX_CONFIGURE_DIR(["../../libiberty"], ["build-libiberty-gdbserver"]) AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl proc_service.h sys/procfs.h linux/elf.h dnl - fcntl.h signal.h sys/file.h malloc.h dnl + fcntl.h signal.h sys/file.h dnl sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl netinet/tcp.h arpa/inet.h) AC_CHECK_FUNCS(pread pwrite pread64 readlink) diff --git a/gdb/gdbserver/gdbreplay.c b/gdb/gdbserver/gdbreplay.c index c70abef7e9..dedf2bb0d4 100644 --- a/gdb/gdbserver/gdbreplay.c +++ b/gdb/gdbserver/gdbreplay.c @@ -48,12 +48,9 @@ #if HAVE_NETINET_TCP_H #include #endif -#if HAVE_ALLOCA_H + #include -#endif -#if HAVE_MALLOC_H -#include -#endif + #if USE_WIN32API #include #endif diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h index cac73e9201..02d751a02e 100644 --- a/gdb/gdbserver/server.h +++ b/gdb/gdbserver/server.h @@ -29,15 +29,6 @@ gdb_static_assert (sizeof (CORE_ADDR) >= sizeof (void *)); #include "version.h" -#ifdef HAVE_ALLOCA_H -#include -#endif -/* On some systems such as MinGW, alloca is declared in malloc.h - (there is no alloca.h). */ -#if HAVE_MALLOC_H -#include -#endif - #if !HAVE_DECL_STRERROR #ifndef strerror extern char *strerror (int); /* X3.159-1989 4.11.6.2 */ diff --git a/gdb/utils.c b/gdb/utils.c index 3915b58c04..ff5c00d205 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -2913,7 +2913,7 @@ gdb_realpath (const char *filename) pathconf()) making it impossible to pass a correctly sized buffer to realpath() (it could always overflow). On those systems, we skip this. */ -#if defined (HAVE_REALPATH) && defined (_PC_PATH_MAX) && defined(HAVE_ALLOCA) +#if defined (HAVE_REALPATH) && defined (_PC_PATH_MAX) { /* Find out the max path size. */ long path_max = pathconf ("/", _PC_PATH_MAX); -- 2.34.1