public inbox for rda@sourceware.org
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: rda@sources.redhat.com
Subject: [RFC] (2nd try) Revise interfaces for *_bytes_{from,to}_reg()
Date: Wed, 27 Nov 2002 15:26:00 -0000	[thread overview]
Message-ID: <1021127232634.ZM9395@localhost.localdomain> (raw)

Here's my second try at revising the conversion interfaces between
a buffer of bytes and a struct gdbserv_reg.  The primary difference
between this patch and the one before is that a ``sign_extend'' flag
has been added to the conversion functions.

Unfortunately, this patch contains a small part of my upcoming
mips64 changes.  I was able to prune out most of it, but wasn't
able to disentangle a small portion of it.

I'll commit this early next week unless someone objects...

Kevin

In ChangeLog:
	* include/gdbserv-utils.h, lib/gdbserv-utils.c
	(gdbserv_be_bytes_to_reg, gdbserv_le_bytes_to_reg)
	(gdbserv_be_bytes_from_reg, gdbserv_le_bytes_from_reg)
	(gdbserv_host_bytes_to_reg, gdbserv_host_bytes_from_reg):
	Revise interfaces.

In unix/ChangeLog:

	* linux-target.c (linux_get_reg, linux_set_reg, reg_from_regset)
	(reg_to_regset, get_regset, put_regset reg_from_gregset)
	(reg_to_gregset, reg_from_fpregset, reg_to_fpregset)
	(reg_from_xregset, reg_to_xregset): Adjust all calls to
	gdbserv_host_bytes_to_reg() and gdbserv_host_bytes_from_reg()
	to account for change in interface.  Remove code which is
	no longer needed due to improvements in the aforementioned
	functions.

Index: include/gdbserv-utils.h
===================================================================
RCS file: /cvs/src/src/rda/include/gdbserv-utils.h,v
retrieving revision 1.1
diff -u -p -r1.1 gdbserv-utils.h
--- include/gdbserv-utils.h	28 Aug 2002 01:22:27 -0000	1.1
+++ include/gdbserv-utils.h	27 Nov 2002 23:16:35 -0000
@@ -60,43 +60,65 @@ extern void gdbserv_ulonglong_to_reg (st
 				      unsigned long long val,
 				      struct gdbserv_reg *reg);
 
-/* Convert between a REG and a buffer representing a numeric type.
-   Handle big endian and little endian cases explicitly.  */
+/* Convert between a REG and a buffer representing a (possibly signed)
+   numeric type.  Handle big endian and little endian cases explicitly.
+   When the source buffer is bigger than the destination buffer, the
+   least significant bytes (as appropriate for the endianess) are
+   transferred.  When the source buffer is smaller than the destination,
+   the most significant bytes of the destination are padded appropriately.
+   
+   Note that gdbserv_be_bytes_from_reg() and gdbserv_le_bytes_from_reg()
+   have a buffer length parameter, but not a register length
+   parameter.  This is because the register length was obtained from a
+   register packet sent by the debug client.  On the other hand,
+   gdbserv_be_bytes_to_reg() and gdbserv_le_bytes_to_reg() take both a
+   buffer length and the register length.  This is because we're
+   constructing a register (which will likely be sent to the client)
+   of a particular size.  */
 
 extern void gdbserv_be_bytes_to_reg (struct gdbserv *gdbserv,
 		                     const void *buf,
-		                     int len,
-		                     struct gdbserv_reg *reg);
+		                     int buflen,
+		                     struct gdbserv_reg *reg,
+				     int reglen,
+				     int sign_extend);
 
 extern void gdbserv_le_bytes_to_reg (struct gdbserv *gdbserv,
 		                     const void *buf,
 		                     int len,
-		                     struct gdbserv_reg *reg);
+		                     struct gdbserv_reg *reg,
+				     int reglen,
+				     int sign_extend);
 
 extern void gdbserv_be_bytes_from_reg (struct gdbserv *gdbserv,
 		                       void *buf,
-		                       int *lenp,
-                                       const struct gdbserv_reg *reg);
+		                       int buflen,
+                                       const struct gdbserv_reg *reg,
+				       int sign_extend);
 
 extern void gdbserv_le_bytes_from_reg (struct gdbserv *gdbserv,
 		                       void *buf,
-		                       int *lenp,
-                                       const struct gdbserv_reg *reg);
-
-/* Convert between a REG and a buffer representing a native numeric
-   type.  These are just wrappers for the routines above, but are
-   useful nonetheless since they free the caller from having to
+		                       int buflen,
+                                       const struct gdbserv_reg *reg,
+				       int sign_extend);
+
+/* Convert between a REG and a buffer representing a native unsigned
+   numeric type.  These are just wrappers for the routines above, but
+   are useful nonetheless since they free the caller from having to
    worry about byte order issues.  */
 
 extern void gdbserv_host_bytes_to_reg (struct gdbserv *gdbserv,
 		                       const void *buf,
-		                       int len,
-		                       struct gdbserv_reg *reg);
+		                       int buflen,
+		                       struct gdbserv_reg *reg,
+				       int reglen,
+				       int sign_extend);
 
 extern void gdbserv_host_bytes_from_reg (struct gdbserv *gdbserv,
 		                         void *buf,
-		                         int *lenp,
-                                         const struct gdbserv_reg *reg);
+		                         int buflen,
+                                         const struct gdbserv_reg *reg,
+					 int sign_extend);
 
 #ifdef __cplusplus
 }
