RFA: Optimization to write_register_bytes()
Andrew Cagney
ac131313@cygnus.com
Fri Jun 9 18:12:00 GMT 2000
Fernando Nasser wrote:
>
> 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.
>
> *************** 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;
> ! }
FYI, I've seen nothing that demonstrates that this change is safe :-(
Unless someone examines every register layout for every target we've
forced to assume otherwize :-(
I'm not even 100% sure of the change I suggested - keep track of which
bytes have been written so that when the number remaining gets to zero
exit. There could easily be a target that has two physical registers
mapped onto a single region - it may expect separate writes for each.
> /* 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;
> +
Here, why clone write_register_gen() why not just call it? We're trying
to reduce the number of places where people blat that register buffer
not increase them.
Sorry,
Andrew
More information about the Gdb-patches
mailing list