From ba4dd7c4a1d99c62a1c2edd68f511a82f8fe041e Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Tue, 12 Jan 2016 15:18:09 +0000 Subject: [PATCH] Change function signature passed to clone I see the following compile error with an old bfin-uclinux gcc to build GDBserver, cc1: warnings being treated as errors gdb/gdbserver/../nat/linux-ptrace.c: In function 'linux_fork_to_function': gdb/gdbserver/../nat/linux-ptrace.c:283: error: passing argument 1 of 'clone' from incompatible pointer type in glibc, clone's prototype is like this, and in uClibc, it is the same, int clone(int (*fn)(void *), void *child_stack, int flags, void *arg, ... /* pid_t *ptid, struct user_desc *tls, pid_t *ctid */ ); so this patch changes function signature from 'void (*function) (gdb_byte *)' to 'int (*function) (void *)'. Note that I find Pedro advised to change argument type from 'void *' to 'gdb_byte *' during the patch review https://sourceware.org/ml/gdb-patches/2013-08/msg00611.html however, I think fix compile error can justify the change back to 'void *'. gdb: 2016-01-12 Yao Qi * nat/linux-ptrace.c (linux_fork_to_function): Change type of argument 'function'. (linux_grandchild_function): Change return type to 'int'. Change child_stack's type to 'void *'. (linux_child_function): Likewise. --- gdb/ChangeLog | 8 ++++++++ gdb/nat/linux-ptrace.c | 10 +++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9f48fa458a3..9184afc41cf 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2016-01-12 Yao Qi + + * nat/linux-ptrace.c (linux_fork_to_function): Change type + of argument 'function'. + (linux_grandchild_function): Change return type to 'int'. + Change child_stack's type to 'void *'. + (linux_child_function): Likewise. + 2016-01-12 Pedro Alves Remove use of the registered trademark symbol throughout. diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c index f25abcf82c3..31757ee71da 100644 --- a/gdb/nat/linux-ptrace.c +++ b/gdb/nat/linux-ptrace.c @@ -261,7 +261,7 @@ linux_ptrace_test_ret_to_nx (void) FUNCTION). For MMU targets, CHILD_STACK is ignored. */ static int -linux_fork_to_function (gdb_byte *child_stack, void (*function) (gdb_byte *)) +linux_fork_to_function (gdb_byte *child_stack, int (*function) (void *)) { int child_pid; @@ -298,8 +298,8 @@ linux_fork_to_function (gdb_byte *child_stack, void (*function) (gdb_byte *)) /* A helper function for linux_check_ptrace_features, called after the child forks a grandchild. */ -static void -linux_grandchild_function (gdb_byte *child_stack) +static int +linux_grandchild_function (void *child_stack) { /* Free any allocated stack. */ xfree (child_stack); @@ -313,8 +313,8 @@ linux_grandchild_function (gdb_byte *child_stack) the parent process forks a child. The child allows itself to be traced by its parent. */ -static void -linux_child_function (gdb_byte *child_stack) +static int +linux_child_function (void *child_stack) { ptrace (PTRACE_TRACEME, 0, (PTRACE_TYPE_ARG3) 0, (PTRACE_TYPE_ARG4) 0); kill (getpid (), SIGSTOP); -- 2.30.2