diff options
author | Pedro Alves <palves@redhat.com> | 2016-04-18 17:42:50 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2016-04-18 17:42:50 +0100 |
commit | 9b30624b65697a5f51bb7120c48686ab5506067f (patch) | |
tree | d5b7fcf105f1ec874d689b32e6355e83b93a0ea1 /gdb/configure | |
parent | a22df60ad216517bbca4b391bec09f9ded06ab7b (diff) | |
download | gdb-9b30624b65697a5f51bb7120c48686ab5506067f.zip gdb-9b30624b65697a5f51bb7120c48686ab5506067f.tar.gz gdb-9b30624b65697a5f51bb7120c48686ab5506067f.tar.bz2 |
Fix PR gdb/19250: ptrace prototype is not detected properly in C++ mode
The ptrace args/return types detection doesn't work properly in C++
mode, on non-GNU/Linux hosts. For example, on gcc70 (NetBSD 5.1),
where the prototype is:
int ptrace(int, __pid_t, void*, int);
configure misdetects it as:
$ grep PTRACE_TYPE config.h
#define PTRACE_TYPE_ARG1 int
#define PTRACE_TYPE_ARG3 int *
#define PTRACE_TYPE_ARG4 int
/* #undef PTRACE_TYPE_ARG5 */
#define PTRACE_TYPE_RET int
resulting in:
../../src/gdb/amd64bsd-nat.c: In function 'void amd64bsd_fetch_inferior_registers(target_ops*, regcache*, int)':
../../src/gdb/amd64bsd-nat.c:56: warning: dereferencing type-punned pointer will break strict-aliasing rules
../../src/gdb/amd64bsd-nat.c: In function 'void amd64bsd_store_inferior_registers(target_ops*, regcache*, int)':
../../src/gdb/amd64bsd-nat.c:104: warning: dereferencing type-punned pointer will break strict-aliasing rules
../../src/gdb/amd64bsd-nat.c:110: warning: dereferencing type-punned pointer will break strict-aliasing rules
We could address this [1], however despite ptrace.m4's claim:
# Needs to be tested in C++ mode, to detect whether we need to cast
# the first argument to enum __ptrace_request.
it appears that there's actually no need to test in C++ mode. Always
running the ptrace tests in C mode works just the same on GNU/Linux.
I remember experimenting with several different ways to handle the
original issue back then, and maybe that was needed in some other
attempt and then I didn't realize it ended up not really necessary.
Confirmed that this fixes the NetBSD 5.1 C++ build, and confirmed that
C and C++ builds on Fedora 23 are unaffected.
[1] - https://sourceware.org/ml/gdb-patches/2016-04/msg00374.html
gdb/ChangeLog:
2016-04-18 Pedro Alves <palves@redhat.com>
* ptrace.m4 (GDB_AC_PTRACE): Don't run tests in C++ mode.
* configure: Regenerate.
gdb/gdbserver/ChangeLog:
2016-04-18 Pedro Alves <palves@redhat.com>
* configure: Regenerate.
Diffstat (limited to 'gdb/configure')
-rwxr-xr-x | gdb/configure | 79 |
1 files changed, 7 insertions, 72 deletions
diff --git a/gdb/configure b/gdb/configure index b523deb..8c2ec0f 100755 --- a/gdb/configure +++ b/gdb/configure @@ -2401,51 +2401,6 @@ $as_echo "$ac_res" >&6; } eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} } # ac_fn_c_check_member - -# ac_fn_cxx_check_decl LINENO SYMBOL VAR -# -------------------------------------- -# Tests whether SYMBOL is declared, setting cache variable VAR accordingly. -ac_fn_cxx_check_decl () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - as_decl_name=`echo $2|sed 's/ *(.*//'` - as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 -$as_echo_n "checking whether $as_decl_name is declared... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$4 -int -main () -{ -#ifndef $as_decl_name -#ifdef __cplusplus - (void) $as_decl_use; -#else - (void) $as_decl_name; -#endif -#endif - - ; - return 0; -} -_ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : - eval "$3=yes" -else - eval "$3=no" -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -eval ac_res=\$$3 - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - -} # ac_fn_cxx_check_decl cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. @@ -12351,7 +12306,6 @@ fi # Check the return and argument types of ptrace. - for ac_header in sys/ptrace.h ptrace.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` @@ -12367,17 +12321,6 @@ fi done -# Needs to be tested in C++ mode, to detect whether we need to cast -# the first argument to enum __ptrace_request. -if test "$enable_build_with_cxx" = "yes"; then - ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - -fi - gdb_ptrace_headers=' #include <sys/types.h> #if HAVE_SYS_PTRACE_H @@ -12388,7 +12331,7 @@ gdb_ptrace_headers=' #endif ' # There is no point in checking if we don't have a prototype. -ac_fn_cxx_check_decl "$LINENO" "ptrace" "ac_cv_have_decl_ptrace" "$gdb_ptrace_headers +ac_fn_c_check_decl "$LINENO" "ptrace" "ac_cv_have_decl_ptrace" "$gdb_ptrace_headers " if test "x$ac_cv_have_decl_ptrace" = x""yes; then : ac_have_decl=1 @@ -12426,7 +12369,7 @@ extern long ptrace (enum __ptrace_request, ...); return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO"; then : gdb_cv_func_ptrace_ret='long' else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -12440,7 +12383,7 @@ extern int ptrace (); return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO"; then : gdb_cv_func_ptrace_ret='int' else gdb_cv_func_ptrace_ret='long' @@ -12474,7 +12417,7 @@ extern long ptrace (enum __ptrace_request, ...); return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO"; then : gdb_cv_func_ptrace_args='enum __ptrace_request,int,long,long' else @@ -12496,7 +12439,7 @@ extern $gdb_cv_func_ptrace_ret return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO"; then : gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4"; break 4; fi @@ -12516,7 +12459,7 @@ extern $gdb_cv_func_ptrace_ret return 0; } _ACEOF -if ac_fn_cxx_try_compile "$LINENO"; then : +if ac_fn_c_try_compile "$LINENO"; then : gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4,$gdb_arg5"; break 5; @@ -12562,15 +12505,6 @@ _ACEOF fi -if test "$enable_build_with_cxx" = "yes"; then - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - -fi - if test "$cross_compiling" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether setpgrp takes no argument" >&5 @@ -14265,6 +14199,7 @@ _ACEOF + # Check whether --enable-werror was given. if test "${enable_werror+set}" = set; then : enableval=$enable_werror; case "${enableval}" in |