Re: Seems like a bug in target_read_stack / dcache_xfer_memory?

Michael Snyder
2009-10-25T02:03:46Z

Doug Evans wrote:
> On Thu, Oct 22, 2009 at 12:54 PM, Michael Snyder <msnyder@vmware.com> wrote:
>> Michael Snyder wrote:
>>> Doug Evans wrote:
>>>> On Mon, Oct 19, 2009 at 2:35 PM, Michael Snyder <msnyder@vmware.com>
>>>> wrote:
>>>>> Anyway, yes, that's what it does. dcache returns zero,
>>>>> and memory_xfer_partial bails out instead of trying the
>>>>> next target down the target stack.
>>>> Hi. If it will help I'll play with your testcase tomorrow.
>>>> I'll also volunteer to make a pass through the code and add some
>>>> comments.
>>>> [I mention that just in case you or someone is already in the process
>>>> of doing that.]
>>> Sure it will help. Thanks, Doug.
>> And the test case is in the repo now -- solib-precsave.exp.
>> How to run tests:
>> http://www.sourceware.org/gdb/wiki/ProcessRecord#head-2f56f7474cf60c6a5879ba6d8a4e4d034e6d0c8e
>
> Thanks for the testcase.
> You may be right about needing to test for "res == 0" but I'm less
> sure now, so I'm going to leave it as is, at least for now.
> dcache calls target_read (TARGET_OBJECT_RAW_MEMORY) which should DTRT.
> And in fact it does with this patch. :-)
> Checked in.

Thanks for the fix. It handles the case I was concerned with.

> 2009-10-23 Doug Evans <dje@google.com>
>
> * record.c (record_core_xfer_partial): Pass correct offset to
> record_beneath_to_xfer_partial.
>
> Index: record.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/record.c,v
> retrieving revision 1.33
> diff -u -p -r1.33 record.c
> --- record.c 23 Oct 2009 16:11:37 -0000 1.33
> +++ record.c 23 Oct 2009 17:07:08 -0000
> @@ -1629,6 +1629,7 @@ record_core_xfer_partial (struct target_
> if (offset >= p->addr)
> {
> struct record_core_buf_entry *entry;
> + ULONGEST sec_offset;
>
> if (offset >= p->endaddr)
> continue;
> @@ -1636,7 +1637,7 @@ record_core_xfer_partial (struct target_
> if (offset + len > p->endaddr)
> len = p->endaddr - offset;
>
> - offset -= p->addr;
> + sec_offset = offset - p->addr;
>
> /* Read readbuf or write writebuf p, offset, len. */
> /* Check flags. */
> @@ -1673,7 +1674,8 @@ record_core_xfer_partial (struct target_
> record_core_buf_list = entry;
> }
>
> - memcpy (entry->buf + offset, writebuf, (size_t) len);
> + memcpy (entry->buf + sec_offset, writebuf,
> + (size_t) len);
> }
> else
> {
> @@ -1683,7 +1685,8 @@ record_core_xfer_partial (struct target_
> object, annex, readbuf, writebuf,
> offset, len);
>
> - memcpy (readbuf, entry->buf + offset, (size_t) len);
> + memcpy (readbuf, entry->buf + sec_offset,
> + (size_t) len);
> }
>
> return len;