Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH v3] Remove stale pre-AIX-7.2 compatibility guards
@ 2026-09-22  4:52 Aditya Vidyadhar Kamath
  2026-09-22 19:58 ` Simon Marchi
  2026-09-22 20:35 ` Simon Marchi
  0 siblings, 2 replies; 5+ messages in thread
From: Aditya Vidyadhar Kamath @ 2026-09-22  4:52 UTC (permalink / raw)
  To: ulrich.weigand, simon.marchi, tom
  Cc: gdb-patches, Aditya.Kamath1, sangamesh.swamy

From: Aditya Kamath <Aditya.Kamath1@ibm.com>

GDB now requires AIX 7.2 as the minimum supported version and will
support AIX 7.2 TL5, AIX 7.3 and upcoming AIX releases.  Remove
dead compatibility code that existed only for older releases.

Remove the HAVE_DECL_GETTHRDS configure check since aix-thread.c was the last
user of that macro.  Merge ptrace64aix and ptrace32 into a single
ptrace_aix function since they became identical after this
cleanup, and collapse all call sites that branched on arch64 just to
pick between the two.  Also clean up rs6000-aix-nat.c by removing the
ARCH3264 and HAVE_PTRACE64 guards along with the ptracex fallback in
rs6000_ptrace32 and rs6000_ptrace64, which are now simple wrappers
around ptrace64.

Also as per https://www.ibm.com/docs/en/aix/7.2.0?topic=p-ptrace-ptracex-ptrace64-subroutine
ptrace64 will also support 32-bit debugees.

In store_regs_user_thread we use ppc_vsr0_upper_regnum when checking validity
and collecting the VSX upper-doubleword registers.

In store_regs_user_thread guard ctx.fpscr with ppc_fpscr_regnum instead of ppc_xer_regnum, and
add the ppc_fpscr_regnum >= 0 check to match the 64-bit path.
Use ppc_num_gprs instead of ppc_num_fprs in the GPR regno range check.
---
 gdb/aix-thread.c     | 238 ++++++++++++++-----------------------------
 gdb/config.in        |   4 -
 gdb/configure        |  16 ---
 gdb/configure.ac     |   5 -
 gdb/rs6000-aix-nat.c |  47 +--------
 5 files changed, 80 insertions(+), 230 deletions(-)

diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index 5ac71d22237..b74540c1a8f 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -1,4 +1,4 @@
-/* Low level interface for debugging AIX 4.3+ pthreads.
+/* Low level interface for debugging AIX 7.2+ pthreads.
 
    Copyright (C) 1999-2026 Free Software Foundation, Inc.
    Written by Nick Duffek <nsd@redhat.com>.
@@ -19,7 +19,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
-/* This module uses the libpthdebug.a library provided by AIX 4.3+ for
+/* This module uses the libpthdebug.a library provided by AIX 7.2+ for
    debugging pthread applications.
 
    Some name prefix conventions:
@@ -56,18 +56,9 @@
 #include <sys/pthdebug.h>
 #include <unordered_set>
 
-#if !HAVE_DECL_GETTHRDS
-extern int getthrds (pid_t, struct thrdsinfo64 *, int, tid_t *, int);
-#endif
-
 /* Whether to emit debugging output.  */
 static bool debug_aix_thread;
 
-/* In AIX 5.1, functions use pthdb_tid_t instead of tid_t.  */
-#ifndef PTHDB_VERSION_3
-#define pthdb_tid_t	tid_t
-#endif
-
 /* Success and failure values returned by pthdb callbacks.  */
 
 #define PDC_SUCCESS	PTHDB_SUCCESS
@@ -315,40 +306,13 @@ ptrace_check (int req, int id, int ret)
   return 0;  /* Not reached.  */
 }
 
-/* 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
+/* Call ptrace64 (REQ, ID, ADDR, DATA, BUF).  Return success.  */
 
 static int
-ptrace64aix (int req, int id, long long addr, int data, int *buf)
+ptraceaix (int req, int id, long long addr, int data, int *buf)
 {
   errno = 0;
-  return ptrace_check (req, id, ptracex (req, id, addr, data, buf));
-}
-
-/* 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, addr_ptr addr, int data, int *buf)
-{
-  errno = 0;
-  return ptrace_check (req, id,
-		       ptrace (req, id, addr, data, buf));
+  return ptrace_check (req, id, ptrace64 (req, id, addr, data, buf));
 }
 
 /* If *PIDP is a composite process/thread id, convert it to a
@@ -444,23 +408,26 @@ pdc_read_regs (pthdb_user_t user_current_pid,
     {
       if (data->arch64)
 	{
-	  if (!ptrace64aix (PTT_READ_GPRS, tid,
-			    (unsigned long) gprs64, 0, NULL))
+	  if (!ptraceaix (PTT_READ_GPRS, tid,
+			  (unsigned long) gprs64, 0, NULL))
 	    memset (gprs64, 0, sizeof (gprs64));
-	  memcpy (context->gpr, gprs64, sizeof(gprs64));
+	  memcpy (context->gpr, gprs64, sizeof (gprs64));
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_GPRS, tid, (uintptr_t) gprs32, 0, NULL))
+	  if (!ptraceaix (PTT_READ_GPRS, tid, (uintptr_t) gprs32, 0, NULL))
 	    memset (gprs32, 0, sizeof (gprs32));
-	  memcpy (context->gpr, gprs32, sizeof(gprs32));
+	  /* context->gpr is uint64_t[]; zero-extend each 32-bit register
+	     value rather than copying raw bytes.  */
+	  for (int i = 0; i < ppc_num_gprs; i++)
+	    context->gpr[i] = gprs32[i];
 	}
     }
 
   /* Floating-point registers.  */
   if (flags & PTHDB_FLAG_FPRS)
     {
-      if (!ptrace32 (PTT_READ_FPRS, tid, (uintptr_t) fprs, 0, NULL))
+      if (!ptraceaix (PTT_READ_FPRS, tid, (uintptr_t) fprs, 0, NULL))
 	memset (fprs, 0, sizeof (fprs));
       memcpy (context->fpr, fprs, sizeof(fprs));
     }
