public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 5/5] make calls to ptrace64 in aix-thread.c when defined
@ 2013-08-01 11:30 Raunaq 12
  2013-08-01 13:28 ` Mark Kettenis
  0 siblings, 1 reply; 13+ messages in thread
From: Raunaq 12 @ 2013-08-01 11:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: tromey, Mark Kettenis


Calls to ptrace and ptracex do not work when we compile 64 BIT GDB on AIX.
So, we check if ptrace64 is defined, if so, then we use ptrace64 in place
of
ptrace and ptracex.

Note:- the 3rd argument to ptrace is of type int * whereas for ptrace64 it
is of type long long. So, we add a macro called addr_ptr to take care of
this.
---
ChangeLog :-
* aixthread.c: call ptrace64 instead of ptracex if defined
 Call ptrace64 instead of ptrace if defined
 Add macro addr_ptr to take care of ptrace address arguement
(pdc_read_regs): Likewise
(pdc_write_regs): Likewise
(aix_thread_resume): Likewise
(fetch_regs_kernel_thread): Likewise
(store_regs_kernel_thread): Likewise
---
Index: ./gdb/aix-thread.c
===================================================================
--- ./gdb.orig/aix-thread.c
+++ .gdb/aix-thread.c
@@ -237,7 +237,14 @@
   return 0;  /* Not reached.  */
 }

-/* Call ptracex (REQ, ID, ADDR, DATA, BUF).  Return success.  */
+/* Call ptracex (REQ, ID, ADDR, DATA, BUF) or
+   ptrace64 (REQ, ID, ADDR, DATA, BUF) if HAVE_PTRACE64.
+   Return success.  */
+
+#ifdef HAVE_PTRACE64
+# define ptracex(request, pid, addr, data, buf) \
+	 ptrace64 (request, pid, addr, data, buf)
+#endif

 static int
 ptrace64aix (int req, int id, long long addr, int data, int *buf)
@@ -246,14 +253,24 @@
   return ptrace_check (req, id, ptracex (req, id, addr, data, buf));
 }

-/* Call ptrace (REQ, ID, ADDR, DATA, BUF).  Return success.  */
+/* Call ptrace (REQ, ID, ADDR, DATA, BUF) or
+   ptrace64 (REQ, ID, ADDR, DATA, BUF) if HAVE_PTRACE64.
+   Return success.  */
+
+#ifdef HAVE_PTRACE64
+# define ptrace(request, pid, addr, data, buf) \
+	 ptrace64 (request, pid, addr, data, buf)
+# define addr_ptr long long
+#else
+# define addr_ptr int *
+#endif

 static int
-ptrace32 (int req, int id, int *addr, int data, int *buf)
+ptrace32 (int req, int id, addr_ptr addr, int data, int *buf)
 {
   errno = 0;
   return ptrace_check (req, id,
-		       ptrace (req, id, (int *) addr, data, buf));
+		       ptrace (req, id, (addr_ptr) addr, data, buf));
 }

 /* If *PIDP is a composite process/thread id, convert it to a
@@ -361,7 +378,7 @@
   /* Floating-point registers.  */
   if (flags & PTHDB_FLAG_FPRS)
     {
-      if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
+      if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL))
 	memset (fprs, 0, sizeof (fprs));
       memcpy (context->fpr, fprs, sizeof(fprs));
     }
@@ -378,7 +395,7 @@
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL))
 	    memset (&sprs32, 0, sizeof (sprs32));
       	  memcpy (&context->msr, &sprs32, sizeof(sprs32));
 	}
@@ -413,13 +430,13 @@
 	ptrace64aix (PTT_WRITE_GPRS, tid,
 		     (unsigned long) context->gpr, 0, NULL);
       else
-	ptrace32 (PTT_WRITE_GPRS, tid, (int *) context->gpr, 0, NULL);
+	ptrace32 (PTT_WRITE_GPRS, tid, (addr_ptr) context->gpr, 0, NULL);
     }

  /* Floating-point registers.  */
   if (flags & PTHDB_FLAG_FPRS)
     {
-      ptrace32 (PTT_WRITE_FPRS, tid, (int *) context->fpr, 0, NULL);
+      ptrace32 (PTT_WRITE_FPRS, tid, (addr_ptr) context->fpr, 0, NULL);
     }

   /* Special-purpose registers.  */
@@ -432,7 +449,7 @@
 	}
       else
 	{
-	  ptrace32 (PTT_WRITE_SPRS, tid, (void *) &context->msr, 0, NULL);
+	  ptrace32 (PTT_WRITE_SPRS, tid, (addr_ptr) &context->msr, 0, NULL);
 	}
     }
   return 0;
@@ -997,10 +1014,10 @@
       tid[1] = 0;

       if (arch64)
-	ptrace64aix (PTT_CONTINUE, tid[0], 1,
+	ptrace64aix (PTT_CONTINUE, tid[0], (long long) 1,
 		     gdb_signal_to_host (sig), (void *) tid);
       else
-	ptrace32 (PTT_CONTINUE, tid[0], (int *) 1,
+	ptrace32 (PTT_CONTINUE, tid[0], (addr_ptr) 1,
 		  gdb_signal_to_host (sig), (void *) tid);
     }
 }
@@ -1239,7 +1256,7 @@
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_GPRS, tid, (addr_ptr) gprs32, 0, NULL))
 	    memset (gprs32, 0, sizeof (gprs32));
 	  for (i = 0; i < ppc_num_gprs; i++)
 	    supply_reg32 (regcache, tdep->ppc_gp0_regnum + i, gprs32[i]);
@@ -1253,7 +1270,7 @@
           || (regno >= tdep->ppc_fp0_regnum
               && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
     {
-      if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
+      if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL))
 	memset (fprs, 0, sizeof (fprs));
       supply_fprs (regcache, fprs);
     }
@@ -1275,7 +1292,7 @@
 	{
 	  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

-	  if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL))
 	    memset (&sprs32, 0, sizeof (sprs32));
 	  supply_sprs32 (regcache, sprs32.pt_iar, sprs32.pt_msr,
sprs32.pt_cr,
 			 sprs32.pt_lr, sprs32.pt_ctr, sprs32.pt_xer,
@@ -1570,9 +1587,9 @@
       else
 	{
 	  /* Pre-fetch: some regs may not be in the cache.  */
-	  ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL);
+	  ptrace32 (PTT_READ_GPRS, tid, (addr_ptr) gprs32, 0, NULL);
 	  fill_gprs32 (regcache, gprs32);
-	  ptrace32 (PTT_WRITE_GPRS, tid, gprs32, 0, NULL);
+	  ptrace32 (PTT_WRITE_GPRS, tid, (addr_ptr) gprs32, 0, NULL);
 	}
     }

@@ -1584,9 +1601,9 @@
               && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
     {
       /* Pre-fetch: some regs may not be in the cache.  */
-      ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL);
+      ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL);
       fill_fprs (regcache, fprs);
-      ptrace32 (PTT_WRITE_FPRS, tid, (void *) fprs, 0, NULL);
+      ptrace32 (PTT_WRITE_FPRS, tid, (addr_ptr) fprs, 0, NULL);
     }

   /* Special-purpose registers.  */
@@ -1618,7 +1635,7 @@
 	  gdb_assert (sizeof (sprs32.pt_iar) == 4);

 	  /* Pre-fetch: some registers won't be in the cache.  */
-	  ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL);
+	  ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL);

 	  fill_sprs32 (regcache, &tmp_iar, &tmp_msr, &tmp_cr, &tmp_lr,
 		       &tmp_ctr, &tmp_xer, &tmp_fpscr);
@@ -1637,7 +1654,7 @@
 	      regcache_raw_collect (regcache, tdep->ppc_mq_regnum,
 				    &sprs32.pt_mq);

-	  ptrace32 (PTT_WRITE_SPRS, tid, (int *) &sprs32, 0, NULL);
+	  ptrace32 (PTT_WRITE_SPRS, tid, (addr_ptr) &sprs32, 0, NULL);
 	}
     }
 }

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

* Re: [PATCH 5/5] make calls to ptrace64 in aix-thread.c when defined
  2013-08-01 11:30 [PATCH 5/5] make calls to ptrace64 in aix-thread.c when defined Raunaq 12
@ 2013-08-01 13:28 ` Mark Kettenis
  2013-08-07 11:29   ` Raunaq 12
  0 siblings, 1 reply; 13+ messages in thread
From: Mark Kettenis @ 2013-08-01 13:28 UTC (permalink / raw)
  To: raunaq12; +Cc: gdb-patches, tromey

From: Raunaq 12 <raunaq12@in.ibm.com>
Date: Thu, 1 Aug 2013 16:58:43 +0530

Calls to ptrace and ptracex do not work when we compile 64 BIT GDB on AIX.
So, we check if ptrace64 is defined, if so, then we use ptrace64 in place
of
ptrace and ptracex.

Note:- the 3rd argument to ptrace is of type int * whereas for ptrace64 it
is of type long long. So, we add a macro called addr_ptr to take care of
this.
---
ChangeLog :-
* aixthread.c: call ptrace64 instead of ptracex if defined
 Call ptrace64 instead of ptrace if defined
 Add macro addr_ptr to take care of ptrace address arguement
(pdc_read_regs): Likewise
(pdc_write_regs): Likewise
(aix_thread_resume): Likewise
(fetch_regs_kernel_thread): Likewise
(store_regs_kernel_thread): Likewise

Again, you're being sloppy here.  Sentences start with a capital
letter and end in a full stop.

---
Index: ./gdb/aix-thread.c
===================================================================
--- ./gdb.orig/aix-thread.c
+++ .gdb/aix-thread.c
@@ -237,7 +237,14 @@
   return 0;  /* Not reached.  */
 }

-/* Call ptracex (REQ, ID, ADDR, DATA, BUF).  Return success.  */
+/* Call ptracex (REQ, ID, ADDR, DATA, BUF) or
+   ptrace64 (REQ, ID, ADDR, DATA, BUF) if HAVE_PTRACE64.
+   Return success.  */
+
+#ifdef HAVE_PTRACE64
+# define ptracex(request, pid, addr, data, buf) \
+	 ptrace64 (request, pid, addr, data, buf)
+#endif

 static int
 ptrace64aix (int req, int id, long long addr, int data, int *buf)
@@ -246,14 +253,24 @@
   return ptrace_check (req, id, ptracex (req, id, addr, data, buf));
 }

-/* Call ptrace (REQ, ID, ADDR, DATA, BUF).  Return success.  */
+/* Call ptrace (REQ, ID, ADDR, DATA, BUF) or
+   ptrace64 (REQ, ID, ADDR, DATA, BUF) if HAVE_PTRACE64.
+   Return success.  */
+
+#ifdef HAVE_PTRACE64
+# define ptrace(request, pid, addr, data, buf) \
+	 ptrace64 (request, pid, addr, data, buf)
+# define addr_ptr long long
+#else
+# define addr_ptr int *
+#endif

 static int
-ptrace32 (int req, int id, int *addr, int data, int *buf)
+ptrace32 (int req, int id, addr_ptr addr, int data, int *buf)
 {
   errno = 0;
   return ptrace_check (req, id,
-		       ptrace (req, id, (int *) addr, data, buf));
+		       ptrace (req, id, (addr_ptr) addr, data, buf));
 }

 /* If *PIDP is a composite process/thread id, convert it to a
@@ -361,7 +378,7 @@
   /* Floating-point registers.  */
   if (flags & PTHDB_FLAG_FPRS)
     {
-      if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
+      if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL))
 	memset (fprs, 0, sizeof (fprs));
       memcpy (context->fpr, fprs, sizeof(fprs));
     }
@@ -378,7 +395,7 @@
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL))
 	    memset (&sprs32, 0, sizeof (sprs32));
       	  memcpy (&context->msr, &sprs32, sizeof(sprs32));
 	}
@@ -413,13 +430,13 @@
 	ptrace64aix (PTT_WRITE_GPRS, tid,
 		     (unsigned long) context->gpr, 0, NULL);
       else
-	ptrace32 (PTT_WRITE_GPRS, tid, (int *) context->gpr, 0, NULL);
+	ptrace32 (PTT_WRITE_GPRS, tid, (addr_ptr) context->gpr, 0, NULL);
     }

  /* Floating-point registers.  */
   if (flags & PTHDB_FLAG_FPRS)
     {
-      ptrace32 (PTT_WRITE_FPRS, tid, (int *) context->fpr, 0, NULL);
+      ptrace32 (PTT_WRITE_FPRS, tid, (addr_ptr) context->fpr, 0, NULL);
     }

   /* Special-purpose registers.  */
@@ -432,7 +449,7 @@
 	}
       else
 	{
-	  ptrace32 (PTT_WRITE_SPRS, tid, (void *) &context->msr, 0, NULL);
+	  ptrace32 (PTT_WRITE_SPRS, tid, (addr_ptr) &context->msr, 0, NULL);
 	}
     }
   return 0;
@@ -997,10 +1014,10 @@
       tid[1] = 0;

       if (arch64)
-	ptrace64aix (PTT_CONTINUE, tid[0], 1,
+	ptrace64aix (PTT_CONTINUE, tid[0], (long long) 1,
 		     gdb_signal_to_host (sig), (void *) tid);
       else
-	ptrace32 (PTT_CONTINUE, tid[0], (int *) 1,
+	ptrace32 (PTT_CONTINUE, tid[0], (addr_ptr) 1,
 		  gdb_signal_to_host (sig), (void *) tid);
     }
 }
@@ -1239,7 +1256,7 @@
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_GPRS, tid, (addr_ptr) gprs32, 0, NULL))
 	    memset (gprs32, 0, sizeof (gprs32));
 	  for (i = 0; i < ppc_num_gprs; i++)
 	    supply_reg32 (regcache, tdep->ppc_gp0_regnum + i, gprs32[i]);
@@ -1253,7 +1270,7 @@
           || (regno >= tdep->ppc_fp0_regnum
               && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
     {
-      if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
+      if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL))
 	memset (fprs, 0, sizeof (fprs));
       supply_fprs (regcache, fprs);
     }
@@ -1275,7 +1292,7 @@
 	{
 	  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

-	  if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL))
 	    memset (&sprs32, 0, sizeof (sprs32));
 	  supply_sprs32 (regcache, sprs32.pt_iar, sprs32.pt_msr,
sprs32.pt_cr,
 			 sprs32.pt_lr, sprs32.pt_ctr, sprs32.pt_xer,
@@ -1570,9 +1587,9 @@
       else
 	{
 	  /* Pre-fetch: some regs may not be in the cache.  */
-	  ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL);
+	  ptrace32 (PTT_READ_GPRS, tid, (addr_ptr) gprs32, 0, NULL);
 	  fill_gprs32 (regcache, gprs32);
-	  ptrace32 (PTT_WRITE_GPRS, tid, gprs32, 0, NULL);
+	  ptrace32 (PTT_WRITE_GPRS, tid, (addr_ptr) gprs32, 0, NULL);
 	}
     }

@@ -1584,9 +1601,9 @@
               && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
     {
       /* Pre-fetch: some regs may not be in the cache.  */
-      ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL);
+      ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL);
       fill_fprs (regcache, fprs);
-      ptrace32 (PTT_WRITE_FPRS, tid, (void *) fprs, 0, NULL);
+      ptrace32 (PTT_WRITE_FPRS, tid, (addr_ptr) fprs, 0, NULL);
     }

   /* Special-purpose registers.  */
@@ -1618,7 +1635,7 @@
 	  gdb_assert (sizeof (sprs32.pt_iar) == 4);

 	  /* Pre-fetch: some registers won't be in the cache.  */
-	  ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL);
+	  ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL);

 	  fill_sprs32 (regcache, &tmp_iar, &tmp_msr, &tmp_cr, &tmp_lr,
 		       &tmp_ctr, &tmp_xer, &tmp_fpscr);
@@ -1637,7 +1654,7 @@
 	      regcache_raw_collect (regcache, tdep->ppc_mq_regnum,
 				    &sprs32.pt_mq);

-	  ptrace32 (PTT_WRITE_SPRS, tid, (int *) &sprs32, 0, NULL);
+	  ptrace32 (PTT_WRITE_SPRS, tid, (addr_ptr) &sprs32, 0, NULL);
 	}
     }
 }


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

* Re: [PATCH 5/5] make calls to ptrace64 in aix-thread.c when defined
  2013-08-01 13:28 ` Mark Kettenis
