binutils-gdb/gdb/features/rx.c
Andrew Burgess ab33b15255 gdb: add an option flag to 'maint print c-tdesc'
GDB has two approaches to generating the target descriptions found in
gdb/features/, the whole description approach, where the XML file
contains a complete target description which is then used to generate
a single C file that builds that target description.  Or, the split
feature approach, where the XML files contain a single target feature,
each feature results in a single C file to create that one feature,
and then a manually written C file is used to build a complete target
description from individual features.

There's a Makefile, gdb/features/Makefile, which is responsible for
managing the regeneration of the C files from the XML files.

However, some of the logic that selects between the whole description
approach, or the split feature approach, is actually hard-coded into
GDB, inside target-descriptions.c:maint_print_c_tdesc_cmd we check the
path to the incoming XML file and use this to choose which type of C
file we should generate.

This commit removes this hard coding from GDB, and makes the Makefile
entirely responsible for choosing the approach.  This makes sense as
the Makefile already has the XML files partitioned based on which
approach they should use.

In order to allow this change the 'maint print c-tdesc' command is
given a new command option '-single-feature', which tells GDB which
type of C file should be created.  The makefile now supplies this flag
to GDB.

This did reveal a bug in features/Makefile, the rx.xml file was in the
wrong list, this didn't matter previously as the actual choice of
which approach to use was done in GDB.  Now the Makefile decides, so
placing each XML file in the correct list is critical.

Tested this by doing 'make GDB=/path/to/gdb clean-cfiles cfiles' to
regenerate all the C files from their XML source.  There are no
changes after this commit.

gdb/ChangeLog:

	* features/Makefile (XMLTOC): Add rx.xml.
	(FEATURE_XMLFILES): Remove rx.xml.
	(FEATURE_CFILES rule): Pass '-single-feature' flag.
	* features/rx.c: Regenerate.
	* features/rx.xml: Wrap in `target` tags, and reindent.
	* target-descriptions.c (struct maint_print_c_tdesc_options): New
	structure.
	(maint_print_c_tdesc_opt_def): New typedef.
	(maint_print_c_tdesc_opt_defs): New static global.
	(make_maint_print_c_tdesc_options_def_group): New function.
	(maint_print_c_tdesc_cmd): Make use of command line flags, only
	print single feature C file for target descriptions containing a
	single feature.
	(maint_print_c_tdesc_cmd_completer): New function.
	(_initialize_target_descriptions): Update call to register command
	completer, and include command line flag in help text.

gdb/doc/ChangeLog:

	* gdb.texinfo (Maintenance Commands): Update description of 'maint
	print c-tdesc'.
2020-11-12 09:44:00 +00:00

81 lines
3.6 KiB
C

/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
Original: rx.xml */
#include "defs.h"
#include "osabi.h"
#include "target-descriptions.h"
struct target_desc *tdesc_rx;
static void
initialize_tdesc_rx (void)
{
target_desc_up result = allocate_target_description ();
struct tdesc_feature *feature;
feature = tdesc_create_feature (result.get (), "org.gnu.gdb.rx.core");
tdesc_type_with_fields *type_with_fields;
type_with_fields = tdesc_create_flags (feature, "psw_flags", 4);
tdesc_add_flag (type_with_fields, 0, "C");
tdesc_add_flag (type_with_fields, 1, "Z");
tdesc_add_flag (type_with_fields, 2, "S");
tdesc_add_flag (type_with_fields, 3, "O");
tdesc_add_flag (type_with_fields, 16, "I");
tdesc_add_flag (type_with_fields, 17, "U");
tdesc_add_flag (type_with_fields, 20, "PM");
tdesc_add_flag (type_with_fields, 24, "IPL0");
tdesc_add_flag (type_with_fields, 25, "IPL1");
tdesc_add_flag (type_with_fields, 26, "IPL2");
tdesc_add_flag (type_with_fields, 27, "IPL3");
type_with_fields = tdesc_create_flags (feature, "fpsw_flags", 4);
tdesc_add_flag (type_with_fields, 0, "RM0");
tdesc_add_flag (type_with_fields, 1, "RM1");
tdesc_add_flag (type_with_fields, 2, "CV");
tdesc_add_flag (type_with_fields, 3, "CO");
tdesc_add_flag (type_with_fields, 4, "CZ");
tdesc_add_flag (type_with_fields, 5, "CU");
tdesc_add_flag (type_with_fields, 6, "CX");
tdesc_add_flag (type_with_fields, 7, "CE");
tdesc_add_flag (type_with_fields, 8, "DN");
tdesc_add_flag (type_with_fields, 10, "EV");
tdesc_add_flag (type_with_fields, 11, "EO");
tdesc_add_flag (type_with_fields, 12, "EZ");
tdesc_add_flag (type_with_fields, 13, "EU");
tdesc_add_flag (type_with_fields, 14, "EX");
tdesc_add_flag (type_with_fields, 26, "FV");
tdesc_add_flag (type_with_fields, 27, "FO");
tdesc_add_flag (type_with_fields, 28, "FZ");
tdesc_add_flag (type_with_fields, 29, "FU");
tdesc_add_flag (type_with_fields, 30, "FX");
tdesc_add_flag (type_with_fields, 31, "FS");
tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "data_ptr");
tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r13", 13, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r14", 14, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "r15", 15, 1, NULL, 32, "uint32");
tdesc_create_reg (feature, "usp", 16, 1, NULL, 32, "data_ptr");
tdesc_create_reg (feature, "isp", 17, 1, NULL, 32, "data_ptr");
tdesc_create_reg (feature, "psw", 18, 1, NULL, 32, "psw_flags");
tdesc_create_reg (feature, "pc", 19, 1, NULL, 32, "code_ptr");
tdesc_create_reg (feature, "intb", 20, 1, NULL, 32, "data_ptr");
tdesc_create_reg (feature, "bpsw", 21, 1, NULL, 32, "psw_flags");
tdesc_create_reg (feature, "bpc", 22, 1, NULL, 32, "code_ptr");
tdesc_create_reg (feature, "fintv", 23, 1, NULL, 32, "code_ptr");
tdesc_create_reg (feature, "fpsw", 24, 1, NULL, 32, "fpsw_flags");
tdesc_create_reg (feature, "acc", 25, 1, NULL, 64, "uint64");
tdesc_rx = result.release ();
}