From patchwork Fri Jan 8 14:45:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 10294 Received: (qmail 42010 invoked by alias); 8 Jan 2016 14:46:00 -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 41992 invoked by uid 89); 8 Jan 2016 14:45:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2477, traced, advised X-HELO: mail-pa0-f50.google.com Received: from mail-pa0-f50.google.com (HELO mail-pa0-f50.google.com) (209.85.220.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 08 Jan 2016 14:45:58 +0000 Received: by mail-pa0-f50.google.com with SMTP id ho8so22566591pac.2 for ; Fri, 08 Jan 2016 06:45:58 -0800 (PST) X-Received: by 10.66.220.170 with SMTP id px10mr12905432pac.145.1452264356777; Fri, 08 Jan 2016 06:45:56 -0800 (PST) Received: from E107787-LIN.cambridge.arm.com (gcc1-power7.osuosl.org. [140.211.15.137]) by smtp.gmail.com with ESMTPSA id sg4sm167922666pac.48.2016.01.08.06.45.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Jan 2016 06:45:56 -0800 (PST) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH] Change function signature passed to clone Date: Fri, 8 Jan 2016 14:45:50 +0000 Message-Id: <1452264350-25126-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes 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-08 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/nat/linux-ptrace.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c index f25abcf..31757ee 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);