[rfc] Merge set_register_cache() and supply_register(,NULL)

Andrew Cagney ac131313@cygnus.com
Fri Mar 9 12:54:00 GMT 2001


Thoughts?

The attatched merges the semantics of the two sequences:

	supply_register (, zero_buf);
	set_register_cache(-1);

and 

	supply_register (, NULL);

Making the latter the only interface.  It marks the register as
unavailable and and stores zeroes in it.

The only thing looking that this ``unavailable'' status is the GUI
(Insight).

A number of existing targets suply NULL as the register value and, in
the cases I've checked the interpretation ``register not available'' is
the most applicable.

	Andrew
2001-03-08  Andrew Cagney  <ac131313@redhat.com>

	* remote.c (remote_fetch_registers): Supply a NULL register when
	register is not available.
	* regcache.h (set_register_cache): Delete declaration.
	(supply_register): Document behavour when register buffer is NULL.
	* regcache.c (set_register_cached): Make static.
	(supply_register): When buffer is NULL, mark register as
	unavailable.

Index: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.19
diff -p -r1.19 regcache.c
*** regcache.c	2001/03/06 08:21:11	1.19
--- regcache.c	2001/03/09 02:32:21
*************** supply_register (int regnum, char *val)
*** 536,548 ****
      }
  #endif
  
!   set_register_cached (regnum, 1);
!   if (val)
!     memcpy (register_buffer (regnum), val, 
! 	    REGISTER_RAW_SIZE (regnum));
    else
!     memset (register_buffer (regnum), '\000', 
! 	    REGISTER_RAW_SIZE (regnum));
  
    /* On some architectures, e.g. HPPA, there are a few stray bits in
       some registers, that the rest of the code would like to ignore.  */
--- 536,553 ----
      }
  #endif
  
!   if (val != NULL)
!     {
!       set_register_cached (regnum, 1);
!       memcpy (register_buffer (regnum), val, 
! 	      REGISTER_RAW_SIZE (regnum));
!     }
    else
!     {
!       set_register_cached (regnum, -1);
!       memset (register_buffer (regnum), '\000', 
! 	      REGISTER_RAW_SIZE (regnum));
!     }
  
    /* On some architectures, e.g. HPPA, there are a few stray bits in
       some registers, that the rest of the code would like to ignore.  */
Index: regcache.h
===================================================================
RCS file: /cvs/src/src/gdb/regcache.h,v
retrieving revision 1.3
diff -p -r1.3 regcache.h
*** regcache.h	2001/03/06 08:21:11	1.3
--- regcache.h	2001/03/09 02:32:21
*************** extern signed char *register_valid;
*** 34,41 ****
  
  extern int register_cached (int regnum);
  
- extern void set_register_cached (int regnum, int state);
- 
  extern void register_changed (int regnum);
  
  extern char *register_buffer (int regnum);
--- 34,39 ----
*************** extern LONGEST read_signed_register_pid 
*** 65,70 ****
--- 63,76 ----
  extern void write_register (int regnum, LONGEST val);
  
  extern void write_register_pid (int regnum, CORE_ADDR val, int pid);
+ 
+ /* Record that register REGNUM contains VAL.  This is used when the
+    value is obtained from the inferior or core dump, so there is no
+    need to store the value there.
+ 
+    If VAL is a NULL pointer, then it's probably an unsupported or
+    unavailable register.  We just set its value to all zeros and
+    record the register as unavailable.  */
  
  extern void supply_register (int regnum, char *val);
  
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.41
diff -p -r1.41 remote.c
*** remote.c	2001/03/06 08:21:13	1.41
--- remote.c	2001/03/09 02:32:36
*************** remote_fetch_registers (int regno)
*** 3092,3100 ****
  supply_them:
    for (i = 0; i < NUM_REGS; i++)
      {
-       supply_register (i, &regs[REGISTER_BYTE (i)]);
        if (buf[REGISTER_BYTE (i) * 2] == 'x')
! 	set_register_cached (i, -1);
      }
  }
  
--- 3092,3101 ----
  supply_them:
    for (i = 0; i < NUM_REGS; i++)
      {
        if (buf[REGISTER_BYTE (i) * 2] == 'x')
! 	supply_register (i, NULL);
!       else
! 	supply_register (i, &regs[REGISTER_BYTE (i)]);
      }
  }
  


More information about the Gdb-patches mailing list