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 27F1B3858CDB for ; Wed, 21 Sep 2022 18:48:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 27F1B3858CDB Received: from ubuntu.lan (unknown [IPv6:2a02:390:9086::635]) by lndn.lancelotsix.com (Postfix) with ESMTPSA id 5406A8758D; Wed, 21 Sep 2022 18:48:18 +0000 (UTC) Date: Wed, 21 Sep 2022 18:48:12 +0000 From: Lancelot SIX To: Tom Tromey Cc: Lancelot SIX via Gdb-patches , Simon Marchi Subject: Re: [PATCH 3/4] gdb: add type::length / type::set_length Message-ID: <20220921184812.7h7umoncvvtq4wfh@ubuntu.lan> References: <20220916150836.527213-1-simon.marchi@efficios.com> <20220916150836.527213-3-simon.marchi@efficios.com> <20220921150144.s62znyu4ws356aro@ubuntu.lan> <87leqc3cfb.fsf@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87leqc3cfb.fsf@tromey.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 18:48:18 +0000 (UTC) X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, 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 18:48:56 -0000 On Wed, Sep 21, 2022 at 10:44:08AM -0600, Tom Tromey wrote: > >>>>> "Lancelot" == Lancelot SIX via Gdb-patches writes: > > >> - TYPE_LENGTH (array_type) = (array_bitsize + 7) / 8; > >> + array_type->set_length ((array_bitsize + 7) / 8); > > Lancelot> Do you think that while at it you could also replace the 7 and 8 > Lancelot> literals with appropriate configured values? > > ... > Lancelot>   / HOST_CHAR_BIT); > > Normally I think the '8' is a target value, not a host value. > Like, if HOST_CHAR_BIT != 8, would this do the wrong thing? Hi, In this case I believe we do want the host value. The description of the m_length field in struct type says: Length of storage for a value of this type. The value is the expression in host bytes of what sizeof(type) would return. [...] Since this field is expressed in host bytes, its value is appropriate to pass to memcpy and such. My understanding from this is that when doing some_type->set_length () the argument should be HOST_CHAR_BIT aware. That being said, I do not think GDB is ever executed on any non-8bit bytes hosts. Part of the comment I quoted above even states: it is assumed that GDB itself always runs on an 8-bits addressable architecture As a consequence, I think the current literals are valid, but giving them an explicit name helps as it reminds that this is not a target byte. Also, as there are no non-8bit bytes targets supported to my knowledge, I am not sure if GDB is currently viable for such use-case. But since we have some some infrastructure to support this, I try to account for it were possible (I am not always sure to what extent I have it right though). Lancelot. > > Tom