From: Joel Brobecker <brobecker@adacore.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: RFA: shrink main_type
Date: Tue, 19 Aug 2008 05:13:00 -0000 [thread overview]
Message-ID: <20080819051306.GQ16894@adacore.com> (raw)
In-Reply-To: <m38wuuw1tz.fsf@fleche.redhat.com>
:REVIEWMAIL:
> 2008-08-18 Tom Tromey <tromey@redhat.com>
(wow, I'm surprised you actually typed the entire changelog).
For the future, I think that saying something like this:
* gdbtype.h (...): bla bla bla.
* xml-tdesc.c: Update throughout.
Is OK. I remember reading something like this in the GNU Coding Standards.
Overall, the patch looks OK to me. I like how it simplifies the code
a little bit. I also like the fact that you separated the type flags and
the instance flags, and added INSTANCE to the enum name.
Most of the rest of the patch is fairly mechanical, and looked fine.
I think there is one incorrect change, however, inside copy_type_recursive:
> @@ -2933,24 +2973,19 @@ copy_type_recursive (struct objfile *objfile,
> stored->new = new_type;
> *slot = stored;
>
> - /* Copy the common fields of types. */
> - TYPE_CODE (new_type) = TYPE_CODE (type);
> - TYPE_ARRAY_UPPER_BOUND_TYPE (new_type) =
> - TYPE_ARRAY_UPPER_BOUND_TYPE (type);
> - TYPE_ARRAY_LOWER_BOUND_TYPE (new_type) =
> - TYPE_ARRAY_LOWER_BOUND_TYPE (type);
> + /* Copy the common fields of types. For the main type, we simply
> + copy the entire thing and then update specific fields as needed. */
> + memcpy (TYPE_MAIN_TYPE (new_type), TYPE_MAIN_TYPE (type),
> + sizeof (struct main_type));
> if (TYPE_NAME (type))
> TYPE_NAME (new_type) = xstrdup (TYPE_NAME (type));
> if (TYPE_TAG_NAME (type))
> TYPE_TAG_NAME (new_type) = xstrdup (TYPE_TAG_NAME (type));
> - TYPE_FLAGS (new_type) = TYPE_FLAGS (type);
> - TYPE_VPTR_FIELDNO (new_type) = TYPE_VPTR_FIELDNO (type);
>
> TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type);
> TYPE_LENGTH (new_type) = TYPE_LENGTH (type);
>
> /* Copy the fields. */
> - TYPE_NFIELDS (new_type) = TYPE_NFIELDS (type);
> if (TYPE_NFIELDS (type))
> {
> int i, nfields;
Because of the memcpy, you end up copying over the objfile field,
which is incorrect, since this code is used to duplicate type
information that is independent of the given objfile. I think there
are other fields as well that are now implicitly copied (such as
vptr_fieldno, and type_specific), but I think that in this case
it's not harmful.
> if (ada_is_packed_array_type (type0) /* revisit? */
> - || (TYPE_FLAGS (type0) & TYPE_FLAG_FIXED_INSTANCE))
> + || (TYPE_FIXED_INSTANCE (type0)))
> return type0;
Major nit-picking: The '('/')' around TYPE_FIXED_INSTANCE (type0) is
no longer necessary. I won't hate you if you don't fix that, but
I do personally like it better without.
> - if (len == 0 && (TYPE_FLAGS (type) & TYPE_FLAG_STUB) != 0)
> + if (len == 0 && (TYPE_STUB (type)) != 0)
> return -1;
Similarly, I thin it would be more readable to have:
if (len == 0 && TYPE_STUB (type))
(again, that might be a personal preference, feel free to disagree)
I spotted a few more areas where I could make the same type of comment:
> diff --git a/gdb/iq2000-tdep.c b/gdb/iq2000-tdep.c
> index 4843ff1..8581aee 100644
> --- a/gdb/iq2000-tdep.c
> +++ b/gdb/iq2000-tdep.c
> @@ -93,7 +93,7 @@ iq2000_pointer_to_address (struct type * type, const gdb_byte * buf)
>
> if (target == TYPE_CODE_FUNC
> || target == TYPE_CODE_METHOD
> - || (TYPE_FLAGS (TYPE_TARGET_TYPE (type)) & TYPE_FLAG_CODE_SPACE) != 0)
> + || (TYPE_CODE_SPACE (TYPE_TARGET_TYPE (type))) != 0)
> --- a/gdb/sh-tdep.c
> +++ b/gdb/sh-tdep.c
> @@ -1080,7 +1080,7 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch,
> non-vararg argument to be on the stack, no matter how many
> registers have been used so far. */
> if (sh_is_renesas_calling_convention (func_type)
> - && (TYPE_FLAGS (func_type) & TYPE_FLAG_VARARGS))
> + && (TYPE_VARARGS (func_type)))
> last_reg_arg = TYPE_NFIELDS (func_type) - 2;
>
> /* first force sp to a 4-byte alignment */
> @@ -1217,7 +1217,7 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch,
> non-vararg argument to be on the stack, no matter how many
> registers have been used so far. */
> if (sh_is_renesas_calling_convention (func_type)
> - && (TYPE_FLAGS (func_type) & TYPE_FLAG_VARARGS))
> + && (TYPE_VARARGS (func_type)))
> last_reg_arg = TYPE_NFIELDS (func_type) - 2;
The testcase update looked fine too, but was very difficult to read.
I didn't see anything wrong, so between you and I, it should be fine.
--
Joel
next prev parent reply other threads:[~2008-08-19 5:13 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-17 18:50 Tom Tromey
2008-08-18 13:01 ` Joel Brobecker
2008-08-18 13:20 ` Daniel Jacobowitz
2008-08-18 13:30 ` Joel Brobecker
2008-08-18 15:19 ` Tom Tromey
2008-08-18 19:39 ` Tom Tromey
2008-08-18 22:17 ` Andreas Schwab
2008-08-18 22:32 ` Daniel Jacobowitz
2008-08-19 5:13 ` Joel Brobecker [this message]
2008-08-19 17:56 ` Tom Tromey
2008-08-24 10:12 ` Joel Brobecker
2008-08-24 16:41 ` Tom Tromey
2008-08-24 18:03 ` Tom Tromey
2008-08-24 20:35 ` Tom Tromey
2008-08-25 15:50 ` Joel Brobecker
2008-08-25 19:12 ` Tom Tromey
2010-09-15 19:23 ` Ken Werner
2010-09-25 14:38 ` Ken Werner
2010-09-30 18:56 ` Joel Brobecker
2010-10-01 13:23 ` Ken Werner
2010-10-01 15:34 ` [patch] move the nottext flag to the instance_flags Ken Werner
2010-10-01 16:15 ` Joel Brobecker
2010-10-05 21:50 ` Tom Tromey
2010-10-06 8:45 ` Ken Werner
2008-08-18 15:04 ` RFA: shrink main_type 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=20080819051306.GQ16894@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@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