* [commit] Avoid builtin_type_int during type construction
@ 2007-10-03 20:41 Daniel Jacobowitz
2007-10-03 21:12 ` Mark Kettenis
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2007-10-03 20:41 UTC (permalink / raw)
To: gdb-patches
I wanted to construct a new type during gdbarch initialization and
ran into two problems caused by the use of builtin_type_int, which
is now a macro referencing current_gdbarch.
Every range type created uses builtin_type_int as the type of its
fields (which hold the range's endpoints). There's an unclear
FIXME here. The use of int isn't necessary; nothing ever looks at the
types of these fields, and the comments in gdbtypes.h suggest that
their types are unused.
And every vector type is an array using int as its index type. Since
vectors are small arrays of constant size, there's no worry about this
type; int32 works just as well.
Tested on x86_64-linux and committed.
--
Daniel Jacobowitz
CodeSourcery
2007-10-03 Daniel Jacobowitz <dan@codesourcery.com>
* gdbtypes.c (create_range_type): Do not set TYPE_FIELD_TYPE for the
bounds.
(init_vector_type): Use builtin_type_int32.
Index: gdbtypes.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.c,v
retrieving revision 1.134
diff -u -p -r1.134 gdbtypes.c
--- gdbtypes.c 5 Sep 2007 00:51:48 -0000 1.134
+++ gdbtypes.c 3 Oct 2007 20:36:41 -0000
@@ -705,8 +705,6 @@ create_range_type (struct type *result_t
memset (TYPE_FIELDS (result_type), 0, 2 * sizeof (struct field));
TYPE_FIELD_BITPOS (result_type, 0) = low_bound;
TYPE_FIELD_BITPOS (result_type, 1) = high_bound;
- TYPE_FIELD_TYPE (result_type, 0) = builtin_type_int; /* FIXME */
- TYPE_FIELD_TYPE (result_type, 1) = builtin_type_int; /* FIXME */
if (low_bound >= 0)
TYPE_FLAGS (result_type) |= TYPE_FLAG_UNSIGNED;
@@ -950,7 +948,7 @@ init_vector_type (struct type *elt_type,
array_type = create_array_type (0, elt_type,
create_range_type (0,
- builtin_type_int,
+ builtin_type_int32,
0, n-1));
make_vector_type (array_type);
return array_type;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [commit] Avoid builtin_type_int during type construction
2007-10-03 20:41 [commit] Avoid builtin_type_int during type construction Daniel Jacobowitz
@ 2007-10-03 21:12 ` Mark Kettenis
2007-10-03 21:16 ` Daniel Jacobowitz
0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2007-10-03 21:12 UTC (permalink / raw)
To: drow; +Cc: gdb-patches
> Date: Wed, 3 Oct 2007 16:41:10 -0400
> From: Daniel Jacobowitz <drow@false.org>
>
> I wanted to construct a new type during gdbarch initialization and
> ran into two problems caused by the use of builtin_type_int, which
> is now a macro referencing current_gdbarch.
>
> Every range type created uses builtin_type_int as the type of its
> fields (which hold the range's endpoints). There's an unclear
> FIXME here. The use of int isn't necessary; nothing ever looks at the
> types of these fields, and the comments in gdbtypes.h suggest that
> their types are unused.
>
> And every vector type is an array using int as its index type. Since
> vectors are small arrays of constant size, there's no worry about this
> type; int32 works just as well.
>
> Tested on x86_64-linux and committed.
>
> --
> Daniel Jacobowitz
> CodeSourcery
>
> 2007-10-03 Daniel Jacobowitz <dan@codesourcery.com>
>
> * gdbtypes.c (create_range_type): Do not set TYPE_FIELD_TYPE for the
> bounds.
> (init_vector_type): Use builtin_type_int32.
This must be wrong somehow; int isn't necessarily a 32-bit type.
> Index: gdbtypes.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbtypes.c,v
> retrieving revision 1.134
> diff -u -p -r1.134 gdbtypes.c
> --- gdbtypes.c 5 Sep 2007 00:51:48 -0000 1.134
> +++ gdbtypes.c 3 Oct 2007 20:36:41 -0000
> @@ -705,8 +705,6 @@ create_range_type (struct type *result_t
> memset (TYPE_FIELDS (result_type), 0, 2 * sizeof (struct field));
> TYPE_FIELD_BITPOS (result_type, 0) = low_bound;
> TYPE_FIELD_BITPOS (result_type, 1) = high_bound;
> - TYPE_FIELD_TYPE (result_type, 0) = builtin_type_int; /* FIXME */
> - TYPE_FIELD_TYPE (result_type, 1) = builtin_type_int; /* FIXME */
>
> if (low_bound >= 0)
> TYPE_FLAGS (result_type) |= TYPE_FLAG_UNSIGNED;
> @@ -950,7 +948,7 @@ init_vector_type (struct type *elt_type,
>
> array_type = create_array_type (0, elt_type,
> create_range_type (0,
> - builtin_type_int,
> + builtin_type_int32,
> 0, n-1));
> make_vector_type (array_type);
> return array_type;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [commit] Avoid builtin_type_int during type construction
2007-10-03 21:12 ` Mark Kettenis
@ 2007-10-03 21:16 ` Daniel Jacobowitz
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 2007-10-03 21:16 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
On Wed, Oct 03, 2007 at 11:12:11PM +0200, Mark Kettenis wrote:
> > 2007-10-03 Daniel Jacobowitz <dan@codesourcery.com>
> >
> > * gdbtypes.c (create_range_type): Do not set TYPE_FIELD_TYPE for the
> > bounds.
> > (init_vector_type): Use builtin_type_int32.
>
> This must be wrong somehow; int isn't necessarily a 32-bit type.
This is not the type of the vector; it's the type of the index
(subscript) of a built-in vector type. I don't think it matters as
long as it is big enough to hold the number of elements, and I've
never seen any vectors that wouldn't fit in builtin_type_int8.
It's definitely possible I overlooked something, though. Does the
range type get used for anything else?
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-10-03 21:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-03 20:41 [commit] Avoid builtin_type_int during type construction Daniel Jacobowitz
2007-10-03 21:12 ` Mark Kettenis
2007-10-03 21:16 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox