From patchwork Sat Nov 15 13:20:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 3764 Received: (qmail 29021 invoked by alias); 15 Nov 2014 13:20:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 28893 invoked by uid 89); 15 Nov 2014 13:20:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 15 Nov 2014 13:20:36 +0000 Received: from svr-orw-fem-02x.mgc.mentorg.com ([147.34.96.206] helo=SVR-ORW-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1XpdHE-0005US-U4 from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Sat, 15 Nov 2014 05:20:32 -0800 Received: from qiyao.dyndns.org.com (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.3.181.6; Sat, 15 Nov 2014 05:20:32 -0800 From: Yao Qi To: Subject: [PATCH 3/7] Include alloca.h unconditionally Date: Sat, 15 Nov 2014 21:20:08 +0800 Message-ID: <1416057612-16155-4-git-send-email-yao@codesourcery.com> In-Reply-To: <1416057612-16155-1-git-send-email-yao@codesourcery.com> References: <1416057612-16155-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 X-IsSubscribed: yes 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 Tested this patch by rebuilding gdb on x86-linux and aix. gdb: 2014-11-15 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-15 Yao Qi * configure.ac: Don't invoke AC_FUNC_ALLOCA. * configure: Re-generated. * server.h: Don't include alloca.h. * gdbreplay.c: Don't check HAVE_ALLOCA_H is defined. --- gdb/common/common-defs.h | 1 + gdb/configure | 190 -------------------------------------------- gdb/configure.ac | 1 - gdb/defs.h | 21 ----- gdb/gdbserver/configure | 193 +-------------------------------------------- gdb/gdbserver/configure.ac | 2 - gdb/gdbserver/gdbreplay.c | 4 +- gdb/gdbserver/server.h | 3 - gdb/utils.c | 2 +- 9 files changed, 5 insertions(+), 412 deletions(-) diff --git a/gdb/common/common-defs.h b/gdb/common/common-defs.h index 4d2e8a7..0a5256a 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 1d6d88b..ade1755 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 2d73669..98eb57b 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 1eb43eb..6b63b6a 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/configure b/gdb/gdbserver/configure index 9495905..f4c4422 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 diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac index 8e5d74f..4cf2d50 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 diff --git a/gdb/gdbserver/gdbreplay.c b/gdb/gdbserver/gdbreplay.c index c70abef..ffe7392 100644 --- a/gdb/gdbserver/gdbreplay.c +++ b/gdb/gdbserver/gdbreplay.c @@ -48,9 +48,9 @@ #if HAVE_NETINET_TCP_H #include #endif -#if HAVE_ALLOCA_H + #include -#endif + #if HAVE_MALLOC_H #include #endif diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h index cac73e9..857875a 100644 --- a/gdb/gdbserver/server.h +++ b/gdb/gdbserver/server.h @@ -29,9 +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 diff --git a/gdb/utils.c b/gdb/utils.c index 3915b58..ff5c00d 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);