This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Change function signature passed to clone


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.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]