]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/irix5-nat.c
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / irix5-nat.c
index 6686713804b02b12a56424323b78110175e2853a..a7b64dc032baf9c965dfa9196ebdf6df036d736f 100644 (file)
@@ -1,7 +1,7 @@
 /* Native support for the SGI Iris running IRIX version 5, for GDB.
 
-   Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
-   1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+   Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998,
+   1999, 2000, 2001, 2002, 2004, 2006, 2007 Free Software Foundation, Inc.
 
    Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU
    and by Per Bothner(bothner@cs.wisc.edu) at U.Wisconsin.
@@ -22,8 +22,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
 
 #include "defs.h"
 #include "inferior.h"
@@ -139,6 +139,7 @@ supply_fpregset (fpregset_t *fpregsetp)
 {
   int regi;
   static char zerobuf[32] = {0};
+  char fsrbuf[8];
 
   /* FIXME, this is wrong for the N32 ABI which has 64 bit FP regs. */
 
@@ -146,9 +147,17 @@ supply_fpregset (fpregset_t *fpregsetp)
     regcache_raw_supply (current_regcache, FP0_REGNUM + regi,
                         (char *) &fpregsetp->fp_r.fp_regs[regi]);
 
+  /* We can't supply the FSR register directly to the regcache,
+     because there is a size issue: On one hand, fpregsetp->fp_csr
+     is 32bits long, while the regcache expects a 64bits long value.
+     So we use a buffer of the correct size and copy into it the register
+     value at the proper location.  */
+  memset (fsrbuf, 0, 4);
+  memcpy (fsrbuf + 4, &fpregsetp->fp_csr, 4);
+
   regcache_raw_supply (current_regcache,
                       mips_regnum (current_gdbarch)->fp_control_status,
-                      (char *) &fpregsetp->fp_csr);
+                      fsrbuf);
 
   /* FIXME: how can we supply FCRIR?  SGI doesn't tell us. */
   regcache_raw_supply (current_regcache,
@@ -173,11 +182,22 @@ fill_fpregset (fpregset_t *fpregsetp, int regno)
        }
     }
 
-  if ((regno == -1)
-      || (regno == mips_regnum (current_gdbarch)->fp_control_status))
-    regcache_raw_read (current_regcache,
-                       mips_regnum (current_gdbarch)->fp_control_status, 
-                       &fpregsetp->fp_csr);
+  if (regno == -1
+      || regno == mips_regnum (current_gdbarch)->fp_control_status)
+    {
+      char fsrbuf[8];
+
+      /* We can't fill the FSR register directly from the regcache,
+         because there is a size issue: On one hand, fpregsetp->fp_csr
+         is 32bits long, while the regcache expects a 64bits long buffer.
+         So we use a buffer of the correct size and copy the register
+         value from that buffer.  */
+      regcache_raw_read (current_regcache,
+                         mips_regnum (current_gdbarch)->fp_control_status,
+                         fsrbuf);
+
+      memcpy (&fpregsetp->fp_csr, fsrbuf + 4, 4);
+    }
 }
 
 
@@ -222,39 +242,22 @@ fetch_core_registers (char *core_reg_sect, unsigned core_reg_size,
                      int which, CORE_ADDR reg_addr)
 {
   char *srcp = core_reg_sect;
+  int regsize = mips_isa_regsize (current_gdbarch);
   int regno;
 
-  if (core_reg_size == deprecated_register_bytes ())
-    {
-      for (regno = 0; regno < NUM_REGS; regno++)
-        {
-          regcache_raw_write (current_regcache, regno, srcp);
-          srcp += register_size (current_gdbarch, regno);
-        }
-    }
-  else if (mips_isa_regsize (current_gdbarch) == 4 &&
-          core_reg_size == (2 * mips_isa_regsize (current_gdbarch)) * NUM_REGS)
-    {
-      /* This is a core file from a N32 executable, 64 bits are saved
-         for all registers.  */
-      for (regno = 0; regno < NUM_REGS; regno++)
-       {
-         if (regno >= FP0_REGNUM && regno < (FP0_REGNUM + 32))
-           {
-              regcache_raw_write (current_regcache, regno, srcp);
-           }
-         else
-           {
-              regcache_raw_write (current_regcache, regno, srcp + 4);
-           }
-          srcp += 8;
-       }
-    }
-  else
+  /* If regsize is 8, this is a N32 or N64 core file.
+     If regsize is 4, this is an O32 core file.  */
+  if (core_reg_size != regsize * NUM_REGS)
     {
       warning (_("wrong size gregset struct in core file"));
       return;
     }
+
+  for (regno = 0; regno < NUM_REGS; regno++)
+    {
+      regcache_raw_write (current_regcache, regno, srcp);
+      srcp += regsize;
+    }
 }
 
 /* Register that we are able to handle irix5 core file formats.