Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: Ulrich Weigand <uweigand@de.ibm.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC] Make init_type/arch_type take a size in bits
Date: Wed, 20 Sep 2017 14:40:00 -0000	[thread overview]
Message-ID: <05d19c3351b9c0fa8ed80e4dc2204024@polymtl.ca> (raw)
In-Reply-To: <20170920135111.469B4D835E2@oc3748833570.ibm.com>

On 2017-09-20 15:51, Ulrich Weigand wrote:
> Simon Marchi wrote:
> 
>> Since this is where we do the division by
>> TARGET_CHAR_BIT, and therefore assume (implicitly) that bit is a
>> multiple of TARGET_CHAR_BIT, I think this is where the assert should 
>> be
>> added.  To avoid adding them everywhere, we could make
>> arch_type/init_type take a size in bits, and do the division and 
>> assert
>> there.
> 
> As discussed, this changes the interfaces to init_type and arch_type
> to take the type length in bits as input (instead of as bytes).  The
> routine asserts that the length is a multiple of TARGET_CHAR_BIT.
> 
> For consistency, arch_flags_type is changed likewise, so that now
> all type creation interfaces always use length in bits.
> 
> All callers are updated in the straightforward manner.
> 
> The assert actually found a bug in stabsread.c:read_range_type, where
> the init_integer_type routine was called with a wrong argument 
> (probably
> a bug introduced with the conversion to use init_integer_type).

I took a quick look, it looks good to me.  Just one comment below.

> Index: binutils-gdb/gdb/gnu-v3-abi.c
> ===================================================================
> --- binutils-gdb.orig/gdb/gnu-v3-abi.c
> +++ binutils-gdb/gdb/gnu-v3-abi.c
> @@ -1024,7 +1024,7 @@ build_std_type_info_type (struct gdbarch
> 
>    gdb_assert (field == (field_list + 2));
> 
> -  t = arch_type (arch, TYPE_CODE_STRUCT, offset, NULL);
> +  t = arch_type (arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, 
> NULL);
>    TYPE_NFIELDS (t) = field - field_list;
>    TYPE_FIELDS (t) = field_list;
>    TYPE_TAG_NAME (t) = "gdb_gnu_v3_type_info";

In gnu-v3-abi.c, there seems to be another call to arch_type that needs 
adjusting in build_gdb_vtable_type:

   t = arch_type (arch, TYPE_CODE_STRUCT, offset, NULL);

Simon


       reply	other threads:[~2017-09-20 14:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170920135111.469B4D835E2@oc3748833570.ibm.com>
2017-09-20 14:40 ` Simon Marchi [this message]
2017-09-20 16:28   ` Ulrich Weigand
2017-09-27 17:08     ` Ulrich Weigand

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=05d19c3351b9c0fa8ed80e4dc2204024@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=gdb-patches@sourceware.org \
    --cc=uweigand@de.ibm.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