Re: [PATCH 1/3] Move the traceframe_available_memory code from memory_xfer_partial_1 down to the targets

Pedro Alves
2014-03-21T11:56:41Z

On 03/11/2014 12:42 PM, Yao Qi wrote:

> (remote_read_bytes): Moved from memory_xfer_partial_1.

Say:

(remote_read_bytes): New, factored out from memory_xfer_partial_1.

> @@ -6847,6 +6928,63 @@ remote_read_bytes (CORE_ADDR memaddr, gdb_byte *myaddr, ULONGEST len,
> if (len == 0)
> return 0;
>
> + if (get_traceframe_number () != -1)
> + {
> + VEC(mem_range_s) *available;
> +
> + /* If we fail to get the set of available memory, then the
> + target does not support querying traceframe info, and so we
> + attempt reading from the traceframe anyway (assuming the
> + target implements the old QTro packet then). */
> + if (traceframe_available_memory (&available, memaddr, len))
> + {
> + struct cleanup *old_chain;
> +
> + old_chain = make_cleanup (VEC_cleanup(mem_range_s), &available);
> +
> + if (VEC_empty (mem_range_s, available)
> + || VEC_index (mem_range_s, available, 0)->start != memaddr)
> + {
> + enum target_xfer_status res;
> +
> + /* Don't read into the traceframe's available
> + memory. */
> + if (!VEC_empty (mem_range_s, available))
> + {
> + LONGEST oldlen = len;
> +
> + len = VEC_index (mem_range_s, available, 0)->start - memaddr;
> + gdb_assert (len <= oldlen);
> + }
> +
> + do_cleanups (old_chain);
> +
> + /* This goes through the topmost target again. */
> + res = memory_xfer_live_readonly_partial (&remote_ops,

This "&remote_ops" here will be wrong in case we're connected
with extended-remote. Looks like remote_read_bytes needs to be
gain an ops parameter.

Otherwise looks good.

Thanks,
--
Pedro Alves