This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[rfa/arm] Fix the types of ARM FPA registers


This has apparently been broken for a while... build an arm-elf GDB, connect
to the simulator, and say 'print $f0'.  You get an internal error because
the virtual size is 8 but the raw size is 12, and we don't define
DEPRECATED_REGISTER_CONVERTIBLE.

I don't think any of the baggage is necessary any more.  We can simply
expose the correct type.  After this patch, we have:

(gdb) ptype $f0
type = builtin_type_arm_ext_littlebyte_bigword
(gdb) p sizeof($f0)
$1 = 12
(gdb) p $f0
$2 = 0

I also got to whack five deprecated methods.

No change in test results on arm-sim, and it fixes the internal error.  I
don't have any hard-FPA targets to try it on (all my Linux setups are
soft-FPA or soft-VFP).

OK?

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2004-03-24  Daniel Jacobowitz  <drow@mvista.com>

	* arm-linux-tdep.c (ARM_LINUX_JB_ELEMENT_SIZE): Define to
	INT_REGISTER_SIZE.
	(arm_linux_push_arguments): Use TARGET_DOUBLE_BIT instead of
	FP_REGISTER_VIRTUAL_SIZE.
	* arm-tdep.c (arm_make_sigtramp_cache): Use register_size instead
	of DEPRECATED_REGISTER_RAW_SIZE.
	(arm_register_type): Add gdbarch argument.
	(arm_register_raw_size, arm_register_virtual_size): Delete.
	(arm_register_byte, arm_extract_return_value)
	(arm_store_return_value, arm_get_longjmp_target): Update references
	to INT_REGISTER_RAW_SIZE and FP_REGISTER_RAW_SIZE.
	(arm_gdbarch_init): Likewise.  Don't set
	deprecated_register_raw_size, deprecated_register_virtual_size,
	deprecated_max_register_raw_size,
	deprecated_max_register_virtual_size, or
	deprecated_max_register_virtual_type.  Do set register_type.
	* arm-tdep.h (ARM_MAX_REGISTER_RAW_SIZE)
	(ARM_MAX_REGISTER_VIRTUAL_SIZE, INT_REGISTER_VIRTUAL_SIZE)
	(FP_REGISTER_VIRTUAL_SIZE): Delete.
	(INT_REGISTER_RAW_SIZE): Rename to INT_REGISTER_SIZE.
	(FP_REGISTER_RAW_SIZE): Rename to FP_REGISTER_SIZE.
	* arm-linux-tdep.c (ARM_NBSD_JB_ELEMENT_SIZE): Define to
	INT_REGISTER_SIZE.
	* remote-rdp.c (remote_rdp_fetch_register): Use MAX_REGISTER_SIZE.
	(remote_rdp_store_register): Likewise.

Index: arm-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-linux-tdep.c,v
retrieving revision 1.39
diff -u -p -r1.39 arm-linux-tdep.c
--- arm-linux-tdep.c	15 Nov 2003 14:02:57 -0000	1.39
+++ arm-linux-tdep.c	24 Mar 2004 21:57:11 -0000
@@ -59,7 +59,7 @@ LONGEST arm_linux_call_dummy_words[] =
 };
 
 /* Description of the longjmp buffer.  */
-#define ARM_LINUX_JB_ELEMENT_SIZE	INT_REGISTER_RAW_SIZE
+#define ARM_LINUX_JB_ELEMENT_SIZE	INT_REGISTER_SIZE
 #define ARM_LINUX_JB_PC			21
 
 /* Extract from an array REGBUF containing the (raw) register state
@@ -130,7 +130,7 @@ arm_linux_push_arguments (int nargs, str
       /* ANSI C code passes float arguments as integers, K&R code
          passes float arguments as doubles.  Correct for this here.  */
       if (TYPE_CODE_FLT == TYPE_CODE (arg_type) && DEPRECATED_REGISTER_SIZE == len)
-	nstack_size += FP_REGISTER_VIRTUAL_SIZE;
+	nstack_size += TARGET_DOUBLE_BIT / TARGET_CHAR_BIT;
       else
 	nstack_size += len;
     }
Index: arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.168
diff -u -p -r1.168 arm-tdep.c
--- arm-tdep.c	23 Mar 2004 14:47:55 -0000	1.168
+++ arm-tdep.c	24 Mar 2004 21:57:12 -0000
@@ -1094,7 +1094,7 @@ arm_make_sigtramp_cache (struct frame_in
   cache->framereg = ARM_SP_REGNUM;
   cache->prev_sp
     = read_memory_integer (cache->saved_regs[cache->framereg].addr,
-			   DEPRECATED_REGISTER_RAW_SIZE (cache->framereg));
+			   register_size (current_gdbarch, cache->framereg));
 
   return cache;
 }
@@ -1396,7 +1396,7 @@ arm_print_float_info (struct gdbarch *gd
    register N.  */
 
 static struct type *
-arm_register_type (int regnum)
+arm_register_type (struct gdbarch *gdbarch, int regnum)
 {
   if (regnum >= ARM_F0_REGNUM && regnum < ARM_F0_REGNUM + NUM_FREGS)
     {
@@ -1416,44 +1416,16 @@ static int
 arm_register_byte (int regnum)
 {
   if (regnum < ARM_F0_REGNUM)
-    return regnum * INT_REGISTER_RAW_SIZE;
+    return regnum * INT_REGISTER_SIZE;
   else if (regnum < ARM_PS_REGNUM)
-    return (NUM_GREGS * INT_REGISTER_RAW_SIZE
-	    + (regnum - ARM_F0_REGNUM) * FP_REGISTER_RAW_SIZE);
+    return (NUM_GREGS * INT_REGISTER_SIZE
+	    + (regnum - ARM_F0_REGNUM) * FP_REGISTER_SIZE);
   else
-    return (NUM_GREGS * INT_REGISTER_RAW_SIZE
-	    + NUM_FREGS * FP_REGISTER_RAW_SIZE
+    return (NUM_GREGS * INT_REGISTER_SIZE
+	    + NUM_FREGS * FP_REGISTER_SIZE
 	    + (regnum - ARM_FPS_REGNUM) * STATUS_REGISTER_SIZE);
 }
 
-/* Number of bytes of storage in the actual machine representation for
-   register N.  All registers are 4 bytes, except fp0 - fp7, which are
-   12 bytes in length.  */
-
-static int
-arm_register_raw_size (int regnum)
-{
-  if (regnum < ARM_F0_REGNUM)
-    return INT_REGISTER_RAW_SIZE;
-  else if (regnum < ARM_FPS_REGNUM)
-    return FP_REGISTER_RAW_SIZE;
-  else
-    return STATUS_REGISTER_SIZE;
-}
-
-/* Number of bytes of storage in a program's representation
-   for register N.  */
-static int
-arm_register_virtual_size (int regnum)
-{
-  if (regnum < ARM_F0_REGNUM)
-    return INT_REGISTER_VIRTUAL_SIZE;
-  else if (regnum < ARM_FPS_REGNUM)
-    return FP_REGISTER_VIRTUAL_SIZE;
-  else
-    return STATUS_REGISTER_SIZE;
-}
-
 /* Map GDB internal REGNUM onto the Arm simulator register numbers.  */
 static int
 arm_register_sim_regno (int regnum)
@@ -2082,7 +2054,7 @@ arm_extract_return_value (struct type *t
 	    /* The value is in register F0 in internal format.  We need to
 	       extract the raw value and then convert it to the desired
 	       internal type.  */
-	    bfd_byte tmpbuf[FP_REGISTER_RAW_SIZE];
+	    bfd_byte tmpbuf[FP_REGISTER_SIZE];
 
 	    regcache_cooked_read (regs, ARM_F0_REGNUM, tmpbuf);
 	    convert_from_extended (floatformat_from_type (type), tmpbuf,
@@ -2095,7 +2067,7 @@ arm_extract_return_value (struct type *t
 	  regcache_cooked_read (regs, ARM_A1_REGNUM, valbuf);
 	  if (TYPE_LENGTH (type) > 4)
 	    regcache_cooked_read (regs, ARM_A1_REGNUM + 1,
-				  valbuf + INT_REGISTER_RAW_SIZE);
+				  valbuf + INT_REGISTER_SIZE);
 	  break;
 
 	default:
@@ -2124,11 +2096,11 @@ arm_extract_return_value (struct type *t
 	     anything special for small big-endian values.  */
 	  regcache_cooked_read_unsigned (regs, regno++, &tmp);
 	  store_unsigned_integer (valbuf, 
-				  (len > INT_REGISTER_RAW_SIZE
-				   ? INT_REGISTER_RAW_SIZE : len),
+				  (len > INT_REGISTER_SIZE
+				   ? INT_REGISTER_SIZE : len),
 				  tmp);
-	  len -= INT_REGISTER_RAW_SIZE;
-	  valbuf += INT_REGISTER_RAW_SIZE;
+	  len -= INT_REGISTER_SIZE;
+	  valbuf += INT_REGISTER_SIZE;
 	}
     }
   else
@@ -2138,15 +2110,15 @@ arm_extract_return_value (struct type *t
          registers with 32-bit load instruction(s).  */
       int len = TYPE_LENGTH (type);
       int regno = ARM_A1_REGNUM;
-      bfd_byte tmpbuf[INT_REGISTER_RAW_SIZE];
+      bfd_byte tmpbuf[INT_REGISTER_SIZE];
 
       while (len > 0)
 	{
 	  regcache_cooked_read (regs, regno++, tmpbuf);
 	  memcpy (valbuf, tmpbuf,
-		  len > INT_REGISTER_RAW_SIZE ? INT_REGISTER_RAW_SIZE : len);
-	  len -= INT_REGISTER_RAW_SIZE;
-	  valbuf += INT_REGISTER_RAW_SIZE;
+		  len > INT_REGISTER_SIZE ? INT_REGISTER_SIZE : len);
+	  len -= INT_REGISTER_SIZE;
+	  valbuf += INT_REGISTER_SIZE;
 	}
     }
 }
@@ -2270,7 +2242,7 @@ arm_store_return_value (struct type *typ
 
   if (TYPE_CODE (type) == TYPE_CODE_FLT)
     {
-      char buf[ARM_MAX_REGISTER_RAW_SIZE];
+      char buf[MAX_REGISTER_SIZE];
 
       switch (arm_get_fp_model (current_gdbarch))
 	{
@@ -2285,7 +2257,7 @@ arm_store_return_value (struct type *typ
 	  regcache_cooked_write (regs, ARM_A1_REGNUM, valbuf);
 	  if (TYPE_LENGTH (type) > 4)
 	    regcache_cooked_write (regs, ARM_A1_REGNUM + 1, 
-				   valbuf + INT_REGISTER_RAW_SIZE);
+				   valbuf + INT_REGISTER_SIZE);
 	  break;
 
 	default:
@@ -2306,10 +2278,10 @@ arm_store_return_value (struct type *typ
 	{
 	  /* Values of one word or less are zero/sign-extended and
 	     returned in r0.  */
-	  bfd_byte tmpbuf[INT_REGISTER_RAW_SIZE];
+	  bfd_byte tmpbuf[INT_REGISTER_SIZE];
 	  LONGEST val = unpack_long (type, valbuf);
 
-	  store_signed_integer (tmpbuf, INT_REGISTER_RAW_SIZE, val);
+	  store_signed_integer (tmpbuf, INT_REGISTER_SIZE, val);
 	  regcache_cooked_write (regs, ARM_A1_REGNUM, tmpbuf);
 	}
       else
@@ -2323,8 +2295,8 @@ arm_store_return_value (struct type *typ
 	  while (len > 0)
 	    {
 	      regcache_cooked_write (regs, regno++, valbuf);
-	      len -= INT_REGISTER_RAW_SIZE;
-	      valbuf += INT_REGISTER_RAW_SIZE;
+	      len -= INT_REGISTER_SIZE;
+	      valbuf += INT_REGISTER_SIZE;
 	    }
 	}
     }
@@ -2335,15 +2307,15 @@ arm_store_return_value (struct type *typ
          registers with 32-bit load instruction(s).  */
       int len = TYPE_LENGTH (type);
       int regno = ARM_A1_REGNUM;
-      bfd_byte tmpbuf[INT_REGISTER_RAW_SIZE];
+      bfd_byte tmpbuf[INT_REGISTER_SIZE];
 
       while (len > 0)
 	{
 	  memcpy (tmpbuf, valbuf,
-		  len > INT_REGISTER_RAW_SIZE ? INT_REGISTER_RAW_SIZE : len);
+		  len > INT_REGISTER_SIZE ? INT_REGISTER_SIZE : len);
 	  regcache_cooked_write (regs, regno++, tmpbuf);
-	  len -= INT_REGISTER_RAW_SIZE;
-	  valbuf += INT_REGISTER_RAW_SIZE;
+	  len -= INT_REGISTER_SIZE;
+	  valbuf += INT_REGISTER_SIZE;
 	}
     }
 }
@@ -2352,16 +2324,16 @@ static int
 arm_get_longjmp_target (CORE_ADDR *pc)
 {
   CORE_ADDR jb_addr;
-  char buf[INT_REGISTER_RAW_SIZE];
+  char buf[INT_REGISTER_SIZE];
   struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
   
   jb_addr = read_register (ARM_A1_REGNUM);
 
   if (target_read_memory (jb_addr + tdep->jb_pc * tdep->jb_elt_size, buf,
-			  INT_REGISTER_RAW_SIZE))
+			  INT_REGISTER_SIZE))
     return 0;
 
-  *pc = extract_unsigned_integer (buf, INT_REGISTER_RAW_SIZE);
+  *pc = extract_unsigned_integer (buf, INT_REGISTER_SIZE);
   return 1;
 }
 
@@ -2805,15 +2777,11 @@ arm_gdbarch_init (struct gdbarch_info in
   set_gdbarch_pc_regnum (gdbarch, ARM_PC_REGNUM);
   set_gdbarch_deprecated_register_byte (gdbarch, arm_register_byte);
   set_gdbarch_deprecated_register_bytes (gdbarch,
-					 (NUM_GREGS * INT_REGISTER_RAW_SIZE
-					  + NUM_FREGS * FP_REGISTER_RAW_SIZE
+					 (NUM_GREGS * INT_REGISTER_SIZE
+					  + NUM_FREGS * FP_REGISTER_SIZE
 					  + NUM_SREGS * STATUS_REGISTER_SIZE));
   set_gdbarch_num_regs (gdbarch, NUM_GREGS + NUM_FREGS + NUM_SREGS);
-  set_gdbarch_deprecated_register_raw_size (gdbarch, arm_register_raw_size);
-  set_gdbarch_deprecated_register_virtual_size (gdbarch, arm_register_virtual_size);
-  set_gdbarch_deprecated_max_register_raw_size (gdbarch, FP_REGISTER_RAW_SIZE);
-  set_gdbarch_deprecated_max_register_virtual_size (gdbarch, FP_REGISTER_VIRTUAL_SIZE);
-  set_gdbarch_deprecated_register_virtual_type (gdbarch, arm_register_type);
+  set_gdbarch_register_type (gdbarch, arm_register_type);
 
   /* Internal <-> external register number maps.  */
   set_gdbarch_register_sim_regno (gdbarch, arm_register_sim_regno);
Index: arm-tdep.h
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.h,v
retrieving revision 1.11
diff -u -p -r1.11 arm-tdep.h
--- arm-tdep.h	22 Mar 2003 20:39:21 -0000	1.11
+++ arm-tdep.h	24 Mar 2004 21:57:12 -0000
@@ -45,24 +45,13 @@ enum gdb_regnum {
   ARM_LAST_FP_ARG_REGNUM = ARM_F3_REGNUM
 };
 
-/* Used in target-specific code when we need to know the size of the
-   largest type of register we need to handle.  */
-#define ARM_MAX_REGISTER_RAW_SIZE	12
-#define ARM_MAX_REGISTER_VIRTUAL_SIZE	8
-
 /* Size of integer registers.  */
-#define INT_REGISTER_RAW_SIZE		4
-#define INT_REGISTER_VIRTUAL_SIZE	4
+#define INT_REGISTER_SIZE		4
 
 /* Say how long FP registers are.  Used for documentation purposes and
    code readability in this header.  IEEE extended doubles are 80
    bits.  DWORD aligned they use 96 bits.  */
-#define FP_REGISTER_RAW_SIZE	12
-
-/* GCC doesn't support long doubles (extended IEEE values).  The FP
-   register virtual size is therefore 64 bits.  Used for documentation
-   purposes and code readability in this header.  */
-#define FP_REGISTER_VIRTUAL_SIZE	8
+#define FP_REGISTER_SIZE	12
 
 /* Status registers are the same size as general purpose registers.
    Used for documentation purposes and code readability in this
Index: armnbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/armnbsd-tdep.c,v
retrieving revision 1.10
diff -u -p -r1.10 armnbsd-tdep.c
--- armnbsd-tdep.c	24 Mar 2003 09:53:41 -0000	1.10
+++ armnbsd-tdep.c	24 Mar 2004 21:57:12 -0000
@@ -27,7 +27,7 @@
 
 /* Description of the longjmp buffer.  */
 #define ARM_NBSD_JB_PC 24
-#define ARM_NBSD_JB_ELEMENT_SIZE INT_REGISTER_RAW_SIZE
+#define ARM_NBSD_JB_ELEMENT_SIZE INT_REGISTER_SIZE
 
 /* For compatibility with previous implemenations of GDB on arm/NetBSD,
    override the default little-endian breakpoint.  */
Index: remote-rdp.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-rdp.c,v
retrieving revision 1.35
diff -u -p -r1.35 remote-rdp.c
--- remote-rdp.c	22 Nov 2003 15:48:30 -0000	1.35
+++ remote-rdp.c	24 Mar 2004 21:57:12 -0000
@@ -630,7 +630,7 @@ remote_rdp_fetch_register (int regno)
     }
   else
     {
-      char buf[ARM_MAX_REGISTER_RAW_SIZE];
+      char buf[MAX_REGISTER_SIZE];
       if (regno < 15)
 	rdp_fetch_one_register (1 << regno, buf);
       else if (regno == ARM_PC_REGNUM)
@@ -660,7 +660,7 @@ remote_rdp_store_register (int regno)
     }
   else
     {
-      char tmp[ARM_MAX_REGISTER_RAW_SIZE];
+      char tmp[MAX_REGISTER_SIZE];
       deprecated_read_register_gen (regno, tmp);
       if (regno < 15)
 	rdp_store_one_register (1 << regno, tmp);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]