public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb: remove HAVE_DECL_PTRACE
@ 2020-03-19 15:27 Simon Marchi
  2020-03-20 15:54 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2020-03-19 15:27 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

I stumbled on this snippet in nat/gdb_ptrace.h:

    /* Some systems, in particular DEC OSF/1, Digital Unix, Compaq Tru64
       or whatever it's called these days, don't provide a prototype for
       ptrace.  Provide one to silence compiler warnings.  */

    #ifndef HAVE_DECL_PTRACE
    extern PTRACE_TYPE_RET ptrace();
    #endif

I believe this is unnecessary today and should be removed.  First, the
comment only mentions OSes we don't support (and to be honest, I had
never even heard of).

But most importantly, in C++, a declaration with empty parenthesis
declares a function that accepts no arguments, unlike in C.  So if this
declaration was really used, GDB wouldn't build, since all ptrace call
sites pass some arguments.  Since we haven't heard anything about this
causing some build failures since we have transitioned to C++, I
conclude that it's not used.

This patch removes it as well as the corresponding configure check.

gdb/ChangeLog:

	* ptrace.m4: Don't check for ptrace declaration.
	* config.in: Re-generate.
	* configure: Re-generate.
	* nat/gdb_ptrace.h: Don't declare ptrace if HAVE_DECL_PTRACE is
	not defined.

gdbserver/ChangeLog:

	* config.in: Re-generate.
	* configure: Re-generate.

gdbsupport/ChangeLog:

	* config.in: Re-generate.
	* configure: Re-generate.
---
 gdb/config.in        |  4 ----
 gdb/configure        | 20 --------------------
 gdb/nat/gdb_ptrace.h |  8 --------
 gdb/ptrace.m4        |  6 +-----
 gdbserver/config.in  |  4 ----
 gdbserver/configure  | 20 --------------------
 gdbsupport/config.in |  4 ----
 gdbsupport/configure | 20 --------------------
 8 files changed, 1 insertion(+), 85 deletions(-)

diff --git a/gdb/config.in b/gdb/config.in
index 7a34b85e5754..118e424580e5 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -109,10 +109,6 @@
    don't. */
 #undef HAVE_DECL_GETTHRDS
 
-/* 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
diff --git a/gdb/configure b/gdb/configure
index 614f3402c3d6..afafc2c8d181 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -15000,26 +15000,6 @@ gdb_ptrace_headers='
 # 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" = xyes; 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.
diff --git a/gdb/nat/gdb_ptrace.h b/gdb/nat/gdb_ptrace.h
index 9c2587f2e822..1278246559c0 100644
--- a/gdb/nat/gdb_ptrace.h
+++ b/gdb/nat/gdb_ptrace.h
@@ -121,14 +121,6 @@
 # endif
 #endif
 
-/* Some systems, in particular DEC OSF/1, Digital Unix, Compaq Tru64
-   or whatever it's called these days, don't provide a prototype for
-   ptrace.  Provide one to silence compiler warnings.  */
-
-#ifndef HAVE_DECL_PTRACE
-extern PTRACE_TYPE_RET ptrace();
-#endif
-
 /* Some systems, at least AIX and HP-UX have a ptrace with five
    arguments.  Since we never use the fifth argument, define a ptrace
    macro that calls the real ptrace with the last argument set to
diff --git a/gdb/ptrace.m4 b/gdb/ptrace.m4
index 4cd7652718a9..0fcd855aa8fd 100644
--- a/gdb/ptrace.m4
+++ b/gdb/ptrace.m4
@@ -31,11 +31,7 @@ gdb_ptrace_headers='
 # 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,
diff --git a/gdbserver/config.in b/gdbserver/config.in
index e62795072f20..da1bdbe3d946 100644
--- a/gdbserver/config.in
+++ b/gdbserver/config.in
@@ -50,10 +50,6 @@
    */
 #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
diff --git a/gdbserver/configure b/gdbserver/configure
index 55cf2416b568..0de11f7ee619 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -9413,26 +9413,6 @@ gdb_ptrace_headers='
 # 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" = xyes; 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.
diff --git a/gdbsupport/config.in b/gdbsupport/config.in
index 6a6b0bc74f09..94e90ecc5451 100644
--- a/gdbsupport/config.in
+++ b/gdbsupport/config.in
@@ -43,10 +43,6 @@
 /* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
 #undef HAVE_DECL_FFS
 
-/* 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
diff --git a/gdbsupport/configure b/gdbsupport/configure
index 2ffe539eb092..186cac6d5745 100755
--- a/gdbsupport/configure
+++ b/gdbsupport/configure
@@ -10666,26 +10666,6 @@ gdb_ptrace_headers='
 # 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" = xyes; 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.
-- 
2.25.1


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

* Re: [PATCH] gdb: remove HAVE_DECL_PTRACE
  2020-03-19 15:27 [PATCH] gdb: remove HAVE_DECL_PTRACE Simon Marchi
@ 2020-03-20 15:54 ` Tom Tromey
  2020-03-20 16:06   ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2020-03-20 15:54 UTC (permalink / raw)
  To: Simon Marchi via Gdb-patches; +Cc: Simon Marchi

>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:

Simon> I stumbled on this snippet in nat/gdb_ptrace.h:
Simon>     /* Some systems, in particular DEC OSF/1, Digital Unix, Compaq Tru64
Simon>        or whatever it's called these days, don't provide a prototype for
Simon>        ptrace.  Provide one to silence compiler warnings.  */

Simon>     #ifndef HAVE_DECL_PTRACE
Simon>     extern PTRACE_TYPE_RET ptrace();
Simon>     #endif

Simon> I believe this is unnecessary today and should be removed.  First, the
Simon> comment only mentions OSes we don't support (and to be honest, I had
Simon> never even heard of).

Thanks, this looks good to me.

Tom


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

* Re: [PATCH] gdb: remove HAVE_DECL_PTRACE
  2020-03-20 15:54 ` Tom Tromey
@ 2020-03-20 16:06   ` Simon Marchi
  0 siblings, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2020-03-20 16:06 UTC (permalink / raw)
  To: Tom Tromey, Simon Marchi via Gdb-patches; +Cc: Simon Marchi

On 2020-03-20 11:54 a.m., Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Simon> I stumbled on this snippet in nat/gdb_ptrace.h:
> Simon>     /* Some systems, in particular DEC OSF/1, Digital Unix, Compaq Tru64
> Simon>        or whatever it's called these days, don't provide a prototype for
> Simon>        ptrace.  Provide one to silence compiler warnings.  */
> 
> Simon>     #ifndef HAVE_DECL_PTRACE
> Simon>     extern PTRACE_TYPE_RET ptrace();
> Simon>     #endif
> 
> Simon> I believe this is unnecessary today and should be removed.  First, the
> Simon> comment only mentions OSes we don't support (and to be honest, I had
> Simon> never even heard of).
> 
> Thanks, this looks good to me.
> 
> Tom
> 

Thanks, I pushed it.

Simon

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

end of thread, other threads:[~2020-03-20 16:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-19 15:27 [PATCH] gdb: remove HAVE_DECL_PTRACE Simon Marchi
2020-03-20 15:54 ` Tom Tromey
2020-03-20 16:06   ` Simon Marchi

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).