This is the mail archive of the gdb-patches@sourceware.org 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]

[RFC] Fix v850 `num_reg' issues


The patch below fixes some problems introduced by the recent commit
of support for v850e2 and v850e2v3.

There are several problems fixed by this patch:

First, the constants E_NUM_OF_V850_REGS and E_NUM_OF_V850E_REGS
were defined, but not used.  This patch causes them to be used.

These constants were also defined incorrectly, each of which was off
by one, thus excluding the fp register.  My patch corrects this
fencepost error.

Lastly, E_NUM_REGS is now the constant that now defines the number of
registers used for v850e2 and v850e2v3.  This constant is (or was,
once my patch is installed) being used for all architectures, even
when the other architectures have fewer registers.  My patch sets
`num_regs' to the correct value for each architecture.  It also uses
gdbarch_num_regs() instead of this constant in other instances where
it's necessary to use the correct value for the architecture in question.

Comments?

Kevin

	* v850-tdep.c (E_NUM_OF_V850_REGS, E_NUM_OF_V850E_REGS): Fix
	fencepost error.
	(v850_frame_cache): Use gdbarch_num_regs() instead of E_NUM_REGS.
	(v850_gdbarch_init): Set `num_regs' as appropriate for the
	architecture.

Index: v850-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/v850-tdep.c,v
retrieving revision 1.120
diff -u -p -r1.120 v850-tdep.c
--- v850-tdep.c	29 Mar 2012 00:57:19 -0000	1.120
+++ v850-tdep.c	29 Mar 2012 19:37:38 -0000
@@ -101,10 +101,12 @@ enum
     E_R62_REGNUM,
     E_R63_REGNUM,
     E_R64_REGNUM, E_PC_REGNUM = E_R64_REGNUM,
-    E_R65_REGNUM, E_NUM_OF_V850_REGS = E_R65_REGNUM, E_NUM_OF_V850E_REGS = E_R65_REGNUM,
+    E_R65_REGNUM,
+    E_NUM_OF_V850_REGS,
+    E_NUM_OF_V850E_REGS = E_NUM_OF_V850_REGS,
 
     /* mpu0 system registers */
-    E_R66_REGNUM,
+    E_R66_REGNUM = E_NUM_OF_V850_REGS,
     E_R67_REGNUM,
     E_R68_REGNUM,
     E_R69_REGNUM,
@@ -1023,7 +1025,7 @@ v850_frame_cache (struct frame_info *thi
 
   /* Adjust all the saved registers such that they contain addresses
      instead of offsets.  */
-  for (i = 0; i < E_NUM_REGS; i++)
+  for (i = 0; i < gdbarch_num_regs (gdbarch); i++)
     if (trad_frame_addr_p (cache->saved_regs, i))
       cache->saved_regs[i].addr += cache->base;
 
@@ -1123,18 +1125,20 @@ v850_gdbarch_init (struct gdbarch_info i
     {
     case bfd_mach_v850:
       set_gdbarch_register_name (gdbarch, v850_register_name);
+      set_gdbarch_num_regs (gdbarch, E_NUM_OF_V850_REGS);
       break;
     case bfd_mach_v850e:
     case bfd_mach_v850e1:
       set_gdbarch_register_name (gdbarch, v850e_register_name);
+      set_gdbarch_num_regs (gdbarch, E_NUM_OF_V850E_REGS);
       break;
     case bfd_mach_v850e2:
     case bfd_mach_v850e2v3:
       set_gdbarch_register_name (gdbarch, v850e2_register_name);
+      set_gdbarch_num_regs (gdbarch, E_NUM_REGS);
       break;
     }
 
-  set_gdbarch_num_regs (gdbarch, E_NUM_REGS);
   set_gdbarch_num_pseudo_regs (gdbarch, 0);
   set_gdbarch_sp_regnum (gdbarch, E_SP_REGNUM);
   set_gdbarch_pc_regnum (gdbarch, E_PC_REGNUM);


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