Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdbserver ptrace() argument type cleanups.
@ 2013-02-04 17:31 Marcus Shawcroft
  2013-02-04 17:35 ` Pedro Alves
  2013-02-04 18:57 ` Mark Kettenis
  0 siblings, 2 replies; 8+ messages in thread
From: Marcus Shawcroft @ 2013-02-04 17:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Pedro Alves

[-- Attachment #1: Type: text/plain, Size: 927 bytes --]

Hi,

This patch is ripped out of the aarch64 gdbserver patch here:

http://sourceware.org/ml/gdb-patches/2013-01/msg00535.html

These changes are not directly related to the aarch64 port itself. 
Since ptrace() has a variadic prototype, the anonymous arguments, 
notably arguments 3 and 4, should be given their correct types.

/Marcus

Proposed ChangeLog:

    gdb/gdbserver/

         * linux-low.c (handle_extended_wait, linux_create_inferior)
         (linux_attach_lwp_1, linux_kill_one_lwp, linux_attach_one_lwp)
         (dequeue_one_deferred_signal, linux_resume_one_thread)
         (fetch_register, linux_write_memory, linux_enable_event_reporting)
         (linux_tracefork_grandchild, linux_test_for_tracefork)
         (linux_read_offsets, linux_xfer_siginfo, linux_xfer_siginfo ): Add
         PTRACE_ARG3_TYPE and PTRACE_ARG4_TYPE cast to ptrace arguments
         where the argument is 0.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gdbserver-ptrace.diff --]
[-- Type: text/x-patch; name=0001-gdbserver-ptrace.diff, Size: 11794 bytes --]

diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 8988509..c52cd2e 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -445,7 +445,8 @@ handle_extended_wait (struct lwp_info *event_child, int wstat)
       unsigned long new_pid;
       int ret, status;
 
-      ptrace (PTRACE_GETEVENTMSG, lwpid_of (event_child), 0, &new_pid);
+      ptrace (PTRACE_GETEVENTMSG, lwpid_of (event_child), (PTRACE_ARG3_TYPE) 0,
+	      &new_pid);
 
       /* If we haven't already seen the new PID stop, wait for it now.  */
       if (!pull_pid_from_list (&stopped_pids, new_pid, &status))
