This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: read_register_byte can't work with pseudo-reg model
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: Andrew Cagney <ac131313 at cygnus dot com>
- Cc: Richard dot Earnshaw at arm dot com, Elena Zannoni <ezannoni at redhat dot com>, gdb at sources dot redhat dot com
- Date: Thu, 16 May 2002 16:35:39 +0100
- Subject: Re: read_register_byte can't work with pseudo-reg model
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
> > I'm guessing. Try:
> >>
> >> if (REGISTER_READ_P ())
> >> {
> >> do something fairly sane;
> >> }
> >> else
> >> {
> >> all the legacy cruft including the call to
> >> legacy_read_register_gen() and that test.
> >> }
> >>
> >> Thing is that there is only one target in the FSF using
> >> READ_REGISTER_P() so there is this dividing line - something using
> >> read_register_p() can be given far stronger requirements than for the
> >> older code.
> >
> >
> > Which target is that, and where is READ_REGISTER_P ? I can't find
> > anything in the either the source or the mailing lists. Mind you, the
> > web-based mailing list search even fails to find your message when I
> > search for READ_REGISTER_P.
Ok, the following solves my problem; it also makes saving/restoring the
regcache far more efficient on machines that have that have
READ_REGISTER_P.
The only assumption is that if this is defined, then pseudos do not need
unique entries in the regcache (ie they always map onto physical
registers), so we can copy the regcache simply by iterating over
0..NUM_REGS.
I need to re-baseline my testsuite runs, but the results look pretty
encouraging compared to previous runs.
Elena, would this be compatible with the SH model?
R.
* regcache.c (read_register_bytes): If read_register_p is defined
and we are saving the entire register set, then short-cut the
save operation.
(write_register_bytes): Similarly for write_register_p and restoring
the register set.
Index: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.34
diff -p -r1.34 regcache.c
*** regcache.c 6 Apr 2002 00:02:50 -0000 1.34
--- regcache.c 16 May 2002 15:31:56 -0000
*************** read_register_bytes (int in_start, char
*** 228,233 ****
--- 228,248 ----
int regnum;
char *reg_buf = alloca (MAX_REGISTER_RAW_SIZE);
+ if (gdbarch_register_read_p (current_gdbarch)
+ && in_start == 0 && in_len == REGISTER_BYTES) /* OK Use. */
+ {
+ /* We assume that if the target has set register_read_p() then
+ all the pseuos will be correctly mapped onto raw registers.
+ Therefore, the regcache describes only the registers in the
+ range [0..NUM_REGS) and the code for reading the entire
+ regset becomes much simpler. */
+
+ for (regnum = 0; regnum < NUM_REGS; regnum++)
+ regcache_read (regnum, in_buf + REGISTER_BYTE (regnum));
+
+ return;
+ }
+
/* See if we are trying to read bytes from out-of-date registers. If so,
update just those registers. */
*************** write_register_bytes (int myregstart, ch
*** 397,402 ****
--- 412,432 ----
int regnum;
target_prepare_to_store ();
+
+ if (gdbarch_register_write_p (current_gdbarch)
+ && myregstart == 0 && inlen == REGISTER_BYTES) /* OK Use. */
+ {
+ /* We assume that if the target has set register_write_p() then
+ all the pseuos will be correctly mapped onto raw registers.
+ Therefore, the regcache describes only the registers in the
+ range [0..NUM_REGS) and the code for restoring things becomes
+ much simpler. */
+
+ for (regnum = 0; regnum < NUM_REGS; regnum++)
+ regcache_write (regnum, myaddr + REGISTER_BYTE (regnum));
+
+ return;
+ }
/* Scan through the registers updating any that are covered by the
range myregstart<=>myregend using write_register_gen, which does