[RFA] mipsnbsd-tdep.c, fill/supply_reg 32/64 bit

Michael Snyder msnyder@specifix.com
Thu Dec 13 02:02:00 GMT 2007


This patch is meant to allow these functions to work
when mips_isa_regsize != mips_abi_regsize.  

I don't actually have a NetBSD system on which to test it --
I'm working on a port of FreeBSD, borrowing heavily from
this code.  There's nothing OS-specific about the method, 
though, which I actually borrowed from mips-linux-tdep.c.

Yes, I do know that the same needs to be done for the 
fill/supply_fpreg functions...

2007-12-12  Michael Snyder  <msnyder@specifix.com>

	* mipsnbsd-tdep.c (mipsnbsd_supply_reg): Convert 32/64 bits, 
	for targets in which mips_abi_size != mips_isa_size.
	(mipsnbsd_fill_reg): Ditto.

Index: mipsnbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mipsnbsd-tdep.c,v
retrieving revision 1.32
diff -u -p -r1.32 mipsnbsd-tdep.c
--- mipsnbsd-tdep.c	16 Nov 2007 04:56:45 -0000	1.32
+++ mipsnbsd-tdep.c	12 Dec 2007 19:27:58 -0000
@@ -152,8 +152,19 @@ mipsnbsd_supply_reg (struct regcache *re
 	  if (gdbarch_cannot_fetch_register (gdbarch, i))
 	    regcache_raw_supply (regcache, i, NULL);
 	  else
-            regcache_raw_supply (regcache, i,
-				 regs + (i * mips_isa_regsize (gdbarch)));
+	    {
+	      /* Convert between abi (input) and isa (output).  
+		 Required in case abi regsize != isa regsize.  */
+	      size_t abisize = mips_abi_regsize (gdbarch);
+	      size_t isasize = register_size (gdbarch, i);
+	      void *addr = regs + i * abisize;
+	      gdb_byte buf[MAX_REGISTER_SIZE];
+	      LONGEST val;
+
+	      val = extract_signed_integer (addr, abisize);
+	      store_signed_integer (buf, isasize, val);
+	      regcache_raw_supply (current_regcache, i, buf);
+	    }
         }
     }
 }
@@ -167,8 +178,19 @@ mipsnbsd_fill_reg (const struct regcache
   for (i = 0; i <= gdbarch_pc_regnum (gdbarch); i++)
     if ((regno == i || regno == -1)
 	&& ! gdbarch_cannot_store_register (gdbarch, i))
-      regcache_raw_collect (regcache, i,
-			    regs + (i * mips_isa_regsize (gdbarch)));
+      {
+	/* Convert between isa (input) and abi (output).  
+	   Required in case abi regsize != isa regsize.  */
+	size_t abisize = mips_abi_regsize (gdbarch);
+	size_t isasize = register_size (gdbarch, i);
+	void *addr = regs + i * abisize;
+	gdb_byte buf[MAX_REGISTER_SIZE];
+	LONGEST val;
+
+	regcache_raw_collect (current_regcache, i, buf);
+	val = extract_signed_integer (buf, isasize);
+	store_signed_integer (addr, abisize, val);
+      }
 }
 
 void




More information about the Gdb-patches mailing list