This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
RFA: Optimization to write_register_bytes()
- To: Andrew Cagney <ac131313 at cygnus dot com>, gdb-patches at sourceware dot cygnus dot com
- Subject: RFA: Optimization to write_register_bytes()
- From: Fernando Nasser <fnasser at cygnus dot com>
- Date: Fri, 09 Jun 2000 14:42:52 +0000
- Organization: Cygnus Solutions (a Red Hat company) - Toronto
- References: <39117943.9609EB0C@cygnus.com> <391198C4.ABC15EEE@cygnus.com> <3911C84D.FC1E138E@cygnus.com> <391210A0.C9DA7860@cygnus.com> <39122F53.6278AF70@cygnus.com> <391243C4.F4B8286A@cygnus.com> <39128035.82819D7B@cygnus.com> <39407599.9D14F301@cygnus. <3940D9F2.65EBDCBF@cygnus.com> <3940FD3E.EB2FBD72@cygnus.com>
This patch includes the changes requested by Andrew Cagney.
Here is the new version, with ChangeLog for approval.
Thanks.
Fernando
2000-06-09 Fernando Nasser <fnasser@totem.to.cygnus.com>
* findvar.c (write_register_bytes): Cut loop short after the
register that contains the last bytes in the range is written.
This makes things a little faster and also prevents that we try to
write to alias registers. Also, we do not write if contents have
not changed.
--
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
Index: findvar.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/findvar.c,v
retrieving revision 1.118
diff -c -p -r1.118 findvar.c
*** findvar.c 2000/05/01 04:46:47 1.118
--- findvar.c 2000/06/09 14:32:34
*************** write_register_bytes (myregstart, myaddr
*** 833,839 ****
/* 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++)
{
--- 834,847 ----
/* 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 registers until the byte at myregend is written.
! This way we prevent unecessary iterations. Make sure the last
! register in the range has the highest number.
! This also 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++)
{
*************** 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
--- 856,866 ----
/* 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
*** 863,873 ****
--- 875,895 ----
Update it from the target before scribbling on it. */
read_register_gen (regno, regbuf);
+ /* If new value == old value, then don't bother doing the
+ actual store. */
+ if (memcmp (registers + overlapstart,
+ myaddr + (overlapstart - myregstart),
+ overlapend - overlapstart) == 0)
+ continue;
+
memcpy (registers + overlapstart,
myaddr + (overlapstart - myregstart),
overlapend - overlapstart);
target_store_registers (regno);
+
+ if (regend >= myregend)
+ break;
}
}
}