This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RFA: Optimization to write_register_bytes()


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;
        }
      }
  }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]