This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 4/5] Consider addressable memory unit size in various value functions
- From: Pedro Alves <palves at redhat dot com>
- To: Simon Marchi <simon dot marchi at ericsson dot com>, gdb-patches at sourceware dot org
- Date: Fri, 24 Jul 2015 12:27:28 +0100
- Subject: Re: [PATCH 4/5] Consider addressable memory unit size in various value functions
- Authentication-results: sourceware.org; auth=none
- References: <1437072684-26565-1-git-send-email-simon dot marchi at ericsson dot com> <1437072684-26565-4-git-send-email-simon dot marchi at ericsson dot com>
On 07/16/2015 07:51 PM, Simon Marchi wrote:
> This patch updates various value handling functions to make them
> consider the addressable memory unit size of the current architecture.
> This allows to correctly extract and print values on architectures whose
> addressable memory unit is not 8 bits.
>
> The patch doesn't cover all the code that would ideally need to be
> adjusted, only the code paths that we happen to use, plus a few obvious
> ones. Specifically, those areas are not covered by this patch:
>
> - Management of unavailable bits
> - Bitfields
> - C++ stuff
>
> Regression-tested on x86-64 Ubuntu 14.04. I saw no related test result
> change.
LGTM, with:
> diff --git a/gdb/value.c b/gdb/value.c
> index af354de..7cc67d9 100644
> --- a/gdb/value.c
> +++ b/gdb/value.c
> @@ -1089,8 +1089,10 @@ set_value_parent (struct value *value, struct value *parent)
> gdb_byte *
> value_contents_raw (struct value *value)
> {
> + struct gdbarch *arch = get_value_arch (value);
> + int unit_size = gdbarch_addressable_memory_unit_size (arch);
Missing line break.
> allocate_value_contents (value);
> - return value->contents + value->embedded_offset;
> + return value->contents + value->embedded_offset * unit_size;
> }
>
>
> /* Copy the meta-data, adjusted. */
> - src_bit_offset = src_offset * TARGET_CHAR_BIT;
> - dst_bit_offset = dst_offset * TARGET_CHAR_BIT;
> - bit_length = length * TARGET_CHAR_BIT;
> + src_bit_offset = src_offset * unit_size * CHAR_BIT;
> + dst_bit_offset = dst_offset * unit_size * CHAR_BIT;
> + bit_length = length * unit_size * CHAR_BIT;
AFAICS, we don't use CHAR_BIT anywhere. Instead, use HOST_CHAR_BIT,
which has a fallback definition in common/host-defs.h.
Thanks,
Pedro Alves