@@ -641,7 +642,7 @@ linux_create_inferior (char *program, char **allargs)
 
   if (pid == 0)
     {
-      ptrace (PTRACE_TRACEME, 0, 0, 0);
+      ptrace (PTRACE_TRACEME, 0, (PTRACE_ARG3_TYPE) 0, (PTRACE_ARG4_TYPE) 0);
 
 #ifndef __ANDROID__ /* Bionic doesn't use SIGRTMIN the way glibc does.  */
       signal (__SIGRTMIN + 1, SIG_DFL);
@@ -703,7 +704,8 @@ linux_attach_lwp_1 (unsigned long lwpid, int initial)
   ptid_t ptid;
   struct lwp_info *new_lwp;
 
-  if (ptrace (PTRACE_ATTACH, lwpid, 0, 0) != 0)
+  if (ptrace (PTRACE_ATTACH, lwpid, (PTRACE_ARG3_TYPE) 0, (PTRACE_ARG4_TYPE) 0)
+      != 0)
     {
       struct buffer buffer;
 
@@ -769,7 +771,7 @@ linux_attach_lwp_1 (unsigned long lwpid, int initial)
       /* Finally, resume the stopped process.  This will deliver the
 	 SIGSTOP (or a higher priority signal, just like normal
 	 PTRACE_ATTACH), which we'll catch later on.  */
-      ptrace (PTRACE_CONT, lwpid, 0, 0);
+      ptrace (PTRACE_CONT, lwpid, (PTRACE_ARG3_TYPE) 0, (PTRACE_ARG4_TYPE) 0);
     }
 
   /* The next time we wait for this LWP we'll see a SIGSTOP as PTRACE_ATTACH
@@ -960,7 +962,7 @@ linux_kill_one_lwp (struct lwp_info *lwp)
 	     errno ? strerror (errno) : "OK");
 
   errno = 0;
-  ptrace (PTRACE_KILL, pid, 0, 0);
+  ptrace (PTRACE_KILL, pid, (PTRACE_ARG3_TYPE) 0, (PTRACE_ARG4_TYPE) 0);
   if (debug_threads)
     fprintf (stderr,
 	     "LKL:  PTRACE_KILL %s, 0, 0 (%s)\n",
@@ -1174,7 +1176,7 @@ linux_detach_one_lwp (struct inferior_list_entry *entry, void *args)
   /* Finally, let it resume.  */
   if (the_low_target.prepare_to_resume != NULL)
     the_low_target.prepare_to_resume (lwp);
-  if (ptrace (PTRACE_DETACH, lwpid_of (lwp), 0,
+  if (ptrace (PTRACE_DETACH, lwpid_of (lwp), (PTRACE_ARG3_TYPE) 0,
 	      (PTRACE_ARG4_TYPE) (long) sig) < 0)
     error (_("Can't detach %s: %s"),
 	   target_pid_to_str (ptid_of (lwp)),
@@ -1605,13 +1607,15 @@ Checking whether LWP %ld needs to move out of the jump pad...it does\n",
 		   || WSTOPSIG (*wstat) == SIGFPE
 		   || WSTOPSIG (*wstat) == SIGBUS
 		   || WSTOPSIG (*wstat) == SIGSEGV)
-		  && ptrace (PTRACE_GETSIGINFO, lwpid_of (lwp), 0, &info) == 0
+		  && ptrace (PTRACE_GETSIGINFO, lwpid_of (lwp),
+			     (PTRACE_ARG3_TYPE) 0, &info) == 0
 		  /* Final check just to make sure we don't clobber
 		     the siginfo of non-kernel-sent signals.  */
 		  && (uintptr_t) info.si_addr == lwp->stop_pc)
 		{
 		  info.si_addr = (void *) (uintptr_t) status.tpoint_addr;
-		  ptrace (PTRACE_SETSIGINFO, lwpid_of (lwp), 0, &info);
+		  ptrace (PTRACE_SETSIGINFO, lwpid_of (lwp),
+			  (PTRACE_ARG3_TYPE) 0, &info);
 		}
 
 	      regcache = get_thread_regcache (get_lwp_thread (lwp), 1);
@@ -1706,7 +1710,8 @@ Deferring signal %d for LWP %ld.\n", WSTOPSIG (*wstat), lwpid_of (lwp));
   p_sig->prev = lwp->pending_signals_to_report;
   p_sig->signal = WSTOPSIG (*wstat);
   memset (&p_sig->info, 0, sizeof (siginfo_t));
-  ptrace (PTRACE_GETSIGINFO, lwpid_of (lwp), 0, &p_sig->info);
+  ptrace (PTRACE_GETSIGINFO, lwpid_of (lwp), (PTRACE_ARG3_TYPE) 0,
+	  &p_sig->info);
 
   lwp->pending_signals_to_report = p_sig;
 }
@@ -1727,7 +1732,8 @@ dequeue_one_deferred_signal (struct lwp_info *lwp, int *wstat)
 
       *wstat = W_STOPCODE ((*p_sig)->signal);
       if ((*p_sig)->info.si_signo != 0)
-	ptrace (PTRACE_SETSIGINFO, lwpid_of (lwp), 0, &(*p_sig)->info);
+	ptrace (PTRACE_SETSIGINFO, lwpid_of (lwp), (PTRACE_ARG3_TYPE) 0,
+		&(*p_sig)->info);
       free (*p_sig);
       *p_sig = NULL;
 
@@ -2597,7 +2603,8 @@ Check if we're already there.\n",
 	fprintf (stderr, "Ignored signal %d for LWP %ld.\n",
 		 WSTOPSIG (w), lwpid_of (event_child));
 
-      if (ptrace (PTRACE_GETSIGINFO, lwpid_of (event_child), 0, &info) == 0)
+      if (ptrace (PTRACE_GETSIGINFO, lwpid_of (event_child),
+		  (PTRACE_ARG3_TYPE) 0, &info) == 0)
 	info_p = &info;
       else
 	info_p = NULL;
@@ -3277,7 +3284,8 @@ lwp %ld wants to get out of fast tracepoint jump pad single-stepping\n",
 
       signal = (*p_sig)->signal;
       if ((*p_sig)->info.si_signo != 0)
-	ptrace (PTRACE_SETSIGINFO, lwpid_of (lwp), 0, &(*p_sig)->info);
+	ptrace (PTRACE_SETSIGINFO, lwpid_of (lwp), (PTRACE_ARG3_TYPE) 0,
+		&(*p_sig)->info);
 
       free (*p_sig);
       *p_sig = NULL;
@@ -3292,7 +3300,8 @@ lwp %ld wants to get out of fast tracepoint jump pad single-stepping\n",
   lwp->stopped = 0;
   lwp->stopped_by_watchpoint = 0;
   lwp->stepping = step;
-  ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (lwp), 0,
+  ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (lwp),
+	  (PTRACE_ARG3_TYPE) 0,
 	  /* Coerce to a uintptr_t first to avoid potential gcc warning
 	     of coercing an 8 byte integer to a 4 byte pointer.  */
 	  (PTRACE_ARG4_TYPE) (uintptr_t) signal);
