2004-06-07 Randolph Chung <tausq@debian.org>
[deliverable/binutils-gdb.git] / gdb / ppc-linux-tdep.c
index 94c67f1a6fe287bc8123ec9d5e15f4c49fa7ed81..a7e58bcb5d7f0b3c457038803c50602511280e99 100644 (file)
@@ -860,8 +860,10 @@ ppc_linux_supply_gregset (struct regcache *regcache,
   struct gdbarch_tdep *regcache_tdep = gdbarch_tdep (regcache_arch);
   const bfd_byte *buf = gregs;
 
-  for (regi = 0; regi < 32; regi++)
-    right_supply_register (regcache, wordsize, regi, buf + wordsize * regi);
+  for (regi = 0; regi < ppc_num_gprs; regi++)
+    right_supply_register (regcache, wordsize,
+                           regcache_tdep->ppc_gp0_regnum + regi,
+                           buf + wordsize * regi);
 
   right_supply_register (regcache, wordsize, gdbarch_pc_regnum (regcache_arch),
                         buf + wordsize * PPC_LINUX_PT_NIP);
@@ -932,7 +934,7 @@ ppc_linux_sigtramp_cache (struct frame_info *next_frame, void **this_cache)
   fpregs = gpregs + 48 * tdep->wordsize;
 
   /* General purpose.  */
-  for (i = 0; i < 32; i++)
+  for (i = 0; i < ppc_num_gprs; i++)
     {
       int regnum = i + tdep->ppc_gp0_regnum;
       cache->saved_regs[regnum].addr = gpregs + i * tdep->wordsize;
@@ -944,12 +946,16 @@ ppc_linux_sigtramp_cache (struct frame_info *next_frame, void **this_cache)
   cache->saved_regs[tdep->ppc_cr_regnum].addr = gpregs + 38 * tdep->wordsize;
 
   /* Floating point registers.  */
-  for (i = 0; i < 32; i++)
+  if (ppc_floating_point_unit_p (gdbarch))
     {
-      int regnum = i + tdep->ppc_fp0_regnum;
-      cache->saved_regs[regnum].addr = fpregs + i * tdep->wordsize;
+      for (i = 0; i < ppc_num_fprs; i++)
+        {
+          int regnum = i + tdep->ppc_fp0_regnum;
+          cache->saved_regs[regnum].addr = fpregs + i * tdep->wordsize;
+        }
+      cache->saved_regs[tdep->ppc_fpscr_regnum].addr
+        = fpregs + 32 * tdep->wordsize;
     }
-  cache->saved_regs[tdep->ppc_fpscr_regnum].addr = fpregs + 32 * tdep->wordsize;
 
   return cache;
 }
@@ -1018,15 +1024,18 @@ ppc_linux_supply_fpregset (const struct regset *regset,
   struct gdbarch_tdep *regcache_tdep = gdbarch_tdep (regcache_arch);
   const bfd_byte *buf = fpset;
 
-  for (regi = 0; regi < 32; regi++)
+  if (! ppc_floating_point_unit_p (regcache_arch))
+    return;
+
+  for (regi = 0; regi < ppc_num_fprs; regi++)
     regcache_raw_supply (regcache, 
                          regcache_tdep->ppc_fp0_regnum + regi,
                          buf + 8 * regi);
 
-  /* The FPSCR is stored in the low order word of the last doubleword in the
-     fpregset.  */
+  /* The FPSCR is stored in the low order word of the last
+     doubleword in the fpregset.  */
   regcache_raw_supply (regcache, regcache_tdep->ppc_fpscr_regnum,
-                      buf + 8 * 32 + 4);
+                       buf + 8 * 32 + 4);
 }
 
 static struct regset ppc_linux_fpregset = { NULL, ppc_linux_supply_fpregset };
This page took 0.024706 seconds and 4 git commands to generate.