public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/4] C++: handle ptrace(enum __ptrace_request, ...)
@ 2015-07-10 21:52 Pedro Alves
  2015-07-10 21:52 ` [PATCH 1/4] make gdbserver use the same ptrace autoconf checks as gdb Pedro Alves
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Pedro Alves @ 2015-07-10 21:52 UTC (permalink / raw)
  To: gdb-patches

Building GDB on GNU/Linux in C++ mode issues ~40 ptrace-related
-fpermissive warnings like this:

../../src/gdb/linux-nat.c: In function ‘int linux_handle_extended_wait(lwp_info*, int, int)’:
../../src/gdb/linux-nat.c:2016:51: warning: invalid conversion from ‘int’ to ‘__ptrace_request’ [-fpermissive]
   ptrace (PTRACE_GETEVENTMSG, pid, 0, &new_pid);

This series fixes them all.

No regressions on x86_64 Fedora 20.

Pedro Alves (4):
  make gdbserver use the same ptrace autoconf checks as gdb
  Move gdb_ptrace.h to nat/
  C++: handle glibc's ptrace(enum __ptrace_request, ...)
  Linux: sys/ptrace.h -> nat/gdb_ptrace.h everywhere

 gdb/aarch64-linux-nat.c           |   2 +-
 gdb/acinclude.m4                  |   3 +
 gdb/alpha-linux-nat.c             |   2 +-
 gdb/amd64-linux-nat.c             |   2 +-
 gdb/arm-linux-nat.c               |   2 +-
 gdb/config.in                     |   3 +
 gdb/configure                     | 109 +++++++++++++--
 gdb/configure.ac                  |  71 +---------
 gdb/gdb_ptrace.h                  | 149 ---------------------
 gdb/gdbserver/acinclude.m4        |   3 +
 gdb/gdbserver/config.in           |  25 ++++
 gdb/gdbserver/configure           | 272 +++++++++++++++++++++++++++++++++++++-
 gdb/gdbserver/configure.ac        |   3 +
 gdb/gdbserver/linux-aarch64-low.c |   2 +-
 gdb/gdbserver/linux-arm-low.c     |   2 +-
 gdb/gdbserver/linux-cris-low.c    |   2 +-
 gdb/gdbserver/linux-crisv32-low.c |   2 +-
 gdb/gdbserver/linux-low.c         |   2 +-
 gdb/gdbserver/linux-m68k-low.c    |   2 +-
 gdb/gdbserver/linux-mips-low.c    |   2 +-
 gdb/gdbserver/linux-nios2-low.c   |   2 +-
 gdb/gdbserver/linux-s390-low.c    |   2 +-
 gdb/gdbserver/linux-sparc-low.c   |   2 +-
 gdb/gdbserver/linux-tic6x-low.c   |   2 +-
 gdb/gdbserver/linux-tile-low.c    |   2 +-
 gdb/gdbserver/linux-x86-low.c     |   3 +-
 gdb/hppa-linux-nat.c              |   2 +-
 gdb/i386-linux-nat.c              |   2 +-
 gdb/ia64-linux-nat.c              |   2 +-
 gdb/inf-ptrace.c                  |   2 +-
 gdb/linux-fork.c                  |   2 +-
 gdb/linux-nat.c                   |   2 +-
 gdb/m32r-linux-nat.c              |   2 +-
 gdb/m68klinux-nat.c               |   2 +-
 gdb/mips-linux-nat.c              |   2 +-
 gdb/nat/gdb_ptrace.h              | 153 +++++++++++++++++++++
 gdb/nat/linux-btrace.c            |   2 +-
 gdb/nat/linux-ptrace.c            |   1 +
 gdb/nat/linux-ptrace.h            |   2 +-
 gdb/nat/mips-linux-watch.c        |   2 +-
 gdb/nat/x86-linux-dregs.c         |   2 +-
 gdb/ppc-linux-nat.c               |   2 +-
 gdb/ptrace.m4                     | 104 +++++++++++++++
 gdb/s390-linux-nat.c              |   2 +-
 gdb/spu-linux-nat.c               |   2 +-
 gdb/tilegx-linux-nat.c            |   2 +-
 gdb/x86-linux-nat.c               |   2 +-
 gdb/xtensa-linux-nat.c            |   2 +-
 48 files changed, 702 insertions(+), 267 deletions(-)
 delete mode 100644 gdb/gdb_ptrace.h
 create mode 100644 gdb/nat/gdb_ptrace.h
 create mode 100644 gdb/ptrace.m4

-- 
1.9.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] make gdbserver use the same ptrace autoconf checks as gdb
  2015-07-10 21:52 [PATCH 0/4] C++: handle ptrace(enum __ptrace_request, ...) Pedro Alves
@ 2015-07-10 21:52 ` Pedro Alves
  2015-07-10 21:52 ` [PATCH 2/4] Move gdb_ptrace.h to nat/ Pedro Alves
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Pedro Alves @ 2015-07-10 21:52 UTC (permalink / raw)
  To: gdb-patches

This factors the ptrace checks out of gdb's configure.ac to a new
ptrace.m4 file, and then makes gdbserver's configure.ac source it too.

gdb/ChangeLog:
2015-07-10  Pedro Alves  <palves@redhat.com>

	* acinclude.m4: Include ptrace.m4.
	* configure.ac: Call GDB_AC_PTRACE and move ptrace checks ...
	* ptrace.m4: ... to this new file.

gdb/gdbserver/ChangeLog:
2015-07-10  Pedro Alves  <palves@redhat.com>

	* acinclude.m4: Include ../ptrace.m4.
	* configure.ac: Call GDB_AC_PTRACE.
	* config.in, configure: Regenerate.
---
 gdb/acinclude.m4           |   3 +
 gdb/configure              |  21 ++++-
 gdb/configure.ac           |  71 +---------------
 gdb/gdbserver/acinclude.m4 |   3 +
 gdb/gdbserver/config.in    |  22 +++++
 gdb/gdbserver/configure    | 198 +++++++++++++++++++++++++++++++++++++++++++++
 gdb/gdbserver/configure.ac |   3 +
 gdb/ptrace.m4              |  92 +++++++++++++++++++++
 8 files changed, 342 insertions(+), 71 deletions(-)
 create mode 100644 gdb/ptrace.m4

diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index 845e65f..0ecfaf9 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -63,6 +63,9 @@ m4_include(libiberty.m4)
 dnl For --enable-build-with-cxx and COMPILER.
 m4_include(build-with-cxx.m4)
 
+dnl For GDB_AC_PTRACE.
+m4_include(ptrace.m4)
+
 ## ----------------------------------------- ##
 ## ANSIfy the C compiler whenever possible.  ##
 ## From Franc,ois Pinard                     ##
diff --git a/gdb/configure b/gdb/configure
index e8979f0..135c6ac 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -11926,8 +11926,24 @@ $as_echo "#define HAVE_SIGSETJMP 1" >>confdefs.h
 fi
 
 
-# Check the return and argument types of ptrace.  No canned test for
-# this, so roll our own.
+# 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`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
 gdb_ptrace_headers='
 #include <sys/types.h>
 #if HAVE_SYS_PTRACE_H
@@ -12107,6 +12123,7 @@ _ACEOF
 
 fi
 
