From: Daniel Jacobowitz <drow@mvista.com>
To: gdb-patches@sources.redhat.com
Subject: Re: [RFC] Move ``length'' from struct main_type to struct type
Date: Wed, 29 Jan 2003 23:14:00 -0000 [thread overview]
Message-ID: <20030129231501.GA25517@nevyn.them.org> (raw)
In-Reply-To: <1030129224829.ZM17897@localhost.localdomain>
On Wed, Jan 29, 2003 at 03:48:29PM -0700, Kevin Buettner wrote:
> A while back, I introduced a change to dwarf2read.c in
> read_tag_pointer_type() which was supposed to create a pointer type
> variant of a (potentially) different length:
>
> if (TYPE_LENGTH (type) != byte_size || addr_class != DW_ADDR_none)
> {
> if (ADDRESS_CLASS_TYPE_FLAGS_P ())
> {
> int type_flags;
>
> type_flags = ADDRESS_CLASS_TYPE_FLAGS (byte_size, addr_class);
> gdb_assert ((type_flags & ~TYPE_FLAG_ADDRESS_CLASS_ALL) == 0);
> type = make_type_with_address_space (type, type_flags);
> }
> ...
> }
>
> TYPE_LENGTH (type) = byte_size;
>
> However, this code doesn't work correctly. As it stands now, the type
> length is shared between all type variants (which differ only in
> qualifiers). This means that as soon as the above TYPE_LENGTH
> assignment is performed, all type variants end up getting the same
> length. I should note that when I initially developed this code, I
> did so on a branch which did not yet implement this sharing via struct
> main_type.
>
> The patch below corrects this problem by moving the length field from
> struct main_type to struct type. I am not entirely happy with this
> approach, but the other approaches I've considered are even less
> palatable.
>
> E.g, another approach that I considered would be to create a new type
> which has a different main_type that varies only in the length field.
> The problem with this is that the names end up being the same, and it
> seems to me that there will be problems with searching and finding the
> right type when the user specifies it by name.
>
> Certainly, if anyone can think of a better approach, I'd be happy to
> hear about it.
It won't actually create a problem if you give them different main
types; the main type is purely internal to the type system, and is
never searched directly.
That said, while I'm not really happy with your approach either, I
think it is more correct and less fragile in general.
> Those of you reviewing this patch should carefully consider the
> comment in replace_type(). I don't think the problem that I mention
> there will actually arise since replace_type() is only called by symbol
> readers which don't know how to (and indeed can't) create variants of
> different sizes, so the situation described in the replace_type() comment
> should never (at the moment anyway) arise.
>
> Comments? (I'll wait at least a week before checking this one in.)
My only comment is that I'd rather you check in replace_type that there
are no types on the variant ring with different space qualifiers, and
internal_error if there are. How's that sound?
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
next prev parent reply other threads:[~2003-01-29 23:14 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-29 22:48 Kevin Buettner
2003-01-29 23:14 ` Daniel Jacobowitz [this message]
[not found] ` <drow@mvista.com>
2003-01-30 0:57 ` Kevin Buettner
2003-02-07 21:45 ` Kevin Buettner
2003-10-07 21:42 RFC: Use program_transform_name correctly Jim Blandy
2003-10-07 21:50 ` Daniel Jacobowitz
2003-10-07 22:03 ` Theodore A. Roth
2003-10-07 22:53 ` Daniel Jacobowitz
2003-10-07 23:59 ` Felix Lee
2003-10-08 1:05 ` Daniel Jacobowitz
2003-10-08 19:15 ` Jim Blandy
2003-10-08 19:18 ` Jim Blandy
2003-10-08 19:31 ` Daniel Jacobowitz
2003-10-08 19:51 ` Andreas Schwab
2003-10-08 21:22 ` Felix Lee
2003-10-08 19:32 ` Jim Blandy
2003-10-08 19:52 ` Theodore A. Roth
2003-10-08 21:32 ` Felix Lee
2003-10-09 2:09 ` Daniel Jacobowitz
2003-10-08 19:14 ` Jim Blandy
2003-10-07 22:48 ` Felix Lee
2003-10-08 17:44 ` Jim Blandy
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=20030129231501.GA25517@nevyn.them.org \
--to=drow@mvista.com \
--cc=gdb-patches@sources.redhat.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