Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Marco Barisione via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Subject: [PATCH v3 3/5] gdb: move declarations and docs for cli-decode.c to cli-decode.h
Date: Fri, 14 May 2021 21:39:55 +0100	[thread overview]
Message-ID: <20210514203955.98069-1-mbarisione@undo.io> (raw)
In-Reply-To: <46adb353-2e92-ca43-2afd-beaa5b779672@polymtl.ca>

Declarations and the documentation should be in the header file for the
corresponding .c file.  This helps keeping command.h cleaner.

I also updated the documentation for add_cmd which ended up being docs
for the wrong function (do_add_cmd) and quite outdated.

gdb/ChangeLog:

	* command.h (cmd_const_cfunc_ftype): Move declaration to
	cli/cli-decode.h.
	(valid_user_defined_cmd_name_p): Ditto.
	(valid_cmd_char_p): Ditto.
	(add_alias_cmd): Ditto.
	(add_prefix_cmd): Ditto.
	(add_abbrev_prefix_cmd): Ditto.
	(cmd_const_sfunc_ftype): Ditto.
	(set_cmd_sfunc): Ditto.
	(set_cmd_completer): Ditto.
	(set_cmd_completer_handle_brkchars): Ditto.
	(cmd_cfunc_eq): Ditto.
	(set_cmd_context): Ditto.
	(get_cmd_context): Ditto.
	(CMD_LIST_AMBIGUOUS): Ditto.
	(lookup_cmd): Ditto.
	(lookup_cmd_exact): Ditto.
	(deprecate_cmd): Ditto.
	(deprecated_cmd_warning): Ditto.
	(lookup_cmd_composition): Ditto.
	(add_com): Ditto.
	(add_com_alias): Ditto.
	(add_info): Ditto.
	(add_info_alias): Ditto.
	(complete_on_cmdlist): Ditto.
	(complete_on_enum): Ditto.
	(help_list): Ditto.
	(add_setshow_enum_cmd): Ditto.
	(add_setshow_auto_boolean_cmd): Ditto.
	(add_setshow_boolean_cmd): Ditto.
	(add_setshow_filename_cmd): Ditto.
	(add_setshow_string_cmd): Ditto.
	(add_setshow_optional_filename_cmd): Ditto.
	(add_setshow_integer_cmd): Ditto.
	(add_setshow_uinteger_cmd): Ditto.
	(add_setshow_zinteger_cmd): Ditto.
	(add_setshow_zuinteger_cmd): Ditto.
	(add_setshow_zuinteger_unlimited_cmd): Ditto.
	(completer_ftype): Move to completer.h.
	(completer_handle_brkchars_ftype): Ditto.
	* cli/cli-decode.h (cmd_const_sfunc_ftype): Move declaration
	from command.h
	(valid_user_defined_cmd_name_p): Ditto.
	(valid_cmd_char_p): Ditto.
	(add_alias_cmd): Ditto.
	(add_prefix_cmd): Ditto.
	(add_abbrev_prefix_cmd): Ditto.
	(set_cmd_sfunc): Ditto.
	(set_cmd_completer): Ditto.
	(set_cmd_completer_handle_brkchars): Ditto.
	(cmd_cfunc_eq): Ditto.
	(set_cmd_context): Ditto.
	(get_cmd_context): Ditto.
	(CMD_LIST_AMBIGUOUS): Ditto.
	(lookup_cmd): Ditto.
	(deprecate_cmd): Ditto.
	(deprecated_cmd_warning): Ditto.
	(lookup_cmd_composition): Ditto.
	(add_com): Ditto.
	(add_com_alias): Ditto.
	(add_info): Ditto.
	(add_info_alias): Ditto.
	(complete_on_cmdlist): Ditto.
	(complete_on_enum): Ditto.
	(help_list): Ditto.
	(add_setshow_enum_cmd): Ditto.
	(add_setshow_auto_boolean_cmd): Ditto.
	(add_setshow_filename_cmd): Ditto.
	(add_setshow_string_cmd): Ditto.
	(add_setshow_integer_cmd): Ditto.
	(add_setshow_uinteger_cmd): Ditto.
	(add_setshow_zinteger_cmd): Ditto.
	(add_setshow_zuinteger_cmd): Ditto.
	(add_cmd): Move declaration from command.h and fix
	documentation.
	* cli/cli-decode.c (add_cmd): Move documentation to
	cli/cli-decode.h
	(add_cmd_suppress_notification): Ditto.
	(update_prefix_field_of_prefixed_commands): Ditto.
	(do_prefix_cmd): Ditto.
	(do_show_prefix_cmd): Ditto.
	(add_show_prefix_cmd): Ditto.
	(add_abbrev_prefix_cmd): Ditto.
	(add_setshow_cmd_full): Ditto.
	(help_cmd): Ditto.
	(find_command_name_length): Ditto.
	(valid_cmd_char_p): Ditto.
	(valid_user_defined_cmd_name_p): Ditto.
	(undef_cmd_error): Ditto.
	(lookup_cmd): Ditto.
	(lookup_cmd_exact): Ditto.
	(lookup_cmd_composition_1): Ditto.
	(lookup_cmd_composition): Ditto.
	(complete_on_cmdlist): Ditto.
	(cmd_func_p): Ditto.
	* (do_add_cmd): Remove outdated documentation and refer to the
	documentation for add_cmd.
	* completer.h (completer_ftype): Moved from command.h.
	(completer_handle_brkchars_ftype): Ditto.
	* breakpoint.h: Include cli/cli-decode.h.
	* charset.c: Ditto.
	* cli/cli-logging.c: Ditto.
	* cli/cli-style.c: Ditto.
	* complaints.c: Ditto.
	* copying.c: Ditto.
	* cp-abi.c: Ditto.
	* filesystem.c: Ditto.
	* gdb-demangle.c: Ditto.
	* interps.c: Ditto.
	* macrocmd.c: Ditto.
	* maint-test-options.c: Ditto.
	* maint-test-settings.c: Ditto.
	* observable.c: Ditto.
	* osabi.c: Ditto.
	* reggroups.c: Ditto.
	* ser-unix.c: Ditto.
	* serial.c: Ditto.
	* user-regs.c: Ditto.
	* xml-support.c: Ditto.
---
 gdb/breakpoint.h          |   1 +
 gdb/charset.c             |   1 +
 gdb/cli/cli-decode.c      | 155 +++----------
 gdb/cli/cli-decode.h      | 473 +++++++++++++++++++++++++++++++++++++-
 gdb/cli/cli-logging.c     |   1 +
 gdb/cli/cli-style.c       |   1 +
 gdb/command.h             | 380 +-----------------------------
 gdb/complaints.c          |   1 +
 gdb/completer.h           |  21 ++
 gdb/copying.c             |   1 +
 gdb/cp-abi.c              |   1 +
 gdb/filesystem.c          |   1 +
 gdb/gdb-demangle.c        |   1 +
 gdb/interps.c             |   1 +
 gdb/macrocmd.c            |   1 +
 gdb/maint-test-options.c  |   1 +
 gdb/maint-test-settings.c |   1 +
 gdb/observable.c          |   1 +
 gdb/osabi.c               |   1 +
 gdb/reggroups.c           |   1 +
 gdb/ser-unix.c            |   1 +
 gdb/serial.c              |   1 +
 gdb/user-regs.c           |   1 +
 gdb/xml-support.c         |   1 +
 24 files changed, 543 insertions(+), 506 deletions(-)

diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 54c5e423e10..15022892d6b 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -30,6 +30,7 @@
 #include "gdbsupport/array-view.h"
 #include "gdbsupport/function-view.h"
 #include "gdbsupport/refcounted-object.h"
+#include "cli/cli-decode.h"
 #include "cli/cli-script.h"
 
 struct block;
diff --git a/gdb/charset.c b/gdb/charset.c
index 9fb1a1f0b67..6fb3cdfaeb7 100644
--- a/gdb/charset.c
+++ b/gdb/charset.c
@@ -19,6 +19,7 @@
 
 #include "defs.h"
 #include "charset.h"
+#include "cli/cli-decode.h"
 #include "gdbcmd.h"
 #include "gdb_obstack.h"
 #include "gdbsupport/gdb_wait.h"
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 32edb526c87..f13bbbf60d9 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -160,23 +160,7 @@ set_cmd_completer_handle_brkchars (struct cmd_list_element *cmd,
   cmd->completer_handle_brkchars = func;
 }
 
