From: Lancelot SIX <lsix@lancelotsix.com>
To: Tom Tromey <tom@tromey.com>
Cc: Lancelot SIX via Gdb-patches <gdb-patches@sourceware.org>,
Simon Marchi <simon.marchi@efficios.com>
Subject: Re: [PATCH 3/4] gdb: add type::length / type::set_length
Date: Wed, 21 Sep 2022 18:48:12 +0000 [thread overview]
Message-ID: <20220921184812.7h7umoncvvtq4wfh@ubuntu.lan> (raw)
In-Reply-To: <87leqc3cfb.fsf@tromey.com>
On Wed, Sep 21, 2022 at 10:44:08AM -0600, Tom Tromey wrote:
> >>>>> "Lancelot" == Lancelot SIX via Gdb-patches <gdb-patches@sourceware.org> 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
next prev parent reply other threads:[~2022-09-21 18:48 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-16 15:08 [PATCH 1/4] gdb: add type::target_type / type::set_target_type Simon Marchi
2022-09-16 15:08 ` [PATCH 2/4] gdb: remove TYPE_TARGET_TYPE Simon Marchi
2022-09-21 14:37 ` Lancelot SIX
2022-09-21 15:01 ` Simon Marchi
2022-09-21 14:57 ` Tom Tromey
2022-09-21 15:02 ` Simon Marchi
2022-09-16 15:08 ` [PATCH 3/4] gdb: add type::length / type::set_length Simon Marchi
2022-09-21 15:00 ` Tom Tromey
2022-09-21 15:01 ` Lancelot SIX
2022-09-21 16:44 ` Tom Tromey
2022-09-21 17:00 ` Simon Marchi
2022-09-21 18:48 ` Lancelot SIX [this message]
2022-09-17 9:48 ` [RESEND PATCH 4/4] gdb: remove TYPE_LENGTH Simon Marchi
2022-09-21 15:03 ` Tom Tromey
2022-09-21 15:04 ` Simon Marchi
2022-09-21 14:52 ` [PATCH 1/4] gdb: add type::target_type / type::set_target_type Tom Tromey
2022-09-21 14:55 ` Tom Tromey
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=20220921184812.7h7umoncvvtq4wfh@ubuntu.lan \
--to=lsix@lancelotsix.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.com \
--cc=tom@tromey.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).