Re: [PATCH v2 5/7] target: consider addressable unit size when reading/writing memory

Pedro Alves
2015-05-21T17:46:39Z

On 04/15/2015 08:47 PM, Simon Marchi wrote:
> If we are reading/writing from a memory object, the length represents
> the number of "addresses" to read/write, so the addressable unit size
> needs to be taken into account when allocating memory on gdb's side.
>
> gdb/ChangeLog:
>
> * target.c (target_read): Consider addressable unit size when
> reading from a memory object.
> (read_memory_robust): Same.
> (read_whatever_is_readable): Same.
> (target_write_with_progress): Consider addressable unit size
> when writing to a memory object.
> * target.h (target_read): Update documentation.
> (target_write): Add documentation.

> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -1589,6 +1589,15 @@ target_read (struct target_ops *ops,
> ULONGEST offset, LONGEST len)
> {
> LONGEST xfered_total = 0;
> + int unit_size = 1;
> +
> + /* If we are reading from a memory object, find the length of an addressable
> + unit for that architecture. */
> + if (object == TARGET_OBJECT_MEMORY
> + || object == TARGET_OBJECT_STACK_MEMORY
> + || object == TARGET_OBJECT_CODE_MEMORY
> + || object == TARGET_OBJECT_RAW_MEMORY)
> + unit_size = gdbarch_addressable_memory_unit_size (target_gdbarch());

Missing space before parens. Otherwise looks OK.

Thanks,
Pedro Alves