-/* Add element named NAME.
-   Space for NAME and DOC must be allocated by the caller.
-   CLASS is the top level category into which commands are broken down
-   for "help" purposes.
-   FUN should be the function to execute the command;
-   it will get a character string as argument, with leading
-   and trailing blanks already eliminated.
-
-   DOC is a documentation string for the command.
-   Its first line should be a complete sentence.
-   It should start with ? for a command that is an abbreviation
-   or with * for a command that most users don't need to know about.
-
-   Add this command to command list *LIST.
-
-   Returns a pointer to the added command (not necessarily the head 
-   of *LIST).  */
+/* Like ADD_CMD, but the command function fields are not modified.  */
 
 static struct cmd_list_element *
 do_add_cmd (const char *name, enum command_class theclass,
@@ -227,6 +211,8 @@ do_add_cmd (const char *name, enum command_class theclass,
   return c;
 }
 
+/* See cli-decode.h.  */
+
 struct cmd_list_element *
 add_cmd (const char *name, enum command_class theclass,
 	 const char *doc, struct cmd_list_element **list)
@@ -237,6 +223,8 @@ add_cmd (const char *name, enum command_class theclass,
   return result;
 }
 
+/* See cli-decode.h.  */
+
 struct cmd_list_element *
 add_cmd (const char *name, enum command_class theclass,
 	 cmd_const_cfunc_ftype *fun,
@@ -247,7 +235,7 @@ add_cmd (const char *name, enum command_class theclass,
   return result;
 }
 
-/* Add an element with a suppress notification to the LIST of commands.  */
+/* See cli-decode.h.  */
 
 struct cmd_list_element *
 add_cmd_suppress_notification (const char *name, enum command_class theclass,
@@ -263,16 +251,7 @@ add_cmd_suppress_notification (const char *name, enum command_class theclass,
   return element;
 }
 
-
-/* Deprecates a command CMD.
-   REPLACEMENT is the name of the command which should be used in
-   place of this command, or NULL if no such command exists.
-
-   This function does not check to see if command REPLACEMENT exists
-   since gdb may not have gotten around to adding REPLACEMENT when
-   this function is called.
-
-   Returns a pointer to the deprecated command.  */
+/* See cli-decode.h.  */
 
 struct cmd_list_element *
 deprecate_cmd (struct cmd_list_element *cmd, const char *replacement)
@@ -372,11 +351,7 @@ update_prefix_field_of_prefixed_commands (struct cmd_list_element *c)
     }
 }
 
-
-/* Like add_cmd but adds an element for a command prefix: a name that
-   should be followed by a subcommand to be looked up in another
-   command list.  PREFIXLIST should be the address of the variable
-   containing that list.  */
+/* See cli-decode.h.  */
 
 struct cmd_list_element *
 add_prefix_cmd (const char *name, enum command_class theclass,
@@ -410,7 +385,7 @@ do_prefix_cmd (const char *args, int from_tty, struct cmd_list_element *c)
 	     all_commands, gdb_stdout);
 }
 
-/* See command.h.  */
+/* See cli-decode.h.  */
 
 struct cmd_list_element *
 add_basic_prefix_cmd (const char *name, enum command_class theclass,
@@ -433,7 +408,7 @@ do_show_prefix_cmd (const char *args, int from_tty, struct cmd_list_element *c)
   cmd_show_list (*c->prefixlist, from_tty);
 }
 
-/* See command.h.  */
+/* See cli-decode.h.  */
 
 struct cmd_list_element *
 add_show_prefix_cmd (const char *name, enum command_class theclass,
@@ -447,8 +422,7 @@ add_show_prefix_cmd (const char *name, enum command_class theclass,
   return cmd;
 }
 
-/* Like ADD_PREFIX_CMD but sets the suppress_notification pointer on the
-   new command list element.  */
+/* See cli-decode.h.  */
 
 struct cmd_list_element *
 add_prefix_cmd_suppress_notification
@@ -465,7 +439,7 @@ add_prefix_cmd_suppress_notification
   return element;
 }
 
-/* Like add_prefix_cmd but sets the abbrev_flag on the new command.  */
+/* See cli-decode.h.  */
 
 struct cmd_list_element *
 add_abbrev_prefix_cmd (const char *name, enum command_class theclass,
@@ -481,7 +455,8 @@ add_abbrev_prefix_cmd (const char *name, enum command_class theclass,
   return c;
 }
 
-/* This is an empty "cfunc".  */
+/* See cli-decode.h.  */
+
 void
 not_just_help_class_command (const char *args, int from_tty)
 {
@@ -581,10 +556,7 @@ add_setshow_cmd_full (const char *name,
     *show_result = show;
 }
 
-/* Add element named NAME to command list LIST (the list for set or
-   some sublist thereof).  CLASS is as in add_cmd.  ENUMLIST is a list
-   of strings which may follow NAME.  VAR is address of the variable
-   which will contain the matching string (from ENUMLIST).  */
+/* See cli-decode.h.  */
 
 void
 add_setshow_enum_cmd (const char *name,
@@ -1274,18 +1246,8 @@ help_cmd (const char *command, struct ui_file *stream)
 		    c->hook_post->name);
 }
 
-/*
- * Get a specific kind of help on a command list.
- *
- * LIST is the list.
- * CMDTYPE is the prefix to use in the title string.
- * CLASS is the class with which to list the nodes of this list (see
- * documentation for help_cmd_list below),  As usual, ALL_COMMANDS for
- * everything, ALL_CLASSES for just classes, and non-negative for only things
- * in a specific class.
- * and STREAM is the output stream on which to print things.
- * If you call this routine with a class >= 0, it recurses.
- */
+/* See cli-decode.h.  */
+
 void
 help_list (struct cmd_list_element *list, const char *cmdtype,
 	   enum command_class theclass, struct ui_file *stream)
@@ -1583,7 +1545,7 @@ find_command_name_length (const char *text)
   return p - text;
 }
 
-/* See command.h.  */
+/* See cli-decode.h.  */
 
 bool
 valid_cmd_char_p (int c)
@@ -1594,7 +1556,7 @@ valid_cmd_char_p (int c)
   return isalnum (c) || c == '-' || c == '_' || c == '.';
 }
 
-/* See command.h.  */
+/* See cli-decode.h.  */
 
 bool
 valid_user_defined_cmd_name_p (const char *name)
@@ -1615,7 +1577,7 @@ valid_user_defined_cmd_name_p (const char *name)
   return true;
 }
 
-/* See command.h.  */
+/* See cli-decode.h.  */
 
 struct cmd_list_element *
 lookup_cmd_1 (const char **text, struct cmd_list_element *clist,
@@ -1751,24 +1713,7 @@ undef_cmd_error (const char *cmdtype, const char *q)
 	 cmdtype);
 }
 
-/* Look up the contents of *LINE as a command in the command list LIST.
-   LIST is a chain of struct cmd_list_element's.
-   If it is found, return the struct cmd_list_element for that command,
-   update *LINE to point after the command name, at the first argument
-   and update *DEFAULT_ARGS (if DEFAULT_ARGS is not null) to the default
-   args to prepend to the user provided args when running the command.
-   Note that if the found cmd_list_element is found via an alias,
-   the default args of the alias are returned.
-
-   If not found, call error if ALLOW_UNKNOWN is zero
-   otherwise (or if error returns) return zero.
-   Call error if specified command is ambiguous,
-   unless ALLOW_UNKNOWN is negative.
-   CMDTYPE precedes the word "command" in the error message.
-
-   If IGNORE_HELP_CLASSES is nonzero, ignore any command list
-   elements which are actually help classes rather than commands (i.e.
-   the function field of the struct cmd_list_element is 0).  */
+/* See cli-decode.h.  */
 
 struct cmd_list_element *
 lookup_cmd (const char **line, struct cmd_list_element *list,
@@ -1872,7 +1817,7 @@ lookup_cmd (const char **line, struct cmd_list_element *list,
   return 0;
 }
 
-/* See command.h.  */
+/* See cli-decode.h.  */
 
 struct cmd_list_element *
 lookup_cmd_exact (const char *name,
@@ -1887,28 +1832,8 @@ lookup_cmd_exact (const char *name,
   return cmd;
 }
 
-/* We are here presumably because an alias or command in TEXT is
-   deprecated and a warning message should be generated.  This
-   function decodes TEXT and potentially generates a warning message
-   as outlined below.
-   
-   Example for 'set endian big' which has a fictitious alias 'seb'.
-   
-   If alias wasn't used in TEXT, and the command is deprecated:
-   "warning: 'set endian big' is deprecated." 
-   
-   If alias was used, and only the alias is deprecated:
-   "warning: 'seb' an alias for the command 'set endian big' is deprecated."
-   
-   If alias was used and command is deprecated (regardless of whether
-   the alias itself is deprecated:
-   
-   "warning: 'set endian big' (seb) is deprecated."
+/* See cli-decode.h.  */
 
-   After the message has been sent, clear the appropriate flags in the
-   command and/or the alias so the user is no longer bothered.
-   
-*/
 void
 deprecated_cmd_warning (const char *text, struct cmd_list_element *list)
 {
@@ -2064,20 +1989,7 @@ lookup_cmd_composition_1 (const char *text,
     }
 }
 
-/* Look up the contents of TEXT as a command in the command list 'cmdlist'.
-   Return 1 on success, 0 on failure.
-
-   If TEXT refers to an alias, *ALIAS will point to that alias.
-
-   If TEXT is a subcommand (i.e. one that is preceded by a prefix
-   command) set *PREFIX_CMD.
-
-   Set *CMD to point to the command TEXT indicates.
-
-   If any of *ALIAS, *PREFIX_CMD, or *CMD cannot be determined or do not
-   exist, they are NULL when we return.
-
-*/
+/* See cli-decode.h.  */
 
 int
 lookup_cmd_composition (const char *text,
@@ -2090,13 +2002,7 @@ lookup_cmd_composition (const char *text,
 
 /* Helper function for SYMBOL_COMPLETION_FUNCTION.  */
 
-/* Return a vector of char pointers which point to the different
-   possible completions in LIST of TEXT.
-
-   WORD points in the same buffer as TEXT, and completions should be
-   returned relative to this position.  For example, suppose TEXT is
-   "foo" and we want to complete to "foobar".  If WORD is "oo", return
-   "oobar"; if WORD is "baz/foo", return "baz/foobar".  */
+/* See cli-decode.h.  */
 
 void
 complete_on_cmdlist (struct cmd_list_element *list,
@@ -2149,12 +2055,7 @@ complete_on_cmdlist (struct cmd_list_element *list,
 
 /* Helper function for SYMBOL_COMPLETION_FUNCTION.  */
 
-/* Add the different possible completions in ENUMLIST of TEXT.
-
-   WORD points in the same buffer as TEXT, and completions should be
-   returned relative to this position.  For example, suppose TEXT is "foo"
-   and we want to complete to "foobar".  If WORD is "oo", return
-   "oobar"; if WORD is "baz/foo", return "baz/foobar".  */
+/* See cli-decode.h.  */
 
 void
 complete_on_enum (completion_tracker &tracker,
@@ -2170,16 +2071,16 @@ complete_on_enum (completion_tracker &tracker,
       tracker.add_completion (make_completion_match_str (name, text, word));
 }
 
+/* See cli-decode.h.  */
 
-/* Check function pointer.  */
 int
 cmd_func_p (struct cmd_list_element *cmd)
 {
   return (cmd->func != NULL);
 }
 
+/* See cli-decode.h.  */
 
-/* Call the command function.  */
 void
 cmd_func (struct cmd_list_element *cmd, const char *args, int from_tty)
 {
diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h
index da6013a6cc5..54057a149be 100644
--- a/gdb/cli/cli-decode.h
+++ b/gdb/cli/cli-decode.h
@@ -37,9 +37,23 @@ enum cmd_types
   show_cmd
 };
 
+struct cmd_list_element;
+
+typedef void cmd_const_sfunc_ftype (const char *args, int from_tty,
+				    cmd_list_element *c);
+
+/* A function implementing a command, see add_cmd and related functions.
+
+   ARGS is a string containing the arguments to the command (with leading
+   and trailing blanks already eliminated).
+
+   FROM_TTY is a flag specifying whether this command was originated from
+   the user invoking it interactively.  */
+
+typedef void cmd_const_cfunc_ftype (const char *args, int from_tty);
+
 /* This structure records one command'd definition.  */
 
-
 struct cmd_list_element
 {
   cmd_list_element (const char *name_, enum command_class theclass_,
@@ -256,8 +270,349 @@ struct cmd_list_element
   int *suppress_notification = nullptr;
 };
 
+/* API to the manipulation of command lists.  */
+
+/* Return TRUE if NAME is a valid user-defined command name.
+   This is a stricter subset of all gdb commands,
+   see find_command_name_length.  */
+
+extern bool valid_user_defined_cmd_name_p (const char *name);
+
+/* Return TRUE if C is a valid command character.  */
+
+extern bool valid_cmd_char_p (int c);
+
+/* Add a command named NAME in command list *LIST.
+
+   NAME and DOC are not duplicated.  If they are not static string, they
+   must have been allocated with xmalloc or xstrdup and the
+   NAME_ALLOCATED/DOC_ALLOCATED fields must be set to 1 on the returned
+   command.
+
+   THECLASS is the top level category into which commands are broken down
+   for "help" purposes.
+
+   FUN is the function which implements the command.
+
+   DOC is a documentation string for the command.
+   Its first line should be a complete sentence.
+   It should start with ? for a command that is an abbreviation
+   or with * for a command that most users don't need to know about.
+
+   If NAME already existed in *LIST, all its hooks and aliases are moved
+   to the new command.
+
+   Return a pointer to the added command (not necessarily the head of
+   *LIST).  */
+
+extern cmd_list_element *add_cmd (const char *name,
+				  command_class theclass,
+				  cmd_const_cfunc_ftype *fun,
+				  const char *doc,
+				  cmd_list_element **list);
+
+/* Like add_cmd, but no command function is specified.  */
+
+extern cmd_list_element *add_cmd (const char *name,
+				  command_class theclass,
+				  const char *doc,
+				  cmd_list_element **list);
+
+/* Add an element with a suppress notification to the LIST of commands.  */
+
+extern cmd_list_element *add_cmd_suppress_notification
+  (const char *name, command_class theclass, cmd_const_cfunc_ftype *fun,
+   const char *doc, cmd_list_element **list, int *suppress_notification);
+
+extern cmd_list_element *add_alias_cmd (const char *name,
+					const char *oldname,
+					command_class theclass,
+					int abbrev_flag,
+					cmd_list_element **list);
+
+extern cmd_list_element *add_alias_cmd (const char *name,
+					cmd_list_element *old,
+					command_class theclass,
+					int abbrev_flag,
+					cmd_list_element **list);
+
+/* Like add_cmd but adds an element for a command prefix: a name that
+   should be followed by a subcommand to be looked up in another
+   command list.  PREFIXLIST should be the address of the variable
+   containing that list.  */
+
+extern cmd_list_element *add_prefix_cmd (const char *name,
+					 command_class theclass,
+					 cmd_const_cfunc_ftype *fun,
+					 const char *doc,
+					 cmd_list_element **prefixlist,
+					 int allow_unknown,
+					 cmd_list_element **list);
+
+/* Like add_prefix_cmd, but sets the callback to a function that
+   simply calls help_list.  */
+
+extern cmd_list_element *add_basic_prefix_cmd
+  (const char *name, command_class theclass, const char *doc,
+   cmd_list_element **prefixlist, int allow_unknown,
+   cmd_list_element **list);
+
+/* Like add_prefix_cmd, but useful for "show" prefixes.  This sets the
+   callback to a function that simply calls cmd_show_list.  */
+
+extern  cmd_list_element *add_show_prefix_cmd
+ (const char *name, command_class theclass, const char *doc,
+  cmd_list_element **prefixlist, int allow_unknown,
+  cmd_list_element **list);
+
+/* Like ADD_PREFIX_CMD but sets the suppress_notification pointer on the
+   new command list element.  */
+
+extern cmd_list_element *add_prefix_cmd_suppress_notification
+  (const char *name, command_class theclass, cmd_const_cfunc_ftype *fun,
+   const char *doc, cmd_list_element **prefixlist, int allow_unknown,
+   cmd_list_element **list, int *suppress_notification);
+
+/* Like add_prefix_cmd but sets the abbrev_flag on the new command.  */
+
+extern cmd_list_element *add_abbrev_prefix_cmd
+  (const char *name, command_class theclass, cmd_const_cfunc_ftype *fun,
+   const char *doc, cmd_list_element **prefixlist, int allow_unknown,
+   cmd_list_element **list);
+
+extern void set_cmd_sfunc (cmd_list_element *cmd,
+			   cmd_const_sfunc_ftype *sfunc);
+
+extern void set_cmd_completer (cmd_list_element *, completer_ftype *);
+
+/* Set the completer_handle_brkchars callback.  */
+
+extern void set_cmd_completer_handle_brkchars
+  (cmd_list_element *, completer_handle_brkchars_ftype *);
+
+/* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
+   around in cmd objects to test the value of the commands sfunc().  */
+extern int cmd_cfunc_eq (cmd_list_element *cmd,
+			 cmd_const_cfunc_ftype *cfun);
+
+/* Each command object has a local context attached to it.  */
+
+extern void set_cmd_context (cmd_list_element *cmd, void *context);
+extern void *get_cmd_context (cmd_list_element *cmd);
+
+/* Flag for an ambiguous cmd_list result.  */
+
+#define CMD_LIST_AMBIGUOUS ((cmd_list_element *) -1)
+
+/* Look up the contents of *LINE as a command in the command list LIST.
+   LIST is a chain of struct cmd_list_element's.
+   If it is found, return the struct cmd_list_element for that command,
+   update *LINE to point after the command name, at the first argument
+   and update *DEFAULT_ARGS (if DEFAULT_ARGS is not null) to the default
+   args to prepend to the user provided args when running the command.
+   Note that if the found cmd_list_element is found via an alias,
+   the default args of the alias are returned.
+
+   If not found, call error if ALLOW_UNKNOWN is zero
+   otherwise (or if error returns) return zero.
+   Call error if specified command is ambiguous,
+   unless ALLOW_UNKNOWN is negative.
+   CMDTYPE precedes the word "command" in the error message.
+
+   If IGNORE_HELP_CLASSES is nonzero, ignore any command list
+   elements which are actually help classes rather than commands (i.e.
+   the function field of the struct cmd_list_element is 0).  */
+
+extern cmd_list_element *lookup_cmd (const char **line,
+				     cmd_list_element *list,
+				     const char *cmdtype,
+				     std::string *default_args,
+				     int allow_unknown,
+				     int ignore_help_classes);
+
+/* This routine takes a line of TEXT and a CLIST in which to start the
+   lookup.  When it returns it will have incremented the text pointer past
+   the section of text it matched, set *RESULT_LIST to point to the list in
+   which the last word was matched, and will return a pointer to the cmd
+   list element which the text matches.  It will return NULL if no match at
+   all was possible.  It will return -1 (cast appropriately, ick) if ambigous
+   matches are possible; in this case *RESULT_LIST will be set to point to
+   the list in which there are ambiguous choices (and *TEXT will be set to
+   the ambiguous text string).
+
+   if DEFAULT_ARGS is not null, *DEFAULT_ARGS is set to the found command
+   default args (possibly empty).
+
+   If the located command was an abbreviation, this routine returns the base
+   command of the abbreviation.  Note that *DEFAULT_ARGS will contain the
+   default args defined for the alias.
+
+   It does no error reporting whatsoever; control will always return
+   to the superior routine.
+
+   In the case of an ambiguous return (-1), *RESULT_LIST will be set to point
+   at the prefix_command (ie. the best match) *or* (special case) will be NULL
+   if no prefix command was ever found.  For example, in the case of "info a",
+   "info" matches without ambiguity, but "a" could be "args" or "address", so
+   *RESULT_LIST is set to the cmd_list_element for "info".  So in this case
+   RESULT_LIST should not be interpreted as a pointer to the beginning of a
+   list; it simply points to a specific command.  In the case of an ambiguous
+   return *TEXT is advanced past the last non-ambiguous prefix (e.g.
+   "info t" can be "info types" or "info target"; upon return *TEXT has been
+   advanced past "info ").
+
+   If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise
+   affect the operation).
+
+   This routine does *not* modify the text pointed to by TEXT.
+
+   If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which
+   are actually help classes rather than commands (i.e. the function field of
+   the struct cmd_list_element is NULL).
+
+   When LOOKUP_FOR_COMPLETION_P is true the completion is being requested
+   for the completion engine, no warnings should be printed.  */
+
+extern cmd_list_element *lookup_cmd_1
+  (const char **text, cmd_list_element *clist,
+   cmd_list_element **result_list, std::string *default_args,
+   int ignore_help_classes, bool lookup_for_completion_p = false);
+
+/* Look up the command called NAME in the command list LIST.
+
+   Unlike LOOKUP_CMD, partial matches are ignored and only exact matches
+   on NAME are considered.
+
+   LIST is a chain of struct cmd_list_element's.
+
+   If IGNORE_HELP_CLASSES is true (the default), ignore any command list
+   elements which are actually help classes rather than commands (i.e.
+   the function field of the struct cmd_list_element is null).
+
+   If found, return the struct cmd_list_element for that command,
+   otherwise return NULLPTR.  */
+
+extern cmd_list_element *lookup_cmd_exact
+  (const char *name, cmd_list_element *list,
+   bool ignore_help_classes = true);
+
+/* Deprecates a command CMD.
+   REPLACEMENT is the name of the command which should be used in
+   place of this command, or NULL if no such command exists.
+
+   This function does not check to see if command REPLACEMENT exists
+   since gdb may not have gotten around to adding REPLACEMENT when
+   this function is called.
+
+   Returns a pointer to the deprecated command.  */
+
+extern cmd_list_element *deprecate_cmd (cmd_list_element *cmd,
+					const char *replacement);
+
+/* We are here presumably because an alias or command in TEXT is
+   deprecated and a warning message should be generated.  This
+   function decodes TEXT and potentially generates a warning message
+   as outlined below.
+
+   Example for 'set endian big' which has a fictitious alias 'seb'.
+
+   If alias wasn't used in TEXT, and the command is deprecated:
+   "warning: 'set endian big' is deprecated."
+
+   If alias was used, and only the alias is deprecated:
+   "warning: 'seb' an alias for the command 'set endian big' is deprecated."
+
+   If alias was used and command is deprecated (regardless of whether
+   the alias itself is deprecated:
+
+   "warning: 'set endian big' (seb) is deprecated."
+
+   After the message has been sent, clear the appropriate flags in the
+   command and/or the alias so the user is no longer bothered.  */
+
+extern void deprecated_cmd_warning (const char *text,
+				    cmd_list_element *list);
+
+/* Look up the contents of TEXT as a command in the command list 'cmdlist'.
+   Return 1 on success, 0 on failure.
+
+   If TEXT refers to an alias, *ALIAS will point to that alias.
+
+   If TEXT is a subcommand (i.e. one that is preceded by a prefix
+   command) set *PREFIX_CMD.
+
+   Set *CMD to point to the command TEXT indicates.
+
+   If any of *ALIAS, *PREFIX_CMD, or *CMD cannot be determined or do not
+   exist, they are NULL when we return.  */
+
+extern int lookup_cmd_composition (const char *text,
+				   cmd_list_element **alias,
+				   cmd_list_element **prefix_cmd,
+				   cmd_list_element **cmd);
+
+extern cmd_list_element *add_com (const char *name,
+				  command_class theclass,
+				  cmd_const_cfunc_ftype *fun,
+				  const char *doc);
+
+extern cmd_list_element *add_com_alias (const char *name,
+					const char *oldname,
+					command_class theclass,
+					int abbrev_flag);
+
+extern cmd_list_element *add_com_suppress_notification
+  (const char *name, command_class theclass, cmd_const_cfunc_ftype *fun,
+   const char *doc, int *supress_notification);
+
+extern cmd_list_element *add_info (const char *name,
+				   cmd_const_cfunc_ftype *fun,
+				   const char *doc);
+
+extern cmd_list_element *add_info_alias (const char *name,
+					 const char *oldname,
+					 int abbrev_flag);
+
+/* Return a vector of char pointers which point to the different
+   possible completions in LIST of TEXT.
+
+   WORD points in the same buffer as TEXT, and completions should be
+   returned relative to this position.  For example, suppose TEXT is
+   "foo" and we want to complete to "foobar".  If WORD is "oo", return
+   "oobar"; if WORD is "baz/foo", return "baz/foobar".  */
+
+extern void complete_on_cmdlist (cmd_list_element *list,
+				 completion_tracker &tracker,
+				 const char *text, const char *word,
+				 int ignore_help_classes);
+
+/* Add the different possible completions in ENUMLIST of TEXT.
+
+   WORD points in the same buffer as TEXT, and completions should be
+   returned relative to this position.  For example, suppose TEXT is "foo"
+   and we want to complete to "foobar".  If WORD is "oo", return
+   "oobar"; if WORD is "baz/foo", return "baz/foobar".  */
+
+extern void complete_on_enum (completion_tracker &tracker,
+			      const char *const *enumlist,
+			      const char *text, const char *word);
+
 /* Functions that implement commands about CLI commands.  */
 
+/* Get a specific kind of help on a command list.
+ *
+ * LIST is the list.
+ * CMDTYPE is the prefix to use in the title string.
+ * CLASS is the class with which to list the nodes of this list (see
+ * documentation for help_cmd_list below),  As usual, ALL_COMMANDS for
+ * everything, ALL_CLASSES for just classes, and non-negative for only things
+ * in a specific class.
+ * and STREAM is the output stream on which to print things.
+ * If you call this routine with a class >= 0, it recurses.  */
+
+extern void help_list (cmd_list_element *list, const char *cmdtype,
+		       command_class theclass, ui_file *stream);
+
 extern void help_cmd (const char *, struct ui_file *);
 
 extern void apropos_cmd (struct ui_file *, struct cmd_list_element *,
@@ -291,4 +646,120 @@ extern int cli_user_command_p (struct cmd_list_element *);
 
 extern int find_command_name_length (const char *);
 
+/* Support for adding set and show commands.  */
+
+/* Add element named NAME to command list LIST (the list for set or
+   some sublist thereof).  CLASS is as in add_cmd.  ENUMLIST is a list
+   of strings which may follow NAME.  VAR is address of the variable
+   which will contain the matching string (from ENUMLIST).  */
+
+extern void add_setshow_enum_cmd (const char *name,
+				  command_class theclass,
+				  const char *const *enumlist,
+				  const char **var, const char *set_doc,
+				  const char *show_doc,
+				  const char *help_doc,
+				  cmd_const_sfunc_ftype *set_func,
+				  show_value_ftype *show_func,
+				  cmd_list_element **set_list,
+				  cmd_list_element **show_list,
+				  void *context = nullptr);
+
+extern void add_setshow_auto_boolean_cmd (const char *name,
+					  command_class theclass,
+					  auto_boolean *var,
+					  const char *set_doc,
+					  const char *show_doc,
+					  const char *help_doc,
+					  cmd_const_sfunc_ftype *set_func,
+					  show_value_ftype *show_func,
+					  cmd_list_element **set_list,
+					  cmd_list_element **show_list);
+
+extern cmd_list_element * add_setshow_boolean_cmd
+  (const char *name, command_class theclass, bool *var,
+   const char *set_doc, const char *show_doc, const char *help_doc,
+   cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func,
+   cmd_list_element **set_list, cmd_list_element **show_list);
+
+extern void add_setshow_filename_cmd (const char *name,
+				      command_class theclass, char **var,
+				      const char *set_doc,
+				      const char *show_doc,
+				      const char *help_doc,
+				      cmd_const_sfunc_ftype *set_func,
+				      show_value_ftype *show_func,
+				      cmd_list_element **set_list,
+				      cmd_list_element **show_list);
+
+extern void add_setshow_string_cmd (const char *name,
+				    command_class theclass, char **var,
+				    const char *set_doc,
+				    const char *show_doc,
+				    const char *help_doc,
+				    cmd_const_sfunc_ftype *set_func,
+				    show_value_ftype *show_func,
+				    cmd_list_element **set_list,
+				    cmd_list_element **show_list);
+
+extern cmd_list_element *add_setshow_string_noescape_cmd
+  (const char *name, command_class theclass, char **var,
+   const char *set_doc, const char *show_doc, const char *help_doc,
+   cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func,
+   cmd_list_element **set_list, cmd_list_element **show_list);
+
+extern void add_setshow_optional_filename_cmd
+  (const char *name, command_class theclass, char **var,
+   const char *set_doc, const char *show_doc, const char *help_doc,
+   cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func,
+   cmd_list_element **set_list, cmd_list_element **show_list);
+
+extern void add_setshow_integer_cmd (const char *name,
+				     command_class theclass, int *var,
+				     const char *set_doc,
+				     const char *show_doc,
+				     const char *help_doc,
+				     cmd_const_sfunc_ftype *set_func,
+				     show_value_ftype *show_func,
+				     cmd_list_element **set_list,
+				     cmd_list_element **show_list);
+
+extern void add_setshow_uinteger_cmd (const char *name,
+				      command_class theclass,
+				      unsigned int *var,
+				      const char *set_doc,
+				      const char *show_doc,
+				      const char *help_doc,
+				      cmd_const_sfunc_ftype *set_func,
+				      show_value_ftype *show_func,
+				      cmd_list_element **set_list,
+				      cmd_list_element **show_list);
+
+extern void add_setshow_zinteger_cmd (const char *name,
+				      command_class theclass, int *var,
+				      const char *set_doc,
+				      const char *show_doc,
+				      const char *help_doc,
+				      cmd_const_sfunc_ftype *set_func,
+				      show_value_ftype *show_func,
+				      cmd_list_element **set_list,
+				      cmd_list_element **show_list);
+
+extern void add_setshow_zuinteger_cmd (const char *name,
+				       command_class theclass,
+				       unsigned int *var,
+				       const char *set_doc,
+				       const char *show_doc,
+				       const char *help_doc,
+				       cmd_const_sfunc_ftype *set_func,
+				       show_value_ftype *show_func,
+				       cmd_list_element **set_list,
+				       cmd_list_element **show_list);
+
+extern void add_setshow_zuinteger_unlimited_cmd
+  (const char *name, command_class theclass, int *var,
+   const char *set_doc, const char *show_doc, const char *help_doc,
+   cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func,
+   cmd_list_element **set_list, cmd_list_element **show_list);
+
 #endif /* CLI_CLI_DECODE_H */
diff --git a/gdb/cli/cli-logging.c b/gdb/cli/cli-logging.c
index dfedd7599a2..44e6d2991af 100644
--- a/gdb/cli/cli-logging.c
+++ b/gdb/cli/cli-logging.c
@@ -21,6 +21,7 @@
 #include "gdbcmd.h"
 #include "ui-out.h"
 #include "interps.h"
+#include "cli/cli-decode.h"
 #include "cli/cli-style.h"
 
 static char *saved_filename;
diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index 25a1d888f86..4f95d7883d0 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -19,6 +19,7 @@
 
 #include "defs.h"
 #include "cli/cli-cmds.h"
+#include "cli/cli-decode.h"
 #include "cli/cli-setshow.h"
 #include "cli/cli-style.h"
 #include "source-cache.h"
diff --git a/gdb/command.h b/gdb/command.h
index 33feb19166c..3e3543927a4 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -128,8 +128,6 @@ var_types;
 /* This structure records one command'd definition.  */
 struct cmd_list_element;
 
-typedef void cmd_const_cfunc_ftype (const char *args, int from_tty);
-
 /* This structure specifies notifications to be suppressed by a cli
    command interpreter.  */
 
@@ -141,252 +139,12 @@ struct cli_suppress_notification
 
 extern struct cli_suppress_notification cli_suppress_notification;
 
-/* Forward-declarations of the entry-points of cli/cli-decode.c.  */
-
-/* API to the manipulation of command lists.  */
-
-/* Return TRUE if NAME is a valid user-defined command name.
-   This is a stricter subset of all gdb commands,
-   see find_command_name_length.  */
-
-extern bool valid_user_defined_cmd_name_p (const char *name);
-
-/* Return TRUE if C is a valid command character.  */
-
-extern bool valid_cmd_char_p (int c);
-
-/* Const-correct variant of the above.  */
-
-extern struct cmd_list_element *add_cmd (const char *, enum command_class,
-					 cmd_const_cfunc_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,
-					 const char *,
-					 struct cmd_list_element **);
-
-extern struct cmd_list_element *add_cmd_suppress_notification
-			(const char *name, enum command_class theclass,
-			 cmd_const_cfunc_ftype *fun, const char *doc,
-			 struct cmd_list_element **list,
-			 int *suppress_notification);
-
-extern struct cmd_list_element *add_alias_cmd (const char *, const char *,
-					       enum command_class, int,
-					       struct cmd_list_element **);
-
-extern struct cmd_list_element *add_alias_cmd (const char *,
-					       cmd_list_element *,
-					       enum command_class, int,
-					       struct cmd_list_element **);
-
-
-extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class,
-						cmd_const_cfunc_ftype *fun,
-						const char *,
-						struct cmd_list_element **,
-						int,
-						struct cmd_list_element **);
-
-/* Like add_prefix_cmd, but sets the callback to a function that
-   simply calls help_list.  */
-
-extern struct cmd_list_element *add_basic_prefix_cmd
-  (const char *, enum command_class, 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 **,
-   int, struct cmd_list_element **);
-
-extern struct cmd_list_element *add_prefix_cmd_suppress_notification
-			(const char *name, enum command_class theclass,
-			 cmd_const_cfunc_ftype *fun,
-			 const char *doc, struct cmd_list_element **prefixlist,
-			 int allow_unknown,
-			 struct cmd_list_element **list,
-			 int *suppress_notification);
-
-extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
-						       enum command_class,
-						       cmd_const_cfunc_ftype *fun,
-						       const char *,
-						       struct cmd_list_element
-						       **, int,
-						       struct cmd_list_element
-						       **);
-
-typedef void cmd_const_sfunc_ftype (const char *args, int from_tty,
-				    struct cmd_list_element *c);
-extern void set_cmd_sfunc (struct cmd_list_element *cmd,
-			   cmd_const_sfunc_ftype *sfunc);
-
-/* A completion routine.  Add possible completions to tracker.
-
-   TEXT is the text beyond what was matched for the command itself
-   (leading whitespace is skipped).  It stops where we are supposed to
-   stop completing (rl_point) and is '\0' terminated.  WORD points in
-   the same buffer as TEXT, and completions should be returned
-   relative to this position.  For example, suppose TEXT is "foo" and
-   we want to complete to "foobar".  If WORD is "oo", return "oobar";
-   if WORD is "baz/foo", return "baz/foobar".  */
-typedef void completer_ftype (struct cmd_list_element *,
-			      completion_tracker &tracker,
-			      const char *text, const char *word);
-
-/* Same, but for set_cmd_completer_handle_brkchars.  */
-typedef void completer_handle_brkchars_ftype (struct cmd_list_element *,
-					      completion_tracker &tracker,
-					      const char *text, const char *word);
-
-extern void set_cmd_completer (struct cmd_list_element *, completer_ftype *);
-
-/* Set the completer_handle_brkchars callback.  */
-
-extern void set_cmd_completer_handle_brkchars (struct cmd_list_element *,
-					       completer_handle_brkchars_ftype *);
-
-/* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
-   around in cmd objects to test the value of the commands sfunc().  */
-extern int cmd_cfunc_eq (struct cmd_list_element *cmd,
-			 cmd_const_cfunc_ftype *cfun);
-
-/* Each command object has a local context attached to it.  */
-extern void set_cmd_context (struct cmd_list_element *cmd,
-			     void *context);
-extern void *get_cmd_context (struct cmd_list_element *cmd);
-
-
 /* Execute CMD's pre/post hook.  Throw an error if the command fails.
    If already executing this pre/post hook, or there is no pre/post
    hook, the call is silently ignored.  */
 extern void execute_cmd_pre_hook (struct cmd_list_element *cmd);
 extern void execute_cmd_post_hook (struct cmd_list_element *cmd);
 
-/* Flag for an ambiguous cmd_list result.  */
-#define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1)
-
-extern struct cmd_list_element *lookup_cmd (const char **,
-					    struct cmd_list_element *,
-					    const char *,
-					    std::string *,
-					    int, int);
-
-/* This routine takes a line of TEXT and a CLIST in which to start the
-   lookup.  When it returns it will have incremented the text pointer past
-   the section of text it matched, set *RESULT_LIST to point to the list in
-   which the last word was matched, and will return a pointer to the cmd
-   list element which the text matches.  It will return NULL if no match at
-   all was possible.  It will return -1 (cast appropriately, ick) if ambigous
-   matches are possible; in this case *RESULT_LIST will be set to point to
-   the list in which there are ambiguous choices (and *TEXT will be set to
-   the ambiguous text string).
-
-   if DEFAULT_ARGS is not null, *DEFAULT_ARGS is set to the found command
-   default args (possibly empty).
-
-   If the located command was an abbreviation, this routine returns the base
-   command of the abbreviation.  Note that *DEFAULT_ARGS will contain the
-   default args defined for the alias.
-
-   It does no error reporting whatsoever; control will always return
-   to the superior routine.
-
-   In the case of an ambiguous return (-1), *RESULT_LIST will be set to point
-   at the prefix_command (ie. the best match) *or* (special case) will be NULL
-   if no prefix command was ever found.  For example, in the case of "info a",
-   "info" matches without ambiguity, but "a" could be "args" or "address", so
-   *RESULT_LIST is set to the cmd_list_element for "info".  So in this case
-   RESULT_LIST should not be interpreted as a pointer to the beginning of a
-   list; it simply points to a specific command.  In the case of an ambiguous
-   return *TEXT is advanced past the last non-ambiguous prefix (e.g.
-   "info t" can be "info types" or "info target"; upon return *TEXT has been
-   advanced past "info ").
-
-   If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise
-   affect the operation).
-
-   This routine does *not* modify the text pointed to by TEXT.
-
-   If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which
-   are actually help classes rather than commands (i.e. the function field of
-   the struct cmd_list_element is NULL).
-
-   When LOOKUP_FOR_COMPLETION_P is true the completion is being requested
-   for the completion engine, no warnings should be printed.  */
-
-extern struct cmd_list_element *lookup_cmd_1
-	(const char **text, struct cmd_list_element *clist,
-	 struct cmd_list_element **result_list, std::string *default_args,
-	 int ignore_help_classes, bool lookup_for_completion_p = false);
-
-/* Look up the command called NAME in the command list LIST.
-
-   Unlike LOOKUP_CMD, partial matches are ignored and only exact matches
-   on NAME are considered.
-
-   LIST is a chain of struct cmd_list_element's.
-
-   If IGNORE_HELP_CLASSES is true (the default), ignore any command list
-   elements which are actually help classes rather than commands (i.e.
-   the function field of the struct cmd_list_element is null).
-
-   If found, return the struct cmd_list_element for that command,
-   otherwise return NULLPTR.  */
-
-extern struct cmd_list_element *lookup_cmd_exact
-			(const char *name,
-			 struct cmd_list_element *list,
-			 bool ignore_help_classes = true);
-
-extern struct cmd_list_element *deprecate_cmd (struct cmd_list_element *,
-					       const char * );
-
-extern void deprecated_cmd_warning (const char *, struct cmd_list_element *);
-
-extern int lookup_cmd_composition (const char *text,
-				   struct cmd_list_element **alias,
-				   struct cmd_list_element **prefix_cmd,
-				   struct cmd_list_element **cmd);
-
-extern struct cmd_list_element *add_com (const char *, enum command_class,
-					 cmd_const_cfunc_ftype *fun,
-					 const char *);
-
-extern struct cmd_list_element *add_com_alias (const char *, const char *,
-					       enum command_class, int);
-
-extern struct cmd_list_element *add_com_suppress_notification
-		       (const char *name, enum command_class theclass,
-			cmd_const_cfunc_ftype *fun, const char *doc,
-			int *supress_notification);
-
-extern struct cmd_list_element *add_info (const char *,
-					  cmd_const_cfunc_ftype *fun,
-					  const char *);
-
-extern struct cmd_list_element *add_info_alias (const char *, const char *,
-						int);
-
-extern void complete_on_cmdlist (struct cmd_list_element *,
-				 completion_tracker &tracker,
-				 const char *, const char *, int);
-
-extern void complete_on_enum (completion_tracker &tracker,
-			      const char *const *enumlist,
-			      const char *, const char *);
-
-/* Functions that implement commands about CLI commands.  */
-
-extern void help_list (struct cmd_list_element *, const char *,
-		       enum command_class, struct ui_file *);
-
 /* Method for show a set/show variable's VALUE on FILE.  If this
    method isn't supplied deprecated_show_value_hack() is called (which
    is not good).  */
@@ -398,142 +156,6 @@ typedef void (show_value_ftype) (struct ui_file *file,
    instead print the value out directly.  */
 extern show_value_ftype deprecated_show_value_hack;
 
-extern void add_setshow_enum_cmd (const char *name,
-				  enum command_class theclass,
-				  const char *const *enumlist,
-				  const char **var,
-				  const char *set_doc,
-				  const char *show_doc,
-				  const char *help_doc,
-				  cmd_const_sfunc_ftype *set_func,
-				  show_value_ftype *show_func,
-				  struct cmd_list_element **set_list,
-				  struct cmd_list_element **show_list,
-				  void *context = nullptr);
-
-extern void add_setshow_auto_boolean_cmd (const char *name,
-					  enum command_class theclass,
-					  enum auto_boolean *var,
-					  const char *set_doc,
-					  const char *show_doc,
-					  const char *help_doc,
-					  cmd_const_sfunc_ftype *set_func,
-					  show_value_ftype *show_func,
-					  struct cmd_list_element **set_list,
-					  struct cmd_list_element **show_list);
-
-extern cmd_list_element *
-  add_setshow_boolean_cmd (const char *name,
-			   enum command_class theclass,
-			   bool *var,
-			   const char *set_doc, const char *show_doc,
-			   const char *help_doc,
-			   cmd_const_sfunc_ftype *set_func,
-			   show_value_ftype *show_func,
-			   struct cmd_list_element **set_list,
-			   struct cmd_list_element **show_list);
-
-extern void add_setshow_filename_cmd (const char *name,
-				      enum command_class theclass,
-				      char **var,
-				      const char *set_doc,
-				      const char *show_doc,
-				      const char *help_doc,
-				      cmd_const_sfunc_ftype *set_func,
-				      show_value_ftype *show_func,
-				      struct cmd_list_element **set_list,
-				      struct cmd_list_element **show_list);
-
-extern void add_setshow_string_cmd (const char *name,
-				    enum command_class theclass,
-				    char **var,
-				    const char *set_doc,
-				    const char *show_doc,
-				    const char *help_doc,
-				    cmd_const_sfunc_ftype *set_func,
-				    show_value_ftype *show_func,
-				    struct cmd_list_element **set_list,
-				    struct cmd_list_element **show_list);
-
-extern struct cmd_list_element *add_setshow_string_noescape_cmd
-		      (const char *name,
-		       enum command_class theclass,
-		       char **var,
-		       const char *set_doc,
-		       const char *show_doc,
-		       const char *help_doc,
-		       cmd_const_sfunc_ftype *set_func,
-		       show_value_ftype *show_func,
-		       struct cmd_list_element **set_list,
-		       struct cmd_list_element **show_list);
-
-extern void add_setshow_optional_filename_cmd (const char *name,
-					       enum command_class theclass,
-					       char **var,
-					       const char *set_doc,
-					       const char *show_doc,
-					       const char *help_doc,
-					       cmd_const_sfunc_ftype *set_func,
-					       show_value_ftype *show_func,
-					       struct cmd_list_element **set_list,
-					       struct cmd_list_element **show_list);
-
-extern void add_setshow_integer_cmd (const char *name,
-				     enum command_class theclass,
-				     int *var,
-				     const char *set_doc,
-				     const char *show_doc,
-				     const char *help_doc,
-				     cmd_const_sfunc_ftype *set_func,
-				     show_value_ftype *show_func,
-				     struct cmd_list_element **set_list,
-				     struct cmd_list_element **show_list);
-
-extern void add_setshow_uinteger_cmd (const char *name,
-				      enum command_class theclass,
-				      unsigned int *var,
-				      const char *set_doc,
-				      const char *show_doc,
-				      const char *help_doc,
-				      cmd_const_sfunc_ftype *set_func,
-				      show_value_ftype *show_func,
-				      struct cmd_list_element **set_list,
-				      struct cmd_list_element **show_list);
-
-extern void add_setshow_zinteger_cmd (const char *name,
-				      enum command_class theclass,
-				      int *var,
-				      const char *set_doc,
-				      const char *show_doc,
-				      const char *help_doc,
-				      cmd_const_sfunc_ftype *set_func,
-				      show_value_ftype *show_func,
-				      struct cmd_list_element **set_list,
-				      struct cmd_list_element **show_list);
-
-extern void add_setshow_zuinteger_cmd (const char *name,
-				       enum command_class theclass,
-				       unsigned int *var,
-				       const char *set_doc,
-				       const char *show_doc,
-				       const char *help_doc,
-				       cmd_const_sfunc_ftype *set_func,
-				       show_value_ftype *show_func,
-				       struct cmd_list_element **set_list,
-				       struct cmd_list_element **show_list);
-
-extern void
-  add_setshow_zuinteger_unlimited_cmd (const char *name,
-				       enum command_class theclass,
-				       int *var,
-				       const char *set_doc,
-				       const char *show_doc,
-				       const char *help_doc,
-				       cmd_const_sfunc_ftype *set_func,
-				       show_value_ftype *show_func,
-				       struct cmd_list_element **set_list,
-				       struct cmd_list_element **show_list);
-
 /* Do a "show" command for each thing on a command list.  */
 
 extern void cmd_show_list (struct cmd_list_element *, int);
@@ -596,9 +218,11 @@ extern void save_command_line (const char *cmd);
 extern void not_just_help_class_command (const char *, int);
 
 /* Check function pointer.  */
+
 extern int cmd_func_p (struct cmd_list_element *cmd);
 
 /* Call the command function.  */
+
 extern void cmd_func (struct cmd_list_element *cmd,
 		      const char *args, int from_tty);
 
diff --git a/gdb/complaints.c b/gdb/complaints.c
index fecbcd74ce5..b36c201ca75 100644
--- a/gdb/complaints.c
+++ b/gdb/complaints.c
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
+#include "cli/cli-decode.h"
 #include "complaints.h"
 #include "command.h"
 #include "gdbcmd.h"
diff --git a/gdb/completer.h b/gdb/completer.h
index 240490f0c05..9aa05bcd26a 100644
--- a/gdb/completer.h
+++ b/gdb/completer.h
@@ -601,6 +601,27 @@ extern char *gdb_completion_word_break_characters (void);
    not "const char *".  */
 extern void set_rl_completer_word_break_characters (const char *break_chars);
 
+/* A completion routine.  Add possible completions to tracker.
+
+   TEXT is the text beyond what was matched for the command itself
+   (leading whitespace is skipped).  It stops where we are supposed to
+   stop completing (rl_point) and is '\0' terminated.  WORD points in
+   the same buffer as TEXT, and completions should be returned
+   relative to this position.  For example, suppose TEXT is "foo" and
+   we want to complete to "foobar".  If WORD is "oo", return "oobar";
+   if WORD is "baz/foo", return "baz/foobar".  */
+
+typedef void completer_ftype (cmd_list_element *,
+			      completion_tracker &tracker,
+			      const char *text, const char *word);
+
+/* Same, but for set_cmd_completer_handle_brkchars.  */
+
+typedef void completer_handle_brkchars_ftype (cmd_list_element *,
+					      completion_tracker &tracker,
+					      const char *text,
+					      const char *word);
+
 /* Get the matching completer_handle_brkchars_ftype function for FN.
    FN is one of the core completer functions above (filename,
    location, symbol, etc.).  This function is useful for cases when
diff --git a/gdb/copying.c b/gdb/copying.c
index 63183450a0e..2cedc9e410a 100644
--- a/gdb/copying.c
+++ b/gdb/copying.c
@@ -3,6 +3,7 @@
    Modify copying.awk instead.  <== */
 
 #include "defs.h"
+#include "cli/cli-decode.h"
 #include "command.h"
 #include "gdbcmd.h"
 
diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c
index f831b2b34b3..2284ea6ca70 100644
--- a/gdb/cp-abi.c
+++ b/gdb/cp-abi.c
@@ -20,6 +20,7 @@
 #include "defs.h"
 #include "value.h"
 #include "cp-abi.h"
+#include "cli/cli-decode.h"
 #include "command.h"
 #include "gdbcmd.h"
 #include "ui-out.h"
diff --git a/gdb/filesystem.c b/gdb/filesystem.c
index f28d24fa1b9..ff8a09690d5 100644
--- a/gdb/filesystem.c
+++ b/gdb/filesystem.c
@@ -19,6 +19,7 @@
 
 #include "defs.h"
 #include "filesystem.h"
+#include "cli/cli-decode.h"
 #include "gdbarch.h"
 #include "gdbcmd.h"
 
diff --git a/gdb/gdb-demangle.c b/gdb/gdb-demangle.c
index 24e92009d73..9000b2d02c4 100644
--- a/gdb/gdb-demangle.c
+++ b/gdb/gdb-demangle.c
@@ -24,6 +24,7 @@
    to a styles of demangling, and GDB specific.  */
 
 #include "defs.h"
+#include "cli/cli-decode.h"
 #include "cli/cli-utils.h" /* for skip_to_space */
 #include "command.h"
 #include "gdbcmd.h"
diff --git a/gdb/interps.c b/gdb/interps.c
index ec19822b571..918ad28d244 100644
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -30,6 +30,7 @@
    them take over the input in their resume proc.  */
 
 #include "defs.h"
+#include "cli/cli-decode.h"
 #include "gdbcmd.h"
 #include "ui-out.h"
 #include "gdbsupport/event-loop.h"
diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c
index 4e4a68d5c1d..015df3f5101 100644
--- a/gdb/macrocmd.c
+++ b/gdb/macrocmd.c
@@ -22,6 +22,7 @@
 #include "macrotab.h"
 #include "macroexp.h"
 #include "macroscope.h"
+#include "cli/cli-decode.h"
 #include "cli/cli-style.h"
 #include "cli/cli-utils.h"
 #include "command.h"
diff --git a/gdb/maint-test-options.c b/gdb/maint-test-options.c
index b773e759bb7..a16fbe55ddc 100644
--- a/gdb/maint-test-options.c
+++ b/gdb/maint-test-options.c
@@ -19,6 +19,7 @@
 
 #include "defs.h"
 #include "gdbcmd.h"
+#include "cli/cli-decode.h"
 #include "cli/cli-option.h"
 
 /* This file defines three "maintenance test-options" subcommands to
diff --git a/gdb/maint-test-settings.c b/gdb/maint-test-settings.c
index 0ce88905518..e4d2889538c 100644
--- a/gdb/maint-test-settings.c
+++ b/gdb/maint-test-settings.c
@@ -19,6 +19,7 @@
 
 
 #include "defs.h"
+#include "cli/cli-decode.h"
 #include "gdbcmd.h"
 
 /* Command list for "maint set test-settings".  */
diff --git a/gdb/observable.c b/gdb/observable.c
index 51f5edb0a1f..9d340f23d83 100644
--- a/gdb/observable.c
+++ b/gdb/observable.c
@@ -19,6 +19,7 @@
 
 #include "defs.h"
 #include "observable.h"
+#include "cli/cli-decode.h"
 #include "command.h"
 #include "gdbcmd.h"
 
diff --git a/gdb/osabi.c b/gdb/osabi.c
index b1603c09c85..165ae61929f 100644
--- a/gdb/osabi.c
+++ b/gdb/osabi.c
@@ -21,6 +21,7 @@
 
 #include "osabi.h"
 #include "arch-utils.h"
+#include "cli/cli-decode.h"
 #include "gdbcmd.h"
 #include "command.h"
 #include "gdb_bfd.h"
diff --git a/gdb/reggroups.c b/gdb/reggroups.c
index 96ff1d3d97d..3a2119aaf47 100644
--- a/gdb/reggroups.c
+++ b/gdb/reggroups.c
@@ -21,6 +21,7 @@
 
 #include "defs.h"
 #include "arch-utils.h"
+#include "cli/cli-decode.h"
 #include "reggroups.h"
 #include "gdbtypes.h"
 #include "regcache.h"
diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c
index e97dc2f925d..9abdb70e1d6 100644
--- a/gdb/ser-unix.c
+++ b/gdb/ser-unix.c
@@ -33,6 +33,7 @@
 #include "gdbsupport/filestuff.h"
 #include <termios.h>
 #include "inflow.h"
+#include "cli/cli-decode.h"
 
 struct hardwire_ttystate
   {
diff --git a/gdb/serial.c b/gdb/serial.c
index 719cd66c08c..71033a9a35e 100644
--- a/gdb/serial.c
+++ b/gdb/serial.c
@@ -21,6 +21,7 @@
 #include <ctype.h>
 #include "serial.h"
 #include "gdbcmd.h"
+#include "cli/cli-decode.h"
 #include "cli/cli-utils.h"
 
 /* Is serial being debugged?  */
diff --git a/gdb/user-regs.c b/gdb/user-regs.c
index 5845eb13a5a..1e4b5e95a65 100644
--- a/gdb/user-regs.c
+++ b/gdb/user-regs.c
@@ -26,6 +26,7 @@
 #include "arch-utils.h"
 #include "command.h"
 #include "cli/cli-cmds.h"
+#include "cli/cli-decode.h"
 
 /* A table of user registers.
 
diff --git a/gdb/xml-support.c b/gdb/xml-support.c
index 5ba1e53bf92..26c7e5de2eb 100644
--- a/gdb/xml-support.c
+++ b/gdb/xml-support.c
@@ -21,6 +21,7 @@
 #include "gdbcmd.h"
 #include "xml-builtin.h"
 #include "xml-support.h"
+#include "cli/cli-decode.h"
 #include "gdbsupport/filestuff.h"
 #include "safe-ctype.h"
 #include <vector>
-- 
2.28.0


  parent reply	other threads:[~2021-05-14 20:40 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-08 10:07 [PATCH 0/4] Add support for command renaming Marco Barisione via Gdb-patches
2021-01-08 10:07 ` [PATCH 1/4] gdb: add lookup_cmd_exact to simplify a common pattern Marco Barisione via Gdb-patches
2021-01-10  0:06   ` Lancelot SIX via Gdb-patches
2021-01-17 10:47     ` Marco Barisione via Gdb-patches
2021-01-17 19:02       ` Lancelot SIX via Gdb-patches
2021-01-25 11:33         ` Luis Machado via Gdb-patches
2021-01-08 10:07 ` [PATCH 2/4] gdb: prevent prefix commands from being hooks Marco Barisione via Gdb-patches
2021-01-08 10:07 ` [PATCH 3/4] gdb: update the docs for add_cmd and do_add_cmd to match reality Marco Barisione via Gdb-patches
2021-01-08 10:07 ` [PATCH 4/4] gdb: Add support for renaming commands Marco Barisione via Gdb-patches
2021-01-08 10:30   ` Eli Zaretskii via Gdb-patches
2021-01-25 11:26 ` [PATCH v2 0/5] Add support for command renaming Marco Barisione via Gdb-patches
2021-01-25 11:26   ` [PATCH v2 1/5] gdb: add lookup_cmd_exact to simplify a common pattern Marco Barisione via Gdb-patches
2021-03-08 18:58     ` Simon Marchi
2021-05-07 14:47       ` Marco Barisione via Gdb-patches
2021-01-25 11:26   ` [PATCH v2 2/5] gdb: prevent prefix commands from being hooks Marco Barisione via Gdb-patches
2021-03-08 21:32     ` Simon Marchi via Gdb-patches
2021-03-09  9:42       ` Marco Barisione via Gdb-patches
2021-03-16  3:17         ` Simon Marchi via Gdb-patches
2021-05-07 14:59           ` Marco Barisione via Gdb-patches
2021-05-07 19:30             ` Simon Marchi via Gdb-patches
2021-05-07 20:11               ` Marco Barisione via Gdb-patches
2021-05-14 20:38       ` [PATCH v3 " Marco Barisione via Gdb-patches
2021-01-25 11:26   ` [PATCH v2 3/5] gdb: update the docs for add_cmd and do_add_cmd to match reality Marco Barisione via Gdb-patches
2021-03-08 22:52     ` Simon Marchi via Gdb-patches
2021-03-08 23:10       ` Simon Marchi via Gdb-patches
2021-05-14 20:39       ` Marco Barisione via Gdb-patches [this message]
2021-01-25 11:26   ` [PATCH v2 4/5] gdb: generate the prefix name for prefix commands on demand Marco Barisione via Gdb-patches
2021-03-08 23:25     ` Simon Marchi via Gdb-patches
2021-03-16 17:00       ` Simon Marchi via Gdb-patches
2021-05-12 11:10       ` Marco Barisione via Gdb-patches
2021-01-25 11:26   ` [PATCH v2 5/5] gdb: Add support for renaming commands Marco Barisione via Gdb-patches
2021-03-23 18:45     ` Simon Marchi via Gdb-patches
2021-05-14 20:41       ` [PATCH v3 5/5] gdb: add " Marco Barisione via Gdb-patches
2021-02-08 17:53   ` [PING] [PATCH v2 0/5] Add support for command renaming Marco Barisione via Gdb-patches
2021-02-15  8:27     ` [PING2] " Marco Barisione via Gdb-patches
2021-02-22  8:28       ` [PING 3] " Marco Barisione via Gdb-patches
2021-03-01  8:32         ` [PING 4] " Marco Barisione via Gdb-patches
2021-03-08  9:23           ` [PING 5] " Marco Barisione via Gdb-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210514203955.98069-1-mbarisione@undo.io \
    --to=gdb-patches@sourceware.org \
    --cc=mbarisione@undo.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox