From: Guinevere Larsen Date: Thu, 18 Sep 2025 19:09:59 +0000 (-0300) Subject: gdb: make command classes be bitmaps X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7028626eff3af25eb28a8cc16598b3ddb7186ea3;p=thirdparty%2Fbinutils-gdb.git gdb: make command classes be bitmaps This commit makes it so GDB's command classes can be represented with a single bit, allowing for a command to have multiple classes. This is primarily done as preparation for the next patch, but it can provide value on its own as some commands could be described as belonging to multiple classes, such as "record" being obscure and related to running the inferior. Approved-By: Tom Tromey --- diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index cd3c12990a6..3531cf12d93 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -41,7 +41,7 @@ static struct cmd_list_element *find_cmd (const char *command, int *nfound); static void help_cmd_list (struct cmd_list_element *list, - enum command_class theclass, + command_classes theclass, bool recurse, struct ui_file *stream); @@ -192,7 +192,7 @@ cmd_list_element::command_components () const of *LIST). */ static struct cmd_list_element * -do_add_cmd (const char *name, enum command_class theclass, +do_add_cmd (const char *name, command_classes theclass, const char *doc, struct cmd_list_element **list) { struct cmd_list_element *c = new struct cmd_list_element (name, theclass, @@ -244,7 +244,7 @@ do_add_cmd (const char *name, enum command_class theclass, } struct cmd_list_element * -add_cmd (const char *name, enum command_class theclass, +add_cmd (const char *name, command_classes theclass, const char *doc, struct cmd_list_element **list) { cmd_list_element *result = do_add_cmd (name, theclass, doc, list); @@ -254,7 +254,7 @@ add_cmd (const char *name, enum command_class theclass, } struct cmd_list_element * -add_cmd (const char *name, enum command_class theclass, +add_cmd (const char *name, command_classes theclass, cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **list) { @@ -266,7 +266,7 @@ add_cmd (const char *name, enum command_class theclass, /* Add an element with a suppress notification to the LIST of commands. */ struct cmd_list_element * -add_cmd_suppress_notification (const char *name, enum command_class theclass, +add_cmd_suppress_notification (const char *name, command_classes theclass, cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **list, bool *suppress_notification) @@ -306,7 +306,7 @@ deprecate_cmd (struct cmd_list_element *cmd, const char *replacement) struct cmd_list_element * add_alias_cmd (const char *name, cmd_list_element *target, - enum command_class theclass, int abbrev_flag, + command_classes theclass, int abbrev_flag, struct cmd_list_element **list) { gdb_assert (target != nullptr); @@ -368,7 +368,7 @@ update_prefix_field_of_prefixed_commands (struct cmd_list_element *c) containing that list. */ struct cmd_list_element * -add_prefix_cmd (const char *name, enum command_class theclass, +add_prefix_cmd (const char *name, command_classes theclass, cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list) @@ -402,7 +402,7 @@ do_prefix_cmd (const char *args, int from_tty, struct cmd_list_element *c) /* See command.h. */ struct cmd_list_element * -add_basic_prefix_cmd (const char *name, enum command_class theclass, +add_basic_prefix_cmd (const char *name, command_classes theclass, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list) { @@ -425,7 +425,7 @@ do_show_prefix_cmd (const char *args, int from_tty, struct cmd_list_element *c) /* See command.h. */ struct cmd_list_element * -add_show_prefix_cmd (const char *name, enum command_class theclass, +add_show_prefix_cmd (const char *name, command_classes theclass, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list) { @@ -439,7 +439,7 @@ add_show_prefix_cmd (const char *name, enum command_class theclass, /* See command.h. */ set_show_commands -add_setshow_prefix_cmd (const char *name, command_class theclass, +add_setshow_prefix_cmd (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, cmd_list_element **set_subcommands_list, cmd_list_element **show_subcommands_list, @@ -463,7 +463,7 @@ add_setshow_prefix_cmd (const char *name, command_class theclass, struct cmd_list_element * add_prefix_cmd_suppress_notification - (const char *name, enum command_class theclass, + (const char *name, command_classes theclass, cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list, @@ -479,7 +479,7 @@ add_prefix_cmd_suppress_notification /* Like add_prefix_cmd but sets the abbrev_flag on the new command. */ struct cmd_list_element * -add_abbrev_prefix_cmd (const char *name, enum command_class theclass, +add_abbrev_prefix_cmd (const char *name, command_classes theclass, cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list) @@ -519,7 +519,7 @@ empty_func (const char *args, int from_tty, cmd_list_element *c) static struct cmd_list_element * add_set_or_show_cmd (const char *name, enum cmd_types type, - enum command_class theclass, + command_classes theclass, var_types var_type, const literal_def *extra_literals, const setting::erased_args &arg, @@ -551,7 +551,7 @@ add_set_or_show_cmd (const char *name, static set_show_commands add_setshow_cmd_full_erased (const char *name, - enum command_class theclass, + command_classes theclass, var_types var_type, const literal_def *extra_literals, const setting::erased_args &args, @@ -639,7 +639,7 @@ integer_literals_completer (struct cmd_list_element *c, template static set_show_commands add_setshow_cmd_full (const char *name, - enum command_class theclass, + command_classes theclass, var_types var_type, T *var, const literal_def *extra_literals, const char *set_doc, const char *show_doc, @@ -676,7 +676,7 @@ add_setshow_cmd_full (const char *name, template static set_show_commands add_setshow_cmd_full (const char *name, - enum command_class theclass, + command_classes theclass, var_types var_type, T *var, const char *set_doc, const char *show_doc, const char *help_doc, @@ -700,7 +700,7 @@ add_setshow_cmd_full (const char *name, set_show_commands add_setshow_enum_cmd (const char *name, - enum command_class theclass, + command_classes theclass, const char *const *enumlist, const char **var, const char *set_doc, @@ -734,7 +734,7 @@ add_setshow_enum_cmd (const char *name, to a global storage buffer. */ set_show_commands -add_setshow_enum_cmd (const char *name, command_class theclass, +add_setshow_enum_cmd (const char *name, command_classes theclass, const char *const *enumlist, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, @@ -790,7 +790,7 @@ color_completer (struct cmd_list_element *ignore, set_show_commands add_setshow_color_cmd (const char *name, - enum command_class theclass, + command_classes theclass, ui_file_style::color *var, const char *set_doc, const char *show_doc, @@ -815,7 +815,7 @@ add_setshow_color_cmd (const char *name, to a global storage buffer. */ set_show_commands -add_setshow_color_cmd (const char *name, command_class theclass, +add_setshow_color_cmd (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, @@ -845,7 +845,7 @@ const char * const auto_boolean_enums[] = { "on", "off", "auto", NULL }; set_show_commands add_setshow_auto_boolean_cmd (const char *name, - enum command_class theclass, + command_classes theclass, enum auto_boolean *var, const char *set_doc, const char *show_doc, const char *help_doc, @@ -869,7 +869,7 @@ add_setshow_auto_boolean_cmd (const char *name, to a global storage buffer. */ set_show_commands -add_setshow_auto_boolean_cmd (const char *name, command_class theclass, +add_setshow_auto_boolean_cmd (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, @@ -901,7 +901,7 @@ const char * const boolean_enums[] = { "on", "off", NULL }; Returns the new command element. */ set_show_commands -add_setshow_boolean_cmd (const char *name, enum command_class theclass, bool *var, +add_setshow_boolean_cmd (const char *name, command_classes theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, @@ -924,7 +924,7 @@ add_setshow_boolean_cmd (const char *name, enum command_class theclass, bool *va to a global storage buffer. */ set_show_commands -add_setshow_boolean_cmd (const char *name, command_class theclass, +add_setshow_boolean_cmd (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, @@ -947,7 +947,7 @@ add_setshow_boolean_cmd (const char *name, command_class theclass, list for set/show or some sublist thereof). */ set_show_commands -add_setshow_filename_cmd (const char *name, enum command_class theclass, +add_setshow_filename_cmd (const char *name, command_classes theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, @@ -971,7 +971,7 @@ add_setshow_filename_cmd (const char *name, enum command_class theclass, to a global storage buffer. */ set_show_commands -add_setshow_filename_cmd (const char *name, command_class theclass, +add_setshow_filename_cmd (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, @@ -995,7 +995,7 @@ add_setshow_filename_cmd (const char *name, command_class theclass, list for set/show or some sublist thereof). */ set_show_commands -add_setshow_string_cmd (const char *name, enum command_class theclass, +add_setshow_string_cmd (const char *name, command_classes theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, @@ -1020,7 +1020,7 @@ add_setshow_string_cmd (const char *name, enum command_class theclass, to a global storage buffer. */ set_show_commands -add_setshow_string_cmd (const char *name, command_class theclass, +add_setshow_string_cmd (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, @@ -1045,7 +1045,7 @@ add_setshow_string_cmd (const char *name, command_class theclass, list for set/show or some sublist thereof). */ set_show_commands -add_setshow_string_noescape_cmd (const char *name, enum command_class theclass, +add_setshow_string_noescape_cmd (const char *name, command_classes theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, @@ -1070,7 +1070,7 @@ add_setshow_string_noescape_cmd (const char *name, enum command_class theclass, to a global storage buffer. */ set_show_commands -add_setshow_string_noescape_cmd (const char *name, command_class theclass, +add_setshow_string_noescape_cmd (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, @@ -1096,7 +1096,7 @@ add_setshow_string_noescape_cmd (const char *name, command_class theclass, list for set/show or some sublist thereof). */ set_show_commands -add_setshow_optional_filename_cmd (const char *name, enum command_class theclass, +add_setshow_optional_filename_cmd (const char *name, command_classes theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, @@ -1120,7 +1120,7 @@ add_setshow_optional_filename_cmd (const char *name, enum command_class theclass to a global storage buffer. */ set_show_commands -add_setshow_optional_filename_cmd (const char *name, command_class theclass, +add_setshow_optional_filename_cmd (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, @@ -1147,7 +1147,7 @@ add_setshow_optional_filename_cmd (const char *name, command_class theclass, function is only used in Python API. Please don't use it elsewhere. */ set_show_commands -add_setshow_integer_cmd (const char *name, enum command_class theclass, +add_setshow_integer_cmd (const char *name, command_classes theclass, int *var, const literal_def *extra_literals, const char *set_doc, const char *show_doc, const char *help_doc, @@ -1168,7 +1168,7 @@ add_setshow_integer_cmd (const char *name, enum command_class theclass, to a global storage buffer. */ set_show_commands -add_setshow_integer_cmd (const char *name, command_class theclass, +add_setshow_integer_cmd (const char *name, command_classes theclass, const literal_def *extra_literals, const char *set_doc, const char *show_doc, const char *help_doc, @@ -1196,7 +1196,7 @@ const literal_def integer_unlimited_literals[] = to a global storage buffer. */ set_show_commands -add_setshow_integer_cmd (const char *name, enum command_class theclass, +add_setshow_integer_cmd (const char *name, command_classes theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, @@ -1218,7 +1218,7 @@ add_setshow_integer_cmd (const char *name, enum command_class theclass, to a global storage buffer. */ set_show_commands -add_setshow_integer_cmd (const char *name, command_class theclass, +add_setshow_integer_cmd (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, @@ -1241,7 +1241,7 @@ add_setshow_integer_cmd (const char *name, command_class theclass, value. SET_DOC and SHOW_DOC are the documentation strings. */ set_show_commands -add_setshow_pinteger_cmd (const char *name, enum command_class theclass, +add_setshow_pinteger_cmd (const char *name, command_classes theclass, int *var, const literal_def *extra_literals, const char *set_doc, const char *show_doc, const char *help_doc, @@ -1262,7 +1262,7 @@ add_setshow_pinteger_cmd (const char *name, enum command_class theclass, to a global storage buffer. */ set_show_commands -add_setshow_pinteger_cmd (const char *name, command_class theclass, +add_setshow_pinteger_cmd (const char *name, command_classes theclass, const literal_def *extra_literals, const char *set_doc, const char *show_doc, const char *help_doc, @@ -1285,7 +1285,7 @@ add_setshow_pinteger_cmd (const char *name, command_class theclass, value. SET_DOC and SHOW_DOC are the documentation strings. */ set_show_commands -add_setshow_uinteger_cmd (const char *name, enum command_class theclass, +add_setshow_uinteger_cmd (const char *name, command_classes theclass, unsigned int *var, const literal_def *extra_literals, const char *set_doc, const char *show_doc, const char *help_doc, @@ -1306,7 +1306,7 @@ add_setshow_uinteger_cmd (const char *name, enum command_class theclass, to a global storage buffer. */ set_show_commands -add_setshow_uinteger_cmd (const char *name, command_class theclass, +add_setshow_uinteger_cmd (const char *name, command_classes theclass, const literal_def *extra_literals, const char *set_doc, const char *show_doc, const char *help_doc, @@ -1336,7 +1336,7 @@ const literal_def uinteger_unlimited_literals[] = to a global storage buffer. */ set_show_commands -add_setshow_uinteger_cmd (const char *name, enum command_class theclass, +add_setshow_uinteger_cmd (const char *name, command_classes theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, @@ -1358,7 +1358,7 @@ add_setshow_uinteger_cmd (const char *name, enum command_class theclass, to a global storage buffer. */ set_show_commands -add_setshow_uinteger_cmd (const char *name, command_class theclass, +add_setshow_uinteger_cmd (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, @@ -1383,7 +1383,7 @@ add_setshow_uinteger_cmd (const char *name, command_class theclass, value. SET_DOC and SHOW_DOC are the documentation strings. */ set_show_commands -add_setshow_zinteger_cmd (const char *name, enum command_class theclass, +add_setshow_zinteger_cmd (const char *name, command_classes theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, @@ -1402,7 +1402,7 @@ add_setshow_zinteger_cmd (const char *name, enum command_class theclass, to a global storage buffer. */ set_show_commands -add_setshow_zinteger_cmd (const char *name, command_class theclass, +add_setshow_zinteger_cmd (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, @@ -1429,7 +1429,7 @@ const literal_def pinteger_unlimited_literals[] = set_show_commands add_setshow_zuinteger_unlimited_cmd (const char *name, - enum command_class theclass, + command_classes theclass, int *var, const char *set_doc, const char *show_doc, @@ -1452,7 +1452,7 @@ add_setshow_zuinteger_unlimited_cmd (const char *name, to a global storage buffer. */ set_show_commands -add_setshow_zuinteger_unlimited_cmd (const char *name, command_class theclass, +add_setshow_zuinteger_unlimited_cmd (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, @@ -1476,7 +1476,7 @@ add_setshow_zuinteger_unlimited_cmd (const char *name, command_class theclass, value. SET_DOC and SHOW_DOC are the documentation strings. */ set_show_commands -add_setshow_zuinteger_cmd (const char *name, enum command_class theclass, +add_setshow_zuinteger_cmd (const char *name, command_classes theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, @@ -1495,7 +1495,7 @@ add_setshow_zuinteger_cmd (const char *name, enum command_class theclass, to a global storage buffer. */ set_show_commands -add_setshow_zuinteger_cmd (const char *name, command_class theclass, +add_setshow_zuinteger_cmd (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, @@ -1596,7 +1596,7 @@ add_info_alias (const char *name, cmd_list_element *target, int abbrev_flag) /* Add an element to the list of commands. */ struct cmd_list_element * -add_com (const char *name, enum command_class theclass, +add_com (const char *name, command_classes theclass, cmd_simple_func_ftype *fun, const char *doc) { @@ -1610,7 +1610,7 @@ add_com (const char *name, enum command_class theclass, cmd_list_element * add_com_alias (const char *name, cmd_list_element *target, - command_class theclass, int abbrev_flag) + command_classes theclass, int abbrev_flag) { return add_alias_cmd (name, target, theclass, abbrev_flag, &cmdlist); } @@ -1618,7 +1618,7 @@ add_com_alias (const char *name, cmd_list_element *target, /* Add an element with a suppress notification to the list of commands. */ struct cmd_list_element * -add_com_suppress_notification (const char *name, enum command_class theclass, +add_com_suppress_notification (const char *name, command_classes theclass, cmd_simple_func_ftype *fun, const char *doc, bool *suppress_notification) { @@ -1933,7 +1933,7 @@ help_cmd (const char *command, struct ui_file *stream) If you call this routine with a class >= 0, it recurses. */ void help_list (struct cmd_list_element *list, const char *cmdtype, - enum command_class theclass, struct ui_file *stream) + command_classes theclass, struct ui_file *stream) { int len = strlen (cmdtype); const char *space = ""; @@ -1954,7 +1954,8 @@ help_list (struct cmd_list_element *list, const char *cmdtype, styled_string (command_style.style (), cmdtype), prefix); - help_cmd_list (list, theclass, theclass >= 0, stream); + bool recurse = (theclass != all_commands) && (theclass != all_classes); + help_cmd_list (list, theclass, recurse, stream); if (theclass == all_classes) { @@ -2107,7 +2108,7 @@ print_help_for_command (const cmd_list_element &c, */ static void -help_cmd_list (struct cmd_list_element *list, enum command_class theclass, +help_cmd_list (struct cmd_list_element *list, command_classes theclass, bool recurse, struct ui_file *stream) { struct cmd_list_element *c; @@ -2120,7 +2121,7 @@ help_cmd_list (struct cmd_list_element *list, enum command_class theclass, continue; } - if (c->is_alias () && theclass != class_alias) + if (c->is_alias () && ((theclass & class_alias) == 0)) { /* Do not show an alias, unless specifically showing the list of aliases: for all other classes, an alias is @@ -2130,7 +2131,7 @@ help_cmd_list (struct cmd_list_element *list, enum command_class theclass, if (theclass == all_commands || (theclass == all_classes && c->is_command_class_help ()) - || (theclass == c->theclass && !c->is_command_class_help ())) + || ((theclass & c->theclass) != 0 && !c->is_command_class_help ())) { /* show C when - showing all commands @@ -2142,13 +2143,13 @@ help_cmd_list (struct cmd_list_element *list, enum command_class theclass, list of sub-commands of the aliased command. */ print_help_for_command (*c, - recurse && (theclass != class_alias || !c->is_alias ()), + recurse && (((theclass & class_alias) == 0) || !c->is_alias ()), stream); continue; } if (recurse - && (theclass == class_user || theclass == class_alias) + && ((theclass & (class_user | class_alias)) != 0) && c->is_prefix ()) { /* User-defined commands or aliases may be subcommands. */ @@ -2832,7 +2833,7 @@ cmd_func (struct cmd_list_element *cmd, const char *args, int from_tty) int cli_user_command_p (struct cmd_list_element *cmd) { - return cmd->theclass == class_user && cmd->func == do_simple_func; + return (cmd->theclass & class_user) != 0 && cmd->func == do_simple_func; } /* See cli-decode.h. */ diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h index 9be446fb641..9e006c1ae87 100644 --- a/gdb/cli/cli-decode.h +++ b/gdb/cli/cli-decode.h @@ -47,7 +47,7 @@ enum cmd_types struct cmd_list_element { - cmd_list_element (const char *name_, enum command_class theclass_, + cmd_list_element (const char *name_, command_classes theclass_, const char *doc_) : name (name_), theclass (theclass_), @@ -123,8 +123,9 @@ struct cmd_list_element /* Name of this command. */ const char *name; - /* Command class; class values are chosen by application program. */ - enum command_class theclass; + /* Command classes; class values are chosen by application program + and are stored as a bitmask. */ + command_classes theclass; /* When 1 indicated that this command is deprecated. It may be removed from gdb's command set in the future. */ diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c index b33a1b9ac99..5a8ddb7956f 100644 --- a/gdb/cli/cli-dump.c +++ b/gdb/cli/cli-dump.c @@ -345,7 +345,7 @@ add_dump_command (const char *name, struct cmd_list_element *c; struct dump_context *d; - c = add_cmd (name, all_commands, descr, &dump_cmdlist); + c = add_cmd (name, no_class, descr, &dump_cmdlist); set_cmd_completer (c, deprecated_filename_completer); d = XNEW (struct dump_context); d->func = func; @@ -353,7 +353,7 @@ add_dump_command (const char *name, c->set_context (d); c->func = call_dump_func; - c = add_cmd (name, all_commands, descr, &append_cmdlist); + c = add_cmd (name, no_class, descr, &append_cmdlist); set_cmd_completer (c, deprecated_filename_completer); d = XNEW (struct dump_context); d->func = func; @@ -587,109 +587,109 @@ Write the value of an expression to a raw binary file.\n\ Arguments are FILE EXPRESSION. Writes the value of EXPRESSION to\n\ the specified FILE in raw target ordered bytes."); - add_basic_prefix_cmd ("srec", all_commands, + add_basic_prefix_cmd ("srec", no_class, _("Write target code/data to an srec file."), &srec_cmdlist, 0 /*allow-unknown*/, &dump_cmdlist); - add_basic_prefix_cmd ("ihex", all_commands, + add_basic_prefix_cmd ("ihex", no_class, _("Write target code/data to an intel hex file."), &ihex_cmdlist, 0 /*allow-unknown*/, &dump_cmdlist); - add_basic_prefix_cmd ("verilog", all_commands, + add_basic_prefix_cmd ("verilog", no_class, _("Write target code/data to a verilog hex file."), &verilog_cmdlist, 0 /*allow-unknown*/, &dump_cmdlist); - add_basic_prefix_cmd ("tekhex", all_commands, + add_basic_prefix_cmd ("tekhex", no_class, _("Write target code/data to a tekhex file."), &tekhex_cmdlist, 0 /*allow-unknown*/, &dump_cmdlist); - add_basic_prefix_cmd ("binary", all_commands, + add_basic_prefix_cmd ("binary", no_class, _("Write target code/data to a raw binary file."), &binary_dump_cmdlist, 0 /*allow-unknown*/, &dump_cmdlist); - add_basic_prefix_cmd ("binary", all_commands, + add_basic_prefix_cmd ("binary", no_class, _("Append target code/data to a raw binary file."), &binary_append_cmdlist, 0 /*allow-unknown*/, &append_cmdlist); - add_cmd ("memory", all_commands, dump_srec_memory, _("\ + add_cmd ("memory", no_class, dump_srec_memory, _("\ Write contents of memory to an srec file.\n\ Arguments are FILE START STOP. Writes the contents of memory\n\ within the range [START .. STOP) to the specified FILE in srec format."), &srec_cmdlist); - add_cmd ("value", all_commands, dump_srec_value, _("\ + add_cmd ("value", no_class, dump_srec_value, _("\ Write the value of an expression to an srec file.\n\ Arguments are FILE EXPRESSION. Writes the value of EXPRESSION\n\ to the specified FILE in srec format."), &srec_cmdlist); - add_cmd ("memory", all_commands, dump_ihex_memory, _("\ + add_cmd ("memory", no_class, dump_ihex_memory, _("\ Write contents of memory to an ihex file.\n\ Arguments are FILE START STOP. Writes the contents of memory within\n\ the range [START .. STOP) to the specified FILE in intel hex format."), &ihex_cmdlist); - add_cmd ("value", all_commands, dump_ihex_value, _("\ + add_cmd ("value", no_class, dump_ihex_value, _("\ Write the value of an expression to an ihex file.\n\ Arguments are FILE EXPRESSION. Writes the value of EXPRESSION\n\ to the specified FILE in intel hex format."), &ihex_cmdlist); - add_cmd ("memory", all_commands, dump_verilog_memory, _("\ + add_cmd ("memory", no_class, dump_verilog_memory, _("\ Write contents of memory to a verilog hex file.\n\ Arguments are FILE START STOP. Writes the contents of memory within\n\ the range [START .. STOP) to the specified FILE in verilog hex format."), &verilog_cmdlist); - add_cmd ("value", all_commands, dump_verilog_value, _("\ + add_cmd ("value", no_class, dump_verilog_value, _("\ Write the value of an expression to a verilog hex file.\n\ Arguments are FILE EXPRESSION. Writes the value of EXPRESSION\n\ to the specified FILE in verilog hex format."), &verilog_cmdlist); - add_cmd ("memory", all_commands, dump_tekhex_memory, _("\ + add_cmd ("memory", no_class, dump_tekhex_memory, _("\ Write contents of memory to a tekhex file.\n\ Arguments are FILE START STOP. Writes the contents of memory\n\ within the range [START .. STOP) to the specified FILE in tekhex format."), &tekhex_cmdlist); - add_cmd ("value", all_commands, dump_tekhex_value, _("\ + add_cmd ("value", no_class, dump_tekhex_value, _("\ Write the value of an expression to a tekhex file.\n\ Arguments are FILE EXPRESSION. Writes the value of EXPRESSION\n\ to the specified FILE in tekhex format."), &tekhex_cmdlist); - add_cmd ("memory", all_commands, dump_binary_memory, _("\ + add_cmd ("memory", no_class, dump_binary_memory, _("\ Write contents of memory to a raw binary file.\n\ Arguments are FILE START STOP. Writes the contents of memory\n\ within the range [START .. STOP) to the specified FILE in binary format."), &binary_dump_cmdlist); - add_cmd ("value", all_commands, dump_binary_value, _("\ + add_cmd ("value", no_class, dump_binary_value, _("\ Write the value of an expression to a raw binary file.\n\ Arguments are FILE EXPRESSION. Writes the value of EXPRESSION\n\ to the specified FILE in raw target ordered bytes."), &binary_dump_cmdlist); - add_cmd ("memory", all_commands, append_binary_memory, _("\ + add_cmd ("memory", no_class, append_binary_memory, _("\ Append contents of memory to a raw binary file.\n\ Arguments are FILE START STOP. Writes the contents of memory within the\n\ range [START .. STOP) to the specified FILE in raw target ordered bytes."), &binary_append_cmdlist); - add_cmd ("value", all_commands, append_binary_value, _("\ + add_cmd ("value", no_class, append_binary_value, _("\ Append the value of an expression to a raw binary file.\n\ Arguments are FILE EXPRESSION. Writes the value of EXPRESSION\n\ to the specified FILE in raw target ordered bytes."), diff --git a/gdb/command.h b/gdb/command.h index f8a02123178..385345a1b29 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -45,29 +45,30 @@ enum command_class Note that help accepts unambiguous abbreviated class names. */ /* Special classes to help_list */ - all_classes = -2, /* help without */ - all_commands = -1, /* all */ + all_classes = 0, /* help without */ + all_commands = ~0, /* all */ /* Classes of commands */ - no_class = -1, - class_run = 0, /* running */ - class_vars, /* data */ - class_stack, /* stack */ - class_files, /* files */ - class_support, /* support */ - class_info, /* status */ - class_breakpoint, /* breakpoints */ - class_trace, /* tracepoints */ - class_alias, /* aliases */ - class_bookmark, - class_obscure, /* obscure */ - class_maintenance, /* internals */ - class_tui, /* text-user-interface */ - class_user, /* user-defined */ + no_class = 1 << 0, + class_run = 1 << 1, /* running */ + class_vars = 1 << 2, /* data */ + class_stack = 1 << 3, /* stack */ + class_files = 1 << 4, /* files */ + class_support = 1 << 5, /* support */ + class_info = 1 << 6, /* status */ + class_breakpoint = 1 << 7, /* breakpoints */ + class_trace = 1 << 8, /* tracepoints */ + class_alias = 1 << 9, /* aliases */ + class_bookmark = 1 << 10, + class_obscure = 1 << 11, /* obscure */ + class_maintenance = 1 << 12, /* internals */ + class_tui = 1 << 13, /* text-user-interface */ + class_user = 1 << 14, /* user-defined */ /* Used for "show" commands that have no corresponding "set" command. */ - no_set_class + no_set_class = 1 << 15 }; +DEF_ENUM_FLAGS_TYPE (enum command_class, command_classes); /* Types of "set" or "show" command. */ enum var_types @@ -433,30 +434,30 @@ struct set_show_commands /* Const-correct variant of the above. */ -extern struct cmd_list_element *add_cmd (const char *, enum command_class, +extern struct cmd_list_element *add_cmd (const char *, command_classes, cmd_simple_func_ftype *fun, const char *, struct cmd_list_element **); /* Like add_cmd, but no command function is specified. */ -extern struct cmd_list_element *add_cmd (const char *, enum command_class, +extern struct cmd_list_element *add_cmd (const char *, command_classes, const char *, struct cmd_list_element **); extern struct cmd_list_element *add_cmd_suppress_notification - (const char *name, enum command_class theclass, + (const char *name, command_classes theclass, cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **list, bool *suppress_notification); extern struct cmd_list_element *add_alias_cmd (const char *, cmd_list_element *, - enum command_class, int, + command_classes, int, struct cmd_list_element **); -extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class, +extern struct cmd_list_element *add_prefix_cmd (const char *, command_classes, cmd_simple_func_ftype *fun, const char *, struct cmd_list_element **, @@ -467,21 +468,21 @@ extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class simply calls help_list. */ extern struct cmd_list_element *add_basic_prefix_cmd - (const char *, enum command_class, const char *, struct cmd_list_element **, + (const char *, command_classes, const char *, struct cmd_list_element **, int, struct cmd_list_element **); /* Like add_prefix_cmd, but useful for "show" prefixes. This sets the callback to a function that simply calls cmd_show_list. */ extern struct cmd_list_element *add_show_prefix_cmd - (const char *, enum command_class, const char *, struct cmd_list_element **, + (const char *, command_classes, const char *, struct cmd_list_element **, int, struct cmd_list_element **); /* Add matching set and show commands using add_basic_prefix_cmd and add_show_prefix_cmd. */ extern set_show_commands add_setshow_prefix_cmd - (const char *name, command_class theclass, const char *set_doc, + (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, cmd_list_element **set_subcommands_list, cmd_list_element **show_subcommands_list, @@ -489,7 +490,7 @@ extern set_show_commands add_setshow_prefix_cmd cmd_list_element **show_list); extern struct cmd_list_element *add_prefix_cmd_suppress_notification - (const char *name, enum command_class theclass, + (const char *name, command_classes theclass, cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, @@ -497,7 +498,7 @@ extern struct cmd_list_element *add_prefix_cmd_suppress_notification bool *suppress_notification); extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *, - enum command_class, + command_classes, cmd_simple_func_ftype *fun, const char *, struct cmd_list_element @@ -630,17 +631,17 @@ extern int lookup_cmd_composition (const char *text, struct cmd_list_element **prefix_cmd, struct cmd_list_element **cmd); -extern struct cmd_list_element *add_com (const char *, enum command_class, +extern struct cmd_list_element *add_com (const char *, command_classes, cmd_simple_func_ftype *fun, const char *); extern cmd_list_element *add_com_alias (const char *name, cmd_list_element *target, - command_class theclass, + command_classes theclass, int abbrev_flag); extern struct cmd_list_element *add_com_suppress_notification - (const char *name, enum command_class theclass, + (const char *name, command_classes theclass, cmd_simple_func_ftype *fun, const char *doc, bool *suppress_notification); @@ -663,7 +664,7 @@ extern void complete_on_enum (completion_tracker &tracker, /* Functions that implement commands about CLI commands. */ extern void help_list (struct cmd_list_element *, const char *, - enum command_class, struct ui_file *); + command_classes, struct ui_file *); /* Method for show a set/show variable's VALUE on FILE. */ typedef void (show_value_ftype) (struct ui_file *file, @@ -677,27 +678,27 @@ extern const literal_def uinteger_unlimited_literals[]; extern const literal_def pinteger_unlimited_literals[]; extern set_show_commands add_setshow_enum_cmd - (const char *name, command_class theclass, const char *const *enumlist, + (const char *name, command_classes theclass, const char *const *enumlist, const char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_enum_cmd - (const char *name, command_class theclass, const char *const *enumlist, + (const char *name, command_classes theclass, const char *const *enumlist, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, setting_func_types::get get_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_color_cmd - (const char *name, command_class theclass, ui_file_style::color *var, + (const char *name, command_classes theclass, ui_file_style::color *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_color_cmd - (const char *name, command_class theclass, + (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, setting_func_types::get get_func, @@ -705,13 +706,13 @@ extern set_show_commands add_setshow_color_cmd cmd_list_element **show_list); extern set_show_commands add_setshow_auto_boolean_cmd - (const char *name, command_class theclass, auto_boolean *var, + (const char *name, command_classes theclass, auto_boolean *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_auto_boolean_cmd - (const char *name, command_class theclass, const char *set_doc, + (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, setting_func_types::get get_func, @@ -719,39 +720,39 @@ extern set_show_commands add_setshow_auto_boolean_cmd cmd_list_element **show_list); extern set_show_commands add_setshow_boolean_cmd - (const char *name, command_class theclass, bool *var, const char *set_doc, + (const char *name, command_classes theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_boolean_cmd - (const char *name, command_class theclass, const char *set_doc, + (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, setting_func_types::get get_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_filename_cmd - (const char *name, command_class theclass, std::string *var, const char *set_doc, + (const char *name, command_classes theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_filename_cmd - (const char *name, command_class theclass, const char *set_doc, + (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, setting_func_types::get get_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_string_cmd - (const char *name, command_class theclass, std::string *var, const char *set_doc, + (const char *name, command_classes theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_string_cmd - (const char *name, command_class theclass, const char *set_doc, + (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, setting_func_types::get get_func, @@ -759,26 +760,26 @@ extern set_show_commands add_setshow_string_cmd cmd_list_element **show_list); extern set_show_commands add_setshow_string_noescape_cmd - (const char *name, command_class theclass, std::string *var, const char *set_doc, + (const char *name, command_classes theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_string_noescape_cmd - (const char *name, command_class theclass, const char *set_doc, + (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, setting_func_types::get get_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_optional_filename_cmd - (const char *name, command_class theclass, std::string *var, const char *set_doc, + (const char *name, command_classes theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_optional_filename_cmd - (const char *name, command_class theclass, const char *set_doc, + (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, setting_func_types::get get_func, @@ -786,107 +787,107 @@ extern set_show_commands add_setshow_optional_filename_cmd cmd_list_element **show_list); extern set_show_commands add_setshow_integer_cmd - (const char *name, command_class theclass, int *var, + (const char *name, command_classes theclass, int *var, const literal_def *extra_literals, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_integer_cmd - (const char *name, command_class theclass, const literal_def *extra_literals, + (const char *name, command_classes theclass, const literal_def *extra_literals, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, setting_func_types::get get_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_integer_cmd - (const char *name, command_class theclass, int *var, const char *set_doc, + (const char *name, command_classes theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_integer_cmd - (const char *name, command_class theclass, const char *set_doc, + (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, setting_func_types::get get_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_pinteger_cmd - (const char *name, command_class theclass, int *var, + (const char *name, command_classes theclass, int *var, const literal_def *extra_literals, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_pinteger_cmd - (const char *name, command_class theclass, const literal_def *extra_literals, + (const char *name, command_classes theclass, const literal_def *extra_literals, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, setting_func_types::get get_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_uinteger_cmd - (const char *name, command_class theclass, unsigned int *var, + (const char *name, command_classes theclass, unsigned int *var, const literal_def *extra_literals, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_uinteger_cmd - (const char *name, command_class theclass, const literal_def *extra_literals, + (const char *name, command_classes theclass, const literal_def *extra_literals, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, setting_func_types::get get_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_uinteger_cmd - (const char *name, command_class theclass, unsigned int *var, + (const char *name, command_classes theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_uinteger_cmd - (const char *name, command_class theclass, const char *set_doc, + (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, setting_func_types::get get_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_zinteger_cmd - (const char *name, command_class theclass, int *var, const char *set_doc, + (const char *name, command_classes theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_zinteger_cmd - (const char *name, command_class theclass, const char *set_doc, + (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, setting_func_types::get get_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_zuinteger_cmd - (const char *name, command_class theclass, unsigned int *var, + (const char *name, command_classes theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_zuinteger_cmd - (const char *name, command_class theclass, const char *set_doc, + (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, setting_func_types::get get_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_zuinteger_unlimited_cmd - (const char *name, command_class theclass, int *var, const char *set_doc, + (const char *name, command_classes theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list); extern set_show_commands add_setshow_zuinteger_unlimited_cmd - (const char *name, command_class theclass, const char *set_doc, + (const char *name, command_classes theclass, const char *set_doc, const char *show_doc, const char *help_doc, setting_func_types::set set_func, setting_func_types::get get_func, show_value_ftype *show_func, cmd_list_element **set_list,