+
 if test "$cross_compiling" = no; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether setpgrp takes no argument" >&5
 $as_echo_n "checking whether setpgrp takes no argument... " >&6; }
diff --git a/gdb/configure.ac b/gdb/configure.ac
index a40860a..905c27b 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1355,75 +1355,8 @@ AC_CHECK_FUNCS([getauxval getrusage getuid getgid \
 AM_LANGINFO_CODESET
 GDB_AC_COMMON
 
-# Check the return and argument types of ptrace.  No canned test for
-# this, so roll our own.
-gdb_ptrace_headers='
-#include <sys/types.h>
-#if HAVE_SYS_PTRACE_H
-# include <sys/ptrace.h>
-#endif
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-'
-# There is no point in checking if we don't have a prototype.
-AC_CHECK_DECLS(ptrace, [], [
-  : ${gdb_cv_func_ptrace_ret='int'}
-  : ${gdb_cv_func_ptrace_args='int,int,long,long'}
-], $gdb_ptrace_headers)
-# Check return type.  Varargs (used on GNU/Linux) conflict with the
-# empty argument list, so check for that explicitly.
-AC_CACHE_CHECK([return type of ptrace], gdb_cv_func_ptrace_ret,
-  AC_TRY_COMPILE($gdb_ptrace_headers,
-    [extern long ptrace (enum __ptrace_request, ...);],
-    gdb_cv_func_ptrace_ret='long',
-    AC_TRY_COMPILE($gdb_ptrace_headers,
-      [extern int ptrace ();],
-      gdb_cv_func_ptrace_ret='int',
-      gdb_cv_func_ptrace_ret='long')))
-AC_DEFINE_UNQUOTED(PTRACE_TYPE_RET, $gdb_cv_func_ptrace_ret,
-  [Define as the return type of ptrace.])
-# Check argument types.
-AC_CACHE_CHECK([types of arguments for ptrace], gdb_cv_func_ptrace_args, [
-  AC_TRY_COMPILE($gdb_ptrace_headers,
-    [extern long ptrace (enum __ptrace_request, ...);],
-    [gdb_cv_func_ptrace_args='int,int,long,long'],[
-for gdb_arg1 in 'int' 'long'; do
- for gdb_arg2 in 'pid_t' 'int' 'long'; do
-  for gdb_arg3 in 'int *' 'caddr_t' 'int' 'long' 'void *'; do
-   for gdb_arg4 in 'int' 'long' 'void *'; do
-     AC_TRY_COMPILE($gdb_ptrace_headers, [
-extern $gdb_cv_func_ptrace_ret
-  ptrace ($gdb_arg1, $gdb_arg2, $gdb_arg3, $gdb_arg4);
-], [gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4";
-    break 4;])
-    for gdb_arg5 in 'int *' 'int' 'long'; do
-     AC_TRY_COMPILE($gdb_ptrace_headers, [
-extern $gdb_cv_func_ptrace_ret
-  ptrace ($gdb_arg1, $gdb_arg2, $gdb_arg3, $gdb_arg4, $gdb_arg5);
-], [
-gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4,$gdb_arg5";
-    break 5;])
-    done
-   done
-  done
- done
-done
-# Provide a safe default value.
-: ${gdb_cv_func_ptrace_args='int,int,long,long'}
-])])
-ac_save_IFS=$IFS; IFS=','
-set dummy `echo "$gdb_cv_func_ptrace_args" | sed 's/\*/\*/g'`
-IFS=$ac_save_IFS
-shift
-AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG3, $[3],
-  [Define to the type of arg 3 for ptrace.])
-AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG4, $[4],
-  [Define to the type of arg 4 for ptrace.])
-if test -n "$[5]"; then
-  AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG5, $[5],
-    [Define to the type of arg 5 for ptrace.])
-fi
+# Check the return and argument types of ptrace.
+GDB_AC_PTRACE
 
 dnl AC_FUNC_SETPGRP does not work when cross compiling
 dnl Instead, assume we will have a prototype for setpgrp if cross compiling.
diff --git a/gdb/gdbserver/acinclude.m4 b/gdb/gdbserver/acinclude.m4
index 0b86c04..284c823 100644
--- a/gdb/gdbserver/acinclude.m4
+++ b/gdb/gdbserver/acinclude.m4
@@ -26,6 +26,9 @@ m4_include(../libiberty.m4)
 dnl For --enable-build-with-cxx and COMPILER.
 m4_include(../build-with-cxx.m4)
 
+dnl For GDB_AC_PTRACE.
+m4_include(../ptrace.m4)
+
 dnl Check for existence of a type $1 in libthread_db.h
 dnl Based on BFD_HAVE_SYS_PROCFS_TYPE in bfd/bfd.m4.
 
diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in
index f24e6bb..6f2d0a1 100644
--- a/gdb/gdbserver/config.in
+++ b/gdb/gdbserver/config.in
@@ -37,6 +37,10 @@
    */
 #undef HAVE_DECL_PERROR
 
+/* Define to 1 if you have the declaration of `ptrace', and to 0 if you don't.
+   */
+#undef HAVE_DECL_PTRACE
+
 /* Define to 1 if you have the declaration of `snprintf', and to 0 if you
    don't. */
 #undef HAVE_DECL_SNPRINTF
@@ -183,6 +187,9 @@
 /* Define if the target supports PTRACE_GETREGS for register access. */
 #undef HAVE_PTRACE_GETREGS
 
+/* Define to 1 if you have the <ptrace.h> header file. */
+#undef HAVE_PTRACE_H
+
 /* Define to 1 if you have the `pwrite' function. */
 #undef HAVE_PWRITE
 
@@ -234,6 +241,9 @@
 /* Define to 1 if you have the <sys/procfs.h> header file. */
 #undef HAVE_SYS_PROCFS_H
 
+/* Define to 1 if you have the <sys/ptrace.h> header file. */
+#undef HAVE_SYS_PTRACE_H
+
 /* Define to 1 if you have the <sys/reg.h> header file. */
 #undef HAVE_SYS_REG_H
 
@@ -300,6 +310,18 @@
 /* Additional package description */
 #undef PKGVERSION
 