@ 2013-08-07 11:29   ` Raunaq 12
  2013-08-07 11:38     ` Mark Kettenis
  0 siblings, 1 reply; 13+ messages in thread
From: Raunaq 12 @ 2013-08-07 11:29 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches, tromey



> ChangeLog :-
> * aixthread.c: call ptrace64 instead of ptracex if defined
>  Call ptrace64 instead of ptrace if defined
>  Add macro addr_ptr to take care of ptrace address arguement
> (pdc_read_regs): Likewise
> (pdc_write_regs): Likewise
> (aix_thread_resume): Likewise
> (fetch_regs_kernel_thread): Likewise
> (store_regs_kernel_thread): Likewise
>
Mark> Again, you're being sloppy here.  Sentences start with a capital
	letter and end in a full stop.

Hi,

Apologize for the overlooking punctuation errors. Fixing it here.
Also re-submitting the patch here for review. Is it okay to Commit?
---
ChangeLog :-
 	* aixthread.c: Call ptrace64 instead of ptracex if defined.
  	Call ptrace64 instead of ptrace if defined.
  	Add macro addr_ptr to take care of ptrace address arguement.
 	(pdc_read_regs): Likewise.
 	(pdc_write_regs): Likewise.
 	(aix_thread_resume): Likewise.
 	(fetch_regs_kernel_thread): Likewise.
 	(store_regs_kernel_thread): Likewise.


 ---
 Index: ./gdb/aix-thread.c
 ===================================================================
 --- ./gdb.orig/aix-thread.c
 +++ .gdb/aix-thread.c
 @@ -237,7 +237,14 @@
    return 0;  /* Not reached.  */
  }

 -/* Call ptracex (REQ, ID, ADDR, DATA, BUF).  Return success.  */
 +/* Call ptracex (REQ, ID, ADDR, DATA, BUF) or
 +   ptrace64 (REQ, ID, ADDR, DATA, BUF) if HAVE_PTRACE64.
 +   Return success.  */
 +
 +#ifdef HAVE_PTRACE64
 +# define ptracex(request, pid, addr, data, buf) \
 +    ptrace64 (request, pid, addr, data, buf)
 +#endif

  static int
  ptrace64aix (int req, int id, long long addr, int data, int *buf)
 @@ -246,14 +253,24 @@
    return ptrace_check (req, id, ptracex (req, id, addr, data, buf));
  }

 -/* Call ptrace (REQ, ID, ADDR, DATA, BUF).  Return success.  */
 +/* Call ptrace (REQ, ID, ADDR, DATA, BUF) or
 +   ptrace64 (REQ, ID, ADDR, DATA, BUF) if HAVE_PTRACE64.
 +   Return success.  */
 +
 +#ifdef HAVE_PTRACE64
 +# define ptrace(request, pid, addr, data, buf) \
 +    ptrace64 (request, pid, addr, data, buf)
 +# define addr_ptr long long
 +#else
 +# define addr_ptr int *
 +#endif

  static int
 -ptrace32 (int req, int id, int *addr, int data, int *buf)
 +ptrace32 (int req, int id, addr_ptr addr, int data, int *buf)
  {
    errno = 0;
    return ptrace_check (req, id,
 -             ptrace (req, id, (int *) addr, data, buf));
 +             ptrace (req, id, (addr_ptr) addr, data, buf));
  }

  /* If *PIDP is a composite process/thread id, convert it to a
 @@ -361,7 +378,7 @@
    /* Floating-point registers.  */
    if (flags & PTHDB_FLAG_FPRS)
      {
 -      if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
 +      if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL))
     memset (fprs, 0, sizeof (fprs));
        memcpy (context->fpr, fprs, sizeof(fprs));
      }
 @@ -378,7 +395,7 @@
     }
        else
     {
 -     if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
 +     if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL))
         memset (&sprs32, 0, sizeof (sprs32));
             memcpy (&context->msr, &sprs32, sizeof(sprs32));
     }
 @@ -413,13 +430,13 @@
     ptrace64aix (PTT_WRITE_GPRS, tid,
             (unsigned long) context->gpr, 0, NULL);
        else
 -   ptrace32 (PTT_WRITE_GPRS, tid, (int *) context->gpr, 0, NULL);
 +   ptrace32 (PTT_WRITE_GPRS, tid, (addr_ptr) context->gpr, 0, NULL);
      }

>   /* Floating-point registers.  */
>    if (flags & PTHDB_FLAG_FPRS)
>      {
> -      ptrace32 (PTT_WRITE_FPRS, tid, (int *) context->fpr, 0, NULL);
> +      ptrace32 (PTT_WRITE_FPRS, tid, (addr_ptr) context->fpr, 0, NULL);
>      }
>
>    /* Special-purpose registers.  */
> @@ -432,7 +449,7 @@
>     }
>        else
>     {
> -     ptrace32 (PTT_WRITE_SPRS, tid, (void *) &context->msr, 0, NULL);
> +     ptrace32 (PTT_WRITE_SPRS, tid, (addr_ptr) &context->msr, 0, NULL);
>     }
>      }
>    return 0;
> @@ -997,10 +1014,10 @@
>        tid[1] = 0;
>
>        if (arch64)
> -   ptrace64aix (PTT_CONTINUE, tid[0], 1,
> +   ptrace64aix (PTT_CONTINUE, tid[0], (long long) 1,
>             gdb_signal_to_host (sig), (void *) tid);
>        else
> -   ptrace32 (PTT_CONTINUE, tid[0], (int *) 1,
> +   ptrace32 (PTT_CONTINUE, tid[0], (addr_ptr) 1,
>          gdb_signal_to_host (sig), (void *) tid);
>      }
>  }
> @@ -1239,7 +1256,7 @@
>     }
>        else
>     {
> -     if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
> +     if (!ptrace32 (PTT_READ_GPRS, tid, (addr_ptr) gprs32, 0, NULL))
>         memset (gprs32, 0, sizeof (gprs32));
>       for (i = 0; i < ppc_num_gprs; i++)
>         supply_reg32 (regcache, tdep->ppc_gp0_regnum + i, gprs32[i]);
> @@ -1253,7 +1270,7 @@
>            || (regno >= tdep->ppc_fp0_regnum
>                && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
>      {
 -      if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
 +      if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL))
     memset (fprs, 0, sizeof (fprs));
        supply_fprs (regcache, fprs);
      }
 @@ -1275,7 +1292,7 @@
     {
       struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

 -     if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
 +     if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL))
         memset (&sprs32, 0, sizeof (sprs32));
       supply_sprs32 (regcache, sprs32.pt_iar, sprs32.pt_msr,
 sprs32.pt_cr,
            sprs32.pt_lr, sprs32.pt_ctr, sprs32.pt_xer,
 @@ -1570,9 +1587,9 @@
        else
     {
       /* Pre-fetch: some regs may not be in the cache.  */
 -     ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL);
 +     ptrace32 (PTT_READ_GPRS, tid, (addr_ptr) gprs32, 0, NULL);
       fill_gprs32 (regcache, gprs32);
 -     ptrace32 (PTT_WRITE_GPRS, tid, gprs32, 0, NULL);
 +     ptrace32 (PTT_WRITE_GPRS, tid, (addr_ptr) gprs32, 0, NULL);
     }
      }

 @@ -1584,9 +1601,9 @@
                && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
      {
        /* Pre-fetch: some regs may not be in the cache.  */
 -      ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL);
 +      ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL);
        fill_fprs (regcache, fprs);
 -      ptrace32 (PTT_WRITE_FPRS, tid, (void *) fprs, 0, NULL);
 +      ptrace32 (PTT_WRITE_FPRS, tid, (addr_ptr) fprs, 0, NULL);
      }

    /* Special-purpose registers.  */
 @@ -1618,7 +1635,7 @@
       gdb_assert (sizeof (sprs32.pt_iar) == 4);

       /* Pre-fetch: some registers won't be in the cache.  */
 -     ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL);
 +     ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL);

       fill_sprs32 (regcache, &tmp_iar, &tmp_msr, &tmp_cr, &tmp_lr,
               &tmp_ctr, &tmp_xer, &tmp_fpscr);
 @@ -1637,7 +1654,7 @@
           regcache_raw_collect (regcache, tdep->ppc_mq_regnum,
                  &sprs32.pt_mq);

 -     ptrace32 (PTT_WRITE_SPRS, tid, (int *) &sprs32, 0, NULL);
 +     ptrace32 (PTT_WRITE_SPRS, tid, (addr_ptr) &sprs32, 0, NULL);
     }
      }
  }
---


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