@@ -470,14 +437,14 @@ pdc_read_regs (pthdb_user_t user_current_pid,
     {
       if (data->arch64)
 	{
-	  if (!ptrace64aix (PTT_READ_SPRS, tid,
+	  if (!ptraceaix (PTT_READ_SPRS, tid,
 			    (unsigned long) &sprs64, 0, NULL))
 	    memset (&sprs64, 0, sizeof (sprs64));
 	  memcpy (&context->msr, &sprs64, sizeof(sprs64));
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_SPRS, tid, (uintptr_t) &sprs32, 0, NULL))
+	  if (!ptraceaix (PTT_READ_SPRS, tid, (uintptr_t) &sprs32, 0, NULL))
 	    memset (&sprs32, 0, sizeof (sprs32));
 	  memcpy (&context->msr, &sprs32, sizeof(sprs32));
 	}
@@ -487,36 +454,18 @@ pdc_read_regs (pthdb_user_t user_current_pid,
   __vmx_context_t vmx;
   if (__power_vmx() && (flags & PTHDB_FLAG_REGS))
     {
-      if (data->arch64)
-	{
-	  if (!ptrace64aix (PTT_READ_VEC, tid, (long long) &vmx, 0, 0))
-	    memset (&vmx, 0, sizeof (vmx));
-	  memcpy (&context->vmx, &vmx, sizeof(__vmx_context_t));
-	}
-      else
-	{
-	  if (!ptrace32 (PTT_READ_VEC, tid, (long long) &vmx, 0, 0))
-	    memset (&vmx, 0, sizeof (vmx));
-	   memcpy (&context->vmx, &vmx, sizeof(__vmx_context_t));
-	}
+      if (!ptraceaix (PTT_READ_VEC, tid, (long long) &vmx, 0, 0))
+	memset (&vmx, 0, sizeof (vmx));
+      memcpy (&context->vmx, &vmx, sizeof (__vmx_context_t));
     }
 
   /* vsx registers.  */
   __vsx_context_t vsx;
   if (__power_vsx() && (flags & PTHDB_FLAG_REGS))
     {
-      if (data->arch64)
-	{
-	  if (!ptrace64aix (PTT_READ_VSX, tid, (long long) &vsx, 0, 0))
-	    memset (&vsx, 0, sizeof (vsx));
-	  memcpy (&context->vsx, &vsx, sizeof(__vsx_context_t));
-	}
-      else
-	{
-	  if (!ptrace32 (PTT_READ_VSX, tid, (long long) &vsx, 0, 0))
-	    memset (&vsx, 0, sizeof (vsx));
-	  memcpy (&context->vsx, &vsx, sizeof(__vsx_context_t));
-	}
+      if (!ptraceaix (PTT_READ_VSX, tid, (long long) &vsx, 0, 0))
+	memset (&vsx, 0, sizeof (vsx));
+      memcpy (&context->vsx, &vsx, sizeof (__vsx_context_t));
     }
   return 0;
 }
@@ -549,49 +498,33 @@ pdc_write_regs (pthdb_user_t user_current_pid,
   if (flags & PTHDB_FLAG_GPRS)
     {
       if (data->arch64)
-	ptrace64aix (PTT_WRITE_GPRS, tid,
-		     (unsigned long) context->gpr, 0, NULL);
+	ptraceaix (PTT_WRITE_GPRS, tid, (long long) context->gpr, 0, NULL);
       else
-	ptrace32 (PTT_WRITE_GPRS, tid, (uintptr_t) context->gpr, 0, NULL);
+	{
+	  /* PTT_WRITE_GPRS for a 32-bit inferior expects a uint32_t array;
+	     truncate each 64-bit context register to 32 bits.  */
+	  uint32_t gprs32[ppc_num_gprs];
+	  for (int i = 0; i < ppc_num_gprs; i++)
+	    gprs32[i] = (uint32_t) context->gpr[i];
+	  ptraceaix (PTT_WRITE_GPRS, tid, (uintptr_t) gprs32, 0, NULL);
+	}
     }
 
- /* Floating-point registers.  */
+  /* Floating-point registers.  */
   if (flags & PTHDB_FLAG_FPRS)
-    {
-      ptrace32 (PTT_WRITE_FPRS, tid, (uintptr_t) context->fpr, 0, NULL);
-    }
+    ptraceaix (PTT_WRITE_FPRS, tid, (long long) context->fpr, 0, NULL);
 
   /* Special-purpose registers.  */
   if (flags & PTHDB_FLAG_SPRS)
-    {
-      if (data->arch64)
-	{
-	  ptrace64aix (PTT_WRITE_SPRS, tid,
-		       (unsigned long) &context->msr, 0, NULL);
-	}
-      else
-	{
-	  ptrace32 (PTT_WRITE_SPRS, tid, (uintptr_t) &context->msr, 0, NULL);
-	}
-    }
+    ptraceaix (PTT_WRITE_SPRS, tid, (long long) &context->msr, 0, NULL);
 
   /* vector registers.  */
   if (__power_vmx() && (flags & PTHDB_FLAG_REGS))
-    {
-      if (data->arch64)
-	ptrace64aix (PTT_WRITE_VEC, tid, (unsigned long) &context->vmx, 0, 0);
-      else
-	ptrace32 (PTT_WRITE_VEC, tid, (uintptr_t) &context->vmx, 0, 0);
-    }
+    ptraceaix (PTT_WRITE_VEC, tid, (long long) &context->vmx, 0, 0);
 
   /* vsx registers.  */
   if (__power_vsx() && (flags & PTHDB_FLAG_REGS))
-    {
-      if (data->arch64)
-	ptrace64aix (PTT_WRITE_VSX, tid, (unsigned long) &context->vsx, 0, 0);
-      else
-	ptrace32 (PTT_WRITE_VSX, tid, (uintptr_t) &context->vsx, 0, 0);
-    }
+    ptraceaix (PTT_WRITE_VSX, tid, (long long) &context->vsx, 0, 0);
   return 0;
 }
 
@@ -1078,12 +1011,8 @@ aix_thread_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
 	       ptid.lwp ());
       tid[1] = 0;
 
-      if (data->arch64)
-	ptrace64aix (PTT_CONTINUE, tid[0], (long long) 1,
-		     gdb_signal_to_host (sig), (PTRACE_TYPE_ARG5) tid);
-      else
-	ptrace32 (PTT_CONTINUE, tid[0], (addr_ptr) 1,
-		  gdb_signal_to_host (sig), (PTRACE_TYPE_ARG5) tid);
+      ptraceaix (PTT_CONTINUE, tid[0], (long long) 1,
+		 gdb_signal_to_host (sig), (PTRACE_TYPE_ARG5) tid);
     }
 }
 
