Re: [PATCH] Delegate to target_ops->beneath to read cache lines

Doug Evans
2013-11-29T19:42:15Z

On Thu, Nov 28, 2013 at 6:52 PM, Yao Qi <yao@codesourcery.com> wrote:
> [...]
> 2013-11-29 Yao Qi <yao@codesourcery.com>
> Pedro Alves <palves@redhat.com>
>
> * dcache.c (dcache_read_line): Use current_target.beneath
> instead of &current_target.
> * target.c (memory_xfer_partial_1): Factor code out to ...
> (raw_memory_xfer_partial): ... it. New function.
> (target_xfer_partial): Call raw_memory_xfer_partial if OBJECT
> is TARGET_OBJECT_RAW_MEMORY.
> ---
> gdb/dcache.c | 4 +-
> gdb/target.c | 67 ++++++++++++++++++++++++++++++++--------------------------
> 2 files changed, 39 insertions(+), 32 deletions(-)
>
> diff --git a/gdb/dcache.c b/gdb/dcache.c
> index ea2b732..12d1a4b 100644
> --- a/gdb/dcache.c
> +++ b/gdb/dcache.c
> @@ -336,8 +336,8 @@ dcache_read_line (DCACHE *dcache, struct dcache_block *db)
> len -= reg_len;
> continue;
> }
> -
> - res = target_read (&current_target, TARGET_OBJECT_RAW_MEMORY,
> +
> + res = target_read (current_target.beneath, TARGET_OBJECT_RAW_MEMORY,
> NULL, myaddr, memaddr, reg_len);
> if (res < reg_len)
> return 0;
> [...]

I think a comment is required here explaining why things are the way they are.
i.e., why we use current_target.beneath instead of &current_target.