* [PATCH] Change function signature passed to clone
@ 2016-01-08 14:46 Yao Qi
2016-01-12 13:05 ` Pedro Alves
2016-01-12 16:28 ` Yao Qi
0 siblings, 2 replies; 4+ messages in thread
From: Yao Qi @ 2016-01-08 14:46 UTC (permalink / raw)
To: gdb-patches
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 <yao.qi@linaro.org>
* 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);
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Change function signature passed to clone
2016-01-08 14:46 [PATCH] Change function signature passed to clone Yao Qi
@ 2016-01-12 13:05 ` Pedro Alves
2016-01-12 15:19 ` Yao Qi
2016-01-12 16:28 ` Yao Qi
1 sibling, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2016-01-12 13:05 UTC (permalink / raw)
To: Yao Qi, gdb-patches
On 01/08/2016 02:45 PM, Yao Qi wrote:
> 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 *'.
Agreed, LGTM.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Change function signature passed to clone
2016-01-12 13:05 ` Pedro Alves
@ 2016-01-12 15:19 ` Yao Qi
0 siblings, 0 replies; 4+ messages in thread
From: Yao Qi @ 2016-01-12 15:19 UTC (permalink / raw)
To: Pedro Alves; +Cc: Yao Qi, gdb-patches
Pedro Alves <palves@redhat.com> writes:
>> 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 *'.
>
> Agreed, LGTM.
Thanks, patch is pushed in.
--
Yao (齐尧)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Change function signature passed to clone
2016-01-08 14:46 [PATCH] Change function signature passed to clone Yao Qi
2016-01-12 13:05 ` Pedro Alves
@ 2016-01-12 16:28 ` Yao Qi
1 sibling, 0 replies; 4+ messages in thread
From: Yao Qi @ 2016-01-12 16:28 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
Yao Qi <qiyaoltc@gmail.com> writes:
> 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);
This patch causes a C++ build error. Patch below fixes it.
--
Yao (齐尧)
Subject: [PATCH] Fix invalid conversion from void * to gdb_byte *
This patch fixes the following GDB build error in C++ mode.
gdb/nat/linux-ptrace.c: In function 'int linux_child_function(void*)':
gdb/nat/linux-ptrace.c:323:65: error: invalid conversion from 'void*' to 'gdb_byte* {aka unsigned char*}' [-fpermissive]
linux_fork_to_function (child_stack, linux_grandchild_function);
^
gdb:
2016-01-12 Yao Qi <yao.qi@linaro.org>
* nat/linux-ptrace.c (linux_child_function): Cast child_stack
to gdb_byte * and pass to linux_fork_to_function.
diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c
index 31757ee..0eaf9a3 100644
--- a/gdb/nat/linux-ptrace.c
+++ b/gdb/nat/linux-ptrace.c
@@ -320,7 +320,7 @@ linux_child_function (void *child_stack)
kill (getpid (), SIGSTOP);
/* Fork a grandchild. */
- linux_fork_to_function (child_stack, linux_grandchild_function);
+ linux_fork_to_function ((gdb_byte *) child_stack, linux_grandchild_function);
/* This code is only reacheable by the child (grandchild's parent)
process. */
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-01-12 16:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-08 14:46 [PATCH] Change function signature passed to clone Yao Qi
2016-01-12 13:05 ` Pedro Alves
2016-01-12 15:19 ` Yao Qi
2016-01-12 16:28 ` Yao Qi
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).