@@ -1357,14 +1286,14 @@ fetch_regs_kernel_thread (struct regcache *regcache, int regno,
     {
       if (data->arch64)
 	{
-	  if (!ptrace64aix (PTT_READ_GPRS, tid,
+	  if (!ptraceaix (PTT_READ_GPRS, tid,
 			    (unsigned long) gprs64, 0, NULL))
 	    memset (gprs64, 0, sizeof (gprs64));
 	  supply_gprs64 (regcache, gprs64);
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_GPRS, tid, (uintptr_t) gprs32, 0, NULL))
+	  if (!ptraceaix (PTT_READ_GPRS, tid, (uintptr_t) 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]);
@@ -1377,9 +1306,9 @@ fetch_regs_kernel_thread (struct regcache *regcache, int regno,
       int ret = 0;
       __vmx_context_t vmx;
       if (data->arch64)
-	ret = ptrace64aix (PTT_READ_VEC, tid, (long long) &vmx, 0, 0);
+	ret = ptraceaix (PTT_READ_VEC, tid, (long long) &vmx, 0, 0);
       else
-	ret = ptrace32 (PTT_READ_VEC, tid, (uintptr_t) &vmx, 0, 0);
+	ret = ptraceaix (PTT_READ_VEC, tid, (uintptr_t) &vmx, 0, 0);
       if (ret < 0)
 	memset(&vmx, 0, sizeof(__vmx_context_t));
       for (i = 0; i < ppc_num_vrs; i++)
@@ -1394,9 +1323,9 @@ fetch_regs_kernel_thread (struct regcache *regcache, int regno,
       __vsx_context_t vsx;
       int ret = 0;
       if (data->arch64)
-	ret = ptrace64aix (PTT_READ_VSX, tid, (long long) &vsx, 0, 0);
+	ret = ptraceaix (PTT_READ_VSX, tid, (long long) &vsx, 0, 0);
       else
-	ret = ptrace32 (PTT_READ_VSX, tid, (long long) &vsx, 0, 0);
+	ret = ptraceaix (PTT_READ_VSX, tid, (uintptr_t) &vsx, 0, 0);
       if (ret < 0)
 	memset(&vsx, 0, sizeof(__vsx_context_t));
       for (i = 0; i < ppc_num_vshrs; i++)
@@ -1410,7 +1339,7 @@ fetch_regs_kernel_thread (struct regcache *regcache, int regno,
 	  || (regno >= tdep->ppc_fp0_regnum
 	      && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
     {
-      if (!ptrace32 (PTT_READ_FPRS, tid, (uintptr_t) fprs, 0, NULL))
+      if (!ptraceaix (PTT_READ_FPRS, tid, (uintptr_t) fprs, 0, NULL))
 	memset (fprs, 0, sizeof (fprs));
       supply_fprs (regcache, fprs);
     }
@@ -1421,7 +1350,7 @@ fetch_regs_kernel_thread (struct regcache *regcache, int regno,
     {
       if (data->arch64)
 	{
-	  if (!ptrace64aix (PTT_READ_SPRS, tid,
+	  if (!ptraceaix (PTT_READ_SPRS, tid,
 			    (unsigned long) &sprs64, 0, NULL))
 	    memset (&sprs64, 0, sizeof (sprs64));
 	  supply_sprs64 (regcache, sprs64.pt_iar, sprs64.pt_msr,
@@ -1430,7 +1359,7 @@ fetch_regs_kernel_thread (struct regcache *regcache, int regno,
 	}
       else
 	{
-	  if (!ptrace32 (PTT_READ_SPRS, tid, (uintptr_t) &sprs32, 0, NULL))
+	  if (!ptraceaix (PTT_READ_SPRS, tid, (uintptr_t) &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,
@@ -1678,9 +1607,9 @@ store_regs_user_thread (const struct regcache *regcache, pthdb_pthread_t pdtid)
     {
       memset(&vsx, 0, sizeof(__vsx_context_t));
       for (i = 0; i < ppc_num_vshrs; i++)
-	if (REG_VALID == regcache->get_register_status (tdep->ppc_vsr0_regnum + i))
+	if (REG_VALID == regcache->get_register_status (tdep->ppc_vsr0_upper_regnum + i))
 	  {
-	    regcache->raw_collect (tdep->ppc_vr0_regnum + i,
+	    regcache->raw_collect (tdep->ppc_vsr0_upper_regnum + i,
 				   &(vsx.__vsr_dw1[i]));
 	    ctx.vsx.__vsr_dw1[i] = vsx.__vsr_dw1[i];
 	  }
@@ -1735,7 +1664,8 @@ store_regs_user_thread (const struct regcache *regcache, pthdb_pthread_t pdtid)
 	ctx.ctr = tmp_ctr;
       if (REG_VALID == regcache->get_register_status (tdep->ppc_xer_regnum))
 	ctx.xer = tmp_xer;
-      if (REG_VALID == regcache->get_register_status (tdep->ppc_xer_regnum))
+      if (tdep->ppc_fpscr_regnum >= 0
+	  && REG_VALID == regcache->get_register_status (tdep->ppc_fpscr_regnum))
 	ctx.fpscr = tmp_fpscr;
     }
 
@@ -1778,21 +1708,21 @@ store_regs_kernel_thread (const struct regcache *regcache, int regno,
   /* General-purpose registers.  */
   if (regno == -1
       || (tdep->ppc_gp0_regnum <= regno
-	  && regno < tdep->ppc_gp0_regnum + ppc_num_fprs))
+	  && regno < tdep->ppc_gp0_regnum + ppc_num_gprs))
     {
       if (data->arch64)
 	{
 	  /* Pre-fetch: some regs may not be in the cache.  */
-	  ptrace64aix (PTT_READ_GPRS, tid, (unsigned long) gprs64, 0, NULL);
+	  ptraceaix (PTT_READ_GPRS, tid, (unsigned long) gprs64, 0, NULL);
 	  fill_gprs64 (regcache, gprs64);
-	  ptrace64aix (PTT_WRITE_GPRS, tid, (unsigned long) gprs64, 0, NULL);
+	  ptraceaix (PTT_WRITE_GPRS, tid, (unsigned long) gprs64, 0, NULL);
 	}
       else
 	{
 	  /* Pre-fetch: some regs may not be in the cache.  */
-	  ptrace32 (PTT_READ_GPRS, tid, (uintptr_t) gprs32, 0, NULL);
+	  ptraceaix (PTT_READ_GPRS, tid, (uintptr_t) gprs32, 0, NULL);
 	  fill_gprs32 (regcache, gprs32);
-	  ptrace32 (PTT_WRITE_GPRS, tid, (uintptr_t) gprs32, 0, NULL);
+	  ptraceaix (PTT_WRITE_GPRS, tid, (uintptr_t) gprs32, 0, NULL);
 	}
     }
 
@@ -1804,9 +1734,9 @@ store_regs_kernel_thread (const struct regcache *regcache, int regno,
 	      && regno < tdep->ppc_fp0_regnum + ppc_num_fprs)))
     {
       /* Pre-fetch: some regs may not be in the cache.  */
-      ptrace32 (PTT_READ_FPRS, tid, (uintptr_t) fprs, 0, NULL);
+      ptraceaix (PTT_READ_FPRS, tid, (uintptr_t) fprs, 0, NULL);
       fill_fprs (regcache, fprs);
-      ptrace32 (PTT_WRITE_FPRS, tid, (uintptr_t) fprs, 0, NULL);
+      ptraceaix (PTT_WRITE_FPRS, tid, (uintptr_t) fprs, 0, NULL);
     }
 
   /* Special-purpose registers.  */
@@ -1816,47 +1746,29 @@ store_regs_kernel_thread (const struct regcache *regcache, int regno,
       if (data->arch64)
 	{
 	  /* Pre-fetch: some registers won't be in the cache.  */
-	  ptrace64aix (PTT_READ_SPRS, tid,
-		       (unsigned long) &sprs64, 0, NULL);
+	  ptraceaix (PTT_READ_SPRS, tid,
+		     (unsigned long) &sprs64, 0, NULL);
 	  fill_sprs64 (regcache, &sprs64.pt_iar, &sprs64.pt_msr,
 		       &sprs64.pt_cr, &sprs64.pt_lr, &sprs64.pt_ctr,
 		       &sprs64.pt_xer, &sprs64.pt_fpscr);
-	  ptrace64aix (PTT_WRITE_SPRS, tid,
-		       (unsigned long) &sprs64, 0, NULL);
+	  ptraceaix (PTT_WRITE_SPRS, tid,
+		     (unsigned long) &sprs64, 0, NULL);
 	}
       else
 	{
-	  /* The contents of "struct ptspr" were declared as "unsigned
-	     long" up to AIX 5.2, but are "unsigned int" since 5.3.
-	     Use temporaries to work around this problem.  Also, add an
-	     assert here to make sure we fail if the system header files
-	     use "unsigned long", and the size of that type is not what
-	     the headers expect.  */
-	  uint32_t tmp_iar, tmp_msr, tmp_cr, tmp_lr, tmp_ctr, tmp_xer,
-		   tmp_fpscr;
-
-	  gdb_assert (sizeof (sprs32.pt_iar) == 4);
-
 	  /* Pre-fetch: some registers won't be in the cache.  */
-	  ptrace32 (PTT_READ_SPRS, tid, (uintptr_t) &sprs32, 0, NULL);
-
-	  fill_sprs32 (regcache, &tmp_iar, &tmp_msr, &tmp_cr, &tmp_lr,
-		       &tmp_ctr, &tmp_xer, &tmp_fpscr);
+	  ptraceaix (PTT_READ_SPRS, tid, (uintptr_t) &sprs32, 0, NULL);
 
-	  sprs32.pt_iar = tmp_iar;
-	  sprs32.pt_msr = tmp_msr;
-	  sprs32.pt_cr = tmp_cr;
-	  sprs32.pt_lr = tmp_lr;
-	  sprs32.pt_ctr = tmp_ctr;
-	  sprs32.pt_xer = tmp_xer;
-	  sprs32.pt_fpscr = tmp_fpscr;
+	  fill_sprs32 (regcache, &sprs32.pt_iar, &sprs32.pt_msr,
+		       &sprs32.pt_cr, &sprs32.pt_lr, &sprs32.pt_ctr,
+		       &sprs32.pt_xer, &sprs32.pt_fpscr);
 
 	  if (tdep->ppc_mq_regnum >= 0)
 	    if (REG_VALID == regcache->get_register_status
 			       (tdep->ppc_mq_regnum))
 	      regcache->raw_collect (tdep->ppc_mq_regnum, &sprs32.pt_mq);
 
-	  ptrace32 (PTT_WRITE_SPRS, tid, (uintptr_t) &sprs32, 0, NULL);
+	  ptraceaix (PTT_WRITE_SPRS, tid, (uintptr_t) &sprs32, 0, NULL);
 	}
     }
 
@@ -1869,16 +1781,16 @@ store_regs_kernel_thread (const struct regcache *regcache, int regno,
 	if (__power_vmx())
 	  {
 	    if (data->arch64)
-	      ret = ptrace64aix (PTT_READ_VEC, tid, (long long) &vmx, 0, 0);
+	      ret = ptraceaix (PTT_READ_VEC, tid, (long long) &vmx, 0, 0);
 	    else
-	      ret = ptrace32 (PTT_READ_VEC, tid, (long long) &vmx, 0, 0);
+	      ret = ptraceaix (PTT_READ_VEC, tid, (uintptr_t) &vmx, 0, 0);
 	    if (ret > 0)
 	      {
 		fill_altivec(regcache, &vmx);
 		if (data->arch64)
-		  ret = ptrace64aix (PTT_WRITE_VEC, tid, (long long) &vmx, 0, 0);
+		  ret = ptraceaix (PTT_WRITE_VEC, tid, (long long) &vmx, 0, 0);
 		else
-		  ret = ptrace32 (PTT_WRITE_VEC, tid, (long long) &vmx, 0, 0);
+		  ret = ptraceaix (PTT_WRITE_VEC, tid, (uintptr_t) &vmx, 0, 0);
 		if (ret < 0)
 		  perror_with_name (_("Unable to store AltiVec register after read"));
 	      }
@@ -1894,16 +1806,16 @@ store_regs_kernel_thread (const struct regcache *regcache, int regno,
 	if (__power_vsx())
 	  {
 	    if (data->arch64)
-	      ret =  ptrace64aix (PTT_READ_VSX, tid, (long long) &vsx, 0, 0);
+	      ret =  ptraceaix (PTT_READ_VSX, tid, (long long) &vsx, 0, 0);
 	    else
-	      ret =  ptrace32 (PTT_READ_VSX, tid, (long long) &vsx, 0, 0);
+	      ret =  ptraceaix (PTT_READ_VSX, tid, (uintptr_t) &vsx, 0, 0);
 	    if (ret > 0)
 	      {
 		fill_vsx (regcache, &vsx);
 		if (data->arch64)
-		  ret = ptrace64aix (PTT_WRITE_VSX, tid, (long long) &vsx, 0, 0);
+		  ret = ptraceaix (PTT_WRITE_VSX, tid, (long long) &vsx, 0, 0);
 		else
-		  ret = ptrace32 (PTT_WRITE_VSX, tid, (long long) &vsx, 0, 0);
+		  ret = ptraceaix (PTT_WRITE_VSX, tid, (uintptr_t) &vsx, 0, 0);
 		if (ret < 0)
 		  perror_with_name (_("Unable to store VSX register after read"));
 	      }
diff --git a/gdb/config.in b/gdb/config.in
index 74745665d4d..b68cc29d587 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -147,10 +147,6 @@
 /* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */
 #undef HAVE_DECL_FFS
 
-/* Define to 1 if you have the declaration of `getthrds', and to 0 if you
-   don't. */
-#undef HAVE_DECL_GETTHRDS
-
 /* Define to 1 if you have the declaration of `snprintf', and to 0 if you
    don't. */
 #undef HAVE_DECL_SNPRINTF
diff --git a/gdb/configure b/gdb/configure
index f411113ea66..0ed570e0571 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -31138,22 +31138,6 @@ $as_echo "$gdb_cv_have_aix_thread_debug" >&6; }
 	 CONFIG_SRCS="${CONFIG_SRCS} aix-thread.c"
 	 CONFIG_OBS="${CONFIG_OBS} aix-thread.o"
 	 LIBS="$LIBS -lpthdebug"
-
-	 # Older versions of AIX do not provide the declaration for
-	 # the getthrds function (it appears that it was introduced
-	 # with AIX 6.x).
-	 ac_fn_c_check_decl "$LINENO" "getthrds" "ac_cv_have_decl_getthrds" "#include <procinfo.h>
-"
-if test "x$ac_cv_have_decl_getthrds" = xyes; then :
-  ac_have_decl=1
-else
-  ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_GETTHRDS $ac_have_decl
-_ACEOF
-
       fi
       ;;
    esac
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 5d8e2d6628f..20d4bef68d4 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1914,11 +1914,6 @@ if test "${build}" = "${host}" -a "${host}" = "${target}" ; then
 	 CONFIG_SRCS="${CONFIG_SRCS} aix-thread.c"
 	 CONFIG_OBS="${CONFIG_OBS} aix-thread.o"
 	 LIBS="$LIBS -lpthdebug"
-
-	 # Older versions of AIX do not provide the declaration for
-	 # the getthrds function (it appears that it was introduced
-	 # with AIX 6.x).
-	 AC_CHECK_DECLS(getthrds, [], [], [[#include <procinfo.h>]])
       fi
       ;;
    esac
diff --git a/gdb/rs6000-aix-nat.c b/gdb/rs6000-aix-nat.c
index 276df378824..ada24b19779 100644
--- a/gdb/rs6000-aix-nat.c
+++ b/gdb/rs6000-aix-nat.c
@@ -60,24 +60,9 @@
 /* Header files for alti-vec reg.  */
 #include <sys/context.h>
 
-/* On AIX4.3+, sys/ldr.h provides different versions of struct ld_info for
-   debugging 32-bit and 64-bit processes.  Define a typedef and macros for
-   accessing fields in the appropriate structures.  */
-
-/* In 32-bit compilation mode (which is the only mode from which ptrace()
-   works on 4.3), __ld_info32 is #defined as equivalent to ld_info.  */
-
-#if defined (__ld_info32) || defined (__ld_info64)
-# define ARCH3264
-#endif
-
 /* Return whether the current architecture is 64-bit.  */
 
-#ifndef ARCH3264
-# define ARCH64() 0
-#else
-# define ARCH64() (register_size (current_inferior ()->arch (), 0) == 8)
-#endif
+#define ARCH64() (register_size (current_inferior ()->arch (), 0) == 8)
 
 class rs6000_nat_target final : public inf_ptrace_target
 {
@@ -246,42 +231,20 @@ regmap (struct gdbarch *gdbarch, int regno, int *isfloat)
     return -1;
 }
 
-/* Call ptrace(REQ, ID, ADDR, DATA, BUF).  */
+/* Call ptrace64(REQ, ID, ADDR, DATA, BUF).  */
 
 static int
 rs6000_ptrace32 (int req, int id, int *addr, int data, int *buf)
 {
-#ifdef HAVE_PTRACE64
-  int ret = ptrace64 (req, id, (uintptr_t) addr, data, buf);
-#else
-  int ret = ptrace (req, id, (int *)addr, data, buf);
-#endif
-#if 0
-  printf ("rs6000_ptrace32 (%d, %d, 0x%x, %08x, 0x%x) = 0x%x\n",
-	  req, id, (unsigned int)addr, data, (unsigned int)buf, ret);
-#endif
-  return ret;
+  return ptrace64 (req, id, (uintptr_t) addr, data, buf);
 }
 
-/* Call ptracex(REQ, ID, ADDR, DATA, BUF).  */
+/* Call ptrace64(REQ, ID, ADDR, DATA, BUF).  */
 
 static int
 rs6000_ptrace64 (int req, int id, long long addr, int data, void *buf)
 {
-#ifdef ARCH3264
-#  ifdef HAVE_PTRACE64
-  int ret = ptrace64 (req, id, addr, data, (PTRACE_TYPE_ARG5) buf);
-#  else
-  int ret = ptracex (req, id, addr, data, (PTRACE_TYPE_ARG5) buf);
-#  endif
-#else
-  int ret = 0;
-#endif
-#if 0
-  printf ("rs6000_ptrace64 (%d, %d, %s, %08x, 0x%x) = 0x%x\n",
-	  req, id, hex_string (addr), data, (unsigned int)buf, ret);
-#endif
-  return ret;
+  return ptrace64 (req, id, addr, data, (PTRACE_TYPE_ARG5) buf);
 }
 
 /* Store the vsx registers.  */
-- 
2.51.2


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

* Re: [PATCH v3] Remove stale pre-AIX-7.2 compatibility guards
  2026-09-22  4:52 [PATCH v3] Remove stale pre-AIX-7.2 compatibility guards Aditya Vidyadhar Kamath
@ 2026-09-22 19:58 ` Simon Marchi
  2026-09-23 12:53   ` Ulrich Weigand
  2026-09-22 20:35 ` Simon Marchi
  1 sibling, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2026-09-22 19:58 UTC (permalink / raw)
  To: Aditya Vidyadhar Kamath, ulrich.weigand, tom
  Cc: gdb-patches, Aditya.Kamath1, sangamesh.swamy

On 9/22/26 12:52 AM, Aditya Vidyadhar Kamath wrote:
> From: Aditya Kamath <Aditya.Kamath1@ibm.com>
> 
> GDB now requires AIX 7.2 as the minimum supported version and will
> support AIX 7.2 TL5, AIX 7.3 and upcoming AIX releases.  Remove
> dead compatibility code that existed only for older releases.
> 
> Remove the HAVE_DECL_GETTHRDS configure check since aix-thread.c was the last
> user of that macro.  Merge ptrace64aix and ptrace32 into a single
> ptrace_aix function since they became identical after this
> cleanup, and collapse all call sites that branched on arch64 just to
> pick between the two.  Also clean up rs6000-aix-nat.c by removing the
> ARCH3264 and HAVE_PTRACE64 guards along with the ptracex fallback in
> rs6000_ptrace32 and rs6000_ptrace64, which are now simple wrappers
> around ptrace64.
> 
> Also as per https://www.ibm.com/docs/en/aix/7.2.0?topic=p-ptrace-ptracex-ptrace64-subroutine
> ptrace64 will also support 32-bit debugees.

On this page I see:

    For ptracex or ptrace64: If the debuggee is a 32-bit process, the
    options that refer to GPRs or SPRs fail with errno = EIO

And I see that in the patch, you call ptrace64 to read registers
(PTT_READ_GPRS) for 32 bit processes.  How does that work?

> @@ -315,40 +306,13 @@ ptrace_check (int req, int id, int ret)
>    return 0;  /* Not reached.  */
>  }
>  
> -/* 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
> +/* Call ptrace64 (REQ, ID, ADDR, DATA, BUF).  Return success.  */

I think that all these "Call ptrace64" comments are not very useful.  We
can see that by reading the code.  Change the comment to explain why
this wrapper function needs to exist (if it really does).

I think you could simplify this one further by moving the actual
ptrace64 call into ptrace_check (so that it does the ptrace call and the
check), and get rid of ptraceaix.  There is one level of abstraction
that is not needed anymore here.

If you only rely on ptrace64 now, I'd suggest changing the "id"
parameters to "long long", to match the type of ptrace64.

Otherwise, that looks fine to me.  I'll let Ulrich check the more
specific AIX details.

Simon

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

* Re: [PATCH v3] Remove stale pre-AIX-7.2 compatibility guards
  2026-09-22  4:52 [PATCH v3] Remove stale pre-AIX-7.2 compatibility guards Aditya Vidyadhar Kamath
  2026-09-22 19:58 ` Simon Marchi
@ 2026-09-22 20:35 ` Simon Marchi
  1 sibling, 0 replies; 5+ messages in thread
From: Simon Marchi @ 2026-09-22 20:35 UTC (permalink / raw)
  To: Aditya Vidyadhar Kamath, ulrich.weigand, tom
  Cc: gdb-patches, Aditya.Kamath1, sangamesh.swamy

On 9/22/26 12:52 AM, Aditya Vidyadhar Kamath wrote:
> From: Aditya Kamath <Aditya.Kamath1@ibm.com>
> 
> GDB now requires AIX 7.2 as the minimum supported version and will
> support AIX 7.2 TL5, AIX 7.3 and upcoming AIX releases.  Remove
> dead compatibility code that existed only for older releases.
> 
> Remove the HAVE_DECL_GETTHRDS configure check since aix-thread.c was the last
> user of that macro.  Merge ptrace64aix and ptrace32 into a single
> ptrace_aix function since they became identical after this
> cleanup, and collapse all call sites that branched on arch64 just to
> pick between the two.  Also clean up rs6000-aix-nat.c by removing the
> ARCH3264 and HAVE_PTRACE64 guards along with the ptracex fallback in
> rs6000_ptrace32 and rs6000_ptrace64, which are now simple wrappers
> around ptrace64.
> 
> Also as per https://www.ibm.com/docs/en/aix/7.2.0?topic=p-ptrace-ptracex-ptrace64-subroutine
> ptrace64 will also support 32-bit debugees.
> 
> In store_regs_user_thread we use ppc_vsr0_upper_regnum when checking validity
> and collecting the VSX upper-doubleword registers.
> 
> In store_regs_user_thread guard ctx.fpscr with ppc_fpscr_regnum instead of ppc_xer_regnum, and
> add the ppc_fpscr_regnum >= 0 check to match the 64-bit path.
> Use ppc_num_gprs instead of ppc_num_fprs in the GPR regno range check.

Sorry, I missed that last bit when reading the first time.  Are those
changed related to removing stale pre-AIX 7.2 code?  Or are they fixes
on their own?  If it's the latter, that should be a separate patch.

I also forgot, but I asked Claude to review this patch, it raised some
good points.  There is this one that sounds important, but I have no way
of checking if it's true:

  - The 32-bit SPR fix is only half done. If the GPR layout problem is
    being fixed in pdc_read_regs, the SPRs have the same problem. memcpy
    (&context->msr,   &sprs32, sizeof (sprs32)) (gdb/aix-thread.c:449)
    copies a struct ptsprs (32-bit fields) over the 64-bit fields of
    pthdb_context_t, and consumers read them field by field
    (supply_sprs32 (regcache, ctx.iar, ctx.msr, ...) at
    gdb/aix-thread.c:1236). pdc_write_regs has the reverse problem: it
    passes &context->msr to PTT_WRITE_SPRS for a 32-bit inferior
    (gdb/aix-thread.c:517). Either fix both in the same (separate)
    commit as the GPRs, or leave it all  for later, but don't do only
    half.

It also pointed out that there is a use of HAVE_PTRACE64 that can be
removed in nat/gdb_ptrace.h.

I wrote some more inline below.

> @@ -470,14 +437,14 @@ pdc_read_regs (pthdb_user_t user_current_pid,
>      {
>        if (data->arch64)
>  	{
> -	  if (!ptrace64aix (PTT_READ_SPRS, tid,
> +	  if (!ptraceaix (PTT_READ_SPRS, tid,
>  			    (unsigned long) &sprs64, 0, NULL))

The indent needs to be adjusted here.

> @@ -1357,14 +1286,14 @@ fetch_regs_kernel_thread (struct regcache *regcache, int regno,
>      {
>        if (data->arch64)
>  	{
> -	  if (!ptrace64aix (PTT_READ_GPRS, tid,
> +	  if (!ptraceaix (PTT_READ_GPRS, tid,
>  			    (unsigned long) gprs64, 0, NULL))

Indent needs to be fixed.

> @@ -1377,9 +1306,9 @@ fetch_regs_kernel_thread (struct regcache *regcache, int regno,
>        int ret = 0;
>        __vmx_context_t vmx;
>        if (data->arch64)
> -	ret = ptrace64aix (PTT_READ_VEC, tid, (long long) &vmx, 0, 0);
> +	ret = ptraceaix (PTT_READ_VEC, tid, (long long) &vmx, 0, 0);
>        else
> -	ret = ptrace32 (PTT_READ_VEC, tid, (uintptr_t) &vmx, 0, 0);
> +	ret = ptraceaix (PTT_READ_VEC, tid, (uintptr_t) &vmx, 0, 0);

Do we still need two separate ptraceaix calls here?

> @@ -1394,9 +1323,9 @@ fetch_regs_kernel_thread (struct regcache *regcache, int regno,
>        __vsx_context_t vsx;
>        int ret = 0;
>        if (data->arch64)
> -	ret = ptrace64aix (PTT_READ_VSX, tid, (long long) &vsx, 0, 0);
> +	ret = ptraceaix (PTT_READ_VSX, tid, (long long) &vsx, 0, 0);
>        else
> -	ret = ptrace32 (PTT_READ_VSX, tid, (long long) &vsx, 0, 0);
> +	ret = ptraceaix (PTT_READ_VSX, tid, (uintptr_t) &vsx, 0, 0);

And here?

> @@ -1421,7 +1350,7 @@ fetch_regs_kernel_thread (struct regcache *regcache, int regno,
>      {
>        if (data->arch64)
>  	{
> -	  if (!ptrace64aix (PTT_READ_SPRS, tid,
> +	  if (!ptraceaix (PTT_READ_SPRS, tid,
>  			    (unsigned long) &sprs64, 0, NULL))

Indent.

> @@ -1678,9 +1607,9 @@ store_regs_user_thread (const struct regcache *regcache, pthdb_pthread_t pdtid)
>      {
>        memset(&vsx, 0, sizeof(__vsx_context_t));
>        for (i = 0; i < ppc_num_vshrs; i++)
> -	if (REG_VALID == regcache->get_register_status (tdep->ppc_vsr0_regnum + i))
> +	if (REG_VALID == regcache->get_register_status (tdep->ppc_vsr0_upper_regnum + i))

This line is now too long.

> @@ -1869,16 +1781,16 @@ store_regs_kernel_thread (const struct regcache *regcache, int regno,
>  	if (__power_vmx())
>  	  {
>  	    if (data->arch64)
> -	      ret = ptrace64aix (PTT_READ_VEC, tid, (long long) &vmx, 0, 0);
> +	      ret = ptraceaix (PTT_READ_VEC, tid, (long long) &vmx, 0, 0);
>  	    else
> -	      ret = ptrace32 (PTT_READ_VEC, tid, (long long) &vmx, 0, 0);
> +	      ret = ptraceaix (PTT_READ_VEC, tid, (uintptr_t) &vmx, 0, 0);

And here?

> @@ -246,42 +231,20 @@ regmap (struct gdbarch *gdbarch, int regno, int *isfloat)
>      return -1;
>  }
>  
> -/* Call ptrace(REQ, ID, ADDR, DATA, BUF).  */
> +/* Call ptrace64(REQ, ID, ADDR, DATA, BUF).  */
>  
>  static int
>  rs6000_ptrace32 (int req, int id, int *addr, int data, int *buf)
>  {
> -#ifdef HAVE_PTRACE64
> -  int ret = ptrace64 (req, id, (uintptr_t) addr, data, buf);
> -#else
> -  int ret = ptrace (req, id, (int *)addr, data, buf);
> -#endif
> -#if 0
> -  printf ("rs6000_ptrace32 (%d, %d, 0x%x, %08x, 0x%x) = 0x%x\n",
> -	  req, id, (unsigned int)addr, data, (unsigned int)buf, ret);
> -#endif
> -  return ret;
> +  return ptrace64 (req, id, (uintptr_t) addr, data, buf);
>  }

Can the rs6000_ptrace32 and rs6000_ptrace64 wrappers be removed?

Simon

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

* Re: [PATCH v3] Remove stale pre-AIX-7.2 compatibility guards
  2026-09-22 19:58 ` Simon Marchi
@ 2026-09-23 12:53   ` Ulrich Weigand
  2026-09-23 13:40     ` Simon Marchi
  0 siblings, 1 reply; 5+ messages in thread
From: Ulrich Weigand @ 2026-09-23 12:53 UTC (permalink / raw)
  To: Simon Marchi, Aditya Vidyadhar Kamath, tom
  Cc: gdb-patches, Aditya Kamath, SANGAMESH MALLAYYA

Simon Marchi <simon.marchi@polymtl.ca> wrote:
>On 9/22/26 12:52 AM, Aditya Vidyadhar Kamath wrote:
> >From: Aditya Kamath <Aditya.Kamath1@ibm.com>
> >
> >GDB now requires AIX 7.2 as the minimum supported version and will
> >support AIX 7.2 TL5, AIX 7.3 and upcoming AIX releases.  Remove
> >dead compatibility code that existed only for older releases.
> >
> >Remove the HAVE_DECL_GETTHRDS configure check since aix-thread.c was
> >the last
> >user of that macro.  Merge ptrace64aix and ptrace32 into a single
> >ptrace_aix function since they became identical after this
> >cleanup, and collapse all call sites that branched on arch64 just to
> >pick between the two.  Also clean up rs6000-aix-nat.c by removing
> >the
> >ARCH3264 and HAVE_PTRACE64 guards along with the ptracex fallback in
> >rs6000_ptrace32 and rs6000_ptrace64, which are now simple wrappers
> >around ptrace64.
> >
> >Also as per >https://www.ibm.com/docs/en/aix/7.2.0?topic=p-ptrace-
> ptracex-ptrace6>4-subroutine 
> >ptrace64 will also support 32-bit debugees.
>
>On this page I see:
>
>    For ptracex or ptrace64: If the debuggee is a 32-bit process, the
>    options that refer to GPRs or SPRs fail with errno = EIO
>
>And I see that in the patch, you call ptrace64 to read registers
>(PTT_READ_GPRS) for 32 bit processes.  How does that work?

I think Simon is correct here.  For GPRS access, I understand only
the following options are supported:

ptrace: 32- or 64-bit GDB, 32-bit inferior
ptracex: 32-bit GDB, 64-bit inferior
ptrace64: 64-bit GDB, 64-bit inferior

As I understand, the current set of indirections is intended to
cover that space - for a 32-bit inferior, you call ptrace, and
for a 64-bit inferior you call either ptracex or ptrace64,
depending on whether GDB is built as 64-bit.

Why do you think we can simplify this?  I guess we could make
possibly make the assumption that GDB itself is always built
as 64-bit these days, but then we still have to select between
ptrace and ptrace64 at the least ...

Bye,
Ulrich

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

* Re: [PATCH v3] Remove stale pre-AIX-7.2 compatibility guards
  2026-09-23 12:53   ` Ulrich Weigand
@ 2026-09-23 13:40     ` Simon Marchi
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Marchi @ 2026-09-23 13:40 UTC (permalink / raw)
  To: Ulrich Weigand, Aditya Vidyadhar Kamath, tom
  Cc: gdb-patches, Aditya Kamath, SANGAMESH MALLAYYA

On 9/23/26 8:53 AM, Ulrich Weigand wrote:
> Simon Marchi <simon.marchi@polymtl.ca> wrote:
>> On 9/22/26 12:52 AM, Aditya Vidyadhar Kamath wrote:
>>> From: Aditya Kamath <Aditya.Kamath1@ibm.com>
>>>
>>> GDB now requires AIX 7.2 as the minimum supported version and will
>>> support AIX 7.2 TL5, AIX 7.3 and upcoming AIX releases.  Remove
>>> dead compatibility code that existed only for older releases.
>>>
>>> Remove the HAVE_DECL_GETTHRDS configure check since aix-thread.c was
>>> the last
>>> user of that macro.  Merge ptrace64aix and ptrace32 into a single
>>> ptrace_aix function since they became identical after this
>>> cleanup, and collapse all call sites that branched on arch64 just to
>>> pick between the two.  Also clean up rs6000-aix-nat.c by removing
>>> the
>>> ARCH3264 and HAVE_PTRACE64 guards along with the ptracex fallback in
>>> rs6000_ptrace32 and rs6000_ptrace64, which are now simple wrappers
>>> around ptrace64.
>>>
>>> Also as per >https://www.ibm.com/docs/en/aix/7.2.0?topic=p-ptrace-
>> ptracex-ptrace6>4-subroutine 
>>> ptrace64 will also support 32-bit debugees.
>>
>> On this page I see:
>>
>>     For ptracex or ptrace64: If the debuggee is a 32-bit process, the
>>     options that refer to GPRs or SPRs fail with errno = EIO
>>
>> And I see that in the patch, you call ptrace64 to read registers
>> (PTT_READ_GPRS) for 32 bit processes.  How does that work?
> 
> I think Simon is correct here.  For GPRS access, I understand only
> the following options are supported:
> 
> ptrace: 32- or 64-bit GDB, 32-bit inferior
> ptracex: 32-bit GDB, 64-bit inferior
> ptrace64: 64-bit GDB, 64-bit inferior
> 
> As I understand, the current set of indirections is intended to
> cover that space - for a 32-bit inferior, you call ptrace, and
> for a 64-bit inferior you call either ptracex or ptrace64,
> depending on whether GDB is built as 64-bit.

Ideally, we wouldn't just guess.  Do you run the testsuite on AIX?  If
so, you should be able to run it in a mode that builds the test programs
as 32-bit programs.  For example:

  $ make check RUNTESTFLAGS='--target_board "unix/-m32"

Taken from:

  https://sourceware.org/gdb/wiki/TestingGDB#Changing_the_compiler_used_to_build_the_testcases

> Why do you think we can simplify this?  I guess we could make
> possibly make the assumption that GDB itself is always built
> as 64-bit these days, but then we still have to select between
> ptrace and ptrace64 at the least ...

I think that requiring GDB to be built as 64-bit program would be
reasonable (if so you should add a static check in the source for that).

Simon

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

end of thread, other threads:[~2026-09-23 13:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-22  4:52 [PATCH v3] Remove stale pre-AIX-7.2 compatibility guards Aditya Vidyadhar Kamath
2026-09-22 19:58 ` Simon Marchi
2026-09-23 12:53   ` Ulrich Weigand
2026-09-23 13:40     ` Simon Marchi
2026-09-22 20:35 ` Simon Marchi

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