This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Re: RFC: Optimization to write_register_bytes()
Andrew Cagney wrote:
>
(...) Register fix plan skipped
>
> PS: Fernando, sorry to hit you with this as a response. You're simply
> the latest in a long list of people (me included) that have had to
> wrestle with the current register-cache design. For as long as I can
> remember people have been comming to grief with this code (just changing
> REGISTER_NAMES[] to REGISTER_NAME() was a radical breakthrough :-). I
> would really like to set out something that is going to finally fix the
> problem.
No problem. I agree with you that all this code needs a redesign and I
believe the answer is some abstraction as you described. It is a good thing to add it to the TODO
list so we eventually get someone to implement it.
Unfortunately I won't be able to work on this at this time, but I still want/need to have the MMX
registers available as soon as possible. And adding the few lines below would allow me to do that
very easily.
Fernando
Index: findvar.c
===================================================================
RCS file: /cvs/src/src/gdb/findvar.c,v
retrieving revision 1.9
diff -c -p -r1.9 findvar.c
*** findvar.c 2000/04/27 15:33:01 1.9
--- findvar.c 2000/05/05 07:58:51
*************** write_register_bytes (myregstart, myaddr
*** 829,840 ****
int regno;
target_prepare_to_store ();
/* Scan through the registers updating any that are covered by the range
myregstart<=>myregend using write_register_gen, which does nice things
like handling threads, and avoiding updates when the new and old contents
! are the same. */
for (regno = 0; regno < NUM_REGS; regno++)
{
int regstart, regend;
--- 829,846 ----
int regno;
target_prepare_to_store ();
+
/* Scan through the registers updating any that are covered by the range
myregstart<=>myregend using write_register_gen, which does nice things
like handling threads, and avoiding updates when the new and old contents
! are the same.
+ We only update a contiguous range of registers, stopping when the
+ byte at myregend is written. This avoids writting to aliased registers
+ twice (note that aliased register numbers must be higher than the
+ real registers they share memory with). */
+
for (regno = 0; regno < NUM_REGS; regno++)
{
int regstart, regend;
*************** write_register_bytes (myregstart, myaddr
*** 848,854 ****
/* Is this register completely within the range the user is writing? */
else if (myregstart <= regstart && regend <= myregend)
! write_register_gen (regno, myaddr + (regstart - myregstart));
/* The register partially overlaps the range being written. */
else
--- 854,864 ----
/* Is this register completely within the range the user is writing? */
else if (myregstart <= regstart && regend <= myregend)
! {
! write_register_gen (regno, myaddr + (regstart - myregstart));
! if (regend >= myregend)
! break;
! }
/* The register partially overlaps the range being written. */
else
*************** write_register_bytes (myregstart, myaddr
*** 868,873 ****
--- 878,886 ----
overlapend - overlapstart);
target_store_registers (regno);
+
+ if (regend >= myregend)
+ break;
}
}
}
--
Fernando Nasser
Cygnus Solutions (a Red Hat company) E-Mail: fnasser@cygnus.com
2323 Yonge Street, Suite #300 Tel: 416-482-2661 ext. 311
Toronto, Ontario M4P 2C9 Fax: 416-482-6299