Index: lib/gdbserv-utils.c
===================================================================
RCS file: /cvs/src/src/rda/lib/gdbserv-utils.c,v
retrieving revision 1.1
diff -u -p -r1.1 gdbserv-utils.c
--- lib/gdbserv-utils.c	28 Aug 2002 01:22:28 -0000	1.1
+++ lib/gdbserv-utils.c	27 Nov 2002 23:16:35 -0000
@@ -227,67 +227,143 @@ reverse_copy_bytes (void *dest, const vo
 void
 gdbserv_be_bytes_to_reg (struct gdbserv *gdbserv,
 		         const void *buf,
-		         int len,
-		         struct gdbserv_reg *reg)
-{
+		         int buflen,
+		         struct gdbserv_reg *reg,
+			 int reglen,
+			 int sign_extend)
+{
+  int bufoffset = 0;
+  int regoffset = 0;
+  int len = buflen;
+
   reg->negative_p = 0;
-  reg->len = len;
-  memcpy (reg->buf, buf, len);
+  reg->len = reglen;
+
+  if (reglen > buflen)
+    {
+      memset (reg->buf,
+              (sign_extend && (((char *) buf)[0] & 0x80)) ? 0xff : 0,
+	      reglen - buflen);
+      regoffset = reglen - buflen;
+    }
+
+  if (buflen > reglen)
+    {
+      bufoffset = buflen - reglen;
+      len = reglen;
+    }
+
+  memcpy (reg->buf + regoffset, (char *)buf + bufoffset, len);
 }
 
 void
 gdbserv_be_bytes_from_reg (struct gdbserv *gdbserv,
 		           void *buf,
-		           int *lenp,
-                           const struct gdbserv_reg *reg)
-{
-  *lenp = reg->len;
-  memcpy (buf, reg->buf, reg->len);
+		           int buflen,
+                           const struct gdbserv_reg *reg,
+			   int sign_extend)
+{
+  int bufoffset = 0;
+  int regoffset = 0;
+  int len = reg->len;
+
+  if (reg->len > buflen)
+    {
+      regoffset = reg->len - buflen;
+      len = buflen;
+    }
+
+  if (buflen > reg->len)
+    {
+      memset (buf,
+              (sign_extend && (reg->buf[0] & 0x80)) ? 0xff : 0,
+	      buflen - reg->len);
+      bufoffset = buflen - reg->len;
+    }
+
+  memcpy ((char *)buf + bufoffset, reg->buf + regoffset, len);
 }
 
 void
 gdbserv_le_bytes_to_reg (struct gdbserv *gdbserv,
 		         const void *buf,
-		         int len,
-		         struct gdbserv_reg *reg)
+		         int buflen,
+		         struct gdbserv_reg *reg,
+			 int reglen,
+			 int sign_extend)
 {
+  int regoffset = 0;
+  int len = buflen;
+
   reg->negative_p = 0;
-  reg->len = len;
-  reverse_copy_bytes (reg->buf, buf, len);
+  reg->len = reglen;
+
+  if (reglen > buflen)
+    {
+      memset (reg->buf,
+              (sign_extend && (((char *) buf)[buflen - 1] & 0x80)) ? 0xff : 0,
+	      reglen - buflen);
+      regoffset = reglen - buflen;
+    }
+
+  if (buflen > reglen)
+      len = reglen;
+
+  reverse_copy_bytes (reg->buf + regoffset, buf, len);
 }
 
 void
 gdbserv_le_bytes_from_reg (struct gdbserv *gdbserv,
 		           void *buf,
-		           int *lenp,
-                           const struct gdbserv_reg *reg)
-{
-  *lenp = reg->len;
-  reverse_copy_bytes (buf, reg->buf, reg->len);
+		           int buflen,
+                           const struct gdbserv_reg *reg,
+			   int sign_extend)
+{
+  int bufoffset = 0;
+  int regoffset = 0;
+  int len = reg->len;
+
+  if (reg->len > buflen)
+    {
+      regoffset = reg->len - buflen;
+      len = buflen;
+    }
+
+  if (buflen > reg->len)
+    {
+      memset ((char *)buf + reg->len,
+              (sign_extend && (reg->buf[reg->len - 1] & 0x80)) ? 0xff : 0,
+	      buflen - reg->len);
+    }
+
+  reverse_copy_bytes (buf, reg->buf + regoffset, reg->len);
 }
 
 void
 gdbserv_host_bytes_to_reg (struct gdbserv *gdbserv,
 		           const void *buf,
-		           int len,
-		           struct gdbserv_reg *reg)
+		           int buflen,
+		           struct gdbserv_reg *reg,
+			   int reglen,
+			   int sign_extend)
 {
 #ifdef WORDS_BIGENDIAN
-  gdbserv_be_bytes_to_reg (gdbserv, buf, len, reg);
+  gdbserv_be_bytes_to_reg (gdbserv, buf, buflen, reg, reglen, sign_extend);
 #else
-  gdbserv_le_bytes_to_reg (gdbserv, buf, len, reg);
+  gdbserv_le_bytes_to_reg (gdbserv, buf, buflen, reg, reglen, sign_extend);
 #endif
 }
 
 void
 gdbserv_host_bytes_from_reg (struct gdbserv *gdbserv,
 		             void *buf,
-		             int *lenp,
-                             const struct gdbserv_reg *reg)
+		             int buflen,
+                             const struct gdbserv_reg *reg,
+			     int sign_extend)
 {
 #ifdef WORDS_BIGENDIAN
-  gdbserv_be_bytes_from_reg (gdbserv, buf, lenp, reg);
+  gdbserv_be_bytes_from_reg (gdbserv, buf, buflen, reg, sign_extend);
 #else
-  gdbserv_le_bytes_from_reg (gdbserv, buf, lenp, reg);
+  gdbserv_le_bytes_from_reg (gdbserv, buf, buflen, reg, sign_extend);
 #endif
 }
Index: unix/linux-target.c
===================================================================
RCS file: /cvs/src/src/rda/unix/linux-target.c,v
retrieving revision 1.1
diff -u -p -r1.1 linux-target.c
--- unix/linux-target.c	28 Aug 2002 01:22:28 -0000	1.1
+++ unix/linux-target.c	27 Nov 2002 23:16:35 -0000
@@ -205,7 +205,8 @@ struct peekuser_pokeuser_reginfo
 enum 
 { 
   PC_REGNUM = 15,
-  NUM_REGS = 26
+  NUM_REGS = 26,
+  sign_extend = 0
 };
 
 static struct getregs_setregs_reginfo reginfo[] =
@@ -261,7 +262,8 @@ static struct getregs_setregs_reginfo re
 enum 
 { 
   PC_REGNUM = 8,
-  NUM_REGS = 42
+  NUM_REGS = 42,
+  sign_extend = 0
 };
 
 
@@ -343,7 +345,8 @@ enum
   SIZEOF_REGMAP = 23,
   SIZEOF_MAPPEDREG = 4,
   NUM_REGS = 24,
-  PC_REGNUM = 16
+  PC_REGNUM = 16,
+  sign_extend = 0
 };
 
 static int regmap[SIZEOF_REGMAP] =
@@ -376,16 +379,47 @@ is_extended_reg (int regnum)
 
 /* End of SH_LINUX_TARGET */
 
