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]

[rfc] Re: read_register_bytes() bug; was my Regcache revamp



> I think the ``real bug'' is that the updated read_register_bytes() can
> leave part of the buffer undefined.  I'm thinking of either changing
> things to:
> 
>     o    initializing the gaps from
>         the regcache (restoring old
>         behavour)


The attached patch implements this.  Thoughts?

	Andrew

2001-08-18  Andrew Cagney  <cagney@redhat.com>

	* regcache.c (read_register_bytes): When REGISTER_NAME indicates
	that a register should be ignored, supply a value for the register
	from the raw registers[] buffer.

Index: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.25
diff -p -r1.25 regcache.c
*** regcache.c	2001/08/10 21:52:17	1.25
--- regcache.c	2001/08/18 20:56:53
*************** read_register_bytes (int in_start, char 
*** 230,238 ****
        int end;
        int byte;
  
-       if (REGISTER_NAME (regnum) == NULL || *REGISTER_NAME (regnum) == '\0')
- 	continue;
- 
        reg_start = REGISTER_BYTE (regnum);
        reg_len = REGISTER_RAW_SIZE (regnum);
        reg_end = reg_start + reg_len;
--- 230,235 ----
*************** read_register_bytes (int in_start, char 
*** 241,248 ****
  	/* The range the user wants to read doesn't overlap with regnum.  */
  	continue;
  
!       /* Force the cache to fetch the entire register. */
!       read_register_gen (regnum, reg_buf);
  
        /* Legacy note: This function, for some reason, allows a NULL
           input buffer.  If the buffer is NULL, the registers are still
--- 238,255 ----
  	/* The range the user wants to read doesn't overlap with regnum.  */
  	continue;
  
!       if (REGISTER_NAME (regnum) != NULL && *REGISTER_NAME (regnum) != '\0')
! 	/* Force the cache to fetch the entire register.  */
! 	read_register_gen (regnum, reg_buf);
!       else
! 	/* Legacy note: even though this register is ``invalid'' we
!            still need to return something.  It would appear that some
!            code relies on apparent gaps in the register array also
!            being returned.  */
! 	/* FIXME: cagney/2001-08-18: This is just silly.  It defeats
!            the entire register read/write flow of control.  Must
!            resist temptation to return 0xdeadbeef.  */
! 	memcpy (reg_buf, registers + reg_start, reg_len);
  
        /* Legacy note: This function, for some reason, allows a NULL
           input buffer.  If the buffer is NULL, the registers are still

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