This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 4/5] Consider addressable memory unit size in various value functions


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]