-#elif defined(MIPS_LINUX_TARGET)
+#elif defined MIPS_LINUX_TARGET || (defined MIPS64_LINUX_TARGET && defined MIPS_ABI_O32)
 
 #define PEEKUSER_POKEUSER_REGINFO 1
 
 enum
 {
   NUM_REGS = 70,
-  PC_REGNUM = 37
+  PC_REGNUM = 37,
+  sign_extend = 1
 };
 
+#ifndef FPR_BASE
+#define FPR_BASE 32
+#endif
+#ifndef PC
+#define PC		64
+#endif
+#ifndef CAUSE
+#define CAUSE		65
+#endif
+#ifndef BADVADDR
+#define BADVADDR	66
+#endif
+#ifndef MMHI
+#define MMHI		67
+#endif
+#ifndef MMLO
+#define MMLO		68
+#endif
+#ifndef FPC_CSR
+#define FPC_CSR		69
+#endif
+#ifndef FPC_EIR
+#define FPC_EIR		70
+#endif
+
+#ifdef MIPS64_LINUX_TARGET
+#define PROTO_SIZE 8
+#else
+#define PROTO_SIZE 4
+#endif
 
 static struct peekuser_pokeuser_reginfo reginfo[] =
 {
@@ -500,7 +648,8 @@ enum 
   SIZEOF_REGMAP = 29, 		/* with FP regs */
   SIZEOF_MAPPEDREG = 4,
   NUM_REGS = 29,
-  PC_REGNUM = 17
+  PC_REGNUM = 17,
+  sign_extend = 0
 };
 
 static int regmap[SIZEOF_REGMAP] =
@@ -557,7 +706,8 @@ is_extended_reg (int regnum)
 enum
 {
   NUM_REGS = 71,
-  PC_REGNUM = 64
+  PC_REGNUM = 64,
+  sign_extend = 0
 };
 
 static struct peekuser_pokeuser_reginfo reginfo[] =
@@ -646,7 +796,8 @@ enum 
   SIZEOF_REGMAP = 66, 
   SIZEOF_MAPPEDREG = 8,
   NUM_REGS = 66,
-  PC_REGNUM = 64
+  PC_REGNUM = 64,
+  sign_extend = 0
 };
 
 static int regmap[SIZEOF_REGMAP] = 
@@ -922,8 +1073,6 @@ linux_get_reg (struct gdbserv *serv, int
       return -1;
     }
 
