binutils-gdb/gdb/features/i386
Simon Marchi d4a0e8b57d Split tdesc_type into multiple classes
This patch makes tdesc_type an abstract base class and creates three
subclasses:

- tdesc_type_builtin, for builtin types
- tdesc_type_vector, for vector types
- tdesc_type_with_fields, for struct, union, flag and enum types

This allows getting rid of the union in tdesc_type and to not allow the
std::vector separately.  I tried to go further and create separate
classes for struct, union, flag and enum, but it proved too difficult.
One problem is that from the point of the of the target description
code, the types tdesc_type_* are opaque (only forward-declared).
Therefore, it doesn't know about inheritance relationship between those
classes.  This makes it impossible to make functions that accept a
pointer to a base class and pass a pointer to a derived class, for
example.  I think this patch here is a good compromise, and if somebody
wants to improve things further, the door is open.

A make_gdb_type virtual pure method is added to tdesc_type, which
replaces the current tdesc_gdb_type function.  Calling this method on a
tdesc_type returns the corresponding built gdb type.

gdb/ChangeLog:

	* target-descriptions.c (struct tdesc_type): Use default
	destructor.
	<u>: Remove.
	<accept>: Remove.
	(struct tdesc_type_builtin): New.
	(struct tdesc_type_vector): New.
	(struct tdesc_type_with_fields): New.
	(tdesc_predefined_types): Change type to tdesc_type_builtin[].
	(tdesc_gdb_type): Remove.
	(tdesc_register_type): Adjust.
	(tdesc_create_vector): Create tdesc_type_vector.
	(tdesc_create_struct): Create tdesc_type_with_fields.
	(tdesc_set_struct_size): Change parameter type.
	(tdesc_create_union): Create tdesc_type_with_fields.
	(tdesc_create_flags): Likewise.
	(tdesc_create_enum): Likewise.
	(tdesc_add_field): Change parameter type.
	(tdesc_add_typed_bitfield): Likewise.
	(tdesc_add_bitfield): Likewise.
	(tdesc_add_flag): Likewise.
	(tdesc_add_enum_value): Likewise.
	(print_c_tdesc) <visit>: Remove overload with tdesc_type
	parameter, add overloads for tdesc_type_builtin,
	tdesc_type_with_fields and tdesc_type_vector.
	<m_printed_type>: Remove.
	<m_printed_element_type, m_printed_type_with_fields>: Add.
	* target-descriptions.h (tdesc_create_enum): Change return type.
	(tdesc_add_typed_bitfield): Change parameter type.
	(tdesc_add_enum_value): Change parameter type.
	* xml-tdesc.c (struct tdesc_parsing_data) <current_type>: Change
	type to tdesc_type_with_fields.
	(tdesc_start_struct): Adjust.
	(tdesc_start_flags): Adjust.
	(tdesc_start_enum): Adjust.
	(tdesc_start_field): Adjust.
	* arch/tdesc.h (struct tdesc_type_builtin): Forward-declare.
	(struct tdesc_type_vector): Forward-declare.
	(struct tdesc_type_with_fields): Forward-declare.
	(tdesc_create_struct): Change return type.
	(tdesc_create_union): Likewise.
	(tdesc_create_flags): Likewise.
	(tdesc_add_field): Change parameter type.
	(tdesc_set_struct_size): Likewise.
	(tdesc_add_bitfield): Likewise.
	(tdesc_add_flag): Likewise.
	* features: Re-generate C files.

gdb/gdbserver/ChangeLog:

	* tdesc.c (struct tdesc_type): Change return type.
	(tdesc_add_flag): Change parameter type.
	(tdesc_add_bitfield): Likewise.
	(tdesc_add_field): Likewise.
	(tdesc_set_struct_size): Likewise.
2017-12-05 16:30:28 -05:00
..
32bit-avx.c Dynamically composite xml in reply to GDB 2017-09-05 09:54:53 +01:00
32bit-avx.xml
32bit-avx512.c Split tdesc_type into multiple classes 2017-12-05 16:30:28 -05:00
32bit-avx512.xml
32bit-core.c Split tdesc_type into multiple classes 2017-12-05 16:30:28 -05:00
32bit-core.xml
32bit-linux.c Dynamically composite xml in reply to GDB 2017-09-05 09:54:53 +01:00
32bit-linux.xml
32bit-mpx.c Split tdesc_type into multiple classes 2017-12-05 16:30:28 -05:00
32bit-mpx.xml
32bit-pkeys.c Dynamically composite xml in reply to GDB 2017-09-05 09:54:53 +01:00
32bit-pkeys.xml
32bit-sse.c Split tdesc_type into multiple classes 2017-12-05 16:30:28 -05:00
32bit-sse.xml
64bit-avx.c Lazily and dynamically create amd64-linux target descriptions 2017-09-05 09:54:54 +01:00
64bit-avx.xml
64bit-avx512.c Split tdesc_type into multiple classes 2017-12-05 16:30:28 -05:00
64bit-avx512.xml
64bit-core.c Split tdesc_type into multiple classes 2017-12-05 16:30:28 -05:00
64bit-core.xml
64bit-linux.c Lazily and dynamically create amd64-linux target descriptions 2017-09-05 09:54:54 +01:00
64bit-linux.xml
64bit-mpx.c Split tdesc_type into multiple classes 2017-12-05 16:30:28 -05:00
64bit-mpx.xml
64bit-pkeys.c Lazily and dynamically create amd64-linux target descriptions 2017-09-05 09:54:54 +01:00
64bit-pkeys.xml
64bit-segments.c Lazily and dynamically create amd64-linux target descriptions 2017-09-05 09:54:54 +01:00
64bit-segments.xml
64bit-sse.c Split tdesc_type into multiple classes 2017-12-05 16:30:28 -05:00
64bit-sse.xml
amd64-avx-avx512-linux.xml
amd64-avx-avx512.xml
amd64-avx-linux.xml
amd64-avx-mpx-avx512-pku-linux.xml
amd64-avx-mpx-avx512-pku.xml
amd64-avx-mpx-linux.xml
amd64-avx-mpx.xml
amd64-avx.xml
amd64-linux.xml
amd64-mpx-linux.xml
amd64-mpx.xml
amd64.xml
i386-avx-avx512-linux.xml
i386-avx-avx512.xml
i386-avx-linux.xml
i386-avx-mpx-avx512-pku-linux.xml
i386-avx-mpx-avx512-pku.xml
i386-avx-mpx-linux.xml
i386-avx-mpx.xml
i386-avx.xml
i386-linux.xml
i386-mmx-linux.xml
i386-mmx.xml
i386-mpx-linux.xml
i386-mpx.xml
i386.xml
x32-avx-avx512-linux.xml
x32-avx-linux.xml
x32-core.c Split tdesc_type into multiple classes 2017-12-05 16:30:28 -05:00
x32-core.xml
x32-linux.xml