2004-06-07 Randolph Chung <tausq@debian.org>
[deliverable/binutils-gdb.git] / gdb / aix-thread.c
index dcaa3fbab70b4986fb58717955b146e2b3118f99..05493ae0f9885eb7b9c22083df0f64735fc3e866 100644 (file)
@@ -50,6 +50,7 @@
 #include "gdbcmd.h"
 #include "language.h"          /* for local_hex_string() */
 #include "ppc-tdep.h"
+#include "gdb_string.h"
 
 #include <procinfo.h>
 #include <sys/types.h>
@@ -338,9 +339,9 @@ pdc_read_regs (pthdb_user_t user,
    this is needed, I have implemented what I think it should do,
    however this code is untested.  */
 
-  uint64_t gprs64[32];
-  uint32_t gprs32[32];
-  double fprs[32];
+  uint64_t gprs64[ppc_num_gprs];
+  uint32_t gprs32[ppc_num_gprs];
+  double fprs[ppc_num_fprs];
   struct ptxsprs sprs64;
   struct ptsprs sprs32;
   
@@ -1001,10 +1002,11 @@ aix_thread_wait (ptid_t ptid, struct target_waitstatus *status)
 static void
 supply_gprs64 (uint64_t *vals)
 {
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
   int regno;
 
-  for (regno = 0; regno < 32; regno++)
-    supply_register (regno, (char *) (vals + regno));
+  for (regno = 0; regno < ppc_num_gprs; regno++)
+    supply_register (tdep->ppc_gp0_regnum + regno, (char *) (vals + regno));
 }
 
 /* Record that 32-bit register REGNO contains VAL.  */
@@ -1025,9 +1027,9 @@ supply_fprs (double *vals)
 
   /* This function should never be called on architectures without
      floating-point registers.  */
-  gdb_assert (ppc_floating_point_p (current_gdbarch));
+  gdb_assert (ppc_floating_point_unit_p (current_gdbarch));
 
-  for (regno = 0; regno < 32; regno++)
+  for (regno = 0; regno < ppc_num_fprs; regno++)
     supply_register (regno + tdep->ppc_fp0_regnum, (char *) (vals + regno));
 }
 
@@ -1098,6 +1100,7 @@ supply_sprs32 (uint32_t iar, uint32_t msr, uint32_t cr,
 static void
 fetch_regs_user_thread (pthdb_pthread_t pdtid)
 {
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
   int status, i;
   pthdb_context_t ctx;
 
@@ -1114,12 +1117,12 @@ fetch_regs_user_thread (pthdb_pthread_t pdtid)
   if (arch64)
     supply_gprs64 (ctx.gpr);
   else
-    for (i = 0; i < 32; i++)
-      supply_reg32 (i, ctx.gpr[i]);
+    for (i = 0; i < ppc_num_gprs; i++)
+      supply_reg32 (tdep->ppc_gp0_regnum + i, ctx.gpr[i]);
 
   /* Floating-point registers.  */
 
-  if (ppc_floating_point_p (current_gdbarch))
+  if (ppc_floating_point_unit_p (current_gdbarch))
     supply_fprs (ctx.fpr);
 
   /* Special registers.  */
@@ -1151,9 +1154,9 @@ static void
 fetch_regs_kernel_thread (int regno, pthdb_tid_t tid)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
-  uint64_t gprs64[32];
-  uint32_t gprs32[32];
-  double fprs[32];
+  uint64_t gprs64[ppc_num_gprs];
+  uint32_t gprs32[ppc_num_gprs];
+  double fprs[ppc_num_fprs];
   struct ptxsprs sprs64;
   struct ptsprs sprs32;
   int i;
@@ -1179,8 +1182,8 @@ fetch_regs_kernel_thread (int regno, pthdb_tid_t tid)
        {
          if (!ptrace32 (PTT_READ_GPRS, tid, gprs32, 0, NULL))
            memset (gprs32, 0, sizeof (gprs32));
-         for (i = 0; i < 32; i++)
-           supply_reg32 (i, gprs32[i]);
+         for (i = 0; i < ppc_num_gprs; i++)
+           supply_reg32 (tdep->ppc_gp0_regnum + i, gprs32[i]);
        }
     }
 
@@ -1281,7 +1284,7 @@ fill_fprs (double *vals)
 
   /* This function should never be called on architectures without
      floating-point registers.  */
-  gdb_assert (ppc_floating_point_p (current_gdbarch));
+  gdb_assert (ppc_floating_point_unit_p (current_gdbarch));
 
   for (regno = tdep->ppc_fp0_regnum;
        regno < tdep->ppc_fp0_regnum + ppc_num_fprs;
@@ -1369,6 +1372,7 @@ fill_sprs32 (unsigned long *iar, unsigned long *msr, unsigned long *cr,
 static void
 store_regs_user_thread (pthdb_pthread_t pdtid)
 {
+  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
   int status, i;
   pthdb_context_t ctx;
   uint32_t int32;
@@ -1388,23 +1392,23 @@ store_regs_user_thread (pthdb_pthread_t pdtid)
 
   /* Collect general-purpose register values from the regcache.  */
 
-  for (i = 0; i < 32; i++)
-    if (register_cached (i))
+  for (i = 0; i < ppc_num_gprs; i++)
+    if (register_cached (tdep->ppc_gp0_regnum + i))
       {
        if (arch64)
          {
-           regcache_collect (i, (void *) &int64);
+           regcache_collect (tdep->ppc_gp0_regnum + i, (void *) &int64);
            ctx.gpr[i] = int64;
          }
        else
          {
-           regcache_collect (i, (void *) &int32);
+           regcache_collect (tdep->ppc_gp0_regnum + i, (void *) &int32);
            ctx.gpr[i] = int32;
          }
       }
 
   /* Collect floating-point register values from the regcache.  */
-  if (ppc_floating_point_p (current_gdbarch))
+  if (ppc_floating_point_unit_p (current_gdbarch))
     fill_fprs (ctx.fpr);
 
   /* Special registers (always kept in ctx as 64 bits).  */
@@ -1421,7 +1425,6 @@ store_regs_user_thread (pthdb_pthread_t pdtid)
         happens, GDB needs to be reconfigured so that longs are 32-bits.)  */
       unsigned long tmp_iar, tmp_msr, tmp_cr, tmp_lr, tmp_ctr, tmp_xer,
                     tmp_fpscr;
-      struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
 
       fill_sprs32 (&tmp_iar, &tmp_msr, &tmp_cr, &tmp_lr, &tmp_ctr, &tmp_xer,
                    &tmp_fpscr);
@@ -1459,13 +1462,12 @@ static void
 store_regs_kernel_thread (int regno, pthdb_tid_t tid)
 {
   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
-  uint64_t gprs64[32];
-  uint32_t gprs32[32];
-  double fprs[32];
+  uint64_t gprs64[ppc_num_gprs];
+  uint32_t gprs32[ppc_num_gprs];
+  double fprs[ppc_num_fprs];
   struct ptxsprs sprs64;
   struct ptsprs  sprs32;
   int i;
-  struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
 
   if (debug_aix_thread)
     fprintf_unfiltered (gdb_stdlog, 
This page took 0.02615 seconds and 4 git commands to generate.