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]

[patch] Add REGISTER_BYTE_P, check consistency


Hello,

Following up on the thread:
http://sources.redhat.com/ml/gdb/2003-05/msg00010.html
this adds REGISTER_BYTE_P and sanity checks to ensure that the [legacy] REGISTER_BYTE is consistent with the register cache. It also eliminates the stray REGISTER_BYTE call in sentinel-frame.


I'll commit it in a day or so ...

Andrew
2003-05-02  Andrew Cagney  <cagney@redhat.com>

	* sentinel-frame.c (sentinel_frame_prev_register): Replace
	REGISTER_BYTE with register_offset_hack.
	* regcache.c (init_regcache_descr): When REGISTER_BYTE_P, check
	that REGISTER_BYTE is consistent with the regcache.
	* gdbarch.sh (REGISTER_BYTE): Add a predicate.
	* gdbarch.h, gdbarch.c: Regenerate.
	
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.228
diff -u -r1.228 gdbarch.sh
--- gdbarch.sh	30 Apr 2003 22:01:37 -0000	1.228
+++ gdbarch.sh	2 May 2003 22:28:33 -0000
@@ -474,7 +474,12 @@
 f:2:REGISTER_NAME:const char *:register_name:int regnr:regnr:::legacy_register_name::0
 v:2:REGISTER_SIZE:int:register_size::::0:-1
 v:2:REGISTER_BYTES:int:register_bytes::::0:-1
-f:2:REGISTER_BYTE:int:register_byte:int reg_nr:reg_nr::generic_register_byte:generic_register_byte::0
+# NOTE: cagney/2002-05-02: This function with predicate has a valid
+# (callable) initial value.  As a consequence, even when the predicate
+# is false, the corresponding function works.  This simplifies the
+# migration process - old code, calling REGISTER_BYTE, doesn't need to
+# be modified.
+F::REGISTER_BYTE:int:register_byte:int reg_nr:reg_nr::generic_register_byte:generic_register_byte
 # The methods REGISTER_VIRTUAL_TYPE, MAX_REGISTER_RAW_SIZE,
 # MAX_REGISTER_VIRTUAL_SIZE, MAX_REGISTER_RAW_SIZE,
 # REGISTER_VIRTUAL_SIZE and REGISTER_RAW_SIZE are all being replaced
Index: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.75
diff -u -r1.75 regcache.c
--- regcache.c	29 Apr 2003 01:49:47 -0000	1.75
+++ regcache.c	2 May 2003 22:28:33 -0000
@@ -187,6 +187,12 @@
       && !gdbarch_pseudo_register_write_p (gdbarch)
       && !gdbarch_register_type_p (gdbarch))
     {
+      /* NOTE: cagney/2003-05-02: Don't add a test for REGISTER_BYTE_P
+	 to the above.  Doing that would cause all the existing
+	 architectures to revert back to the legacy regcache
+	 mechanisms, and that is not a good thing.  Instead just,
+	 later, check that the register cache's layout is consistent
+	 with REGISTER_BYTE.  */
       descr->legacy_p = 1;
       init_legacy_regcache_descr (gdbarch, descr);
       return descr;
@@ -233,21 +239,19 @@
      buffer.  Ulgh!  */
   descr->sizeof_raw_registers = descr->sizeof_cooked_registers;
 
-#if 0
-  /* Sanity check.  Confirm that the assumptions about gdbarch are
-     true.  The REGCACHE_DESCR_HANDLE is set before doing the checks
-     so that targets using the generic methods supplied by regcache
-     don't go into infinite recursion trying to, again, create the
-     regcache.  */
-  set_gdbarch_data (gdbarch, regcache_descr_handle, descr);
+  /* Sanity check.  Confirm that there is agreement between the
+     regcache and the target's redundant REGISTER_BYTE (new targets
+     should not even be defining it).  */
   for (i = 0; i < descr->nr_cooked_registers; i++)
     {
+      if (REGISTER_BYTE_P ())
+	gdb_assert (descr->register_offset[i] == REGISTER_BYTE (i));
+#if 0
       gdb_assert (descr->sizeof_register[i] == REGISTER_RAW_SIZE (i));
       gdb_assert (descr->sizeof_register[i] == REGISTER_VIRTUAL_SIZE (i));
-      gdb_assert (descr->register_offset[i] == REGISTER_BYTE (i));
+#endif
     }
   /* gdb_assert (descr->sizeof_raw_registers == REGISTER_BYTES (i));  */
-#endif
 
   return descr;
 }
Index: sentinel-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/sentinel-frame.c,v
retrieving revision 1.6
diff -u -r1.6 sentinel-frame.c
--- sentinel-frame.c	5 Apr 2003 03:56:00 -0000	1.6
+++ sentinel-frame.c	2 May 2003 22:28:33 -0000
@@ -56,7 +56,7 @@
      onto the corresponding hardware register.  */
   *optimized = 0;
   *lvalp = lval_register;
-  *addrp = REGISTER_BYTE (regnum);
+  *addrp = register_offset_hack (current_gdbarch, regnum);
   *realnum = regnum;
 
   /* If needed, find and return the value of the register.  */

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