+/* Define to the type of arg 3 for ptrace. */
+#undef PTRACE_TYPE_ARG3
+
+/* Define to the type of arg 4 for ptrace. */
+#undef PTRACE_TYPE_ARG4
+
+/* Define to the type of arg 5 for ptrace. */
+#undef PTRACE_TYPE_ARG5
+
+/* Define as the return type of ptrace. */
+#undef PTRACE_TYPE_RET
+
 /* Bug reporting address */
 #undef REPORT_BUGS_TO
 
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index e8cf136..fc6b966 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -5748,6 +5748,204 @@ $as_echo "#define HAVE_SIGSETJMP 1" >>confdefs.h
 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`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+gdb_ptrace_headers='
+#include <sys/types.h>
+#if HAVE_SYS_PTRACE_H
+# include <sys/ptrace.h>
+#endif
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+'
+# There is no point in checking if we don't have a prototype.
+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
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_PTRACE $ac_have_decl
+_ACEOF
+if test $ac_have_decl = 1; then :
+
+else
+
+  : ${gdb_cv_func_ptrace_ret='int'}
+  : ${gdb_cv_func_ptrace_args='int,int,long,long'}
+
+fi
+
+# Check return type.  Varargs (used on GNU/Linux) conflict with the
+# empty argument list, so check for that explicitly.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of ptrace" >&5
+$as_echo_n "checking return type of ptrace... " >&6; }
+if test "${gdb_cv_func_ptrace_ret+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$gdb_ptrace_headers
+int
+main ()
+{
+extern long ptrace (enum __ptrace_request, ...);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gdb_cv_func_ptrace_ret='long'
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$gdb_ptrace_headers
+int
+main ()
+{
+extern int ptrace ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gdb_cv_func_ptrace_ret='int'
+else
+  gdb_cv_func_ptrace_ret='long'
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_func_ptrace_ret" >&5
+$as_echo "$gdb_cv_func_ptrace_ret" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define PTRACE_TYPE_RET $gdb_cv_func_ptrace_ret
+_ACEOF
+
+# Check argument types.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking types of arguments for ptrace" >&5
+$as_echo_n "checking types of arguments for ptrace... " >&6; }
+if test "${gdb_cv_func_ptrace_args+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$gdb_ptrace_headers
+int
+main ()
+{
+extern long ptrace (enum __ptrace_request, ...);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gdb_cv_func_ptrace_args='int,int,long,long'
+else
+
+for gdb_arg1 in 'int' 'long'; do
+ for gdb_arg2 in 'pid_t' 'int' 'long'; do
+  for gdb_arg3 in 'int *' 'caddr_t' 'int' 'long' 'void *'; do
+   for gdb_arg4 in 'int' 'long' 'void *'; do
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$gdb_ptrace_headers
+int
+main ()
+{
+
+extern $gdb_cv_func_ptrace_ret
+  ptrace ($gdb_arg1, $gdb_arg2, $gdb_arg3, $gdb_arg4);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4";
+    break 4;
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    for gdb_arg5 in 'int *' 'int' 'long'; do
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$gdb_ptrace_headers
+int
+main ()
+{
+
+extern $gdb_cv_func_ptrace_ret
+  ptrace ($gdb_arg1, $gdb_arg2, $gdb_arg3, $gdb_arg4, $gdb_arg5);
+
+  ;
+  return 0;
+}
+_ACEOF
+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;
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    done
+   done
+  done
+ done
+done
+# Provide a safe default value.
+: ${gdb_cv_func_ptrace_args='int,int,long,long'}
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_func_ptrace_args" >&5
+$as_echo "$gdb_cv_func_ptrace_args" >&6; }
+ac_save_IFS=$IFS; IFS=','
+set dummy `echo "$gdb_cv_func_ptrace_args" | sed 's/\*/\*/g'`
+IFS=$ac_save_IFS
+shift
+
+cat >>confdefs.h <<_ACEOF
+#define PTRACE_TYPE_ARG3 $3
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PTRACE_TYPE_ARG4 $4
+_ACEOF
+
+if test -n "$5"; then
+
+cat >>confdefs.h <<_ACEOF
+#define PTRACE_TYPE_ARG5 $5
+_ACEOF
+
+fi
+
+
 # Check for UST
 ustlibs=""
 ustinc=""
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index b465c43..0fe0a35 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -98,6 +98,9 @@ AC_CHECK_FUNCS(getauxval pread pwrite pread64 setns)
 
 GDB_AC_COMMON
 
+# Check the return and argument types of ptrace.
+GDB_AC_PTRACE
+
 # Check for UST
 ustlibs=""
 ustinc=""
diff --git a/gdb/ptrace.m4 b/gdb/ptrace.m4
new file mode 100644
index 0000000..e5fe7fa
--- /dev/null
+++ b/gdb/ptrace.m4
@@ -0,0 +1,92 @@
+dnl Copyright (C) 2012-2015 Free Software Foundation, Inc.
+dnl
+dnl This file is part of GDB.
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; either version 3 of the License, or
+dnl (at your option) any later version.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+dnl Check the return and argument types of ptrace.
+
+AC_DEFUN([GDB_AC_PTRACE],
+[
+
+AC_CHECK_HEADERS([sys/ptrace.h ptrace.h])
+
+gdb_ptrace_headers='
+#include <sys/types.h>
+#if HAVE_SYS_PTRACE_H
+# include <sys/ptrace.h>
+#endif
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+'
+# There is no point in checking if we don't have a prototype.
+AC_CHECK_DECLS(ptrace, [], [
+  : ${gdb_cv_func_ptrace_ret='int'}
+  : ${gdb_cv_func_ptrace_args='int,int,long,long'}
+], $gdb_ptrace_headers)
+# Check return type.  Varargs (used on GNU/Linux) conflict with the
+# empty argument list, so check for that explicitly.
+AC_CACHE_CHECK([return type of ptrace], gdb_cv_func_ptrace_ret,
+  AC_TRY_COMPILE($gdb_ptrace_headers,
+    [extern long ptrace (enum __ptrace_request, ...);],
+    gdb_cv_func_ptrace_ret='long',
+    AC_TRY_COMPILE($gdb_ptrace_headers,
+      [extern int ptrace ();],
+      gdb_cv_func_ptrace_ret='int',
+      gdb_cv_func_ptrace_ret='long')))
+AC_DEFINE_UNQUOTED(PTRACE_TYPE_RET, $gdb_cv_func_ptrace_ret,
+  [Define as the return type of ptrace.])
+# Check argument types.
+AC_CACHE_CHECK([types of arguments for ptrace], gdb_cv_func_ptrace_args, [
+  AC_TRY_COMPILE($gdb_ptrace_headers,
+    [extern long ptrace (enum __ptrace_request, ...);],
+    [gdb_cv_func_ptrace_args='int,int,long,long'],[
+for gdb_arg1 in 'int' 'long'; do
+ for gdb_arg2 in 'pid_t' 'int' 'long'; do
+  for gdb_arg3 in 'int *' 'caddr_t' 'int' 'long' 'void *'; do
+   for gdb_arg4 in 'int' 'long' 'void *'; do
+     AC_TRY_COMPILE($gdb_ptrace_headers, [
+extern $gdb_cv_func_ptrace_ret
+  ptrace ($gdb_arg1, $gdb_arg2, $gdb_arg3, $gdb_arg4);
+], [gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4";
+    break 4;])
+    for gdb_arg5 in 'int *' 'int' 'long'; do
+     AC_TRY_COMPILE($gdb_ptrace_headers, [
+extern $gdb_cv_func_ptrace_ret
+  ptrace ($gdb_arg1, $gdb_arg2, $gdb_arg3, $gdb_arg4, $gdb_arg5);
+], [
+gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4,$gdb_arg5";
+    break 5;])
+    done
+   done
+  done
+ done
+done
+# Provide a safe default value.
+: ${gdb_cv_func_ptrace_args='int,int,long,long'}
+])])
+ac_save_IFS=$IFS; IFS=','
+set dummy `echo "$gdb_cv_func_ptrace_args" | sed 's/\*/\*/g'`
+IFS=$ac_save_IFS
+shift
+AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG3, $[3],
+  [Define to the type of arg 3 for ptrace.])
+AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG4, $[4],
+  [Define to the type of arg 4 for ptrace.])
+if test -n "$[5]"; then
+  AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG5, $[5],
+    [Define to the type of arg 5 for ptrace.])
+fi
+])
-- 
1.9.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/4] Move gdb_ptrace.h to nat/
  2015-07-10 21:52 [PATCH 0/4] C++: handle ptrace(enum __ptrace_request, ...) Pedro Alves
  2015-07-10 21:52 ` [PATCH 1/4] make gdbserver use the same ptrace autoconf checks as gdb Pedro Alves
