This is the mail archive of the gdb-patches@sources.redhat.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]

Re: [rfc] Regcache revamp (vip)


The change to read_register_bytes() included:

> !       if (reg_start >= in_start && reg_end <= in_end)
> !       /* register fits inside of in_buf. */
> !       memcpy (in_buf + (reg_start - in_start), reg_buf, reg_len);
> !       else if (reg_start >= in_start && reg_end > in_end)
> !       /* register crosses the end of in_buf. */
> !       memcpy (in_buf + (reg_start - in_start), reg_buf, in_end - reg_start);
> !       else if (reg_start < in_start && reg_end <= in_end)
> !       /* register crosses the start of in_buf. */
> !       memcpy (in_buf, reg_buf + (in_start - reg_start),
> !               reg_end - in_start);
> !       else
> !       internal_error (__FILE__, __LINE__, "read_register_bytes botch");

Hmm, this is missing one case - in_buf fits in register.  Lets instead
try:

      /* start = max (reg_start, in_start) */
      if (reg_start > in_start)
        start = reg_start;
      else
        start = in_start;

      /* end = min (reg_end, in_end) */
      if (reg_end < in_end)
        end = reg_end;
      else
        end = in_end;

      /* Transfer just the bytes common to both IN_BUF and REG_BUF */
      for (byte = start; byte < end; byte++)
        {
          in_buf[byte - in_start] = reg_buf[byte - reg_start];
        }

Andrew


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