@@ -3760,7 +3769,8 @@ linux_resume_one_thread (struct inferior_list_entry *entry, void *arg)
 	     PTRACE_SETSIGINFO.  */
 	  if (WIFSTOPPED (lwp->last_status)
 	      && WSTOPSIG (lwp->last_status) == lwp->resume->sig)
-	    ptrace (PTRACE_GETSIGINFO, lwpid_of (lwp), 0, &p_sig->info);
+	    ptrace (PTRACE_GETSIGINFO, lwpid_of (lwp), (PTRACE_ARG3_TYPE) 0,
+		    &p_sig->info);
 
 	  lwp->pending_signals = p_sig;
 	}
@@ -4221,7 +4231,7 @@ fetch_register (struct regcache *regcache, int regno)
 	ptrace (PTRACE_PEEKUSER, pid,
 		/* Coerce to a uintptr_t first to avoid potential gcc warning
 		   of coercing an 8 byte integer to a 4 byte pointer.  */
-		(PTRACE_ARG3_TYPE) (uintptr_t) regaddr, 0);
+		(PTRACE_ARG3_TYPE) (uintptr_t) regaddr, (PTRACE_ARG4_TYPE) 0);
       regaddr += sizeof (PTRACE_XFER_TYPE);
       if (errno != 0)
 	error ("reading register %d: %s", regno, strerror (errno));
@@ -4449,7 +4459,8 @@ linux_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
       /* Coerce the 3rd arg to a uintptr_t first to avoid potential gcc warning
 	 about coercing an 8 byte integer to a 4 byte pointer.  */
       buffer[i] = ptrace (PTRACE_PEEKTEXT, pid,
-			  (PTRACE_ARG3_TYPE) (uintptr_t) addr, 0);
+			  (PTRACE_ARG3_TYPE) (uintptr_t) addr,
+			  (PTRACE_ARG4_TYPE) 0);
       if (errno)
 	break;
     }
@@ -4509,7 +4520,8 @@ linux_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
   /* Coerce the 3rd arg to a uintptr_t first to avoid potential gcc warning
      about coercing an 8 byte integer to a 4 byte pointer.  */
   buffer[0] = ptrace (PTRACE_PEEKTEXT, pid,
-		      (PTRACE_ARG3_TYPE) (uintptr_t) addr, 0);
+		      (PTRACE_ARG3_TYPE) (uintptr_t) addr,
+		      (PTRACE_ARG4_TYPE) 0);
   if (errno)
     return errno;
 
@@ -4522,7 +4534,7 @@ linux_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
 		     about coercing an 8 byte integer to a 4 byte pointer.  */
 		  (PTRACE_ARG3_TYPE) (uintptr_t) (addr + (count - 1)
 						  * sizeof (PTRACE_XFER_TYPE)),
-		  0);
+		  (PTRACE_ARG4_TYPE) 0);
       if (errno)
 	return errno;
     }
@@ -4558,7 +4570,8 @@ linux_enable_event_reporting (int pid)
   if (!linux_supports_tracefork_flag)
     return;
 
-  ptrace (PTRACE_SETOPTIONS, pid, 0, (PTRACE_ARG4_TYPE) PTRACE_O_TRACECLONE);
+  ptrace (PTRACE_SETOPTIONS, pid, (PTRACE_ARG3_TYPE) 0,
+	  (PTRACE_ARG4_TYPE) PTRACE_O_TRACECLONE);
 }
 
 /* Helper functions for linux_test_for_tracefork, called via clone ().  */
@@ -4574,7 +4587,7 @@ linux_tracefork_grandchild (void *arg)
 static int
 linux_tracefork_child (void *arg)
 {
-  ptrace (PTRACE_TRACEME, 0, 0, 0);
+  ptrace (PTRACE_TRACEME, 0, (PTRACE_ARG3_TYPE) 0, (PTRACE_ARG4_TYPE) 0);
   kill (getpid (), SIGSTOP);
 
 #if !(defined(__UCLIBC__) && defined(HAS_NOMMU))
@@ -4642,11 +4655,12 @@ linux_test_for_tracefork (void)
   if (! WIFSTOPPED (status))
     error ("linux_test_for_tracefork: waitpid: unexpected status %d.", status);
 
-  ret = ptrace (PTRACE_SETOPTIONS, child_pid, 0,
+  ret = ptrace (PTRACE_SETOPTIONS, child_pid, (PTRACE_ARG3_TYPE) 0,
 		(PTRACE_ARG4_TYPE) PTRACE_O_TRACEFORK);
   if (ret != 0)
     {
-      ret = ptrace (PTRACE_KILL, child_pid, 0, 0);
+      ret = ptrace (PTRACE_KILL, child_pid, (PTRACE_ARG3_TYPE) 0,
+		    (PTRACE_ARG4_TYPE) 0);
       if (ret != 0)
 	{
 	  warning ("linux_test_for_tracefork: failed to kill child");
@@ -4663,7 +4677,8 @@ linux_test_for_tracefork (void)
       return;
     }
 
-  ret = ptrace (PTRACE_CONT, child_pid, 0, 0);
+  ret = ptrace (PTRACE_CONT, child_pid, (PTRACE_ARG3_TYPE) 0,
+		(PTRACE_ARG4_TYPE) 0);
   if (ret != 0)
     warning ("linux_test_for_tracefork: failed to resume child");
 
@@ -4673,14 +4688,16 @@ linux_test_for_tracefork (void)
       && status >> 16 == PTRACE_EVENT_FORK)
     {
       second_pid = 0;
-      ret = ptrace (PTRACE_GETEVENTMSG, child_pid, 0, &second_pid);
+      ret = ptrace (PTRACE_GETEVENTMSG, child_pid, (PTRACE_ARG3_TYPE) 0,
+		    &second_pid);
       if (ret == 0 && second_pid != 0)
 	{
 	  int second_status;
 
 	  linux_supports_tracefork_flag = 1;
 	  my_waitpid (second_pid, &second_status, 0);
-	  ret = ptrace (PTRACE_KILL, second_pid, 0, 0);
+	  ret = ptrace (PTRACE_KILL, second_pid, (PTRACE_ARG3_TYPE) 0,
+			(PTRACE_ARG4_TYPE) 0);
 	  if (ret != 0)
 	    warning ("linux_test_for_tracefork: failed to kill second child");
 	  my_waitpid (second_pid, &status, 0);
@@ -4692,7 +4709,8 @@ linux_test_for_tracefork (void)
 
   do
     {
-      ret = ptrace (PTRACE_KILL, child_pid, 0, 0);
+      ret = ptrace (PTRACE_KILL, child_pid, (PTRACE_ARG3_TYPE) 0,
+		    (PTRACE_ARG4_TYPE) 0);
       if (ret != 0)
 	warning ("linux_test_for_tracefork: failed to kill child");
       my_waitpid (child_pid, &status, 0);
@@ -4839,9 +4857,12 @@ linux_read_offsets (CORE_ADDR *text_p, CORE_ADDR *data_p)
 
   errno = 0;
 
-  text = ptrace (PTRACE_PEEKUSER, pid, (long)PT_TEXT_ADDR, 0);
-  text_end = ptrace (PTRACE_PEEKUSER, pid, (long)PT_TEXT_END_ADDR, 0);
-  data = ptrace (PTRACE_PEEKUSER, pid, (long)PT_DATA_ADDR, 0);
+  text = ptrace (PTRACE_PEEKUSER, pid, (PTRACE_ARG3_TYPE) PT_TEXT_ADDR,
+		 (PTRACE_ARG4_TYPE) 0);
+  text_end = ptrace (PTRACE_PEEKUSER, pid, (PTRACE_ARG3_TYPE) PT_TEXT_END_ADDR,
+		     (PTRACE_ARG4_TYPE) 0);
+  data = ptrace (PTRACE_PEEKUSER, pid, (PTRACE_ARG3_TYPE) PT_DATA_ADDR,
+		 (PTRACE_ARG4_TYPE) 0);
 
   if (errno == 0)
     {
@@ -4915,7 +4936,7 @@ linux_xfer_siginfo (const char *annex, unsigned char *readbuf,
   if (offset >= sizeof (siginfo))
     return -1;
 
-  if (ptrace (PTRACE_GETSIGINFO, pid, 0, &siginfo) != 0)
+  if (ptrace (PTRACE_GETSIGINFO, pid, (PTRACE_ARG3_TYPE) 0, &siginfo) != 0)
     return -1;
 
   /* When GDBSERVER is built as a 64-bit application, ptrace writes into
@@ -4936,7 +4957,7 @@ linux_xfer_siginfo (const char *annex, unsigned char *readbuf,
       /* Convert back to ptrace layout before flushing it out.  */
       siginfo_fixup (&siginfo, inf_siginfo, 1);
 
-      if (ptrace (PTRACE_SETSIGINFO, pid, 0, &siginfo) != 0)
+      if (ptrace (PTRACE_SETSIGINFO, pid, (PTRACE_ARG3_TYPE) 0, &siginfo) != 0)
 	return -1;
     }
 

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

* Re: [PATCH] gdbserver ptrace() argument type cleanups.
  2013-02-04 17:31 [PATCH] gdbserver ptrace() argument type cleanups Marcus Shawcroft
@ 2013-02-04 17:35 ` Pedro Alves
  2013-02-04 17:41   ` Marcus Shawcroft
  2013-02-04 18:57 ` Mark Kettenis
  1 sibling, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2013-02-04 17:35 UTC (permalink / raw)
  To: Marcus Shawcroft; +Cc: gdb-patches

Hi Marcus,

On 02/04/2013 05:30 PM, Marcus Shawcroft wrote:

> This patch is ripped out of the aarch64 gdbserver patch here:
> 
> http://sourceware.org/ml/gdb-patches/2013-01/msg00535.html
> 
> These changes are not directly related to the aarch64 port itself. Since ptrace() has a variadic prototype, the anonymous arguments, notably arguments 3 and 4, should be given their correct types.

Excellent.  Thanks for doing this.

>    gdb/gdbserver/
> 
>         * linux-low.c (handle_extended_wait, linux_create_inferior)
>         (linux_attach_lwp_1, linux_kill_one_lwp, linux_attach_one_lwp)
>         (dequeue_one_deferred_signal, linux_resume_one_thread)
>         (fetch_register, linux_write_memory, linux_enable_event_reporting)
>         (linux_tracefork_grandchild, linux_test_for_tracefork)
>         (linux_read_offsets, linux_xfer_siginfo, linux_xfer_siginfo ): Add

Spurious space ------------------------------------------------------^

>         PTRACE_ARG3_TYPE and PTRACE_ARG4_TYPE cast to ptrace arguments
>         where the argument is 0.

This is OK.

Thanks!

-- 
Pedro Alves


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

* Re: [PATCH] gdbserver ptrace() argument type cleanups.
  2013-02-04 17:35 ` Pedro Alves
@ 2013-02-04 17:41   ` Marcus Shawcroft
  0 siblings, 0 replies; 8+ messages in thread
From: Marcus Shawcroft @ 2013-02-04 17:41 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

On 04/02/13 17:35, Pedro Alves wrote:
> Hi Marcus,
>
> On 02/04/2013 05:30 PM, Marcus Shawcroft wrote:
>
>> This patch is ripped out of the aarch64 gdbserver patch here:
>>
>> http://sourceware.org/ml/gdb-patches/2013-01/msg00535.html
>>
>> These changes are not directly related to the aarch64 port itself. Since ptrace() has a variadic prototype, the anonymous arguments, notably arguments 3 and 4, should be given their correct types.
>
> Excellent.  Thanks for doing this.
>
>>     gdb/gdbserver/
>>
>>          * linux-low.c (handle_extended_wait, linux_create_inferior)
>>          (linux_attach_lwp_1, linux_kill_one_lwp, linux_attach_one_lwp)
>>          (dequeue_one_deferred_signal, linux_resume_one_thread)
>>          (fetch_register, linux_write_memory, linux_enable_event_reporting)
>>          (linux_tracefork_grandchild, linux_test_for_tracefork)
>>          (linux_read_offsets, linux_xfer_siginfo, linux_xfer_siginfo ): Add
>
> Spurious space ------------------------------------------------------^

Ooops... I'll fix it up when I commit.

Sorry
/Marcus

>
>>          PTRACE_ARG3_TYPE and PTRACE_ARG4_TYPE cast to ptrace arguments
>>          where the argument is 0.
>
> This is OK.
>
> Thanks!
>



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

* Re: [PATCH] gdbserver ptrace() argument type cleanups.
  2013-02-04 17:31 [PATCH] gdbserver ptrace() argument type cleanups Marcus Shawcroft
  2013-02-04 17:35 ` Pedro Alves
@ 2013-02-04 18:57 ` Mark Kettenis
  2013-02-04 19:01   ` Tom Tromey
  2013-02-04 19:04   ` Marcus Shawcroft
  1 sibling, 2 replies; 8+ messages in thread
From: Mark Kettenis @ 2013-02-04 18:57 UTC (permalink / raw)
  To: marcus.shawcroft; +Cc: gdb-patches, palves

> Date: Mon, 04 Feb 2013 17:30:48 +0000
> From: Marcus Shawcroft <marcus.shawcroft@arm.com>
> 
> Hi,
> 
> This patch is ripped out of the aarch64 gdbserver patch here:
> 
> http://sourceware.org/ml/gdb-patches/2013-01/msg00535.html
> 
> These changes are not directly related to the aarch64 port itself.
> Since ptrace() has a variadic prototype, the anonymous arguments,
> notably arguments 3 and 4, should be given their correct types.
> 
> /Marcus
> 
> Proposed ChangeLog:
> 
>     gdb/gdbserver/
> 
>          * linux-low.c (handle_extended_wait, linux_create_inferior)
>          (linux_attach_lwp_1, linux_kill_one_lwp, linux_attach_one_lwp)
>          (dequeue_one_deferred_signal, linux_resume_one_thread)
>          (fetch_register, linux_write_memory, linux_enable_event_reporting)
>          (linux_tracefork_grandchild, linux_test_for_tracefork)
>          (linux_read_offsets, linux_xfer_siginfo, linux_xfer_siginfo ): Add
>          PTRACE_ARG3_TYPE and PTRACE_ARG4_TYPE cast to ptrace arguments
>          where the argument is 0.

> diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
> index 8988509..c52cd2e 100644
> --- a/gdb/gdbserver/linux-low.c
> +++ b/gdb/gdbserver/linux-low.c
> @@ -445,7 +445,8 @@ handle_extended_wait (struct lwp_info *event_child, int=
>  wstat)
>        unsigned long new_pid;
>        int ret, status;
> =20
> -      ptrace (PTRACE_GETEVENTMSG, lwpid_of (event_child), 0, &new_pid);
> +      ptrace (PTRACE_GETEVENTMSG, lwpid_of (event_child), (PTRACE_ARG3_TYPE) 0,
> +	      &new_pid);

I'd use the word "obfuscation" instead of "cleanup".


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

* Re: [PATCH] gdbserver ptrace() argument type cleanups.
  2013-02-04 18:57 ` Mark Kettenis
@ 2013-02-04 19:01   ` Tom Tromey
  2013-02-04 19:25     ` Pedro Alves
  2013-02-04 22:09     ` Mark Kettenis
  2013-02-04 19:04   ` Marcus Shawcroft
  1 sibling, 2 replies; 8+ messages in thread
From: Tom Tromey @ 2013-02-04 19:01 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: marcus.shawcroft, gdb-patches, palves

>>>>> "Mark" == Mark Kettenis <mark.kettenis@xs4all.nl> writes:

Mark> I'd use the word "obfuscation" instead of "cleanup".

It is awful but necessary.
I think calls in gdb proper probably need this as well.


I did try writing a patch to fix it a different way, without as many
casts:

+static inline PTRACE_TYPE_RET
+gdb_ptrace (int request, pid_t pid, PTRACE_TYPE_ARG3 addr, void *data)
+{
+  return ptrace (request, pid, addr, data);
+}
+
+#undef ptrace
+#define ptrace ERROR


... followed by using gdb_ptrace everywhere.

However you do still need casts at some call points.
It's quite awful.

I can send this if anyone thinks it is better.

Tom


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

* Re: [PATCH] gdbserver ptrace() argument type cleanups.
  2013-02-04 18:57 ` Mark Kettenis
  2013-02-04 19:01   ` Tom Tromey
@ 2013-02-04 19:04   ` Marcus Shawcroft
  1 sibling, 0 replies; 8+ messages in thread
From: Marcus Shawcroft @ 2013-02-04 19:04 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches, palves

On 04/02/13 18:57, Mark Kettenis wrote:
>> Date: Mon, 04 Feb 2013 17:30:48 +0000
>> From: Marcus Shawcroft <marcus.shawcroft@arm.com>
>
>> -      ptrace (PTRACE_GETEVENTMSG, lwpid_of (event_child), 0, &new_pid);
>> +      ptrace (PTRACE_GETEVENTMSG, lwpid_of (event_child), (PTRACE_ARG3_TYPE) 0,
>> +	      &new_pid);
>
> I'd use the word "obfuscation" instead of "cleanup".
>

This change is ugly, agreed.  I'm open to better suggestions.

/Marcus



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

* Re: [PATCH] gdbserver ptrace() argument type cleanups.
  2013-02-04 19:01   ` Tom Tromey
@ 2013-02-04 19:25     ` Pedro Alves
  2013-02-04 22:09     ` Mark Kettenis
  1 sibling, 0 replies; 8+ messages in thread
From: Pedro Alves @ 2013-02-04 19:25 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Mark Kettenis, marcus.shawcroft, gdb-patches

On 02/04/2013 07:01 PM, Tom Tromey wrote:
>>>>>> "Mark" == Mark Kettenis <mark.kettenis@xs4all.nl> writes:
> 
> Mark> I'd use the word "obfuscation" instead of "cleanup".
> 
> It is awful but necessary.
> I think calls in gdb proper probably need this as well.
> 
> 
> I did try writing a patch to fix it a different way, without as many
> casts:
> 
> +static inline PTRACE_TYPE_RET
> +gdb_ptrace (int request, pid_t pid, PTRACE_TYPE_ARG3 addr, void *data)
> +{
> +  return ptrace (request, pid, addr, data);
> +}
> +
> +#undef ptrace
> +#define ptrace ERROR
> 
> 
> ... followed by using gdb_ptrace everywhere.
> 
> However you do still need casts at some call points.
> It's quite awful.
> 
> I can send this if anyone thinks it is better.

Yeah, the same occurred to me.  I didn't try it, but I guessed
you'd need casts anyway, given some ptrace calls take
pointers as extra arguments, while others take integers.
In the end, I just tucked in under the "oh well, it's not that
important" rug.  :-)  However, Marcus' patch is only following
the status quo (*), so I didn't bring that up.  Without seeing the
result it's hard to say which is better.

(*) - http://sourceware.org/ml/gdb-patches/2012-03/msg01072.html

-- 
Pedro Alves


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

* Re: [PATCH] gdbserver ptrace() argument type cleanups.
  2013-02-04 19:01   ` Tom Tromey
  2013-02-04 19:25     ` Pedro Alves
@ 2013-02-04 22:09     ` Mark Kettenis
  1 sibling, 0 replies; 8+ messages in thread
From: Mark Kettenis @ 2013-02-04 22:09 UTC (permalink / raw)
  To: tromey; +Cc: marcus.shawcroft, gdb-patches, palves

> From: Tom Tromey <tromey@redhat.com>
> Date: Mon, 04 Feb 2013 12:01:30 -0700
> 
> >>>>> "Mark" == Mark Kettenis <mark.kettenis@xs4all.nl> writes:
> 
> Mark> I'd use the word "obfuscation" instead of "cleanup".
> 
> It is awful but necessary.

Yeah I know.  Somebody should lock up the developers of the viarious
Linux libc's in a room and don't let them out until they come up with
prototype for ptrace that they all agree on.


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

end of thread, other threads:[~2013-02-04 22:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-04 17:31 [PATCH] gdbserver ptrace() argument type cleanups Marcus Shawcroft
2013-02-04 17:35 ` Pedro Alves
2013-02-04 17:41   ` Marcus Shawcroft
2013-02-04 18:57 ` Mark Kettenis
2013-02-04 19:01   ` Tom Tromey
2013-02-04 19:25     ` Pedro Alves
2013-02-04 22:09     ` Mark Kettenis
2013-02-04 19:04   ` Marcus Shawcroft

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox