+2020-11-12 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * 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.
+
2020-11-11 Andrew Burgess <andrew.burgess@embecosm.com>
* riscv-tdep.c (riscv_dwarf_reg_to_regnum): Decode DWARF CSR
+2020-11-12 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * gdb.texinfo (Maintenance Commands): Update description of 'maint
+ print c-tdesc'.
+
2020-11-02 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.texinfo (Mode Options): Descriptions of initialization files
Print the entire architecture configuration. The optional argument
@var{file} names the file where the output goes.
-@kindex maint print c-tdesc @r{[}@var{file}@r{]}
-@item maint print c-tdesc
+@kindex maint print c-tdesc
+@item maint print c-tdesc @r{[}-single-feature@r{]} @r{[}@var{file}@r{]}
Print the target description (@pxref{Target Descriptions}) as
a C source file. By default, the target description is for the current
target, but if the optional argument @var{file} is provided, that file
built again. This command is used by developers after they add or
modify XML target descriptions.
+When the optional flag @samp{-single-feature} is provided then the
+target description being processed (either the default, or from
+@var{file}) must only contain a single feature. The source file
+produced is different in this case.
+
@kindex maint print xml-tdesc
@item maint print xml-tdesc @r{[}@var{file}@r{]}
Print the target description (@pxref{Target Descriptions}) as an XML
rs6000/powerpc-vsx64.xml \
rs6000/powerpc-vsx64l.xml \
rs6000/rs6000.xml \
+ rx.xml \
s390-linux32.xml \
s390-linux32v1.xml \
s390-linux32v2.xml \
riscv/32bit-fpu.xml \
riscv/64bit-cpu.xml \
riscv/64bit-fpu.xml \
- rx.xml \
tic6x-c6xp.xml \
tic6x-core.xml \
tic6x-gp.xml
$(FEATURE_CFILES): %.c: %.xml.tmp
$(GDB) -nx -q -batch \
- -ex 'maint print c-tdesc $<' > $@.tmp
+ -ex 'maint print c-tdesc -single-feature $<' > $@.tmp
sh ../../move-if-change $@.tmp $@
rm $<
/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
- Original: rx.xml.tmp */
+ Original: rx.xml */
#include "defs.h"
#include "osabi.h"
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. -->
-<!DOCTYPE feature SYSTEM "gdb-target.dtd">
-<feature name="org.gnu.gdb.rx.core">
- <reg name="r0" bitsize="32" type="data_ptr"/>
- <reg name="r1" bitsize="32" type="uint32"/>
- <reg name="r2" bitsize="32" type="uint32"/>
- <reg name="r3" bitsize="32" type="uint32"/>
- <reg name="r4" bitsize="32" type="uint32"/>
- <reg name="r5" bitsize="32" type="uint32"/>
- <reg name="r6" bitsize="32" type="uint32"/>
- <reg name="r7" bitsize="32" type="uint32"/>
- <reg name="r8" bitsize="32" type="uint32"/>
- <reg name="r9" bitsize="32" type="uint32"/>
- <reg name="r10" bitsize="32" type="uint32"/>
- <reg name="r11" bitsize="32" type="uint32"/>
- <reg name="r12" bitsize="32" type="uint32"/>
- <reg name="r13" bitsize="32" type="uint32"/>
- <reg name="r14" bitsize="32" type="uint32"/>
- <reg name="r15" bitsize="32" type="uint32"/>
+<!DOCTYPE target SYSTEM "gdb-target.dtd">
+<target>
+ <feature name="org.gnu.gdb.rx.core">
+ <reg name="r0" bitsize="32" type="data_ptr"/>
+ <reg name="r1" bitsize="32" type="uint32"/>
+ <reg name="r2" bitsize="32" type="uint32"/>
+ <reg name="r3" bitsize="32" type="uint32"/>
+ <reg name="r4" bitsize="32" type="uint32"/>
+ <reg name="r5" bitsize="32" type="uint32"/>
+ <reg name="r6" bitsize="32" type="uint32"/>
+ <reg name="r7" bitsize="32" type="uint32"/>
+ <reg name="r8" bitsize="32" type="uint32"/>
+ <reg name="r9" bitsize="32" type="uint32"/>
+ <reg name="r10" bitsize="32" type="uint32"/>
+ <reg name="r11" bitsize="32" type="uint32"/>
+ <reg name="r12" bitsize="32" type="uint32"/>
+ <reg name="r13" bitsize="32" type="uint32"/>
+ <reg name="r14" bitsize="32" type="uint32"/>
+ <reg name="r15" bitsize="32" type="uint32"/>
- <flags id="psw_flags" size="4">
- <field name="C" start="0" end="0"/>
- <field name="Z" start="1" end="1"/>
- <field name="S" start="2" end="2"/>
- <field name="O" start="3" end="3"/>
- <field name="I" start="16" end="16"/>
- <field name="U" start="17" end="17"/>
- <field name="PM" start="20" end="20"/>
- <field name="IPL0" start="24" end="24"/>
- <field name="IPL1" start="25" end="25"/>
- <field name="IPL2" start="26" end="26"/>
- <field name="IPL3" start="27" end="27"/>
- </flags>
+ <flags id="psw_flags" size="4">
+ <field name="C" start="0" end="0"/>
+ <field name="Z" start="1" end="1"/>
+ <field name="S" start="2" end="2"/>
+ <field name="O" start="3" end="3"/>
+ <field name="I" start="16" end="16"/>
+ <field name="U" start="17" end="17"/>
+ <field name="PM" start="20" end="20"/>
+ <field name="IPL0" start="24" end="24"/>
+ <field name="IPL1" start="25" end="25"/>
+ <field name="IPL2" start="26" end="26"/>
+ <field name="IPL3" start="27" end="27"/>
+ </flags>
- <flags id="fpsw_flags" size="4">
- <field name="RM0" start="0" end="0"/>
- <field name="RM1" start="1" end="1"/>
- <field name="CV" start="2" end="2"/>
- <field name="CO" start="3" end="3"/>
- <field name="CZ" start="4" end="4"/>
- <field name="CU" start="5" end="5"/>
- <field name="CX" start="6" end="6"/>
- <field name="CE" start="7" end="7"/>
- <field name="DN" start="8" end="8"/>
- <field name="EV" start="10" end="10"/>
- <field name="EO" start="11" end="11"/>
- <field name="EZ" start="12" end="12"/>
- <field name="EU" start="13" end="13"/>
- <field name="EX" start="14" end="14"/>
- <field name="FV" start="26" end="26"/>
- <field name="FO" start="27" end="27"/>
- <field name="FZ" start="28" end="28"/>
- <field name="FU" start="29" end="29"/>
- <field name="FX" start="30" end="30"/>
- <field name="FS" start="31" end="31"/>
- </flags>
+ <flags id="fpsw_flags" size="4">
+ <field name="RM0" start="0" end="0"/>
+ <field name="RM1" start="1" end="1"/>
+ <field name="CV" start="2" end="2"/>
+ <field name="CO" start="3" end="3"/>
+ <field name="CZ" start="4" end="4"/>
+ <field name="CU" start="5" end="5"/>
+ <field name="CX" start="6" end="6"/>
+ <field name="CE" start="7" end="7"/>
+ <field name="DN" start="8" end="8"/>
+ <field name="EV" start="10" end="10"/>
+ <field name="EO" start="11" end="11"/>
+ <field name="EZ" start="12" end="12"/>
+ <field name="EU" start="13" end="13"/>
+ <field name="EX" start="14" end="14"/>
+ <field name="FV" start="26" end="26"/>
+ <field name="FO" start="27" end="27"/>
+ <field name="FZ" start="28" end="28"/>
+ <field name="FU" start="29" end="29"/>
+ <field name="FX" start="30" end="30"/>
+ <field name="FS" start="31" end="31"/>
+ </flags>
- <reg name="usp" bitsize="32" type="data_ptr"/>
- <reg name="isp" bitsize="32" type="data_ptr"/>
- <reg name="psw" bitsize="32" type="psw_flags"/>
- <reg name="pc" bitsize="32" type="code_ptr"/>
- <reg name="intb" bitsize="32" type="data_ptr"/>
- <reg name="bpsw" bitsize="32" type="psw_flags"/>
- <reg name="bpc" bitsize="32" type="code_ptr"/>
- <reg name="fintv" bitsize="32" type="code_ptr"/>
- <reg name="fpsw" bitsize="32" type="fpsw_flags"/>
- <reg name="acc" bitsize="64" type="uint64"/>
-</feature>
+ <reg name="usp" bitsize="32" type="data_ptr"/>
+ <reg name="isp" bitsize="32" type="data_ptr"/>
+ <reg name="psw" bitsize="32" type="psw_flags"/>
+ <reg name="pc" bitsize="32" type="code_ptr"/>
+ <reg name="intb" bitsize="32" type="data_ptr"/>
+ <reg name="bpsw" bitsize="32" type="psw_flags"/>
+ <reg name="bpc" bitsize="32" type="code_ptr"/>
+ <reg name="fintv" bitsize="32" type="code_ptr"/>
+ <reg name="fpsw" bitsize="32" type="fpsw_flags"/>
+ <reg name="acc" bitsize="64" type="uint64"/>
+ </feature>
+</target>
return tdesc->xmltarget;
}
+/* Data structures and functions to setup the option flags for 'maintenance
+ print c-tdesc command. */
+
+struct maint_print_c_tdesc_options
+{
+ /* True when the '-single-feature' flag was passed. */
+ bool single_feature = false;
+};
+
+using maint_print_c_tdesc_opt_def
+ = gdb::option::flag_option_def<maint_print_c_tdesc_options>;
+
+static const gdb::option::option_def maint_print_c_tdesc_opt_defs[] = {
+ maint_print_c_tdesc_opt_def {
+ "single-feature",
+ [] (maint_print_c_tdesc_options *opt) { return &opt->single_feature; },
+ N_("Print C description of just a single feature.")
+ },
+};
+
+static inline gdb::option::option_def_group
+make_maint_print_c_tdesc_options_def_group (maint_print_c_tdesc_options *opts)
+{
+ return {{maint_print_c_tdesc_opt_defs}, opts};
+}
+
+/* Implement 'maintenance print c-tdesc' command. */
+
static void
maint_print_c_tdesc_cmd (const char *args, int from_tty)
{
const struct target_desc *tdesc;
const char *filename;
+ maint_print_c_tdesc_options opts;
+ auto grp = make_maint_print_c_tdesc_options_def_group (&opts);
+ gdb::option::process_options
+ (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, grp);
+
if (args == NULL)
{
/* Use the global target-supplied description, not the current
/* Print c files for target features instead of target descriptions,
because c files got from target features are more flexible than the
counterparts. */
- if (startswith (filename_after_features.c_str (), "i386/32bit-")
- || startswith (filename_after_features.c_str (), "i386/64bit-")
- || startswith (filename_after_features.c_str (), "i386/x32-core.xml")
- || startswith (filename_after_features.c_str (), "riscv/")
- || startswith (filename_after_features.c_str (), "tic6x-")
- || startswith (filename_after_features.c_str (), "aarch64")
- || startswith (filename_after_features.c_str (), "arm/")
- || startswith (filename_after_features.c_str (), "arc/"))
+ if (opts.single_feature)
{
+ if (tdesc->features.size () != 1)
+ error (_("only target descriptions with 1 feature can be used "
+ "with -single-feature option"));
+
print_c_feature v (filename_after_features);
tdesc->accept (v);
}
}
+/* Completer for the "backtrace" command. */
+
+static void
+maint_print_c_tdesc_cmd_completer (struct cmd_list_element *ignore,
+ completion_tracker &tracker,
+ const char *text, const char *word)
+{
+ auto grp = make_maint_print_c_tdesc_options_def_group (nullptr);
+ if (gdb::option::complete_options
+ (tracker, &text, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_ERROR, grp))
+ return;
+
+ word = advance_to_filename_complete_word_point (tracker, text);
+ filename_completer (ignore, tracker, text, word);
+}
+
/* Implement the maintenance print xml-tdesc command. */
static void
When unset, GDB will read the description from the target."),
&tdesc_unset_cmdlist);
- cmd = add_cmd ("c-tdesc", class_maintenance, maint_print_c_tdesc_cmd, _("\
-Print the current target description as a C source file."),
- &maintenanceprintlist);
- set_cmd_completer (cmd, filename_completer);
+ auto grp = make_maint_print_c_tdesc_options_def_group (nullptr);
+ static std::string help_text
+ = gdb::option::build_help (_("\
+Print the current target description as a C source file.\n\
+Usage: maintenance print c-tdesc [OPTION] [FILENAME]\n\
+\n\
+Options:\n\
+%OPTIONS%\n\
+\n\
+When FILENAME is not provided then print the current target\n\
+description, otherwise an XML target description is read from\n\
+FILENAME and printed as a C function.\n\
+\n\
+When '-single-feature' is used then the target description should\n\
+contain a single feature and the generated C code will only create\n\
+that feature within an already existing target_desc object."), grp);
+ cmd = add_cmd ("c-tdesc", class_maintenance, maint_print_c_tdesc_cmd,
+ help_text.c_str (), &maintenanceprintlist);
+ set_cmd_completer_handle_brkchars (cmd, maint_print_c_tdesc_cmd_completer);
cmd = add_cmd ("xml-tdesc", class_maintenance, maint_print_xml_tdesc_cmd, _("\
Print the current target description as an XML file."),