Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] infptrace.c: use regcache_collect
@ 2001-11-07 15:02 Elena Zannoni
  2001-11-07 17:58 ` Andrew Cagney
  0 siblings, 1 reply; 3+ messages in thread
From: Elena Zannoni @ 2001-11-07 15:02 UTC (permalink / raw)
  To: gdb-patches


Is this ok?

Thanks
Elena

2001-11-19  Elena Zannoni  <ezannoni@redhat.com>

	* infptrace.c (fetch_register): Dynamically allocate buffer for
	register.
	(store_register): Use regcache_collect, instead of accessing the
	register buffer directly.


Index: infptrace.c
===================================================================
RCS file: /cvs/uberbaum/gdb/infptrace.c,v
retrieving revision 1.18
diff -u -p -c -r1.18 infptrace.c
cvs server: conflicting specifications of output style
*** infptrace.c	2001/10/21 14:53:46	1.18
--- infptrace.c	2001/11/19 19:23:08
*************** fetch_register (int regno)
*** 359,365 ****
    char mess[128];		/* For messages */
    register int i;
    unsigned int offset;		/* Offset of registers within the u area.  */
!   char buf[MAX_REGISTER_RAW_SIZE];
    int tid;
  
    if (CANNOT_FETCH_REGISTER (regno))
--- 359,365 ----
    char mess[128];		/* For messages */
    register int i;
    unsigned int offset;		/* Offset of registers within the u area.  */
!   char *buf = alloca (MAX_REGISTER_RAW_SIZE);
    int tid;
  
    if (CANNOT_FETCH_REGISTER (regno))
*************** store_register (int regno)
*** 424,429 ****
--- 424,430 ----
    register int i;
    unsigned int offset;		/* Offset of registers within the u area.  */
    int tid;
+   char *buf = alloca (MAX_REGISTER_RAW_SIZE);
  
    if (CANNOT_STORE_REGISTER (regno))
      {
*************** store_register (int regno)
*** 437,447 ****
    offset = U_REGS_OFFSET;
  
    regaddr = register_addr (regno, offset);
    for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (PTRACE_XFER_TYPE))
      {
        errno = 0;
        ptrace (PT_WRITE_U, tid, (PTRACE_ARG3_TYPE) regaddr,
! 	      *(PTRACE_XFER_TYPE *) & registers[REGISTER_BYTE (regno) + i]);
        regaddr += sizeof (PTRACE_XFER_TYPE);
        if (errno != 0)
  	{
--- 438,453 ----
    offset = U_REGS_OFFSET;
  
    regaddr = register_addr (regno, offset);
+ 
+   /* Put the contents of regno into a local buffer */
+   regcache_collect (regno, buf);
+ 
+   /* Store the local buffer into the inferior a chunk at the time. */
    for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (PTRACE_XFER_TYPE))
      {
        errno = 0;
        ptrace (PT_WRITE_U, tid, (PTRACE_ARG3_TYPE) regaddr,
! 	      *(PTRACE_XFER_TYPE *) (buf + i));
        regaddr += sizeof (PTRACE_XFER_TYPE);
        if (errno != 0)
  	{


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA] infptrace.c: use regcache_collect
  2001-11-07 15:02 [RFA] infptrace.c: use regcache_collect Elena Zannoni
@ 2001-11-07 17:58 ` Andrew Cagney
  2001-11-07 18:31   ` Elena Zannoni
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cagney @ 2001-11-07 17:58 UTC (permalink / raw)
  To: Elena Zannoni; +Cc: gdb-patches

> 2001-11-19  Elena Zannoni  <ezannoni@redhat.com>
> 
> * infptrace.c (fetch_register): Dynamically allocate buffer for
> 	register.

[Grrr]

> 	(store_register): Use regcache_collect, instead of accessing the
> 	register buffer directly.
> 

Provided this has been tested and doesn't show regressions, I think the 
elimination of code like this can be considered pretty obvious.  (Only 
400 uses of registers[] remaining ...)

	Andrew



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFA] infptrace.c: use regcache_collect
  2001-11-07 17:58 ` Andrew Cagney
@ 2001-11-07 18:31   ` Elena Zannoni
  0 siblings, 0 replies; 3+ messages in thread
From: Elena Zannoni @ 2001-11-07 18:31 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: Elena Zannoni, gdb-patches

Andrew Cagney writes:
 > > 2001-11-19  Elena Zannoni  <ezannoni@redhat.com>
 > > 
 > > * infptrace.c (fetch_register): Dynamically allocate buffer for
 > > 	register.
 > 
 > [Grrr]
 > 
 > > 	(store_register): Use regcache_collect, instead of accessing the
 > > 	register buffer directly.
 > > 
 > 
 > Provided this has been tested and doesn't show regressions, I think the 
 > elimination of code like this can be considered pretty obvious.  (Only 
 > 400 uses of registers[] remaining ...)
 > 
 > 	Andrew
 > 


I had tested on ppc-linux native. No regressions.
(I am going to get rid of another few...)

Elena


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-11-19 23:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-07 15:02 [RFA] infptrace.c: use regcache_collect Elena Zannoni
2001-11-07 17:58 ` Andrew Cagney
2001-11-07 18:31   ` Elena Zannoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox