Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] legacy_[read/write]_register_gen
@ 2002-01-28 17:09 Michael Snyder
  2002-01-28 19:19 ` Andrew Cagney
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Snyder @ 2002-01-28 17:09 UTC (permalink / raw)
  To: gdb-patches; +Cc: cagney


These two functions need to be able to read/write 
a pseudo-register as well as a real register.  

2002-01-28  Michael Snyder  <msnyder@redhat.com>

	* regcache.c (legacy_read_register_gen): Need to be able to
	read pseudo-register as well as real register.
	(legacy_write_register_gen): Ditto.

Index: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.30
diff -c -3 -p -r1.30 regcache.c
*** regcache.c	2002/01/15 02:06:46	1.30
--- regcache.c	2002/01/29 01:02:29
*************** legacy_read_register_gen (int regnum, ch
*** 310,316 ****
  void
  regcache_read (int rawnum, char *buf)
  {
!   gdb_assert (rawnum >= 0 && rawnum < NUM_REGS);
    /* For moment, just use underlying legacy code. Ulgh!!! */
    legacy_read_register_gen (rawnum, buf);
  }
--- 310,316 ----
  void
  regcache_read (int rawnum, char *buf)
  {
!   gdb_assert (rawnum >= 0 && rawnum < (NUM_REGS + NUM_PSEUDO_REGS));
    /* For moment, just use underlying legacy code. Ulgh!!! */
    legacy_read_register_gen (rawnum, buf);
  }
*************** legacy_write_register_gen (int regnum, c
*** 369,375 ****
  void
  regcache_write (int rawnum, char *buf)
  {
!   gdb_assert (rawnum >= 0 && rawnum < NUM_REGS);
    /* For moment, just use underlying legacy code. Ulgh!!! */
    legacy_write_register_gen (rawnum, buf);
  }
--- 369,375 ----
  void
  regcache_write (int rawnum, char *buf)
  {
!   gdb_assert (rawnum >= 0 && rawnum < (NUM_REGS + NUM_PSEUDO_REGS));
    /* For moment, just use underlying legacy code. Ulgh!!! */
    legacy_write_register_gen (rawnum, buf);
  }


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

* Re: [RFA] legacy_[read/write]_register_gen
  2002-01-28 17:09 [RFA] legacy_[read/write]_register_gen Michael Snyder
@ 2002-01-28 19:19 ` Andrew Cagney
  2002-01-29 10:45   ` Michael Snyder
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Cagney @ 2002-01-28 19:19 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb-patches, cagney

> These two functions need to be able to read/write 
> a pseudo-register as well as a real register.  
> 
> 2002-01-28  Michael Snyder  <msnyder@redhat.com>
> 
> * regcache.c (legacy_read_register_gen): Need to be able to
> 	read pseudo-register as well as real register.
> 	(legacy_write_register_gen): Ditto.


Michael,

When is this occuring?  Dig dig, I've a similar patch sitting in my 
sand-pit so, hmm, I've also seen it but don't remember why :-(

Andrew


> Index: regcache.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/regcache.c,v
> retrieving revision 1.30
> diff -c -3 -p -r1.30 regcache.c
> *** regcache.c	2002/01/15 02:06:46	1.30
> --- regcache.c	2002/01/29 01:02:29
> *************** legacy_read_register_gen (int regnum, ch
> *** 310,316 ****
>   void
>   regcache_read (int rawnum, char *buf)
>   {
> !   gdb_assert (rawnum >= 0 && rawnum < NUM_REGS);
>     /* For moment, just use underlying legacy code. Ulgh!!! */
>     legacy_read_register_gen (rawnum, buf);
>   }
> --- 310,316 ----
>   void
>   regcache_read (int rawnum, char *buf)
>   {
> !   gdb_assert (rawnum >= 0 && rawnum < (NUM_REGS + NUM_PSEUDO_REGS));
>     /* For moment, just use underlying legacy code. Ulgh!!! */
>     legacy_read_register_gen (rawnum, buf);
>   }
> *************** legacy_write_register_gen (int regnum, c
> *** 369,375 ****
>   void
>   regcache_write (int rawnum, char *buf)
>   {
> !   gdb_assert (rawnum >= 0 && rawnum < NUM_REGS);
>     /* For moment, just use underlying legacy code. Ulgh!!! */
>     legacy_write_register_gen (rawnum, buf);
>   }
> --- 369,375 ----
>   void
>   regcache_write (int rawnum, char *buf)
>   {
> !   gdb_assert (rawnum >= 0 && rawnum < (NUM_REGS + NUM_PSEUDO_REGS));
>     /* For moment, just use underlying legacy code. Ulgh!!! */
>     legacy_write_register_gen (rawnum, buf);
>   }
> 
> 
> 



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

* Re: [RFA] legacy_[read/write]_register_gen
  2002-01-28 19:19 ` Andrew Cagney