-  memset (tmp_buf, 0, reginfo[regno].proto_size);
-
   if (reginfo[regno].whichregs != NOREGS)
     {
       /* Get the register value. */
@@ -931,9 +1080,12 @@ linux_get_reg (struct gdbserv *serv, int
       if (status < 0)
 	return -1;	/* fail */
     }
+  else
+    memset (tmp_buf, 0, reginfo[regno].ptrace_size);
 
   /* Copy the bytes to the gdbserv_reg struct.  */
-  gdbserv_host_bytes_to_reg (serv, tmp_buf, reginfo[regno].proto_size, reg);
+  gdbserv_host_bytes_to_reg (serv, tmp_buf, reginfo[regno].ptrace_size,
+                             reg, reginfo[regno].proto_size, sign_extend);
 
   return 0;	/* success */
   
@@ -958,17 +1110,10 @@ linux_set_reg (struct gdbserv *serv, int
       struct child_process *process = gdbserv_target_data (serv);
       char tmp_buf[MAX_REG_SIZE];
       int status;
-      int len;
-
-      /* Clear out a temporary buffer into which to fetch the bytes that
-	 we'll be setting.  We do this in case ptrace_size != proto_size.  */
-      memset (tmp_buf, 0, reginfo[regno].ptrace_size);
 
       /* Copy the bytes from the gdbserv_reg struct to our temporary buffer.  */
-      gdbserv_host_bytes_from_reg (serv, tmp_buf, &len, reg);
-
-      if (len != reginfo[regno].proto_size)
-	return -1;
+      gdbserv_host_bytes_from_reg (serv, tmp_buf, reginfo[regno].ptrace_size,
+                                   reg, sign_extend);
 
       /* Write the child's register. */
       status = write_reg_bytes (process->pid, regno, tmp_buf);
@@ -990,7 +1135,6 @@ reg_from_regset (struct gdbserv *serv, 
 		 const void *regset,
 		 enum regset whichregs)
 {
-  char tmp_buf[MAX_REG_SIZE];
   char *regbytes;
 
   if (regno < 0 || regno >= NUM_REGS 
@@ -1001,10 +1145,8 @@ reg_from_regset (struct gdbserv *serv, 
 
   regbytes = ((char *) regset) + reginfo[regno].regset_field_offset;
 
-  memset (tmp_buf, 0, reginfo[regno].proto_size);
-  memcpy (tmp_buf, regbytes, reginfo[regno].regset_field_size);
-
-  gdbserv_host_bytes_to_reg (serv, tmp_buf, reginfo[regno].proto_size, reg);
+  gdbserv_host_bytes_to_reg (serv, regbytes, reginfo[regno].regset_field_size,
+                             reg, reginfo[regno].proto_size, sign_extend);
 
   return 0;
 }
@@ -1020,9 +1162,7 @@ reg_to_regset (struct gdbserv *serv, 
 	       void *regset,
 	       enum regset whichregs)
 {
-  char tmp_buf[MAX_REG_SIZE];
   char *regbytes;
-  int len;
 
   if (regno < 0 || regno >= NUM_REGS 
       || reginfo[regno].whichregs != whichregs)
@@ -1030,15 +1170,10 @@ reg_to_regset (struct gdbserv *serv, 
       return -1;
     }
 
-  memset (tmp_buf, 0, reginfo[regno].regset_field_size);
-  gdbserv_host_bytes_from_reg (serv, tmp_buf, &len, reg);
-
-  if (len != reginfo[regno].proto_size)
-    return -1;
-
   regbytes = ((char *) regset) + reginfo[regno].regset_field_offset;
 
-  memcpy (regbytes, tmp_buf, reginfo[regno].regset_field_size);
+  gdbserv_host_bytes_from_reg (serv, regbytes, reginfo[regno].regset_field_size,
+                               reg, sign_extend);
 
   return 0;
 }
@@ -1137,16 +1272,15 @@ get_regset (struct gdbserv *serv, int pi
 	  struct gdbserv_reg reg;
 	  int status;
 
-	  memset (tmp_buf, 0, reginfo[regno].proto_size);
-
 	  /* Get the register value. */
 	  status = read_reg_bytes (pid, regno, tmp_buf);
 	  if (status < 0)
 	    return -1;	/* fail */
 
 	  /* Copy the bytes to the gdbserv_reg struct.  */
-	  gdbserv_host_bytes_to_reg (serv, tmp_buf,
-	                             reginfo[regno].proto_size, &reg);
+	  gdbserv_host_bytes_to_reg (serv, tmp_buf, reginfo[regno].ptrace_size,
+	                             &reg, reginfo[regno].proto_size,
+				     sign_extend);
 
 	  /* Now insert them into the regset.  */
 	  reg_to_regset (serv, &reg, regno, regset, whichregs);
@@ -1173,20 +1307,15 @@ put_regset (struct gdbserv *serv,
 	{
 	  char tmp_buf[MAX_REG_SIZE];
 	  struct gdbserv_reg reg;
-	  int len;
 	  int status;
 
 	  /* Fetch the reg from the regset.  */
 	  reg_from_regset (serv, &reg, regno, regset, whichregs);
 
-	  /* Clear out a temporary buffer into which to put the bytes that
-	     we'll be setting.  We do this in case ptrace_size != proto_size.  */
-	  memset (tmp_buf, 0, reginfo[regno].ptrace_size);
-
 	  /* Copy the bytes from the gdbserv_reg struct to our temporary buffer.  */
-	  gdbserv_host_bytes_from_reg (serv, tmp_buf, &len, &reg);
-	  if (len != reginfo[regno].proto_size)
-	    return -1;
+	  gdbserv_host_bytes_from_reg (serv, tmp_buf,
+	                               reginfo[regno].ptrace_size, &reg,
+				       sign_extend);
 
 	  /* Write the child's register. */
 	  status = write_reg_bytes (pid, regno, tmp_buf);
@@ -1343,7 +1472,6 @@ linux_get_reg (struct gdbserv *serv, int
   elf_fpregset_t fpregs;
   void *fpxregs;
   char *buf;
-  char tmp_buf[MAX_REG_SIZE];
 
   if (regno < 0 || regno >= NUM_REGS)
     {
@@ -1394,14 +1522,9 @@ linux_get_reg (struct gdbserv *serv, int
   /* Adjust buf to point at the starting byte of the register.  */
   buf += reginfo[regno].offset;
 
-  /* We go through these memset / memcpy shenanigans in case
-     proto_size != ptrace_size.  */
-  memset (tmp_buf, 0, reginfo[regno].proto_size);
-  if (reginfo[regno].ptrace_size > 0)
-    memcpy (tmp_buf, buf, reginfo[regno].ptrace_size);
-
   /* Copy the bytes to the gdbserv_reg struct.  */
-  gdbserv_host_bytes_to_reg (serv, tmp_buf, reginfo[regno].proto_size, reg);
+  gdbserv_host_bytes_to_reg (serv, buf, reginfo[regno].ptrace_size,
+                             reg, reginfo[regno].proto_size, sign_extend);
 
   return 0;
 }
@@ -1419,7 +1542,6 @@ linux_set_reg (struct gdbserv *serv, int
   void *fpxregs = NULL;
   char *buf;
   char tmp_buf[MAX_REG_SIZE];
-  int len;
 
   if (regno < 0 || regno >= NUM_REGS)
     {
@@ -1468,18 +1590,9 @@ linux_set_reg (struct gdbserv *serv, int
   /* Adjust buf to point at the starting byte of the register.  */
   buf += reginfo[regno].offset;
 
-  /* Clear out a temporary buffer into which to fetch the bytes that
-     we'll be setting.  We do this in case ptrace_size != proto_size.  */
-  memset (tmp_buf, 0, reginfo[regno].ptrace_size);
-
   /* Copy the bytes from the gdbserv_reg struct to our temporary buffer.  */
-  gdbserv_host_bytes_from_reg (serv, tmp_buf, &len, reg);
-
-  if (len != reginfo[regno].proto_size)
-    return -1;
-
-  /* Copy the bytes to the appropriate position in the ptrace struct.  */
-  memcpy (buf, tmp_buf, reginfo[regno].ptrace_size);
+  gdbserv_host_bytes_from_reg (serv, buf, reginfo[regno].ptrace_size, reg,
+                               sign_extend);
 
   /* Write the register set to the process.  */
   if (reginfo[regno].whichregs == GREGS)
@@ -1521,7 +1634,6 @@ reg_from_gregset (struct gdbserv *serv, 
 		  int regno, 
 		  const GREGSET_T gregset)
 {
-  char tmp_buf[MAX_REG_SIZE];
   char *regbytes;
 
   if (regno < 0 || regno >= NUM_REGS 
@@ -1532,10 +1644,8 @@ reg_from_gregset (struct gdbserv *serv, 
 
   regbytes = ((char *) gregset) + reginfo[regno].offset;
 
-  memset (tmp_buf, 0, reginfo[regno].proto_size);
-  memcpy (tmp_buf, regbytes, reginfo[regno].ptrace_size);
-
-  gdbserv_host_bytes_to_reg (serv, tmp_buf, reginfo[regno].proto_size, reg);
+  gdbserv_host_bytes_to_reg (serv, regbytes, reginfo[regno].ptrace_size,
+                             reg, reginfo[regno].proto_size, sign_extend);
 
   return 0;
 }
@@ -1550,9 +1660,7 @@ reg_to_gregset (struct gdbserv *serv, 
 		int regno, 
 		GREGSET_T gregset)
 {
-  char tmp_buf[MAX_REG_SIZE];
   char *regbytes;
-  int len;
 
   if (regno < 0 || regno >= NUM_REGS 
       || reginfo[regno].whichregs != GREGS)
@@ -1562,13 +1670,8 @@ reg_to_gregset (struct gdbserv *serv, 
 
   regbytes = ((char *) gregset) + reginfo[regno].offset;
 
-  memset (tmp_buf, 0, reginfo[regno].ptrace_size);
-  gdbserv_host_bytes_from_reg (serv, tmp_buf, &len, reg);
-
-  if (len != reginfo[regno].proto_size)
-    return -1;
-
-  memcpy (regbytes, tmp_buf, reginfo[regno].ptrace_size);
+  gdbserv_host_bytes_from_reg (serv, regbytes, reginfo[regno].ptrace_size, reg,
+                               sign_extend);
 
   return 0;
 }
@@ -1583,7 +1686,6 @@ reg_from_fpregset (struct gdbserv *serv,
 		   int regno, 
 		   const FPREGSET_T *fpregset)
 {
-  char tmp_buf[MAX_REG_SIZE];
   char *regbytes;
 
   if (regno < 0 || regno >= NUM_REGS 
@@ -1594,10 +1696,8 @@ reg_from_fpregset (struct gdbserv *serv,
 
   regbytes = ((char *) fpregset) + reginfo[regno].offset;
 
-  memset (tmp_buf, 0, reginfo[regno].proto_size);
-  memcpy (tmp_buf, regbytes, reginfo[regno].ptrace_size);
-
-  gdbserv_host_bytes_to_reg (serv, tmp_buf, reginfo[regno].proto_size, reg);
+  gdbserv_host_bytes_to_reg (serv, regbytes, reginfo[regno].ptrace_size,
+                             reg, reginfo[regno].proto_size, sign_extend);
 
   return 0;
 }
@@ -1612,9 +1712,7 @@ reg_to_fpregset (struct gdbserv *serv, 
 		 int regno, 
 		 FPREGSET_T *fpregset)
 {
-  char tmp_buf[MAX_REG_SIZE];
   char *regbytes;
-  int len;
 
   if (regno < 0 || regno >= NUM_REGS 
       || reginfo[regno].whichregs != FPREGS)
@@ -1624,13 +1722,8 @@ reg_to_fpregset (struct gdbserv *serv, 
 
   regbytes = ((char *) fpregset) + reginfo[regno].offset;
 
-  memset (tmp_buf, 0, reginfo[regno].ptrace_size);
-  gdbserv_host_bytes_from_reg (serv, tmp_buf, &len, reg);
-
-  if (len != reginfo[regno].proto_size)
-    return -1;
-
-  memcpy (regbytes, tmp_buf, reginfo[regno].ptrace_size);
+  gdbserv_host_bytes_from_reg (serv, regbytes, reginfo[regno].ptrace_size, reg,
+                               sign_extend);
 
   return 0;
 }
@@ -1645,7 +1738,6 @@ reg_from_xregset (struct gdbserv *serv, 
 		  int regno, 
 		  const void *xregset)
 {
-  char tmp_buf[MAX_REG_SIZE];
   char *regbytes;
 
   if (regno < 0 || regno >= NUM_REGS 
@@ -1656,10 +1748,8 @@ reg_from_xregset (struct gdbserv *serv, 
 
   regbytes = ((char *) xregset) + reginfo[regno].offset;
 
-  memset (tmp_buf, 0, reginfo[regno].proto_size);
-  memcpy (tmp_buf, regbytes, reginfo[regno].ptrace_size);
-
-  gdbserv_host_bytes_to_reg (serv, tmp_buf, reginfo[regno].proto_size, reg);
+  gdbserv_host_bytes_to_reg (serv, regbytes, reginfo[regno].ptrace_size,
+                             reg, reginfo[regno].proto_size, sign_extend);
 
   return 0;
 }
@@ -1674,9 +1764,7 @@ reg_to_xregset (struct gdbserv *serv, 
 		int regno, 
 		void *xregset)
 {
-  char tmp_buf[MAX_REG_SIZE];
   char *regbytes;
-  int len;
 
   if (regno < 0 || regno >= NUM_REGS 
       || reginfo[regno].whichregs != FPXREGS)
@@ -1686,13 +1774,8 @@ reg_to_xregset (struct gdbserv *serv, 
 
   regbytes = ((char *) xregset) + reginfo[regno].offset;
 
-  memset (tmp_buf, 0, reginfo[regno].ptrace_size);
-  gdbserv_host_bytes_from_reg (serv, tmp_buf, &len, reg);
-
-  if (len != reginfo[regno].proto_size)
-    return -1;
-
-  memcpy (regbytes, tmp_buf, reginfo[regno].ptrace_size);
+  gdbserv_host_bytes_from_reg (serv, regbytes, reginfo[regno].ptrace_size, reg,
+                               sign_extend);
 
   return 0;
 }

             reply	other threads:[~2002-11-27 23:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-27 15:26 Kevin Buettner [this message]
2002-12-02 19:25 ` Kevin Buettner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1021127232634.ZM9395@localhost.localdomain \
    --to=kevinb@redhat.com \
    --cc=rda@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).