* Re: [PATCH 5/5] make calls to ptrace64 in aix-thread.c when defined
  2013-08-07 11:29   ` Raunaq 12
@ 2013-08-07 11:38     ` Mark Kettenis
  2013-08-07 11:45       ` Raunaq 12
  0 siblings, 1 reply; 13+ messages in thread
From: Mark Kettenis @ 2013-08-07 11:38 UTC (permalink / raw)
  To: raunaq12; +Cc: gdb-patches, tromey

> From: Raunaq 12 <raunaq12@in.ibm.com>
> Date: Wed, 7 Aug 2013 16:57:50 +0530
> 
> > ChangeLog :-
> > * aixthread.c: call ptrace64 instead of ptracex if defined
> >  Call ptrace64 instead of ptrace if defined
> >  Add macro addr_ptr to take care of ptrace address arguement
> > (pdc_read_regs): Likewise
> > (pdc_write_regs): Likewise
> > (aix_thread_resume): Likewise
> > (fetch_regs_kernel_thread): Likewise
> > (store_regs_kernel_thread): Likewise
> >
> Mark> Again, you're being sloppy here.  Sentences start with a capital
> 	letter and end in a full stop.
> 
> Hi,
> 
> Apologize for the overlooking punctuation errors. Fixing it here.
> Also re-submitting the patch here for review. Is it okay to Commit?

Yes, fine with me.  Do you have a copyright assignment in place?  Or
is this covered by a company-wide assignment that IBM has in place?


> ---
> ChangeLog :-
>  	* aixthread.c: Call ptrace64 instead of ptracex if defined.
>   	Call ptrace64 instead of ptrace if defined.
>   	Add macro addr_ptr to take care of ptrace address arguement.
>  	(pdc_read_regs): Likewise.
>  	(pdc_write_regs): Likewise.
>  	(aix_thread_resume): Likewise.
>  	(fetch_regs_kernel_thread): Likewise.
>  	(store_regs_kernel_thread): Likewise.
> 
> 
>  ---
>  Index: ./gdb/aix-thread.c
>  ===================================================================
>  --- ./gdb.orig/aix-thread.c
>  +++ .gdb/aix-thread.c
>  @@ -237,7 +237,14 @@
>     return 0;  /* Not reached.  */
>   }
> 
>  -/* Call ptracex (REQ, ID, ADDR, DATA, BUF).  Return success.  */
>  +/* Call ptracex (REQ, ID, ADDR, DATA, BUF) or
>  +   ptrace64 (REQ, ID, ADDR, DATA, BUF) if HAVE_PTRACE64.
>  +   Return success.  */
>  +
>  +#ifdef HAVE_PTRACE64
>  +# define ptracex(request, pid, addr, data, buf) \
>  +    ptrace64 (request, pid, addr, data, buf)
>  +#endif
> 
>   static int
>   ptrace64aix (int req, int id, long long addr, int data, int *buf)
>  @@ -246,14 +253,24 @@
>     return ptrace_check (req, id, ptracex (req, id, addr, data, buf));
>   }
> 
>  -/* Call ptrace (REQ, ID, ADDR, DATA, BUF).  Return success.  */
>  +/* Call ptrace (REQ, ID, ADDR, DATA, BUF) or
>  +   ptrace64 (REQ, ID, ADDR, DATA, BUF) if HAVE_PTRACE64.
>  +   Return success.  */
>  +
>  +#ifdef HAVE_PTRACE64
>  +# define ptrace(request, pid, addr, data, buf) \
>  +    ptrace64 (request, pid, addr, data, buf)
>  +# define addr_ptr long long
>  +#else
>  +# define addr_ptr int *
>  +#endif
> 
>   static int
>  -ptrace32 (int req, int id, int *addr, int data, int *buf)
>  +ptrace32 (int req, int id, addr_ptr addr, int data, int *buf)
>   {
>     errno = 0;
>     return ptrace_check (req, id,
>  -             ptrace (req, id, (int *) addr, data, buf));
>  +             ptrace (req, id, (addr_ptr) addr, data, buf));
>   }
> 
>   /* If *PIDP is a composite process/thread id, convert it to a
>  @@ -361,7 +378,7 @@
>     /* Floating-point registers.  */
>     if (flags & PTHDB_FLAG_FPRS)
>       {
>  -      if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
>  +      if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL))
>      memset (fprs, 0, sizeof (fprs));
>         memcpy (context->fpr, fprs, sizeof(fprs));
>       }
>  @@ -378,7 +395,7 @@
>      }
>         else
>      {
>  -     if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
>  +     if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL))
>          memset (&sprs32, 0, sizeof (sprs32));
>              memcpy (&context->msr, &sprs32, sizeof(sprs32));
>      }
>  @@ -413,13 +430,13 @@
>      ptrace64aix (PTT_WRITE_GPRS, tid,
>              (unsigned long) context->gpr, 0, NULL);
>         else
>  -   ptrace32 (PTT_WRITE_GPRS, tid, (int *) context->gpr, 0, NULL);
>  +   ptrace32 (PTT_WRITE_GPRS, tid, (addr_ptr) context->gpr, 0, NULL);
>       }
> 
> >   /* Floating-point registers.  */
> >    if (flags & PTHDB_FLAG_FPRS)
> >      {
> > -      ptrace32 (PTT_WRITE_FPRS, tid, (int *) context->fpr, 0, NULL);
> > +      ptrace32 (PTT_WRITE_FPRS, tid, (addr_ptr) context->fpr, 0, NULL);
> >      }
> >
> >    /* Special-purpose registers.  */
> > @@ -432,7 +449,7 @@
> >     }
> >        else
> >     {
> > -     ptrace32 (PTT_WRITE_SPRS, tid, (void *) &context->msr, 0, NULL);
> > +     ptrace32 (PTT_WRITE_SPRS, tid, (addr_ptr) &context->msr, 0, NULL);
> >     }
> >      }
> >    return 0;
> > @@ -997,10 +1014,10 @@
> >        tid[1] = 0;
> >
> >        if (arch64)
> > -   ptrace64aix (PTT_CONTINUE, tid[0], 1,
> > +   ptrace64aix (PTT_CONTINUE, tid[0], (long long) 1,
> >             gdb_signal_to_host (sig), (void *) tid);
> >        else
> > -   ptrace32 (PTT_CONTINUE, tid[0], (int *) 1,
> > +   ptrace32 (PTT_CONTINUE, tid[0], (addr_ptr) 1,
> >          gdb_signal_to_host (sig), (void *) tid);
> >      }
> >  }
> > @@ -1239,7 +1256,7 @@
> >     }
> >        else
> >     {
> > -     if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
> > +     if (!ptrace32 (PTT_READ_GPRS, tid, (addr_ptr) gprs32, 0, NULL))
> >         memset (gprs32, 0, sizeof (gprs32));
> >       for (i = 0; i < ppc_num_gprs; i++)
> >         supply_reg32 (regcache, tdep->ppc_gp0_regnum + i, gprs32[i]);
> > @@ -1253,7 +1270,7 @@
> >            || (regno >= tdep->ppc_fp0_regnum
> >                && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
> >      {
>  -      if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
>  +      if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL))
>      memset (fprs, 0, sizeof (fprs));
>         supply_fprs (regcache, fprs);
>       }
>  @@ -1275,7 +1292,7 @@
>      {
>        struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
> 
>  -     if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
>  +     if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL))
>          memset (&sprs32, 0, sizeof (sprs32));
>        supply_sprs32 (regcache, sprs32.pt_iar, sprs32.pt_msr,
>  sprs32.pt_cr,
>             sprs32.pt_lr, sprs32.pt_ctr, sprs32.pt_xer,
>  @@ -1570,9 +1587,9 @@
>         else
>      {
>        /* Pre-fetch: some regs may not be in the cache.  */
>  -     ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL);
>  +     ptrace32 (PTT_READ_GPRS, tid, (addr_ptr) gprs32, 0, NULL);
>        fill_gprs32 (regcache, gprs32);
>  -     ptrace32 (PTT_WRITE_GPRS, tid, gprs32, 0, NULL);
>  +     ptrace32 (PTT_WRITE_GPRS, tid, (addr_ptr) gprs32, 0, NULL);
>      }
>       }
> 
>  @@ -1584,9 +1601,9 @@
>                 && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
>       {
>         /* Pre-fetch: some regs may not be in the cache.  */
>  -      ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL);
>  +      ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL);
>         fill_fprs (regcache, fprs);
>  -      ptrace32 (PTT_WRITE_FPRS, tid, (void *) fprs, 0, NULL);
>  +      ptrace32 (PTT_WRITE_FPRS, tid, (addr_ptr) fprs, 0, NULL);
>       }
> 
>     /* Special-purpose registers.  */
>  @@ -1618,7 +1635,7 @@
>        gdb_assert (sizeof (sprs32.pt_iar) == 4);
> 
>        /* Pre-fetch: some registers won't be in the cache.  */
>  -     ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL);
>  +     ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL);
> 
>        fill_sprs32 (regcache, &tmp_iar, &tmp_msr, &tmp_cr, &tmp_lr,
>                &tmp_ctr, &tmp_xer, &tmp_fpscr);
>  @@ -1637,7 +1654,7 @@
>            regcache_raw_collect (regcache, tdep->ppc_mq_regnum,
>                   &sprs32.pt_mq);
> 
>  -     ptrace32 (PTT_WRITE_SPRS, tid, (int *) &sprs32, 0, NULL);
>  +     ptrace32 (PTT_WRITE_SPRS, tid, (addr_ptr) &sprs32, 0, NULL);
>      }
>       }
>   }
> ---
> 
> 
> 

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

* Re: [PATCH 5/5] make calls to ptrace64 in aix-thread.c when defined
  2013-08-07 11:38     ` Mark Kettenis
@ 2013-08-07 11:45       ` Raunaq 12
  2013-08-07 12:03         ` Ulrich Weigand
  0 siblings, 1 reply; 13+ messages in thread
From: Raunaq 12 @ 2013-08-07 11:45 UTC (permalink / raw)
  To: Mark Kettenis, Ulrich Weigand; +Cc: gdb-patches, tromey


Mark Kettenis <mark.kettenis@xs4all.nl> wrote on 08/07/2013 05:07:35 PM:

> From: Mark Kettenis <mark.kettenis@xs4all.nl>
> To: Raunaq 12/India/IBM@IBMIN
> Cc: gdb-patches@sourceware.org, tromey@redhat.com
> Date: 08/07/2013 05:06 PM
> Subject: Re: [PATCH 5/5] make calls to ptrace64 in aix-thread.c when
defined
>
> > From: Raunaq 12 <raunaq12@in.ibm.com>
> > Date: Wed, 7 Aug 2013 16:57:50 +0530
> >
> > > ChangeLog :-
> > > * aixthread.c: call ptrace64 instead of ptracex if defined
> > >  Call ptrace64 instead of ptrace if defined
> > >  Add macro addr_ptr to take care of ptrace address arguement
> > > (pdc_read_regs): Likewise
> > > (pdc_write_regs): Likewise
> > > (aix_thread_resume): Likewise
> > > (fetch_regs_kernel_thread): Likewise
> > > (store_regs_kernel_thread): Likewise
> > >
> > Mark> Again, you're being sloppy here.  Sentences start with a capital
> >    letter and end in a full stop.
> >
> > Hi,
> >
> > Apologize for the overlooking punctuation errors. Fixing it here.
> > Also re-submitting the patch here for review. Is it okay to Commit?
>
> Yes, fine with me.  Do you have a copyright assignment in place?  Or
> is this covered by a company-wide assignment that IBM has in place?

Looping Ulrich Weigand in here. He has agreed to help me out with this.

Hi Ulrich,
Any comments regarding this ?
>
>
> > ---
> > ChangeLog :-
> >     * aixthread.c: Call ptrace64 instead of ptracex if defined.
> >      Call ptrace64 instead of ptrace if defined.
> >      Add macro addr_ptr to take care of ptrace address arguement.
> >     (pdc_read_regs): Likewise.
> >     (pdc_write_regs): Likewise.
> >     (aix_thread_resume): Likewise.
> >     (fetch_regs_kernel_thread): Likewise.
> >     (store_regs_kernel_thread): Likewise.
> >
> >
> >  ---
> >  Index: ./gdb/aix-thread.c
> >  ===================================================================
> >  --- ./gdb.orig/aix-thread.c
> >  +++ .gdb/aix-thread.c
> >  @@ -237,7 +237,14 @@
> >     return 0;  /* Not reached.  */
> >   }
> >
> >  -/* Call ptracex (REQ, ID, ADDR, DATA, BUF).  Return success.  */
> >  +/* Call ptracex (REQ, ID, ADDR, DATA, BUF) or
> >  +   ptrace64 (REQ, ID, ADDR, DATA, BUF) if HAVE_PTRACE64.
> >  +   Return success.  */
> >  +
> >  +#ifdef HAVE_PTRACE64
> >  +# define ptracex(request, pid, addr, data, buf) \
> >  +    ptrace64 (request, pid, addr, data, buf)
> >  +#endif
> >
> >   static int
> >   ptrace64aix (int req, int id, long long addr, int data, int *buf)
> >  @@ -246,14 +253,24 @@
> >     return ptrace_check (req, id, ptracex (req, id, addr, data, buf));
> >   }
> >
> >  -/* Call ptrace (REQ, ID, ADDR, DATA, BUF).  Return success.  */
> >  +/* Call ptrace (REQ, ID, ADDR, DATA, BUF) or
> >  +   ptrace64 (REQ, ID, ADDR, DATA, BUF) if HAVE_PTRACE64.
> >  +   Return success.  */
> >  +
> >  +#ifdef HAVE_PTRACE64
> >  +# define ptrace(request, pid, addr, data, buf) \
> >  +    ptrace64 (request, pid, addr, data, buf)
> >  +# define addr_ptr long long
> >  +#else
> >  +# define addr_ptr int *
> >  +#endif
> >
> >   static int
> >  -ptrace32 (int req, int id, int *addr, int data, int *buf)
> >  +ptrace32 (int req, int id, addr_ptr addr, int data, int *buf)
> >   {
> >     errno = 0;
> >     return ptrace_check (req, id,
> >  -             ptrace (req, id, (int *) addr, data, buf));
> >  +             ptrace (req, id, (addr_ptr) addr, data, buf));
> >   }
> >
> >   /* If *PIDP is a composite process/thread id, convert it to a
> >  @@ -361,7 +378,7 @@
> >     /* Floating-point registers.  */
> >     if (flags & PTHDB_FLAG_FPRS)
> >       {
> >  -      if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
> >  +      if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL))
> >      memset (fprs, 0, sizeof (fprs));
> >         memcpy (context->fpr, fprs, sizeof(fprs));
> >       }
> >  @@ -378,7 +395,7 @@
> >      }
> >         else
> >      {
> >  -     if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
> >  +     if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL))
> >          memset (&sprs32, 0, sizeof (sprs32));
> >              memcpy (&context->msr, &sprs32, sizeof(sprs32));
> >      }
> >  @@ -413,13 +430,13 @@
> >      ptrace64aix (PTT_WRITE_GPRS, tid,
> >              (unsigned long) context->gpr, 0, NULL);
> >         else
> >  -   ptrace32 (PTT_WRITE_GPRS, tid, (int *) context->gpr, 0, NULL);
> >  +   ptrace32 (PTT_WRITE_GPRS, tid, (addr_ptr) context->gpr, 0, NULL);
> >       }
> >
> > >   /* Floating-point registers.  */
> > >    if (flags & PTHDB_FLAG_FPRS)
> > >      {
> > > -      ptrace32 (PTT_WRITE_FPRS, tid, (int *) context->fpr, 0, NULL);
> > > +      ptrace32 (PTT_WRITE_FPRS, tid, (addr_ptr) context->fpr, 0,
NULL);
> > >      }
> > >
> > >    /* Special-purpose registers.  */
> > > @@ -432,7 +449,7 @@
> > >     }
> > >        else
> > >     {
> > > -     ptrace32 (PTT_WRITE_SPRS, tid, (void *) &context->msr, 0,
NULL);
> > > +     ptrace32 (PTT_WRITE_SPRS, tid, (addr_ptr) &context->msr, 0,
NULL);
> > >     }
> > >      }
> > >    return 0;
> > > @@ -997,10 +1014,10 @@
> > >        tid[1] = 0;
> > >
> > >        if (arch64)
> > > -   ptrace64aix (PTT_CONTINUE, tid[0], 1,
> > > +   ptrace64aix (PTT_CONTINUE, tid[0], (long long) 1,
> > >             gdb_signal_to_host (sig), (void *) tid);
> > >        else
> > > -   ptrace32 (PTT_CONTINUE, tid[0], (int *) 1,
> > > +   ptrace32 (PTT_CONTINUE, tid[0], (addr_ptr) 1,
> > >          gdb_signal_to_host (sig), (void *) tid);
> > >      }
> > >  }
> > > @@ -1239,7 +1256,7 @@
> > >     }
> > >        else
> > >     {
> > > -     if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
> > > +     if (!ptrace32 (PTT_READ_GPRS, tid, (addr_ptr) gprs32, 0, NULL))
> > >         memset (gprs32, 0, sizeof (gprs32));
> > >       for (i = 0; i < ppc_num_gprs; i++)
> > >         supply_reg32 (regcache, tdep->ppc_gp0_regnum + i, gprs32[i]);
> > > @@ -1253,7 +1270,7 @@
> > >            || (regno >= tdep->ppc_fp0_regnum
> > >                && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
> > >      {
> >  -      if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
> >  +      if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL))
> >      memset (fprs, 0, sizeof (fprs));
> >         supply_fprs (regcache, fprs);
> >       }
> >  @@ -1275,7 +1292,7 @@
> >      {
> >        struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
> >
> >  -     if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
> >  +     if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL))
> >          memset (&sprs32, 0, sizeof (sprs32));
> >        supply_sprs32 (regcache, sprs32.pt_iar, sprs32.pt_msr,
> >  sprs32.pt_cr,
> >             sprs32.pt_lr, sprs32.pt_ctr, sprs32.pt_xer,
> >  @@ -1570,9 +1587,9 @@
> >         else
> >      {
> >        /* Pre-fetch: some regs may not be in the cache.  */
> >  -     ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL);
> >  +     ptrace32 (PTT_READ_GPRS, tid, (addr_ptr) gprs32, 0, NULL);
> >        fill_gprs32 (regcache, gprs32);
> >  -     ptrace32 (PTT_WRITE_GPRS, tid, gprs32, 0, NULL);
> >  +     ptrace32 (PTT_WRITE_GPRS, tid, (addr_ptr) gprs32, 0, NULL);
> >      }
> >       }
> >
> >  @@ -1584,9 +1601,9 @@
> >                 && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
> >       {
> >         /* Pre-fetch: some regs may not be in the cache.  */
> >  -      ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL);
> >  +      ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL);
> >         fill_fprs (regcache, fprs);
> >  -      ptrace32 (PTT_WRITE_FPRS, tid, (void *) fprs, 0, NULL);
> >  +      ptrace32 (PTT_WRITE_FPRS, tid, (addr_ptr) fprs, 0, NULL);
> >       }
> >
> >     /* Special-purpose registers.  */
> >  @@ -1618,7 +1635,7 @@
> >        gdb_assert (sizeof (sprs32.pt_iar) == 4);
> >
> >        /* Pre-fetch: some registers won't be in the cache.  */
> >  -     ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL);
> >  +     ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL);
> >
> >        fill_sprs32 (regcache, &tmp_iar, &tmp_msr, &tmp_cr, &tmp_lr,
> >                &tmp_ctr, &tmp_xer, &tmp_fpscr);
> >  @@ -1637,7 +1654,7 @@
> >            regcache_raw_collect (regcache, tdep->ppc_mq_regnum,
> >                   &sprs32.pt_mq);
> >
> >  -     ptrace32 (PTT_WRITE_SPRS, tid, (int *) &sprs32, 0, NULL);
> >  +     ptrace32 (PTT_WRITE_SPRS, tid, (addr_ptr) &sprs32, 0, NULL);
> >      }
> >       }
> >   }
> > ---
> >
> >
> >
>

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

* Re: [PATCH 5/5] make calls to ptrace64 in aix-thread.c when defined
  2013-08-07 11:45       ` Raunaq 12
@ 2013-08-07 12:03         ` Ulrich Weigand
  2013-08-07 12:36           ` Raunaq 12
  0 siblings, 1 reply; 13+ messages in thread
From: Ulrich Weigand @ 2013-08-07 12:03 UTC (permalink / raw)
  To: Raunaq 12; +Cc: Mark Kettenis, Ulrich Weigand, gdb-patches, tromey

Raunaq 12 wrote:
> Mark Kettenis <mark.kettenis@xs4all.nl> wrote on 08/07/2013 05:07:35 PM:
> > Yes, fine with me.  Do you have a copyright assignment in place?  Or
> > is this covered by a company-wide assignment that IBM has in place?
> 
> Looping Ulrich Weigand in here. He has agreed to help me out with this.
> 
> Hi Ulrich,
> Any comments regarding this ?

I'll be happy to check the patch in; then it is covered by the IBM
agreements.

Can you send me the final patch ready for check-in -- the copies you
sent to the list seem to have whitespace / line-wrap issues; if it
is easier for you, free free to send as attachment.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com

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

* Re: [PATCH 5/5] make calls to ptrace64 in aix-thread.c when defined
  2013-08-07 12:03         ` Ulrich Weigand
@ 2013-08-07 12:36           ` Raunaq 12
  2013-08-07 13:27             ` Ulrich Weigand
  0 siblings, 1 reply; 13+ messages in thread
From: Raunaq 12 @ 2013-08-07 12:36 UTC (permalink / raw)
  To: Ulrich Weigand; +Cc: gdb-patches, Mark Kettenis, tromey, Ulrich Weigand

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

> I'll be happy to check the patch in; then it is covered by the IBM
> agreements.
>
> Can you send me the final patch ready for check-in -- the copies you
> sent to the list seem to have whitespace / line-wrap issues; if it
> is easier for you, free free to send as attachment.

Hi Ulrich,
Thanks a lot for the help. Attaching the patch after the Changelog
entry below.

Changelog :-
 	* aixthread.c: Call ptrace64 instead of ptracex if defined.
  	Call ptrace64 instead of ptrace if defined.
  	Add macro addr_ptr to take care of ptrace address arguement.
 	(pdc_read_regs): Likewise.
 	(pdc_write_regs): Likewise.
 	(aix_thread_resume): Likewise.
 	(fetch_regs_kernel_thread): Likewise.
 	(store_regs_kernel_thread): Likewise.

(See attached file: gdb-7.6-aix-thread.patch)

Regards,
Raunaq M. Bathija

[-- Attachment #2: gdb-7.6-aix-thread.patch --]
[-- Type: application/octet-stream, Size: 5860 bytes --]

Index: ./gdb/aix-thread.c
===================================================================
--- ./gdb.orig/aix-thread.c
+++ ./gdb/aix-thread.c
@@ -237,7 +237,14 @@
   return 0;  /* Not reached.  */
 }
 
-/* Call ptracex (REQ, ID, ADDR, DATA, BUF).  Return success.  */
+/* Call ptracex (REQ, ID, ADDR, DATA, BUF) or
+   ptrace64 (REQ, ID, ADDR, DATA, BUF) if HAVE_PTRACE64.
+   Return success.  */
+
+#ifdef HAVE_PTRACE64
+# define ptracex(request, pid, addr, data, buf) \
+	 ptrace64 (request, pid, addr, data, buf)
+#endif
 
 static int
 ptrace64aix (int req, int id, long long addr, int data, int *buf)
@@ -246,14 +253,24 @@
   return ptrace_check (req, id, ptracex (req, id, addr, data, buf));
 }
 
-/* Call ptrace (REQ, ID, ADDR, DATA, BUF).  Return success.  */
+/* Call ptrace (REQ, ID, ADDR, DATA, BUF) or
+   ptrace64 (REQ, ID, ADDR, DATA, BUF) if HAVE_PTRACE64.
+   Return success.  */
+
+#ifdef HAVE_PTRACE64
+# define ptrace(request, pid, addr, data, buf) \
+	 ptrace64 (request, pid, addr, data, buf)
+# define addr_ptr long long
+#else
+# define addr_ptr int *
+#endif
 
 static int
-ptrace32 (int req, int id, int *addr, int data, int *buf)
+ptrace32 (int req, int id, addr_ptr addr, int data, int *buf)
 {
   errno = 0;
   return ptrace_check (req, id, 
-		       ptrace (req, id, (int *) addr, data, buf));
+		       ptrace (req, id, (addr_ptr) addr, data, buf));
 }
 
 /* If *PIDP is a composite process/thread id, convert it to a
@@ -361,7 +378,7 @@
   /* Floating-point registers.  */
   if (flags & PTHDB_FLAG_FPRS)
     {
-      if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
+      if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL))
 	memset (fprs, 0, sizeof (fprs));
       memcpy (context->fpr, fprs, sizeof(fprs));
     }
@@ -378,7 +395,7 @@
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL))
 	    memset (&sprs32, 0, sizeof (sprs32));
       	  memcpy (&context->msr, &sprs32, sizeof(sprs32));
 	}
@@ -413,13 +430,13 @@
 	ptrace64aix (PTT_WRITE_GPRS, tid, 
 		     (unsigned long) context->gpr, 0, NULL);
       else
-	ptrace32 (PTT_WRITE_GPRS, tid, (int *) context->gpr, 0, NULL);
+	ptrace32 (PTT_WRITE_GPRS, tid, (addr_ptr) context->gpr, 0, NULL);
     }
 
  /* Floating-point registers.  */
   if (flags & PTHDB_FLAG_FPRS)
     {
-      ptrace32 (PTT_WRITE_FPRS, tid, (int *) context->fpr, 0, NULL);
+      ptrace32 (PTT_WRITE_FPRS, tid, (addr_ptr) context->fpr, 0, NULL);
     }
 
   /* Special-purpose registers.  */
@@ -432,7 +449,7 @@
 	}
       else
 	{
-	  ptrace32 (PTT_WRITE_SPRS, tid, (void *) &context->msr, 0, NULL);
+	  ptrace32 (PTT_WRITE_SPRS, tid, (addr_ptr) &context->msr, 0, NULL);
 	}
     }
   return 0;
@@ -997,10 +1014,10 @@
       tid[1] = 0;
 
       if (arch64)
-	ptrace64aix (PTT_CONTINUE, tid[0], 1, 
+	ptrace64aix (PTT_CONTINUE, tid[0], (long long) 1,
 		     gdb_signal_to_host (sig), (void *) tid);
       else
-	ptrace32 (PTT_CONTINUE, tid[0], (int *) 1,
+	ptrace32 (PTT_CONTINUE, tid[0], (addr_ptr) 1,
 		  gdb_signal_to_host (sig), (void *) tid);
     }
 }
@@ -1239,7 +1256,7 @@
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_GPRS, tid, (addr_ptr) gprs32, 0, NULL))
 	    memset (gprs32, 0, sizeof (gprs32));
 	  for (i = 0; i < ppc_num_gprs; i++)
 	    supply_reg32 (regcache, tdep->ppc_gp0_regnum + i, gprs32[i]);
@@ -1253,7 +1270,7 @@
           || (regno >= tdep->ppc_fp0_regnum
               && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
     {
-      if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
+      if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL))
 	memset (fprs, 0, sizeof (fprs));
       supply_fprs (regcache, fprs);
     }
@@ -1275,7 +1292,7 @@
 	{
 	  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
 
-	  if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL))
 	    memset (&sprs32, 0, sizeof (sprs32));
 	  supply_sprs32 (regcache, sprs32.pt_iar, sprs32.pt_msr, sprs32.pt_cr,
 			 sprs32.pt_lr, sprs32.pt_ctr, sprs32.pt_xer,
@@ -1570,9 +1587,9 @@
       else
 	{
 	  /* Pre-fetch: some regs may not be in the cache.  */
-	  ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL);
+	  ptrace32 (PTT_READ_GPRS, tid, (addr_ptr) gprs32, 0, NULL);
 	  fill_gprs32 (regcache, gprs32);
-	  ptrace32 (PTT_WRITE_GPRS, tid, gprs32, 0, NULL);
+	  ptrace32 (PTT_WRITE_GPRS, tid, (addr_ptr) gprs32, 0, NULL);
 	}
     }
 
@@ -1584,9 +1601,9 @@
               && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
     {
       /* Pre-fetch: some regs may not be in the cache.  */
-      ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL);
+      ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL);
       fill_fprs (regcache, fprs);
-      ptrace32 (PTT_WRITE_FPRS, tid, (void *) fprs, 0, NULL);
+      ptrace32 (PTT_WRITE_FPRS, tid, (addr_ptr) fprs, 0, NULL);
     }
 
   /* Special-purpose registers.  */
@@ -1618,7 +1635,7 @@
 	  gdb_assert (sizeof (sprs32.pt_iar) == 4);
 
 	  /* Pre-fetch: some registers won't be in the cache.  */
-	  ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL);
+	  ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL);
 
 	  fill_sprs32 (regcache, &tmp_iar, &tmp_msr, &tmp_cr, &tmp_lr,
 		       &tmp_ctr, &tmp_xer, &tmp_fpscr);
@@ -1637,7 +1654,7 @@
 	      regcache_raw_collect (regcache, tdep->ppc_mq_regnum,
 				    &sprs32.pt_mq);
 
-	  ptrace32 (PTT_WRITE_SPRS, tid, (int *) &sprs32, 0, NULL);
+	  ptrace32 (PTT_WRITE_SPRS, tid, (addr_ptr) &sprs32, 0, NULL);
 	}
     }
 }

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

* Re: [PATCH 5/5] make calls to ptrace64 in aix-thread.c when defined
  2013-08-07 12:36           ` Raunaq 12
@ 2013-08-07 13:27             ` Ulrich Weigand
  2013-08-07 13:32               ` Mark Kettenis
  0 siblings, 1 reply; 13+ messages in thread
From: Ulrich Weigand @ 2013-08-07 13:27 UTC (permalink / raw)
  To: Raunaq 12; +Cc: gdb-patches, Mark Kettenis, tromey, Ulrich Weigand

Raunaq 12 wrote:

> Thanks a lot for the help. Attaching the patch after the Changelog
> entry below.
> 
> Changelog :-
>  	* aixthread.c: Call ptrace64 instead of ptracex if defined.
>   	Call ptrace64 instead of ptrace if defined.
>   	Add macro addr_ptr to take care of ptrace address arguement.
>  	(pdc_read_regs): Likewise.
>  	(pdc_write_regs): Likewise.
>  	(aix_thread_resume): Likewise.
>  	(fetch_regs_kernel_thread): Likewise.
>  	(store_regs_kernel_thread): Likewise.
> 
> (See attached file: gdb-7.6-aix-thread.patch)

I've checked this in now.

Thanks,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com

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

* Re: [PATCH 5/5] make calls to ptrace64 in aix-thread.c when defined
  2013-08-07 13:27             ` Ulrich Weigand
@ 2013-08-07 13:32               ` Mark Kettenis
  2013-08-07 14:10                 ` [PATCH 1/5] config support for powerpc64-aix Raunaq 12
  0 siblings, 1 reply; 13+ messages in thread
From: Mark Kettenis @ 2013-08-07 13:32 UTC (permalink / raw)
  To: uweigand; +Cc: raunaq12, gdb-patches, tromey, Ulrich.Weigand

> Date: Wed, 7 Aug 2013 15:27:19 +0200 (CEST)
> From: "Ulrich Weigand" <uweigand@de.ibm.com>
> 
> Raunaq 12 wrote:
> 
> > Thanks a lot for the help. Attaching the patch after the Changelog
> > entry below.
> > 
> > Changelog :-
> >  	* aixthread.c: Call ptrace64 instead of ptracex if defined.
> >   	Call ptrace64 instead of ptrace if defined.
> >   	Add macro addr_ptr to take care of ptrace address arguement.
> >  	(pdc_read_regs): Likewise.
> >  	(pdc_write_regs): Likewise.
> >  	(aix_thread_resume): Likewise.
> >  	(fetch_regs_kernel_thread): Likewise.
> >  	(store_regs_kernel_thread): Likewise.
> > 
> > (See attached file: gdb-7.6-aix-thread.patch)
> 
> I've checked this in now.
> 

Patch 1/5 and 4/5 are ok with me as well.  I'm not really familliar
with XCOFF and XLC, so reviewing the other ones should probably done
by someone else.  Although I do see a few coding style violations in
those diffs.

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

* [PATCH 1/5] config support for powerpc64-aix
  2013-08-07 13:32               ` Mark Kettenis
@ 2013-08-07 14:10                 ` Raunaq 12
  2013-08-07 14:45                   ` Ulrich Weigand
  0 siblings, 1 reply; 13+ messages in thread
From: Raunaq 12 @ 2013-08-07 14:10 UTC (permalink / raw)
  To: Mark Kettenis, Ulrich Weigand; +Cc: gdb-patches, tromey

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

> Patch 1/5 and 4/5 are ok with me as well.

Attaching the [patch 1/5] below.

I have a patch that makes changes to ./bfd/configure ./bfd/Makefile.in
to add support for 64 bit core handling in 64 bit GDB.

Should that be submitted to this mailing list or binutils list?

Thanks,
Raunaq
---
ChangeLog-
                * configure.tgt (powerpc64-*-aix*): Match powerpc64 running
aix.
	* configure.host (powerpc64-*-aix*): Likewise.

(See attached file: gdb-7.6-ppc64aix.patch)




[-- Attachment #2: gdb-7.6-ppc64aix.patch --]
[-- Type: application/octet-stream, Size: 1152 bytes --]

Index: ./gdb/configure.host
===================================================================
--- ./gdb.orig/configure.host
+++ ./gdb/configure.host
@@ -126,7 +126,7 @@
 			gdb_host=nbsd ;;
 mips64*-*-openbsd*)	gdb_host=obsd64 ;;
 
-powerpc-*-aix* | rs6000-*-*)
+powerpc-*-aix* | rs6000-*-* | powerpc64-*-aix*)
 			gdb_host=aix ;;
 powerpc*-*-freebsd*)	gdb_host=fbsd ;;
 powerpc-*-linux*)	gdb_host=linux ;;
Index: ./gdb/configure.tgt
===================================================================
--- ./gdb.orig/configure.tgt
+++ ./gdb/configure.tgt
@@ -427,7 +427,7 @@
 			solib-svr4.o \
 			ravenscar-thread.o ppc-ravenscar-thread.o"
 	;;
-powerpc-*-aix* | rs6000-*-*)
+powerpc-*-aix* | rs6000-*-* | powerpc64-*-aix*)
 	# Target: PowerPC running AIX
 	gdb_target_obs="rs6000-tdep.o rs6000-aix-tdep.o xcoffread.o \
 			ppc-sysv-tdep.o solib-aix.o \
@@ -714,6 +714,8 @@
 *-*-dicos*)	gdb_osabi=GDB_OSABI_DICOS ;;
 *-*-symbianelf*)
 		gdb_osabi=GDB_OSABI_SYMBIAN ;;
+powerpc-*-aix* | rs6000-*-* | powerpc64-*-aix*)
+                gdb_osabi=GDB_OSABI_AIX ;;
 esac
 
 # Check whether this target supports gcore.

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

* Re: [PATCH 1/5] config support for powerpc64-aix
  2013-08-07 14:10                 ` [PATCH 1/5] config support for powerpc64-aix Raunaq 12
@ 2013-08-07 14:45                   ` Ulrich Weigand
  0 siblings, 0 replies; 13+ messages in thread
From: Ulrich Weigand @ 2013-08-07 14:45 UTC (permalink / raw)
  To: Raunaq 12; +Cc: Mark Kettenis, Ulrich Weigand, gdb-patches, tromey

Raunaq 12 wrote:

> I have a patch that makes changes to ./bfd/configure ./bfd/Makefile.in
> to add support for 64 bit core handling in 64 bit GDB.
> 
> Should that be submitted to this mailing list or binutils list?

These need to go to the binutils list (please CC this list too).
Once approved there, I can check them in as well.

> ChangeLog-
> 	* configure.tgt (powerpc64-*-aix*): Match powerpc64 running aix.
> 	* configure.host (powerpc64-*-aix*): Likewise.
> 
> (See attached file: gdb-7.6-ppc64aix.patch)

I've checked this in too.

Thanks,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  Ulrich.Weigand@de.ibm.com

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

* [PATCH 5/5] make calls to ptrace64 in aix-thread.c when defined
@ 2013-07-29  6:17 Raunaq 12
  0 siblings, 0 replies; 13+ messages in thread
From: Raunaq 12 @ 2013-07-29  6:17 UTC (permalink / raw)
  To: gdb-patches; +Cc: tromey, Mark Kettenis


Calls to ptrace and ptracex do not work when we compile 64 BIT GDB.
So, we check if ptrace64 is defined, if so, then we use ptrace64 in place
of
ptrace and ptracex.

Note:- the 3rd argument to ptrace is of type int * whereas for ptrace64 it
is of type long long. So, we add a macro called addr_ptr to take care of
this.
---
ChangeLog :-
* aixthread.c: call ptrace64 instead of ptracex if defined
 Call ptrace64 instead of ptrace if defined
 Add macro addr_ptr to take care of ptrace address arguement
(pdc_read_regs): Likewise
(pdc_write_regs): Likewise
(aix_thread_resume): Likewise
(fetch_regs_kernel_thread): Likewise
(store_regs_kernel_thread): Likewise
---
Index: ./gdb/aix-thread.c
===================================================================
--- ./gdb.orig/aix-thread.c
+++ .gdb/aix-thread.c
@@ -237,7 +237,14 @@
   return 0;  /* Not reached.  */
 }

-/* Call ptracex (REQ, ID, ADDR, DATA, BUF).  Return success.  */
+/* Call ptracex (REQ, ID, ADDR, DATA, BUF) or
+   ptrace64 (REQ, ID, ADDR, DATA, BUF) if HAVE_PTRACE64.
+   Return success.  */
+
+#ifdef HAVE_PTRACE64
+# define ptracex(request, pid, addr, data, buf) \
+	 ptrace64 (request, pid, addr, data, buf)
+#endif

 static int
 ptrace64aix (int req, int id, long long addr, int data, int *buf)
@@ -246,14 +253,24 @@
   return ptrace_check (req, id, ptracex (req, id, addr, data, buf));
 }

-/* Call ptrace (REQ, ID, ADDR, DATA, BUF).  Return success.  */
+/* Call ptrace (REQ, ID, ADDR, DATA, BUF) or
+   ptrace64 (REQ, ID, ADDR, DATA, BUF) if HAVE_PTRACE64.
+   Return success.  */
+
+#ifdef HAVE_PTRACE64
+# define ptrace(request, pid, addr, data, buf) \
+	 ptrace64 (request, pid, addr, data, buf)
+# define addr_ptr long long
+#else
+# define addr_ptr int *
+#endif

 static int
-ptrace32 (int req, int id, int *addr, int data, int *buf)
+ptrace32 (int req, int id, addr_ptr addr, int data, int *buf)
 {
   errno = 0;
   return ptrace_check (req, id,
-		       ptrace (req, id, (int *) addr, data, buf));
+		       ptrace (req, id, (addr_ptr) addr, data, buf));
 }

 /* If *PIDP is a composite process/thread id, convert it to a
@@ -361,7 +378,7 @@
   /* Floating-point registers.  */
   if (flags & PTHDB_FLAG_FPRS)
     {
-      if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
+      if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL))
 	memset (fprs, 0, sizeof (fprs));
       memcpy (context->fpr, fprs, sizeof(fprs));
     }
@@ -378,7 +395,7 @@
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL))
 	    memset (&sprs32, 0, sizeof (sprs32));
       	  memcpy (&context->msr, &sprs32, sizeof(sprs32));
 	}
@@ -413,13 +430,13 @@
 	ptrace64aix (PTT_WRITE_GPRS, tid,
 		     (unsigned long) context->gpr, 0, NULL);
       else
-	ptrace32 (PTT_WRITE_GPRS, tid, (int *) context->gpr, 0, NULL);
+	ptrace32 (PTT_WRITE_GPRS, tid, (addr_ptr) context->gpr, 0, NULL);
     }

  /* Floating-point registers.  */
   if (flags & PTHDB_FLAG_FPRS)
     {
-      ptrace32 (PTT_WRITE_FPRS, tid, (int *) context->fpr, 0, NULL);
+      ptrace32 (PTT_WRITE_FPRS, tid, (addr_ptr) context->fpr, 0, NULL);
     }

   /* Special-purpose registers.  */
@@ -432,7 +449,7 @@
 	}
       else
 	{
-	  ptrace32 (PTT_WRITE_SPRS, tid, (void *) &context->msr, 0, NULL);
+	  ptrace32 (PTT_WRITE_SPRS, tid, (addr_ptr) &context->msr, 0, NULL);
 	}
     }
   return 0;
@@ -997,10 +1014,10 @@
       tid[1] = 0;

       if (arch64)
-	ptrace64aix (PTT_CONTINUE, tid[0], 1,
+	ptrace64aix (PTT_CONTINUE, tid[0], (long long) 1,
 		     gdb_signal_to_host (sig), (void *) tid);
       else
-	ptrace32 (PTT_CONTINUE, tid[0], (int *) 1,
+	ptrace32 (PTT_CONTINUE, tid[0], (addr_ptr) 1,
 		  gdb_signal_to_host (sig), (void *) tid);
     }
 }
@@ -1239,7 +1256,7 @@
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_GPRS, tid, (addr_ptr) gprs32, 0, NULL))
 	    memset (gprs32, 0, sizeof (gprs32));
 	  for (i = 0; i < ppc_num_gprs; i++)
 	    supply_reg32 (regcache, tdep->ppc_gp0_regnum + i, gprs32[i]);
@@ -1253,7 +1270,7 @@
           || (regno >= tdep->ppc_fp0_regnum
               && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
     {
-      if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
+      if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL))
 	memset (fprs, 0, sizeof (fprs));
       supply_fprs (regcache, fprs);
     }
@@ -1275,7 +1292,7 @@
 	{
 	  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

-	  if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL))
 	    memset (&sprs32, 0, sizeof (sprs32));
 	  supply_sprs32 (regcache, sprs32.pt_iar, sprs32.pt_msr,
sprs32.pt_cr,
 			 sprs32.pt_lr, sprs32.pt_ctr, sprs32.pt_xer,
@@ -1570,9 +1587,9 @@
       else
 	{
 	  /* Pre-fetch: some regs may not be in the cache.  */
-	  ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL);
+	  ptrace32 (PTT_READ_GPRS, tid, (addr_ptr) gprs32, 0, NULL);
 	  fill_gprs32 (regcache, gprs32);
-	  ptrace32 (PTT_WRITE_GPRS, tid, gprs32, 0, NULL);
+	  ptrace32 (PTT_WRITE_GPRS, tid, (addr_ptr) gprs32, 0, NULL);
 	}
     }

@@ -1584,9 +1601,9 @@
               && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
     {
       /* Pre-fetch: some regs may not be in the cache.  */
-      ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL);
+      ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL);
       fill_fprs (regcache, fprs);
-      ptrace32 (PTT_WRITE_FPRS, tid, (void *) fprs, 0, NULL);
+      ptrace32 (PTT_WRITE_FPRS, tid, (addr_ptr) fprs, 0, NULL);
     }

   /* Special-purpose registers.  */
@@ -1618,7 +1635,7 @@
 	  gdb_assert (sizeof (sprs32.pt_iar) == 4);

 	  /* Pre-fetch: some registers won't be in the cache.  */
-	  ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL);
+	  ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL);

 	  fill_sprs32 (regcache, &tmp_iar, &tmp_msr, &tmp_cr, &tmp_lr,
 		       &tmp_ctr, &tmp_xer, &tmp_fpscr);
@@ -1637,7 +1654,7 @@
 	      regcache_raw_collect (regcache, tdep->ppc_mq_regnum,
 				    &sprs32.pt_mq);

-	  ptrace32 (PTT_WRITE_SPRS, tid, (int *) &sprs32, 0, NULL);
+	  ptrace32 (PTT_WRITE_SPRS, tid, (addr_ptr) &sprs32, 0, NULL);
 	}
     }
 }

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

* [PATCH 5/5] make calls to ptrace64 in aix-thread.c when defined
@ 2013-07-24 13:18 Raunaq 12
  0 siblings, 0 replies; 13+ messages in thread
From: Raunaq 12 @ 2013-07-24 13:18 UTC (permalink / raw)
  To: gdb-patches; +Cc: tromey


Calls to ptrace and ptracex do not work when we compile 64 BIT GDB.
So, we check if ptrace64 is defined, if so, then we use ptrace64 in place
of
ptrace and ptracex.

Note:- the 3rd argument to ptrace is of type int * whereas for ptrace64 it
is of type long long. So, we add a macro called addr_ptr to take care of
this.
---
ChangeLog :-
* aixthread.c: call ptrace64 instead of ptracex if defined
 Call ptrace64 instead of ptrace if defined
 Add macro addr_ptr to take care of ptrace address arguement
(pdc_read_regs): Likewise
(pdc_write_regs): Likewise
(aix_thread_resume): Likewise
(fetch_regs_kernel_thread): Likewise
(store_regs_kernel_thread): Likewise
---
Index: ./gdb/aix-thread.c
===================================================================
--- ./gdb.orig/aix-thread.c
+++ .gdb/aix-thread.c
@@ -237,7 +237,14 @@
   return 0;  /* Not reached.  */
 }

-/* Call ptracex (REQ, ID, ADDR, DATA, BUF).  Return success.  */
+/* Call ptracex (REQ, ID, ADDR, DATA, BUF) or
+   ptrace64 (REQ, ID, ADDR, DATA, BUF) if HAVE_PTRACE64.
+   Return success.  */
+
+#ifdef HAVE_PTRACE64
+# define ptracex(request, pid, addr, data, buf) \
+	 ptrace64 (request, pid, addr, data, buf)
+#endif

 static int
 ptrace64aix (int req, int id, long long addr, int data, int *buf)
@@ -246,14 +253,24 @@
   return ptrace_check (req, id, ptracex (req, id, addr, data, buf));
 }

-/* Call ptrace (REQ, ID, ADDR, DATA, BUF).  Return success.  */
+/* Call ptrace (REQ, ID, ADDR, DATA, BUF) or
+   ptrace64 (REQ, ID, ADDR, DATA, BUF) if HAVE_PTRACE64.
+   Return success.  */
+
+#ifdef HAVE_PTRACE64
+# define ptrace(request, pid, addr, data, buf) \
+	 ptrace64 (request, pid, addr, data, buf)
+# define addr_ptr long long
+#else
+# define addr_ptr int *
+#endif

 static int
-ptrace32 (int req, int id, int *addr, int data, int *buf)
+ptrace32 (int req, int id, addr_ptr addr, int data, int *buf)
 {
   errno = 0;
   return ptrace_check (req, id,
-		       ptrace (req, id, (int *) addr, data, buf));
+		       ptrace (req, id, (addr_ptr) addr, data, buf));
 }

 /* If *PIDP is a composite process/thread id, convert it to a
@@ -361,7 +378,7 @@
   /* Floating-point registers.  */
   if (flags & PTHDB_FLAG_FPRS)
     {
-      if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
+      if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL))
 	memset (fprs, 0, sizeof (fprs));
       memcpy (context->fpr, fprs, sizeof(fprs));
     }
@@ -378,7 +395,7 @@
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL))
 	    memset (&sprs32, 0, sizeof (sprs32));
       	  memcpy (&context->msr, &sprs32, sizeof(sprs32));
 	}
@@ -413,13 +430,13 @@
 	ptrace64aix (PTT_WRITE_GPRS, tid,
 		     (unsigned long) context->gpr, 0, NULL);
       else
-	ptrace32 (PTT_WRITE_GPRS, tid, (int *) context->gpr, 0, NULL);
+	ptrace32 (PTT_WRITE_GPRS, tid, (addr_ptr) context->gpr, 0, NULL);
     }

  /* Floating-point registers.  */
   if (flags & PTHDB_FLAG_FPRS)
     {
-      ptrace32 (PTT_WRITE_FPRS, tid, (int *) context->fpr, 0, NULL);
+      ptrace32 (PTT_WRITE_FPRS, tid, (addr_ptr) context->fpr, 0, NULL);
     }

   /* Special-purpose registers.  */
@@ -432,7 +449,7 @@
 	}
       else
 	{
-	  ptrace32 (PTT_WRITE_SPRS, tid, (void *) &context->msr, 0, NULL);
+	  ptrace32 (PTT_WRITE_SPRS, tid, (addr_ptr) &context->msr, 0, NULL);
 	}
     }
   return 0;
@@ -997,10 +1014,10 @@
       tid[1] = 0;

       if (arch64)
-	ptrace64aix (PTT_CONTINUE, tid[0], 1,
+	ptrace64aix (PTT_CONTINUE, tid[0], (long long) 1,
 		     gdb_signal_to_host (sig), (void *) tid);
       else
-	ptrace32 (PTT_CONTINUE, tid[0], (int *) 1,
+	ptrace32 (PTT_CONTINUE, tid[0], (addr_ptr) 1,
 		  gdb_signal_to_host (sig), (void *) tid);
     }
 }
@@ -1239,7 +1256,7 @@
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_GPRS, tid, (addr_ptr) gprs32, 0, NULL))
 	    memset (gprs32, 0, sizeof (gprs32));
 	  for (i = 0; i < ppc_num_gprs; i++)
 	    supply_reg32 (regcache, tdep->ppc_gp0_regnum + i, gprs32[i]);
@@ -1253,7 +1270,7 @@
           || (regno >= tdep->ppc_fp0_regnum
               && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
     {
-      if (!ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL))
+      if (!ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL))
 	memset (fprs, 0, sizeof (fprs));
       supply_fprs (regcache, fprs);
     }
@@ -1275,7 +1292,7 @@
 	{
 	  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);

-	  if (!ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL))
+	  if (!ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL))
 	    memset (&sprs32, 0, sizeof (sprs32));
 	  supply_sprs32 (regcache, sprs32.pt_iar, sprs32.pt_msr,
sprs32.pt_cr,
 			 sprs32.pt_lr, sprs32.pt_ctr, sprs32.pt_xer,
@@ -1570,9 +1587,9 @@
       else
 	{
 	  /* Pre-fetch: some regs may not be in the cache.  */
-	  ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL);
+	  ptrace32 (PTT_READ_GPRS, tid, (addr_ptr) gprs32, 0, NULL);
 	  fill_gprs32 (regcache, gprs32);
-	  ptrace32 (PTT_WRITE_GPRS, tid, gprs32, 0, NULL);
+	  ptrace32 (PTT_WRITE_GPRS, tid, (addr_ptr) gprs32, 0, NULL);
 	}
     }

@@ -1584,9 +1601,9 @@
               && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
     {
       /* Pre-fetch: some regs may not be in the cache.  */
-      ptrace32 (PTT_READ_FPRS, tid, (void *) fprs, 0, NULL);
+      ptrace32 (PTT_READ_FPRS, tid, (addr_ptr) fprs, 0, NULL);
       fill_fprs (regcache, fprs);
-      ptrace32 (PTT_WRITE_FPRS, tid, (void *) fprs, 0, NULL);
+      ptrace32 (PTT_WRITE_FPRS, tid, (addr_ptr) fprs, 0, NULL);
     }

   /* Special-purpose registers.  */
@@ -1618,7 +1635,7 @@
 	  gdb_assert (sizeof (sprs32.pt_iar) == 4);

 	  /* Pre-fetch: some registers won't be in the cache.  */
-	  ptrace32 (PTT_READ_SPRS, tid, (int *) &sprs32, 0, NULL);
+	  ptrace32 (PTT_READ_SPRS, tid, (addr_ptr) &sprs32, 0, NULL);

 	  fill_sprs32 (regcache, &tmp_iar, &tmp_msr, &tmp_cr, &tmp_lr,
 		       &tmp_ctr, &tmp_xer, &tmp_fpscr);
@@ -1637,7 +1654,7 @@
 	      regcache_raw_collect (regcache, tdep->ppc_mq_regnum,
 				    &sprs32.pt_mq);

-	  ptrace32 (PTT_WRITE_SPRS, tid, (int *) &sprs32, 0, NULL);
+	  ptrace32 (PTT_WRITE_SPRS, tid, (addr_ptr) &sprs32, 0, NULL);
 	}
     }
 }

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

end of thread, other threads:[~2013-08-07 14:45 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-01 11:30 [PATCH 5/5] make calls to ptrace64 in aix-thread.c when defined Raunaq 12
2013-08-01 13:28 ` Mark Kettenis
2013-08-07 11:29   ` Raunaq 12
2013-08-07 11:38     ` Mark Kettenis
2013-08-07 11:45       ` Raunaq 12
2013-08-07 12:03         ` Ulrich Weigand
2013-08-07 12:36           ` Raunaq 12
2013-08-07 13:27             ` Ulrich Weigand
2013-08-07 13:32               ` Mark Kettenis
2013-08-07 14:10                 ` [PATCH 1/5] config support for powerpc64-aix Raunaq 12
2013-08-07 14:45                   ` Ulrich Weigand
  -- strict thread matches above, loose matches on Subject: below --
2013-07-29  6:17 [PATCH 5/5] make calls to ptrace64 in aix-thread.c when defined Raunaq 12
2013-07-24 13:18 Raunaq 12

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).