@ 2002-01-29 10:45   ` Michael Snyder
  2002-01-29 11:22     ` Andrew Cagney
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Snyder @ 2002-01-29 10:45 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: Michael Snyder, gdb-patches, cagney

Andrew Cagney wrote:
> 
> > These two functions need to be able to read/write
> > a pseudo-register as well as a real register.
> >
> > 2002-01-28  Michael Snyder  <msnyder@redhat.com>
> >
> > * regcache.c (legacy_read_register_gen): Need to be able to
> >       read pseudo-register as well as real register.
> >       (legacy_write_register_gen): Ditto.
> 
> Michael,
> 
> When is this occuring?  Dig dig, I've a similar patch sitting in my
> sand-pit so, hmm, I've also seen it but don't remember why :-(
> 
> Andrew

Simplest case -- say you want to have a pseudo-register that
mirrors the contents of a real register.

static void
my_fetch_pseudo_register (int regnum)
{
  if (regnum == MY_MIRROR_REGNUM)
    {
	char buf[REGISTER_SIZE];
	regcache_read (MY_REAL_REGNUM, buf);
	regcache_write (MY_MIRROR_REGNUM, buf);
    }
}

You can't do that unles legacy_write_register_bytes can address
the regcache location of your pseudo-register.

> > Index: regcache.c
> > ===================================================================
> > RCS file: /cvs/src/src/gdb/regcache.c,v
> > retrieving revision 1.30
> > diff -c -3 -p -r1.30 regcache.c
> > *** regcache.c        2002/01/15 02:06:46     1.30
> > --- regcache.c        2002/01/29 01:02:29
> > *************** legacy_read_register_gen (int regnum, ch
> > *** 310,316 ****
> >   void
> >   regcache_read (int rawnum, char *buf)
> >   {
> > !   gdb_assert (rawnum >= 0 && rawnum < NUM_REGS);
> >     /* For moment, just use underlying legacy code. Ulgh!!! */
> >     legacy_read_register_gen (rawnum, buf);
> >   }
> > --- 310,316 ----
> >   void
> >   regcache_read (int rawnum, char *buf)
> >   {
> > !   gdb_assert (rawnum >= 0 && rawnum < (NUM_REGS + NUM_PSEUDO_REGS));
> >     /* For moment, just use underlying legacy code. Ulgh!!! */
> >     legacy_read_register_gen (rawnum, buf);
> >   }
> > *************** legacy_write_register_gen (int regnum, c
> > *** 369,375 ****
> >   void
> >   regcache_write (int rawnum, char *buf)
> >   {
> > !   gdb_assert (rawnum >= 0 && rawnum < NUM_REGS);
> >     /* For moment, just use underlying legacy code. Ulgh!!! */
> >     legacy_write_register_gen (rawnum, buf);
> >   }
> > --- 369,375 ----
> >   void
> >   regcache_write (int rawnum, char *buf)
> >   {
> > !   gdb_assert (rawnum >= 0 && rawnum < (NUM_REGS + NUM_PSEUDO_REGS));
> >     /* For moment, just use underlying legacy code. Ulgh!!! */
> >     legacy_write_register_gen (rawnum, buf);
> >   }
> >
> >
> >


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

* Re: [RFA] legacy_[read/write]_register_gen
  2002-01-29 10:45   ` Michael Snyder
@ 2002-01-29 11:22     ` Andrew Cagney
  2002-01-29 11:31       ` Michael Snyder
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Cagney @ 2002-01-29 11:22 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb-patches


> Simplest case -- say you want to have a pseudo-register that
> mirrors the contents of a real register.
> 
> static void
> my_fetch_pseudo_register (int regnum)
> {
>   if (regnum == MY_MIRROR_REGNUM)
>     {
> 	char buf[REGISTER_SIZE];
> 	regcache_read (MY_REAL_REGNUM, buf);
> 	regcache_write (MY_MIRROR_REGNUM, buf);
>     }
> }
> 
> You can't do that unles legacy_write_register_bytes can address
> the regcache location of your pseudo-register.


That should be implemented as:

	my_register_read (int regnum, ...)
	{
	  if (regnum == MY_MIRROR_REGNUM)
	    regcache_read (MY_REAL_REGNUM, buf)
	  else
	    regcache_read (regnum, buf);
	}

GDB no longer needs to have duplicated register values in the regcache.

Anyway, I have figured out why the change is needed.  You can end up 
with ``real'' registers in the [NUM_REGS .. NUM_REGS+NUM_PSEUDO_REGS) 
range.  This happens (at present still theory) when a register that 
isn't in the G packet is fetched.

Andrew


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

* Re: [RFA] legacy_[read/write]_register_gen
  2002-01-29 11:22     ` Andrew Cagney
@ 2002-01-29 11:31       ` Michael Snyder
  2002-01-29 13:29         ` Andrew Cagney
  0 siblings, 1 reply; 7+ messages in thread
From: Michael Snyder @ 2002-01-29 11:31 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

Andrew Cagney wrote:
> 
> > Simplest case -- say you want to have a pseudo-register that
> > mirrors the contents of a real register.
> >
> > static void
> > my_fetch_pseudo_register (int regnum)
> > {
> >   if (regnum == MY_MIRROR_REGNUM)
> >     {
> >       char buf[REGISTER_SIZE];
> >       regcache_read (MY_REAL_REGNUM, buf);
> >       regcache_write (MY_MIRROR_REGNUM, buf);
> >     }
> > }
> >
> > You can't do that unles legacy_write_register_bytes can address
> > the regcache location of your pseudo-register.
> 
> That should be implemented as:
> 
>         my_register_read (int regnum, ...)
>         {
>           if (regnum == MY_MIRROR_REGNUM)
>             regcache_read (MY_REAL_REGNUM, buf)
>           else
>             regcache_read (regnum, buf);
>         }
> 
> GDB no longer needs to have duplicated register values in the regcache.
> 
> Anyway, I have figured out why the change is needed.  You can end up
> with ``real'' registers in the [NUM_REGS .. NUM_REGS+NUM_PSEUDO_REGS)
> range.  This happens (at present still theory) when a register that
> isn't in the G packet is fetched.

Shall I check it in?


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

* Re: [RFA] legacy_[read/write]_register_gen
  2002-01-29 11:31       ` Michael Snyder
@ 2002-01-29 13:29         ` Andrew Cagney
  2002-01-29 14:48           ` Michael Snyder
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew Cagney @ 2002-01-29 13:29 UTC (permalink / raw)
  To: Michael Snyder; +Cc: gdb-patches

> That should be implemented as:
>> 
>> my_register_read (int regnum, ...)
>> {
>> if (regnum == MY_MIRROR_REGNUM)
>> regcache_read (MY_REAL_REGNUM, buf)
>> else
>> regcache_read (regnum, buf);
>> }
>> 
>> GDB no longer needs to have duplicated register values in the regcache.
>> 
>> Anyway, I have figured out why the change is needed.  You can end up
>> with ``real'' registers in the [NUM_REGS .. NUM_REGS+NUM_PSEUDO_REGS)
>> range.  This happens (at present still theory) when a register that
>> isn't in the G packet is fetched.
> 
> 
> Shall I check it in?


Yes.  Thanks!

Andrew




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

* Re: [RFA] legacy_[read/write]_register_gen
  2002-01-29 13:29         ` Andrew Cagney
@ 2002-01-29 14:48           ` Michael Snyder
  0 siblings, 0 replies; 7+ messages in thread
From: Michael Snyder @ 2002-01-29 14:48 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: gdb-patches

Andrew Cagney wrote:
> 
> > That should be implemented as:
> >>
> >> my_register_read (int regnum, ...)
> >> {
> >> if (regnum == MY_MIRROR_REGNUM)
> >> regcache_read (MY_REAL_REGNUM, buf)
> >> else
> >> regcache_read (regnum, buf);
> >> }
> >>
> >> GDB no longer needs to have duplicated register values in the regcache.
> >>
> >> Anyway, I have figured out why the change is needed.  You can end up
> >> with ``real'' registers in the [NUM_REGS .. NUM_REGS+NUM_PSEUDO_REGS)
> >> range.  This happens (at present still theory) when a register that
> >> isn't in the G packet is fetched.
> >
> >
> > Shall I check it in?
> 
> Yes.  Thanks!
> 
> Andrew

Committed.


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

end of thread, other threads:[~2002-01-29 22:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-28 17:09 [RFA] legacy_[read/write]_register_gen Michael Snyder
2002-01-28 19:19 ` Andrew Cagney
2002-01-29 10:45   ` Michael Snyder
2002-01-29 11:22     ` Andrew Cagney
2002-01-29 11:31       ` Michael Snyder
2002-01-29 13:29         ` Andrew Cagney
2002-01-29 14:48           ` Michael Snyder

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