Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 4/5] Consider addressable memory unit size in various value functions
Date: Fri, 24 Jul 2015 11:27:00 -0000	[thread overview]
Message-ID: <55B22120.5010707@redhat.com> (raw)
In-Reply-To: <1437072684-26565-4-git-send-email-simon.marchi@ericsson.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


  reply	other threads:[~2015-07-24 11:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-16 18:51 [PATCH 1/5] Update comment for struct type's length field, introduce type_length_units Simon Marchi
2015-07-16 18:51 ` [PATCH 3/5] Introduce get_value_arch Simon Marchi
2015-07-24 11:27   ` Pedro Alves
2015-07-27 21:47     ` Simon Marchi
2015-07-28 10:25       ` Pedro Alves
2015-07-28 14:56         ` Simon Marchi
2015-07-28 15:06         ` Simon Marchi
2015-07-16 18:51 ` [PATCH 4/5] Consider addressable memory unit size in various value functions Simon Marchi
2015-07-24 11:27   ` Pedro Alves [this message]
2015-07-27 22:05     ` Simon Marchi
2015-07-28 10:29       ` Pedro Alves
2015-07-28 15:07         ` Simon Marchi
2015-07-16 18:51 ` [PATCH 5/5] Add new test internalvar.exp Simon Marchi
2015-07-24 11:41   ` Pedro Alves
2015-07-16 18:51 ` [PATCH 2/5] Update comments in struct value for non-8-bits architectures Simon Marchi
2015-07-24 11:27   ` Pedro Alves
2015-07-27 21:46     ` Simon Marchi
2015-07-28 10:20       ` Pedro Alves
2015-07-24 11:26 ` [PATCH 1/5] Update comment for struct type's length field, introduce type_length_units Pedro Alves
2015-07-27 21:37   ` Simon Marchi
2015-07-28 10:19     ` Pedro Alves
2015-07-28 15:04       ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55B22120.5010707@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@ericsson.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox