From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lndn.lancelotsix.com (lndn.lancelotsix.com [51.195.220.111]) by sourceware.org (Postfix) with ESMTPS id BC40E3858023 for ; Wed, 21 Sep 2022 15:01:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BC40E3858023 Received: from ubuntu.lan (unknown [IPv6:2a02:390:9086::635]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id C774281141; Wed, 21 Sep 2022 15:01:50 +0000 (UTC) Date: Wed, 21 Sep 2022 15:01:44 +0000 From: Lancelot SIX To: Simon Marchi Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 3/4] gdb: add type::length / type::set_length Message-ID: <20220921150144.s62znyu4ws356aro@ubuntu.lan> References: <20220916150836.527213-1-simon.marchi@efficios.com> <20220916150836.527213-3-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220916150836.527213-3-simon.marchi@efficios.com> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.11 (lndn.lancelotsix.com [0.0.0.0]); Wed, 21 Sep 2022 15:01:50 +0000 (UTC) X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Sep 2022 15:02:54 -0000 Hi, On Fri, Sep 16, 2022 at 11:08:35AM -0400, Simon Marchi via Gdb-patches wrote: > From: Simon Marchi > > Add the `length` and `set_length` methods on `struct type`, in order to remove > the `TYPE_LENGTH` macro. In this patch, the macro is changed to use the > getter, so all the call sites of the macro that are used as a setter are > changed to use the setter method directly. The next patch will remove the > macro completely. > > Change-Id: Id1090244f15c9856969b9be5006aefe8d8897ca4 > --- > gdb/ada-lang.c | 47 +++++++++++++------------- > gdb/coffread.c | 14 ++++---- > gdb/cp-valprint.c | 2 +- > gdb/ctfread.c | 10 +++--- > gdb/dwarf2/read.c | 44 ++++++++++-------------- > gdb/eval.c | 2 +- > gdb/f-valprint.c | 6 ++-- > gdb/gdbtypes.c | 71 ++++++++++++++++++++------------------- > gdb/gdbtypes.h | 16 +++++++-- > gdb/mdebugread.c | 4 +-- > gdb/opencl-lang.c | 2 +- > gdb/rust-lang.c | 5 ++- > gdb/stabsread.c | 10 +++--- > gdb/target-descriptions.c | 2 +- > 14 files changed, 119 insertions(+), 116 deletions(-) > > diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c > index d0b13a6bed2..06eab777f57 100644 > --- a/gdb/ada-lang.c > +++ b/gdb/ada-lang.c > @@ -2165,7 +2165,7 @@ ada_type_of_array (struct value *arr, int bounds) > int array_bitsize = > (hi - lo + 1) * TYPE_FIELD_BITSIZE (elt_type, 0); > > - TYPE_LENGTH (array_type) = (array_bitsize + 7) / 8; > + array_type->set_length ((array_bitsize + 7) / 8); Do you think that while at it you could also replace the 7 and 8 literals with appropriate configured values? array_type->set_length ((array_bitsize + HOST_CHAR_BIT - 1)   / HOST_CHAR_BIT); This is not directly linked to what you are changing, might be done in a separate patch. > } > } > } > diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c > index 843e0efb321..1bead475f5f 100644 > --- a/gdb/gdbtypes.c > +++ b/gdb/gdbtypes.c > @@ -1307,12 +1307,11 @@ update_static_array_size (struct type *type) > special, it's still just a single element array) so do > consider that case when touching this code. */ > LONGEST element_count = std::abs (high_bound - low_bound + 1); > - TYPE_LENGTH (type) > - = ((std::abs (stride) * element_count) + 7) / 8; > + type->set_length (((std::abs (stride) * element_count) + 7) / 8); Same here. > } > else > - TYPE_LENGTH (type) = > - TYPE_LENGTH (element_type) * (high_bound - low_bound + 1); > + type->set_length (TYPE_LENGTH (element_type) > + * (high_bound - low_bound + 1)); > > /* If this array's element is itself an array with a bit stride, > then we want to update this array's bit stride to reflect the > diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h > index 6f4b2d61ca8..6d12a489b15 100644 > --- a/gdb/gdbtypes.h > +++ b/gdb/gdbtypes.h > @@ -1443,7 +1453,7 @@ struct type > bool bit_size_differs_p () const > { > return (main_type->type_specific_field == TYPE_SPECIFIC_INT > - && main_type->type_specific.int_stuff.bit_size != 8 * length); > + && main_type->type_specific.int_stuff.bit_size != 8 * length ()); Same, HOST_CHAR_BIT * length () > } Best, Lancelot.