@ 2015-07-10 21:52 ` Pedro Alves
  2015-07-10 21:52 ` [PATCH 3/4] C++: handle glibc's ptrace(enum __ptrace_request, ...) Pedro Alves
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Pedro Alves @ 2015-07-10 21:52 UTC (permalink / raw)
  To: gdb-patches

Now that gdbserver's configure defines PTRACE_TYPE_ARGx etc., we'll be
able to make gdbserver use gdb_ptrace.h too.  Move it to the native
target files directory.

gdb/ChangeLog:
2015-07-10  Pedro Alves  <palves@redhat.com>

	* gdb_ptrace.h: Move ...
	* nat/gdb_ptrace.h: ... here.
	* inf-ptrace.c: Adjust
---
 gdb/inf-ptrace.c           | 2 +-
 gdb/{ => nat}/gdb_ptrace.h | 0
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename gdb/{ => nat}/gdb_ptrace.h (100%)

diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index cd58dfb..f3c5105 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -24,7 +24,7 @@
 #include "terminal.h"
 #include "gdbcore.h"
 #include "regcache.h"
-#include "gdb_ptrace.h"
+#include "nat/gdb_ptrace.h"
 #include "gdb_wait.h"
 #include <signal.h>
 
diff --git a/gdb/gdb_ptrace.h b/gdb/nat/gdb_ptrace.h
similarity index 100%
rename from gdb/gdb_ptrace.h
rename to gdb/nat/gdb_ptrace.h
-- 
1.9.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/4] C++: handle glibc's ptrace(enum __ptrace_request, ...)
  2015-07-10 21:52 [PATCH 0/4] C++: handle ptrace(enum __ptrace_request, ...) Pedro Alves
  2015-07-10 21:52 ` [PATCH 1/4] make gdbserver use the same ptrace autoconf checks as gdb Pedro Alves
  2015-07-10 21:52 ` [PATCH 2/4] Move gdb_ptrace.h to nat/ Pedro Alves
@ 2015-07-10 21:52 ` Pedro Alves
  2015-07-10 22:00 ` [PATCH 4/4] Linux: sys/ptrace.h -> nat/gdb_ptrace.h everywhere Pedro Alves
  2015-07-24 14:22 ` [PATCH 0/4] C++: handle ptrace(enum __ptrace_request, ...) Pedro Alves
  4 siblings, 0 replies; 6+ messages in thread
From: Pedro Alves @ 2015-07-10 21:52 UTC (permalink / raw)
  To: gdb-patches

Building in C++ mode issues ~40 warnings like this:

 ../../src/gdb/linux-nat.c: In function ‘int linux_handle_extended_wait(lwp_info*, int, int)’:
 ../../src/gdb/linux-nat.c:2016:51: warning: invalid conversion from ‘int’ to ‘__ptrace_request’ [-fpermissive]
	ptrace (PTRACE_GETEVENTMSG, pid, 0, &new_pid);

The issue is that in glibc, ptrace's first parameter is an enum.
That's not a problem if we pick the PTRACE_XXX requests from
sys/ptrace.h, as those will be values of the corresponding enum.
However, we have fallback definitions for PTRACE_XXX symbols when the
system headers miss them (such as PTRACE_GETEVENTMSG above), and those
are plain integer constants.  E.g., nat/linux-ptrace.h:

 #define PTRACE_GETEVENTMSG	0x4201

One idea would be to fix this by defining those fallbacks like:

 -#define PTRACE_GETEVENTMSG	0x4201
 +#define PTRACE_GETEVENTMSG	((enum __ptrace_request) 0x4201)

However, while glibc's ptrace uses enum __ptrace_request for first
parameter:

  extern long int ptrace (enum __ptrace_request __request, ...) __THROW;

other libc's, like e.g., Android's bionic do not -- in that case, the
first parameter is int:

  long ptrace(int request, pid_t pid, void * addr, void * data);

So the fix I came up is to make configure/ptrace.m4 also detect the
type of the ptrace's first parameter and defin PTRACE_TYPE_ARG1, as
already does the for parameters 3-4, and then simply wrap ptrace with
a macro that casts the first argument to the detected type.  (I'm
leaving adding a nicer wrapper for when we drop building in C).

While this adds the wrapper, GNU/Linux files won't use it until the
next patch, which makes all native GNU/Linux files include
gdb_ptrace.h.

gdb/ChangeLog:
2015-07-10  Pedro Alves  <palves@redhat.com>

	* ptrace.m4 (ptrace tests): Test in C++ mode.  Try with 'enum
	__ptrace_request as first parameter type instead of int.
	(PTRACE_TYPE_ARG1): Define.
	* nat/gdb_ptrace.h [!PTRACE_TYPE_ARG5] (ptrace): Define as wrapper
	that casts first argument to PTRACE_TYPE_ARG1.
	* config.in: Regenerate.
	* configure: Regenerate.

gdb/gdbserver/ChangeLog:
2015-07-10  Pedro Alves  <palves@redhat.com>

	* config.in: Regenerate.
	* configure: Regenerate.
---
 gdb/config.in           |  3 ++
 gdb/configure           | 88 ++++++++++++++++++++++++++++++++++++++++++++-----
 gdb/gdbserver/config.in |  3 ++
 gdb/gdbserver/configure | 88 ++++++++++++++++++++++++++++++++++++++++++++-----
 gdb/nat/gdb_ptrace.h    |  4 +++
 gdb/ptrace.m4           | 14 +++++++-
 6 files changed, 181 insertions(+), 19 deletions(-)

diff --git a/gdb/config.in b/gdb/config.in
index 9ef53b3..d188088 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -653,6 +653,9 @@
    assorted other type changes. */
 #undef PROC_SERVICE_IS_OLD
 
+/* Define to the type of arg 1 for ptrace. */
+#undef PTRACE_TYPE_ARG1
+
 /* Define to the type of arg 3 for ptrace. */
 #undef PTRACE_TYPE_ARG3
 
diff --git a/gdb/configure b/gdb/configure
index 135c6ac..e1b778b 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -2398,6 +2398,51 @@ $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.
@@ -11929,6 +11974,7 @@ 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`
@@ -11944,6 +11990,17 @@ 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
@@ -11954,7 +12011,7 @@ gdb_ptrace_headers='
 #endif
 '
 # There is no point in checking if we don't have a prototype.
-ac_fn_c_check_decl "$LINENO" "ptrace" "ac_cv_have_decl_ptrace" "$gdb_ptrace_headers
+ac_fn_cxx_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
@@ -11992,7 +12049,7 @@ extern long ptrace (enum __ptrace_request, ...);
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_cxx_try_compile "$LINENO"; then :
   gdb_cv_func_ptrace_ret='long'
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -12006,7 +12063,7 @@ extern int ptrace ();
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_cxx_try_compile "$LINENO"; then :
   gdb_cv_func_ptrace_ret='int'
 else
   gdb_cv_func_ptrace_ret='long'
@@ -12040,8 +12097,8 @@ extern long ptrace (enum __ptrace_request, ...);
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gdb_cv_func_ptrace_args='int,int,long,long'
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  gdb_cv_func_ptrace_args='enum __ptrace_request,int,long,long'
 else
 
 for gdb_arg1 in 'int' 'long'; do
@@ -12062,7 +12119,7 @@ extern $gdb_cv_func_ptrace_ret
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_cxx_try_compile "$LINENO"; then :
   gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4";
     break 4;
 fi
@@ -12082,7 +12139,7 @@ extern $gdb_cv_func_ptrace_ret
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_cxx_try_compile "$LINENO"; then :
 
 gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4,$gdb_arg5";
     break 5;
@@ -12107,6 +12164,11 @@ IFS=$ac_save_IFS
 shift
 
 cat >>confdefs.h <<_ACEOF
+#define PTRACE_TYPE_ARG1 $1
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
 #define PTRACE_TYPE_ARG3 $3
 _ACEOF
 
@@ -12123,6 +12185,15 @@ _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
@@ -13942,8 +14013,7 @@ $as_echo_n "checking compiler warning flags... " >&6; }
 	    CFLAGS="$CFLAGS $w"
 	    saved_CXXFLAGS="$CXXFLAGS"
 	    CXXFLAGS="$CXXFLAGS $w"
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in
index 6f2d0a1..e2566a9 100644
--- a/gdb/gdbserver/config.in
+++ b/gdb/gdbserver/config.in
@@ -310,6 +310,9 @@
 /* Additional package description */
 #undef PKGVERSION
 
+/* Define to the type of arg 1 for ptrace. */
+#undef PTRACE_TYPE_ARG1
+
 /* Define to the type of arg 3 for ptrace. */
 #undef PTRACE_TYPE_ARG3
 
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index fc6b966..409f42b 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -1878,6 +1878,51 @@ $as_echo "$ac_res" >&6; }
 
 } # ac_fn_c_check_decl
 
+# 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
+
 # ac_fn_c_check_type LINENO TYPE VAR INCLUDES
 # -------------------------------------------
 # Tests whether TYPE exists after having included INCLUDES, setting cache
@@ -5751,6 +5796,7 @@ 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`
@@ -5766,6 +5812,17 @@ 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
@@ -5776,7 +5833,7 @@ gdb_ptrace_headers='
 #endif
 '
 # There is no point in checking if we don't have a prototype.
-ac_fn_c_check_decl "$LINENO" "ptrace" "ac_cv_have_decl_ptrace" "$gdb_ptrace_headers
+ac_fn_cxx_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
@@ -5814,7 +5871,7 @@ extern long ptrace (enum __ptrace_request, ...);
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_cxx_try_compile "$LINENO"; then :
   gdb_cv_func_ptrace_ret='long'
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -5828,7 +5885,7 @@ extern int ptrace ();
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_cxx_try_compile "$LINENO"; then :
   gdb_cv_func_ptrace_ret='int'
 else
   gdb_cv_func_ptrace_ret='long'
@@ -5862,8 +5919,8 @@ extern long ptrace (enum __ptrace_request, ...);
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  gdb_cv_func_ptrace_args='int,int,long,long'
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  gdb_cv_func_ptrace_args='enum __ptrace_request,int,long,long'
 else
 
 for gdb_arg1 in 'int' 'long'; do
@@ -5884,7 +5941,7 @@ extern $gdb_cv_func_ptrace_ret
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_cxx_try_compile "$LINENO"; then :
   gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4";
     break 4;
 fi
@@ -5904,7 +5961,7 @@ extern $gdb_cv_func_ptrace_ret
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
+if ac_fn_cxx_try_compile "$LINENO"; then :
 
 gdb_cv_func_ptrace_args="$gdb_arg1,$gdb_arg2,$gdb_arg3,$gdb_arg4,$gdb_arg5";
     break 5;
@@ -5929,6 +5986,11 @@ IFS=$ac_save_IFS
 shift
 
 cat >>confdefs.h <<_ACEOF
+#define PTRACE_TYPE_ARG1 $1
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
 #define PTRACE_TYPE_ARG3 $3
 _ACEOF
 
@@ -5945,6 +6007,15 @@ _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
+
 
 # Check for UST
 ustlibs=""
@@ -6087,8 +6158,7 @@ $as_echo_n "checking compiler warning flags... " >&6; }
 	    CFLAGS="$CFLAGS $w"
 	    saved_CXXFLAGS="$CXXFLAGS"
 	    CXXFLAGS="$CXXFLAGS $w"
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+	    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
diff --git a/gdb/nat/gdb_ptrace.h b/gdb/nat/gdb_ptrace.h
index a969681..0a98239 100644
--- a/gdb/nat/gdb_ptrace.h
+++ b/gdb/nat/gdb_ptrace.h
@@ -144,6 +144,10 @@ extern PTRACE_TYPE_RET ptrace();
 #  define ptrace(request, pid, addr, data) \
           ptrace (request, pid, addr, data, 0)
 # endif
+#else
+/* Wrapper that avoids adding a pointless cast to all callers.  */
+# define ptrace(request, pid, addr, data) \
+         ptrace ((PTRACE_TYPE_ARG1) request, pid, addr, data)
 #endif
 
 #endif /* gdb_ptrace.h */
diff --git a/gdb/ptrace.m4 b/gdb/ptrace.m4
index e5fe7fa..f01c692 100644
--- a/gdb/ptrace.m4
+++ b/gdb/ptrace.m4
@@ -22,6 +22,12 @@ AC_DEFUN([GDB_AC_PTRACE],
 
 AC_CHECK_HEADERS([sys/ptrace.h ptrace.h])
 
+# 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_LANG_PUSH([C++])
+fi
+
 gdb_ptrace_headers='
 #include <sys/types.h>
 #if HAVE_SYS_PTRACE_H
@@ -52,7 +58,7 @@ AC_DEFINE_UNQUOTED(PTRACE_TYPE_RET, $gdb_cv_func_ptrace_ret,
 AC_CACHE_CHECK([types of arguments for ptrace], gdb_cv_func_ptrace_args, [
   AC_TRY_COMPILE($gdb_ptrace_headers,
     [extern long ptrace (enum __ptrace_request, ...);],
-    [gdb_cv_func_ptrace_args='int,int,long,long'],[
+    [gdb_cv_func_ptrace_args='enum __ptrace_request,int,long,long'],[
 for gdb_arg1 in 'int' 'long'; do
  for gdb_arg2 in 'pid_t' 'int' 'long'; do
   for gdb_arg3 in 'int *' 'caddr_t' 'int' 'long' 'void *'; do
@@ -81,6 +87,8 @@ ac_save_IFS=$IFS; IFS=','
 set dummy `echo "$gdb_cv_func_ptrace_args" | sed 's/\*/\*/g'`
 IFS=$ac_save_IFS
 shift
+AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG1, $[1],
+  [Define to the type of arg 1 for ptrace.])
 AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG3, $[3],
   [Define to the type of arg 3 for ptrace.])
 AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG4, $[4],
@@ -89,4 +97,8 @@ if test -n "$[5]"; then
   AC_DEFINE_UNQUOTED(PTRACE_TYPE_ARG5, $[5],
     [Define to the type of arg 5 for ptrace.])
 fi
+
+if test "$enable_build_with_cxx" = "yes"; then
+    AC_LANG_POP([C++])
+fi
 ])
-- 
1.9.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 4/4] Linux: sys/ptrace.h -> nat/gdb_ptrace.h everywhere
  2015-07-10 21:52 [PATCH 0/4] C++: handle ptrace(enum __ptrace_request, ...) Pedro Alves
                   ` (2 preceding siblings ...)
  2015-07-10 21:52 ` [PATCH 3/4] C++: handle glibc's ptrace(enum __ptrace_request, ...) Pedro Alves
@ 2015-07-10 22:00 ` Pedro Alves
  2015-07-24 14:22 ` [PATCH 0/4] C++: handle ptrace(enum __ptrace_request, ...) Pedro Alves
  4 siblings, 0 replies; 6+ messages in thread
From: Pedro Alves @ 2015-07-10 22:00 UTC (permalink / raw)
  To: gdb-patches

So that we pick the enum __ptrace_request fix everywhere.

gdb/ChangeLog:
2015-07-10  Pedro Alves  <palves@redhat.com>

	* aarch64-linux-nat.c: Include nat/gdb_ptrace.h instead of
	sys/ptrace.h.
	* alpha-linux-nat.c: Likewise.
	* amd64-linux-nat.c: Likewise.
	* arm-linux-nat.c: Likewise.
	* hppa-linux-nat.c: Likewise.
	* i386-linux-nat.c: Likewise.
	* ia64-linux-nat.c: Likewise.
	* linux-fork.c: Likewise.
	* linux-nat.c: Likewise.
	* m32r-linux-nat.c: Likewise.
	* m68klinux-nat.c: Likewise.
	* mips-linux-nat.c: Likewise.
	* nat/linux-btrace.c: Likewise.
	* nat/linux-ptrace.c: Likewise.
	* nat/linux-ptrace.h
	* nat/mips-linux-watch.c: Likewise.
	* nat/x86-linux-dregs.c: Likewise.
	* ppc-linux-nat.c: Likewise.
	* s390-linux-nat.c: Likewise.
	* spu-linux-nat.c: Likewise.
	* tilegx-linux-nat.c: Likewise.
	* x86-linux-nat.c: Likewise.
	* xtensa-linux-nat.c: Likewise.

gdb/gdbserver/ChangeLog:
2015-07-10  Pedro Alves  <palves@redhat.c: Likewise.om>

	* linux-aarch64-low.c: Include nat/gdb_ptrace.h instead of
	sys/ptrace.h.
	* linux-arm-low.c: Likewise.
	* linux-cris-low.c: Likewise.
	* linux-crisv32-low.c: Likewise.
	* linux-low.c: Likewise.
	* linux-m68k-low.c: Likewise.
	* linux-mips-low.c: Likewise.
	* linux-nios2-low.c: Likewise.
	* linux-s390-low.c: Likewise.
	* linux-sparc-low.c: Likewise.
	* linux-tic6x-low.c: Likewise.
	* linux-tile-low.c: Likewise.
	* linux-x86-low.c: Likewise.
---
 gdb/aarch64-linux-nat.c           | 2 +-
 gdb/alpha-linux-nat.c             | 2 +-
 gdb/amd64-linux-nat.c             | 2 +-
 gdb/arm-linux-nat.c               | 2 +-
 gdb/gdbserver/linux-aarch64-low.c | 2 +-
 gdb/gdbserver/linux-arm-low.c     | 2 +-
 gdb/gdbserver/linux-cris-low.c    | 2 +-
 gdb/gdbserver/linux-crisv32-low.c | 2 +-
 gdb/gdbserver/linux-low.c         | 2 +-
 gdb/gdbserver/linux-m68k-low.c    | 2 +-
 gdb/gdbserver/linux-mips-low.c    | 2 +-
 gdb/gdbserver/linux-nios2-low.c   | 2 +-
 gdb/gdbserver/linux-s390-low.c    | 2 +-
 gdb/gdbserver/linux-sparc-low.c   | 2 +-
 gdb/gdbserver/linux-tic6x-low.c   | 2 +-
 gdb/gdbserver/linux-tile-low.c    | 2 +-
 gdb/gdbserver/linux-x86-low.c     | 3 ++-
 gdb/hppa-linux-nat.c              | 2 +-
 gdb/i386-linux-nat.c              | 2 +-
 gdb/ia64-linux-nat.c              | 2 +-
 gdb/linux-fork.c                  | 2 +-
 gdb/linux-nat.c                   | 2 +-
 gdb/m32r-linux-nat.c              | 2 +-
 gdb/m68klinux-nat.c               | 2 +-
 gdb/mips-linux-nat.c              | 2 +-
 gdb/nat/linux-btrace.c            | 2 +-
 gdb/nat/linux-ptrace.c            | 1 +
 gdb/nat/linux-ptrace.h            | 2 +-
 gdb/nat/mips-linux-watch.c        | 2 +-
 gdb/nat/x86-linux-dregs.c         | 2 +-
 gdb/ppc-linux-nat.c               | 2 +-
 gdb/s390-linux-nat.c              | 2 +-
 gdb/spu-linux-nat.c               | 2 +-
 gdb/tilegx-linux-nat.c            | 2 +-
 gdb/x86-linux-nat.c               | 2 +-
 gdb/xtensa-linux-nat.c            | 2 +-
 36 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index c4ddad5..1b350c2 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -34,7 +34,7 @@
 #include "elf/external.h"
 #include "elf/common.h"
 
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <sys/utsname.h>
 #include <asm/ptrace.h>
 
diff --git a/gdb/alpha-linux-nat.c b/gdb/alpha-linux-nat.c
index 52fbdad..f735ffc 100644
--- a/gdb/alpha-linux-nat.c
+++ b/gdb/alpha-linux-nat.c
@@ -23,7 +23,7 @@
 
 #include "alpha-tdep.h"
 
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <alpha/ptrace.h>
 
 #include <sys/procfs.h>
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index 2e1b081..397f664 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -23,7 +23,7 @@
 #include "regcache.h"
 #include "elf/common.h"
 #include <sys/uio.h>
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <asm/prctl.h>
 #include <sys/reg.h>
 #include "gregset.h"
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index f0ab98c..ff156d0 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -33,7 +33,7 @@
 
 #include <elf/common.h>
 #include <sys/user.h>
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <sys/utsname.h>
 #include <sys/procfs.h>
 
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index b068e55..6893295 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -25,7 +25,7 @@
 
 #include <signal.h>
 #include <sys/user.h>
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <asm/ptrace.h>
 #include <sys/uio.h>
 
diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c
index dd77b48..14c96a3 100644
--- a/gdb/gdbserver/linux-arm-low.c
+++ b/gdb/gdbserver/linux-arm-low.c
@@ -24,7 +24,7 @@
 #ifndef ELFMAG0
 #include <elf.h>
 #endif
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <signal.h>
 
 /* Defined in auto-generated files.  */
diff --git a/gdb/gdbserver/linux-cris-low.c b/gdb/gdbserver/linux-cris-low.c
index 4e5e4c0..e0bfa1a 100644
--- a/gdb/gdbserver/linux-cris-low.c
+++ b/gdb/gdbserver/linux-cris-low.c
@@ -18,7 +18,7 @@
 
 #include "server.h"
 #include "linux-low.h"
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 
 /* Defined in auto-generated file reg-cris.c.  */
 void init_registers_cris (void);
diff --git a/gdb/gdbserver/linux-crisv32-low.c b/gdb/gdbserver/linux-crisv32-low.c
index 65e6c09..5120863 100644
--- a/gdb/gdbserver/linux-crisv32-low.c
+++ b/gdb/gdbserver/linux-crisv32-low.c
@@ -18,7 +18,7 @@
 
 #include "server.h"
 #include "linux-low.h"
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 
 /* Defined in auto-generated file reg-crisv32.c.  */
 void init_registers_crisv32 (void);
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 7bb9f7f..4d7e376 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -26,7 +26,7 @@
 #include "nat/linux-nat.h"
 #include "nat/linux-waitpid.h"
 #include "gdb_wait.h"
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include "nat/linux-ptrace.h"
 #include "nat/linux-procfs.h"
 #include "nat/linux-personality.h"
diff --git a/gdb/gdbserver/linux-m68k-low.c b/gdb/gdbserver/linux-m68k-low.c
index 4501904..39c9cc5 100644
--- a/gdb/gdbserver/linux-m68k-low.c
+++ b/gdb/gdbserver/linux-m68k-low.c
@@ -68,7 +68,7 @@ m68k_cannot_fetch_register (int regno)
 
 #ifdef HAVE_PTRACE_GETREGS
 #include <sys/procfs.h>
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 
 static void
 m68k_fill_gregset (struct regcache *regcache, void *buf)
diff --git a/gdb/gdbserver/linux-mips-low.c b/gdb/gdbserver/linux-mips-low.c
index 1695c4c..d3b01d6 100644
--- a/gdb/gdbserver/linux-mips-low.c
+++ b/gdb/gdbserver/linux-mips-low.c
@@ -19,7 +19,7 @@
 #include "server.h"
 #include "linux-low.h"
 
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <endian.h>
 
 #include "nat/mips-linux-watch.h"
diff --git a/gdb/gdbserver/linux-nios2-low.c b/gdb/gdbserver/linux-nios2-low.c
index 7bd3c97..8a7ac28 100644
--- a/gdb/gdbserver/linux-nios2-low.c
+++ b/gdb/gdbserver/linux-nios2-low.c
@@ -22,7 +22,7 @@
 #include "server.h"
 #include "linux-low.h"
 #include "elf/common.h"
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <endian.h>
 #include "gdb_proc_service.h"
 #include <asm/ptrace.h>
diff --git a/gdb/gdbserver/linux-s390-low.c b/gdb/gdbserver/linux-s390-low.c
index 5d4ea1f..8a0a689 100644
--- a/gdb/gdbserver/linux-s390-low.c
+++ b/gdb/gdbserver/linux-s390-low.c
@@ -24,7 +24,7 @@
 #include "elf/common.h"
 
 #include <asm/ptrace.h>
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <sys/uio.h>
 #include <elf.h>
 
diff --git a/gdb/gdbserver/linux-sparc-low.c b/gdb/gdbserver/linux-sparc-low.c
index 8f5cdbf..796af8a 100644
--- a/gdb/gdbserver/linux-sparc-low.c
+++ b/gdb/gdbserver/linux-sparc-low.c
@@ -19,7 +19,7 @@
 #include "server.h"
 #include "linux-low.h"
 
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 
 #include "gdb_proc_service.h"
 
diff --git a/gdb/gdbserver/linux-tic6x-low.c b/gdb/gdbserver/linux-tic6x-low.c
index 0a0d220..a2ac3ee 100644
--- a/gdb/gdbserver/linux-tic6x-low.c
+++ b/gdb/gdbserver/linux-tic6x-low.c
@@ -22,7 +22,7 @@
 #include "server.h"
 #include "linux-low.h"
 
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <endian.h>
 
 #include "gdb_proc_service.h"
diff --git a/gdb/gdbserver/linux-tile-low.c b/gdb/gdbserver/linux-tile-low.c
index 2f72fdb..6aaea6a 100644
--- a/gdb/gdbserver/linux-tile-low.c
+++ b/gdb/gdbserver/linux-tile-low.c
@@ -21,7 +21,7 @@
 #include "linux-low.h"
 
 #include <arch/abi.h>
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 
 /* Defined in auto-generated file reg-tilegx.c.  */
 void init_registers_tilegx (void);
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index 484eadb..ec2d906 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -25,6 +25,7 @@
 #include "i387-fp.h"
 #include "x86-low.h"
 #include "x86-xstate.h"
+#include "nat/gdb_ptrace.h"
 
 #include "gdb_proc_service.h"
 /* Don't include elf/common.h if linux/elf.h got included by
@@ -117,7 +118,7 @@ static const char *xmltarget_amd64_linux_no_xml = "@<target>\
 
 #include <sys/reg.h>
 #include <sys/procfs.h>
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <sys/uio.h>
 
 #ifndef PTRACE_GET_THREAD_AREA
diff --git a/gdb/hppa-linux-nat.c b/gdb/hppa-linux-nat.c
index cfadf73..0694f61 100644
--- a/gdb/hppa-linux-nat.c
+++ b/gdb/hppa-linux-nat.c
@@ -25,7 +25,7 @@
 #include "linux-nat.h"
 
 #include <sys/procfs.h>
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <linux/version.h>
 
 #include <asm/ptrace.h>
diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
index 349ce68..63d2648 100644
--- a/gdb/i386-linux-nat.c
+++ b/gdb/i386-linux-nat.c
@@ -22,7 +22,7 @@
 #include "gdbcore.h"
 #include "regcache.h"
 #include "elf/common.h"
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <sys/uio.h>
 #include "gregset.h"
 #include "gdb_proc_service.h"
diff --git a/gdb/ia64-linux-nat.c b/gdb/ia64-linux-nat.c
index 31b3248..fc17d81 100644
--- a/gdb/ia64-linux-nat.c
+++ b/gdb/ia64-linux-nat.c
@@ -27,7 +27,7 @@
 #include "linux-nat.h"
 
 #include <signal.h>
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include "gdb_wait.h"
 #ifdef HAVE_SYS_REG_H
 #include <sys/reg.h>
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 27603b3..dbaa36e 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -30,7 +30,7 @@
 #include "gdbthread.h"
 #include "source.h"
 
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include "gdb_wait.h"
 #include <dirent.h>
 #include <ctype.h>
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index be429f8..e383d8a 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -28,7 +28,7 @@
 #include <unistd.h>
 #include <sys/syscall.h>
 #endif
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include "linux-nat.h"
 #include "nat/linux-ptrace.h"
 #include "nat/linux-procfs.h"
diff --git a/gdb/m32r-linux-nat.c b/gdb/m32r-linux-nat.c
index e5e867b..781bb78 100644
--- a/gdb/m32r-linux-nat.c
+++ b/gdb/m32r-linux-nat.c
@@ -23,7 +23,7 @@
 #include "regcache.h"
 #include "linux-nat.h"
 #include "target.h"
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <sys/user.h>
 #include <sys/procfs.h>
 
diff --git a/gdb/m68klinux-nat.c b/gdb/m68klinux-nat.c
index 8f89d7b..e6a4ad9 100644
--- a/gdb/m68klinux-nat.c
+++ b/gdb/m68klinux-nat.c
@@ -30,7 +30,7 @@
 
 #include <sys/dir.h>
 #include <signal.h>
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <sys/user.h>
 #include <sys/ioctl.h>
 #include <fcntl.h>
diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
index a36bb63..961cb6f 100644
--- a/gdb/mips-linux-nat.c
+++ b/gdb/mips-linux-nat.c
@@ -32,7 +32,7 @@
 #include "gregset.h"
 
 #include <sgidefs.h>
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <asm/ptrace.h>
 
 #include "nat/mips-linux-watch.h"
diff --git a/gdb/nat/linux-btrace.c b/gdb/nat/linux-btrace.c
index b6e13d3..93408be 100644
--- a/gdb/nat/linux-btrace.c
+++ b/gdb/nat/linux-btrace.c
@@ -33,7 +33,7 @@
 #include <unistd.h>
 #include <sys/mman.h>
 #include <sys/user.h>
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <sys/types.h>
 #include <signal.h>
 #include <sys/utsname.h>
diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
index 1a926f9..f097c8a 100644
--- a/gdb/nat/linux-ptrace.c
+++ b/gdb/nat/linux-ptrace.c
@@ -22,6 +22,7 @@
 #include "linux-waitpid.h"
 #include "buffer.h"
 #include "gdb_wait.h"
+#include "gdb_ptrace.h"
 
 /* Stores the ptrace options supported by the running kernel.
    A value of -1 means we did not check for features yet.  A value
diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h
index be6c395..41f668c 100644
--- a/gdb/nat/linux-ptrace.h
+++ b/gdb/nat/linux-ptrace.h
@@ -20,7 +20,7 @@
 
 struct buffer;
 
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 
 #ifdef __UCLIBC__
 #if !(defined(__UCLIBC_HAS_MMU__) || defined(__ARCH_HAS_MMU__))
diff --git a/gdb/nat/mips-linux-watch.c b/gdb/nat/mips-linux-watch.c
index 464f709..02d83f6 100644
--- a/gdb/nat/mips-linux-watch.c
+++ b/gdb/nat/mips-linux-watch.c
@@ -16,7 +16,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "common-defs.h"
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include "mips-linux-watch.h"
 
 /* Assuming usable watch registers REGS, return the irw_mask of
diff --git a/gdb/nat/x86-linux-dregs.c b/gdb/nat/x86-linux-dregs.c
index 9389803..666d86a 100644
--- a/gdb/nat/x86-linux-dregs.c
+++ b/gdb/nat/x86-linux-dregs.c
@@ -18,7 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "common-defs.h"
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <sys/user.h>
 #include "target/waitstatus.h"
 #include "nat/x86-linux.h"
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index 4ed03d0..7514685 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -33,7 +33,7 @@
 #include "gdb_wait.h"
 #include <fcntl.h>
 #include <sys/procfs.h>
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 
 /* Prototypes for supply_gregset etc.  */
 #include "gregset.h"
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index cedc505..94edce8 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -33,7 +33,7 @@
 #include "elf/common.h"
 
 #include <asm/ptrace.h>
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <asm/types.h>
 #include <sys/procfs.h>
 #include <sys/ucontext.h>
diff --git a/gdb/spu-linux-nat.c b/gdb/spu-linux-nat.c
index a043f53..cb182be 100644
--- a/gdb/spu-linux-nat.c
+++ b/gdb/spu-linux-nat.c
@@ -30,7 +30,7 @@
 #include "gdbthread.h"
 #include "gdb_bfd.h"
 
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <asm/ptrace.h>
 #include <sys/types.h>
 
diff --git a/gdb/tilegx-linux-nat.c b/gdb/tilegx-linux-nat.c
index b8f0c76..b9ce47a 100644
--- a/gdb/tilegx-linux-nat.c
+++ b/gdb/tilegx-linux-nat.c
@@ -23,7 +23,7 @@
 #include "regcache.h"
 #include "linux-nat.h"
 
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 
 #include <sys/procfs.h>
 
diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c
index 04917d0..34a9257 100644
--- a/gdb/x86-linux-nat.c
+++ b/gdb/x86-linux-nat.c
@@ -21,7 +21,7 @@
 #include "inferior.h"
 #include "elf/common.h"
 #include "gdb_proc_service.h"
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <sys/user.h>
 #include <sys/procfs.h>
 #include <sys/uio.h>
diff --git a/gdb/xtensa-linux-nat.c b/gdb/xtensa-linux-nat.c
index fa62732..7f530ce 100644
--- a/gdb/xtensa-linux-nat.c
+++ b/gdb/xtensa-linux-nat.c
@@ -31,7 +31,7 @@
 #include "gdb_wait.h"
 #include <fcntl.h>
 #include <sys/procfs.h>
-#include <sys/ptrace.h>
+#include "nat/gdb_ptrace.h"
 #include <asm/ptrace.h>
 
 #include "gregset.h"
-- 
1.9.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] C++: handle ptrace(enum __ptrace_request, ...)
  2015-07-10 21:52 [PATCH 0/4] C++: handle ptrace(enum __ptrace_request, ...) Pedro Alves
                   ` (3 preceding siblings ...)
  2015-07-10 22:00 ` [PATCH 4/4] Linux: sys/ptrace.h -> nat/gdb_ptrace.h everywhere Pedro Alves
@ 2015-07-24 14:22 ` Pedro Alves
  4 siblings, 0 replies; 6+ messages in thread
From: Pedro Alves @ 2015-07-24 14:22 UTC (permalink / raw)
  To: GDB Patches

On 07/10/2015 10:52 PM, Pedro Alves wrote:
> Building GDB on GNU/Linux in C++ mode issues ~40 ptrace-related
> -fpermissive warnings like this:
> 
> ../../src/gdb/linux-nat.c: In function ‘int linux_handle_extended_wait(lwp_info*, int, int)’:
> ../../src/gdb/linux-nat.c:2016:51: warning: invalid conversion from ‘int’ to ‘__ptrace_request’ [-fpermissive]
>    ptrace (PTRACE_GETEVENTMSG, pid, 0, &new_pid);
> 
> This series fixes them all.
> 
> No regressions on x86_64 Fedora 20.
> 
> Pedro Alves (4):
>   make gdbserver use the same ptrace autoconf checks as gdb
>   Move gdb_ptrace.h to nat/
>   C++: handle glibc's ptrace(enum __ptrace_request, ...)
>   Linux: sys/ptrace.h -> nat/gdb_ptrace.h everywhere

FYI, I pushed these in.

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-07-24 14:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-10 21:52 [PATCH 0/4] C++: handle ptrace(enum __ptrace_request, ...) Pedro Alves
2015-07-10 21:52 ` [PATCH 1/4] make gdbserver use the same ptrace autoconf checks as gdb Pedro Alves
2015-07-10 21:52 ` [PATCH 2/4] Move gdb_ptrace.h to nat/ Pedro Alves
2015-07-10 21:52 ` [PATCH 3/4] C++: handle glibc's ptrace(enum __ptrace_request, ...) Pedro Alves
2015-07-10 22:00 ` [PATCH 4/4] Linux: sys/ptrace.h -> nat/gdb_ptrace.h everywhere Pedro Alves
2015-07-24 14:22 ` [PATCH 0/4] C++: handle ptrace(enum __ptrace_request, ...) Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).