xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/command.h (revision 8b657b0747480f8989760d71343d6dd33f8d4cf9)
1 /* Header file for command creation.
2 
3    Copyright (C) 1986-2023 Free Software Foundation, Inc.
4 
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 3 of the License, or
8    (at your option) any later version.
9 
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14 
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17 
18 #if !defined (COMMAND_H)
19 #define COMMAND_H 1
20 
21 #include "gdbsupport/gdb_vecs.h"
22 #include "gdbsupport/scoped_restore.h"
23 
24 struct completion_tracker;
25 
26 /* This file defines the public interface for any code wanting to
27    create commands.  */
28 
29 /* Command classes are top-level categories into which commands are
30    broken down for "help" purposes.
31 
32    The class_alias is used for the user-defined aliases, defined
33    using the "alias" command.
34 
35    Aliases pre-defined by GDB (e.g. the alias "bt" of the "backtrace" command)
36    are not using the class_alias.
37    Different pre-defined aliases of the same command do not necessarily
38    have the same classes.  For example, class_stack is used for the
39    "backtrace" and its "bt" alias", while "info stack" (also an alias
40    of "backtrace" uses class_info.  */
41 
42 enum command_class
43 {
44   /* Classes of commands followed by a comment giving the name
45      to use in "help <classname>".
46      Note that help accepts unambiguous abbreviated class names.  */
47 
48   /* Special classes to help_list */
49   all_classes = -2,  /* help without <classname> */
50   all_commands = -1, /* all */
51 
52   /* Classes of commands */
53   no_class = -1,
54   class_run = 0,     /* running */
55   class_vars,        /* data */
56   class_stack,       /* stack */
57   class_files,       /* files */
58   class_support,     /* support */
59   class_info,        /* status */
60   class_breakpoint,  /* breakpoints */
61   class_trace,       /* tracepoints */
62   class_alias,       /* aliases */
63   class_bookmark,
64   class_obscure,     /* obscure */
65   class_maintenance, /* internals */
66   class_tui,         /* text-user-interface */
67   class_user,        /* user-defined */
68 
69   /* Used for "show" commands that have no corresponding "set" command.  */
70   no_set_class
71 };
72 
73 /* Types of "set" or "show" command.  */
74 enum var_types
75   {
76     /* "on" or "off".  *VAR is a bool which is true for on,
77        false for off.  */
78     var_boolean,
79 
80     /* "on" / "true" / "enable" or "off" / "false" / "disable" or
81        "auto.  *VAR is an ``enum auto_boolean''.  NOTE: In general a
82        custom show command will need to be implemented - one that for
83        "auto" prints both the "auto" and the current auto-selected
84        value.  */
85     var_auto_boolean,
86 
87     /* Unsigned Integer.  *VAR is an unsigned int.  The user can type
88        0 to mean "unlimited", which is stored in *VAR as UINT_MAX.  */
89     var_uinteger,
90 
91     /* Like var_uinteger but signed.  *VAR is an int.  The user can
92        type 0 to mean "unlimited", which is stored in *VAR as
93        INT_MAX.  The only remaining use of it is the Python API.
94        Don't use it elsewhere.  */
95     var_integer,
96 
97     /* String which the user enters with escapes (e.g. the user types
98        \n and it is a real newline in the stored string).
99        *VAR is a std::string, "" if the string is empty.  */
100     var_string,
101     /* String which stores what the user types verbatim.
102        *VAR is std::string, "" if the string is empty.  */
103     var_string_noescape,
104     /* String which stores a filename.  (*VAR) is a std::string,
105        "" if the string was empty.  */
106     var_optional_filename,
107     /* String which stores a filename.  (*VAR) is a std::string.  */
108     var_filename,
109     /* ZeroableInteger.  *VAR is an int.  Like var_integer except
110        that zero really means zero.  */
111     var_zinteger,
112     /* ZeroableUnsignedInteger.  *VAR is an unsigned int.  Zero really
113        means zero.  */
114     var_zuinteger,
115     /* ZeroableUnsignedInteger with unlimited value.  *VAR is an int,
116        but its range is [0, INT_MAX].  -1 stands for unlimited and
117        other negative numbers are not allowed.  */
118     var_zuinteger_unlimited,
119     /* Enumerated type.  Can only have one of the specified values.
120        *VAR is a char pointer to the name of the element that we
121        find.  */
122     var_enum
123   };
124 
125 /* Return true if a setting of type VAR_TYPE is backed with type T.
126 
127    This function is left without definition intentionally.  This template is
128    specialized for all valid types that are used to back var_types.  Therefore
129    if one tries to instantiate this un-specialized template it means the T
130    parameter is not a type used to back a var_type and it is most likely a
131    programming error.  */
132 template<typename T>
133 bool var_type_uses (var_types var_type) = delete;
134 
135 /* Return true if a setting of type T is backed by a bool variable.  */
136 template<>
137 inline bool var_type_uses<bool> (var_types t)
138 {
139   return t == var_boolean;
140 };
141 
142 /* Return true if a setting of type T is backed by a auto_boolean variable.
143 */
144 template<>
145 inline bool var_type_uses<enum auto_boolean> (var_types t)
146 {
147   return t == var_auto_boolean;
148 }
149 
150 /* Return true if a setting of type T is backed by an unsigned int variable.
151 */
152 template<>
153 inline bool var_type_uses<unsigned int> (var_types t)
154 {
155   return (t == var_uinteger || t == var_zinteger || t == var_zuinteger);
156 }
157 
158 /* Return true if a setting of type T is backed by an int variable.  */
159 template<>
160 inline bool var_type_uses<int> (var_types t)
161 {
162   return (t == var_integer || t == var_zinteger
163 	  || t == var_zuinteger_unlimited);
164 }
165 
166 /* Return true if a setting of type T is backed by a std::string variable.  */
167 template<>
168 inline bool var_type_uses<std::string> (var_types t)
169 {
170   return (t == var_string || t == var_string_noescape
171 	  || t == var_optional_filename || t == var_filename);
172 }
173 
174 /* Return true if a setting of type T is backed by a const char * variable.
175 */
176 template<>
177 inline bool var_type_uses<const char *> (var_types t)
178 {
179   return t == var_enum;
180 }
181 
182 template<bool is_scalar, typename T> struct setting_func_types_1;
183 
184 template<typename T>
185 struct setting_func_types_1<true, T>
186 {
187   using type = T;
188   using set = void (*) (type);
189   using get = type (*) ();
190 };
191 
192 template<typename T>
193 struct setting_func_types_1<false, T>
194 {
195   using type = const T &;
196   using set = void (*) (type);
197   using get = type (*) ();
198 };
199 
200 template<typename T>
201 struct setting_func_types
202 {
203   using type = typename setting_func_types_1<std::is_scalar<T>::value, T>::type;
204   using set = typename setting_func_types_1<std::is_scalar<T>::value, T>::set;
205   using get = typename setting_func_types_1<std::is_scalar<T>::value, T>::get;
206 };
207 
208 /* Generic/type-erased function pointer.  */
209 
210 using erased_func = void (*) ();
211 
212 /* Interface for getting and setting a setting's value.
213 
214    The underlying data can be of any VAR_TYPES type.  */
215 struct setting
216 {
217   /* Create a setting backed by a variable of type T.
218 
219      Type T must match the var type VAR_TYPE (see VAR_TYPE_USES).  */
220   template<typename T>
221   setting (var_types var_type, T *var)
222     : m_var_type (var_type), m_var (var)
223   {
224     gdb_assert (var != nullptr);
225     gdb_assert (var_type_uses<T> (var_type));
226   }
227 
228   /* A setting can also be constructed with a pre-validated
229      type-erased variable.  Use the following function to
230      validate & type-erase said variable/function pointers.  */
231 
232   struct erased_args
233   {
234     void *var;
235     erased_func setter;
236     erased_func getter;
237   };
238 
239   template<typename T>
240   static erased_args erase_args (var_types var_type,
241 				 T *var,
242 				 typename setting_func_types<T>::set set_setting_func,
243 				 typename setting_func_types<T>::get get_setting_func)
244   {
245     gdb_assert (var_type_uses<T> (var_type));
246   /* The getter and the setter must be both provided or both omitted.  */
247     gdb_assert
248       ((set_setting_func == nullptr) == (get_setting_func == nullptr));
249 
250   /* The caller must provide a pointer to a variable or get/set functions, but
251      not both.  */
252     gdb_assert ((set_setting_func == nullptr) != (var == nullptr));
253 
254     return {
255 	var,
256 	reinterpret_cast<erased_func> (set_setting_func),
257 	reinterpret_cast<erased_func> (get_setting_func)
258     };
259   }
260 
261   /* Create a setting backed by pre-validated type-erased args.
262      ERASED_VAR's fields' real types must match the var type VAR_TYPE
263      (see VAR_TYPE_USES).  */
264   setting (var_types var_type, const erased_args &args)
265     : m_var_type (var_type),
266       m_var (args.var),
267       m_getter (args.getter),
268       m_setter (args.setter)
269   {
270   }
271 
272   /* Create a setting backed by setter and getter functions.
273 
274      Type T must match the var type VAR_TYPE (see VAR_TYPE_USES).  */
275   template<typename T>
276   setting (var_types var_type,
277 	   typename setting_func_types<T>::set setter,
278 	   typename setting_func_types<T>::get getter)
279     : m_var_type (var_type)
280   {
281     gdb_assert (var_type_uses<T> (var_type));
282 
283     /* Getters and setters are cast to and from the arbitrary `void (*) ()`
284        function pointer type.  Make sure that the two types are really of the
285        same size.  */
286     gdb_static_assert (sizeof (m_getter) == sizeof (getter));
287     gdb_static_assert (sizeof (m_setter) == sizeof (setter));
288 
289     m_getter = reinterpret_cast<erased_func> (getter);
290     m_setter = reinterpret_cast<erased_func> (setter);
291   }
292 
293   /* Access the type of the current setting.  */
294   var_types type () const
295   { return m_var_type; }
296 
297   /* Return the current value.
298 
299      The template parameter T is the type of the variable used to store the
300      setting.  */
301   template<typename T>
302   typename setting_func_types<T>::type get () const
303   {
304     gdb_assert (var_type_uses<T> (m_var_type));
305 
306     if (m_var == nullptr)
307       {
308 	gdb_assert (m_getter != nullptr);
309 	auto getter = reinterpret_cast<typename setting_func_types<T>::get> (m_getter);
310 	return getter ();
311       }
312     else
313       return *static_cast<const T *> (m_var);
314   }
315 
316   /* Sets the value of the setting to V.  Returns true if the setting was
317      effectively changed, false if the update failed and the setting is left
318      unchanged.
319 
320      If we have a user-provided setter, use it to set the setting.  Otherwise
321      copy the value V to the internally referenced buffer.
322 
323      The template parameter T indicates the type of the variable used to store
324      the setting.
325 
326      The var_type of the setting must match T.  */
327   template<typename T>
328   bool set (const T &v)
329   {
330     /* Check that the current instance is of one of the supported types for
331        this instantiation.  */
332     gdb_assert (var_type_uses<T> (m_var_type));
333 
334     const T old_value = this->get<T> ();
335 
336     if (m_var == nullptr)
337       {
338 	gdb_assert (m_setter != nullptr);
339 	auto setter = reinterpret_cast<typename setting_func_types<T>::set> (m_setter);
340 	setter (v);
341       }
342     else
343       *static_cast<T *> (m_var) = v;
344 
345     return old_value != this->get<T> ();
346   }
347 
348 private:
349   /* The type of the variable M_VAR is pointing to, or that M_GETTER / M_SETTER
350      get or set.  */
351   var_types m_var_type;
352 
353   /* Pointer to the enclosed variable
354 
355      Either M_VAR is non-nullptr, or both M_GETTER and M_SETTER are
356      non-nullptr.  */
357   void *m_var = nullptr;
358 
359   /* Pointer to a user provided getter.  */
360   erased_func m_getter = nullptr;
361 
362   /* Pointer to a user provided setter.  */
363   erased_func m_setter = nullptr;
364 };
365 
366 /* This structure records one command'd definition.  */
367 struct cmd_list_element;
368 
369 /* The "simple" signature of command callbacks, which doesn't include a
370    cmd_list_element parameter.  */
371 
372 typedef void cmd_simple_func_ftype (const char *args, int from_tty);
373 
374 /* This structure specifies notifications to be suppressed by a cli
375    command interpreter.  */
376 
377 struct cli_suppress_notification
378 {
379   /* Inferior, thread, frame selected notification suppressed?  */
380   bool user_selected_context = false;
381 
382   /* Normal stop event suppressed? */
383   bool normal_stop = false;
384 };
385 
386 extern struct cli_suppress_notification cli_suppress_notification;
387 
388 /* Forward-declarations of the entry-points of cli/cli-decode.c.  */
389 
390 /* API to the manipulation of command lists.  */
391 
392 /* Return TRUE if NAME is a valid user-defined command name.
393    This is a stricter subset of all gdb commands,
394    see find_command_name_length.  */
395 
396 extern bool valid_user_defined_cmd_name_p (const char *name);
397 
398 /* Return TRUE if C is a valid command character.  */
399 
400 extern bool valid_cmd_char_p (int c);
401 
402 /* Return value type for the add_setshow_* functions.  */
403 
404 struct set_show_commands
405 {
406   cmd_list_element *set, *show;
407 };
408 
409 /* Const-correct variant of the above.  */
410 
411 extern struct cmd_list_element *add_cmd (const char *, enum command_class,
412 					 cmd_simple_func_ftype *fun,
413 					 const char *,
414 					 struct cmd_list_element **);
415 
416 /* Like add_cmd, but no command function is specified.  */
417 
418 extern struct cmd_list_element *add_cmd (const char *, enum command_class,
419 					 const char *,
420 					 struct cmd_list_element **);
421 
422 extern struct cmd_list_element *add_cmd_suppress_notification
423 			(const char *name, enum command_class theclass,
424 			 cmd_simple_func_ftype *fun, const char *doc,
425 			 struct cmd_list_element **list,
426 			 bool *suppress_notification);
427 
428 extern struct cmd_list_element *add_alias_cmd (const char *,
429 					       cmd_list_element *,
430 					       enum command_class, int,
431 					       struct cmd_list_element **);
432 
433 
434 extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class,
435 						cmd_simple_func_ftype *fun,
436 						const char *,
437 						struct cmd_list_element **,
438 						int,
439 						struct cmd_list_element **);
440 
441 /* Like add_prefix_cmd, but sets the callback to a function that
442    simply calls help_list.  */
443 
444 extern struct cmd_list_element *add_basic_prefix_cmd
445   (const char *, enum command_class, const char *, struct cmd_list_element **,
446    int, struct cmd_list_element **);
447 
448 /* Like add_prefix_cmd, but useful for "show" prefixes.  This sets the
449    callback to a function that simply calls cmd_show_list.  */
450 
451 extern struct cmd_list_element *add_show_prefix_cmd
452   (const char *, enum command_class, const char *, struct cmd_list_element **,
453    int, struct cmd_list_element **);
454 
455 /* Add matching set and show commands using add_basic_prefix_cmd and
456    add_show_prefix_cmd.  */
457 
458 extern set_show_commands add_setshow_prefix_cmd
459   (const char *name, command_class theclass, const char *set_doc,
460    const char *show_doc,
461    cmd_list_element **set_subcommands_list,
462    cmd_list_element **show_subcommands_list,
463    cmd_list_element **set_list,
464    cmd_list_element **show_list);
465 
466 extern struct cmd_list_element *add_prefix_cmd_suppress_notification
467 			(const char *name, enum command_class theclass,
468 			 cmd_simple_func_ftype *fun,
469 			 const char *doc, struct cmd_list_element **subcommands,
470 			 int allow_unknown,
471 			 struct cmd_list_element **list,
472 			 bool *suppress_notification);
473 
474 extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
475 						       enum command_class,
476 						       cmd_simple_func_ftype *fun,
477 						       const char *,
478 						       struct cmd_list_element
479 						       **, int,
480 						       struct cmd_list_element
481 						       **);
482 
483 typedef void cmd_func_ftype (const char *args, int from_tty,
484 			     cmd_list_element *c);
485 
486 /* A completion routine.  Add possible completions to tracker.
487 
488    TEXT is the text beyond what was matched for the command itself
489    (leading whitespace is skipped).  It stops where we are supposed to
490    stop completing (rl_point) and is '\0' terminated.  WORD points in
491    the same buffer as TEXT, and completions should be returned
492    relative to this position.  For example, suppose TEXT is "foo" and
493    we want to complete to "foobar".  If WORD is "oo", return "oobar";
494    if WORD is "baz/foo", return "baz/foobar".  */
495 typedef void completer_ftype (struct cmd_list_element *,
496 			      completion_tracker &tracker,
497 			      const char *text, const char *word);
498 
499 /* Same, but for set_cmd_completer_handle_brkchars.  */
500 typedef void completer_handle_brkchars_ftype (struct cmd_list_element *,
501 					      completion_tracker &tracker,
502 					      const char *text, const char *word);
503 
504 extern void set_cmd_completer (struct cmd_list_element *, completer_ftype *);
505 
506 /* Set the completer_handle_brkchars callback.  */
507 
508 extern void set_cmd_completer_handle_brkchars (struct cmd_list_element *,
509 					       completer_handle_brkchars_ftype *);
510 
511 /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
512    around in cmd objects to test the value of the commands sfunc().  */
513 extern int cmd_simple_func_eq (struct cmd_list_element *cmd,
514 			 cmd_simple_func_ftype *cfun);
515 
516 /* Execute CMD's pre/post hook.  Throw an error if the command fails.
517    If already executing this pre/post hook, or there is no pre/post
518    hook, the call is silently ignored.  */
519 extern void execute_cmd_pre_hook (struct cmd_list_element *cmd);
520 extern void execute_cmd_post_hook (struct cmd_list_element *cmd);
521 
522 /* Flag for an ambiguous cmd_list result.  */
523 #define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1)
524 
525 extern struct cmd_list_element *lookup_cmd (const char **,
526 					    struct cmd_list_element *,
527 					    const char *,
528 					    std::string *,
529 					    int, int);
530 
531 /* This routine takes a line of TEXT and a CLIST in which to start the
532    lookup.  When it returns it will have incremented the text pointer past
533    the section of text it matched, set *RESULT_LIST to point to the list in
534    which the last word was matched, and will return a pointer to the cmd
535    list element which the text matches.  It will return NULL if no match at
536    all was possible.  It will return -1 (cast appropriately, ick) if ambigous
537    matches are possible; in this case *RESULT_LIST will be set to point to
538    the list in which there are ambiguous choices (and *TEXT will be set to
539    the ambiguous text string).
540 
541    if DEFAULT_ARGS is not null, *DEFAULT_ARGS is set to the found command
542    default args (possibly empty).
543 
544    If the located command was an abbreviation, this routine returns the base
545    command of the abbreviation.  Note that *DEFAULT_ARGS will contain the
546    default args defined for the alias.
547 
548    It does no error reporting whatsoever; control will always return
549    to the superior routine.
550 
551    In the case of an ambiguous return (-1), *RESULT_LIST will be set to point
552    at the prefix_command (ie. the best match) *or* (special case) will be NULL
553    if no prefix command was ever found.  For example, in the case of "info a",
554    "info" matches without ambiguity, but "a" could be "args" or "address", so
555    *RESULT_LIST is set to the cmd_list_element for "info".  So in this case
556    RESULT_LIST should not be interpreted as a pointer to the beginning of a
557    list; it simply points to a specific command.  In the case of an ambiguous
558    return *TEXT is advanced past the last non-ambiguous prefix (e.g.
559    "info t" can be "info types" or "info target"; upon return *TEXT has been
560    advanced past "info ").
561 
562    If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise
563    affect the operation).
564 
565    This routine does *not* modify the text pointed to by TEXT.
566 
567    If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which
568    are actually help classes rather than commands (i.e. the function field of
569    the struct cmd_list_element is NULL).
570 
571    When LOOKUP_FOR_COMPLETION_P is true the completion is being requested
572    for the completion engine, no warnings should be printed.  */
573 
574 extern struct cmd_list_element *lookup_cmd_1
575 	(const char **text, struct cmd_list_element *clist,
576 	 struct cmd_list_element **result_list, std::string *default_args,
577 	 int ignore_help_classes, bool lookup_for_completion_p = false);
578 
579 /* Look up the command called NAME in the command list LIST.
580 
581    Unlike LOOKUP_CMD, partial matches are ignored and only exact matches
582    on NAME are considered.
583 
584    LIST is a chain of struct cmd_list_element's.
585 
586    If IGNORE_HELP_CLASSES is true (the default), ignore any command list
587    elements which are actually help classes rather than commands (i.e.
588    the function field of the struct cmd_list_element is null).
589 
590    If found, return the struct cmd_list_element for that command,
591    otherwise return NULLPTR.  */
592 
593 extern struct cmd_list_element *lookup_cmd_exact
594 			(const char *name,
595 			 struct cmd_list_element *list,
596 			 bool ignore_help_classes = true);
597 
598 extern struct cmd_list_element *deprecate_cmd (struct cmd_list_element *,
599 					       const char * );
600 
601 extern void deprecated_cmd_warning (const char *, struct cmd_list_element *);
602 
603 extern int lookup_cmd_composition (const char *text,
604 				   struct cmd_list_element **alias,
605 				   struct cmd_list_element **prefix_cmd,
606 				   struct cmd_list_element **cmd);
607 
608 extern struct cmd_list_element *add_com (const char *, enum command_class,
609 					 cmd_simple_func_ftype *fun,
610 					 const char *);
611 
612 extern cmd_list_element *add_com_alias (const char *name,
613 					cmd_list_element *target,
614 					command_class theclass,
615 					int abbrev_flag);
616 
617 extern struct cmd_list_element *add_com_suppress_notification
618 		       (const char *name, enum command_class theclass,
619 			cmd_simple_func_ftype *fun, const char *doc,
620 			bool *supress_notification);
621 
622 extern struct cmd_list_element *add_info (const char *,
623 					  cmd_simple_func_ftype *fun,
624 					  const char *);
625 
626 extern cmd_list_element *add_info_alias (const char *name,
627 					 cmd_list_element *target,
628 					 int abbrev_flag);
629 
630 extern void complete_on_cmdlist (struct cmd_list_element *,
631 				 completion_tracker &tracker,
632 				 const char *, const char *, int);
633 
634 extern void complete_on_enum (completion_tracker &tracker,
635 			      const char *const *enumlist,
636 			      const char *, const char *);
637 
638 /* Functions that implement commands about CLI commands.  */
639 
640 extern void help_list (struct cmd_list_element *, const char *,
641 		       enum command_class, struct ui_file *);
642 
643 /* Method for show a set/show variable's VALUE on FILE.  If this
644    method isn't supplied deprecated_show_value_hack() is called (which
645    is not good).  */
646 typedef void (show_value_ftype) (struct ui_file *file,
647 				 int from_tty,
648 				 struct cmd_list_element *cmd,
649 				 const char *value);
650 /* NOTE: i18n: This function is not i18n friendly.  Callers should
651    instead print the value out directly.  */
652 extern show_value_ftype deprecated_show_value_hack;
653 
654 extern set_show_commands add_setshow_enum_cmd
655   (const char *name, command_class theclass, const char *const *enumlist,
656    const char **var, const char *set_doc, const char *show_doc,
657    const char *help_doc, cmd_func_ftype *set_func,
658    show_value_ftype *show_func, cmd_list_element **set_list,
659    cmd_list_element **show_list);
660 
661 extern set_show_commands add_setshow_enum_cmd
662   (const char *name, command_class theclass, const char *const *enumlist,
663    const char *set_doc, const char *show_doc,
664    const char *help_doc, setting_func_types<const char *>::set set_func,
665    setting_func_types<const char *>::get get_func, show_value_ftype *show_func,
666    cmd_list_element **set_list, cmd_list_element **show_list);
667 
668 extern set_show_commands add_setshow_auto_boolean_cmd
669   (const char *name, command_class theclass, auto_boolean *var,
670    const char *set_doc, const char *show_doc, const char *help_doc,
671    cmd_func_ftype *set_func, show_value_ftype *show_func,
672    cmd_list_element **set_list, cmd_list_element **show_list);
673 
674 extern set_show_commands add_setshow_auto_boolean_cmd
675   (const char *name, command_class theclass, const char *set_doc,
676    const char *show_doc, const char *help_doc,
677    setting_func_types<enum auto_boolean>::set set_func,
678    setting_func_types<enum auto_boolean>::get get_func,
679    show_value_ftype *show_func, cmd_list_element **set_list,
680    cmd_list_element **show_list);
681 
682 extern set_show_commands add_setshow_boolean_cmd
683   (const char *name, command_class theclass, bool *var, const char *set_doc,
684    const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
685    show_value_ftype *show_func, cmd_list_element **set_list,
686    cmd_list_element **show_list);
687 
688 extern set_show_commands add_setshow_boolean_cmd
689   (const char *name, command_class theclass, const char *set_doc,
690    const char *show_doc, const char *help_doc,
691    setting_func_types<bool>::set set_func,
692    setting_func_types<bool>::get get_func, show_value_ftype *show_func,
693    cmd_list_element **set_list, cmd_list_element **show_list);
694 
695 extern set_show_commands add_setshow_filename_cmd
696   (const char *name, command_class theclass, std::string *var, const char *set_doc,
697    const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
698    show_value_ftype *show_func, cmd_list_element **set_list,
699    cmd_list_element **show_list);
700 
701 extern set_show_commands add_setshow_filename_cmd
702   (const char *name, command_class theclass, const char *set_doc,
703    const char *show_doc, const char *help_doc,
704    setting_func_types<std::string>::set set_func,
705    setting_func_types<std::string>::get get_func, show_value_ftype *show_func,
706    cmd_list_element **set_list, cmd_list_element **show_list);
707 
708 extern set_show_commands add_setshow_string_cmd
709   (const char *name, command_class theclass, std::string *var, const char *set_doc,
710    const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
711    show_value_ftype *show_func, cmd_list_element **set_list,
712    cmd_list_element **show_list);
713 
714 extern set_show_commands add_setshow_string_cmd
715   (const char *name, command_class theclass, const char *set_doc,
716    const char *show_doc, const char *help_doc,
717    setting_func_types<std::string>::set set_func,
718    setting_func_types<std::string>::get get_func,
719    show_value_ftype *show_func, cmd_list_element **set_list,
720    cmd_list_element **show_list);
721 
722 extern set_show_commands add_setshow_string_noescape_cmd
723   (const char *name, command_class theclass, std::string *var, const char *set_doc,
724    const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
725    show_value_ftype *show_func, cmd_list_element **set_list,
726    cmd_list_element **show_list);
727 
728 extern set_show_commands add_setshow_string_noescape_cmd
729   (const char *name, command_class theclass, const char *set_doc,
730    const char *show_doc, const char *help_doc,
731    setting_func_types<std::string>::set set_func,
732    setting_func_types<std::string>::get get_func, show_value_ftype *show_func,
733    cmd_list_element **set_list, cmd_list_element **show_list);
734 
735 extern set_show_commands add_setshow_optional_filename_cmd
736   (const char *name, command_class theclass, std::string *var, const char *set_doc,
737    const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
738    show_value_ftype *show_func, cmd_list_element **set_list,
739    cmd_list_element **show_list);
740 
741 extern set_show_commands add_setshow_optional_filename_cmd
742   (const char *name, command_class theclass, const char *set_doc,
743    const char *show_doc, const char *help_doc,
744    setting_func_types<std::string>::set set_func,
745    setting_func_types<std::string>::get get_func,
746    show_value_ftype *show_func, cmd_list_element **set_list,
747    cmd_list_element **show_list);
748 
749 extern set_show_commands add_setshow_integer_cmd
750   (const char *name, command_class theclass, int *var, const char *set_doc,
751    const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
752    show_value_ftype *show_func, cmd_list_element **set_list,
753    cmd_list_element **show_list);
754 
755 extern set_show_commands add_setshow_integer_cmd
756   (const char *name, command_class theclass, const char *set_doc,
757    const char *show_doc, const char *help_doc,
758    setting_func_types<int>::set set_func,
759    setting_func_types<int>::get get_func, show_value_ftype *show_func,
760    cmd_list_element **set_list, cmd_list_element **show_list);
761 
762 extern set_show_commands add_setshow_uinteger_cmd
763   (const char *name, command_class theclass, unsigned int *var,
764    const char *set_doc, const char *show_doc, const char *help_doc,
765    cmd_func_ftype *set_func, show_value_ftype *show_func,
766    cmd_list_element **set_list, cmd_list_element **show_list);
767 
768 extern set_show_commands add_setshow_uinteger_cmd
769   (const char *name, command_class theclass, const char *set_doc,
770    const char *show_doc, const char *help_doc,
771    setting_func_types<unsigned int>::set set_func,
772    setting_func_types<unsigned int>::get get_func, show_value_ftype *show_func,
773    cmd_list_element **set_list, cmd_list_element **show_list);
774 
775 extern set_show_commands add_setshow_zinteger_cmd
776   (const char *name, command_class theclass, int *var, const char *set_doc,
777    const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
778    show_value_ftype *show_func, cmd_list_element **set_list,
779    cmd_list_element **show_list);
780 
781 extern set_show_commands add_setshow_zinteger_cmd
782   (const char *name, command_class theclass, const char *set_doc,
783    const char *show_doc, const char *help_doc,
784    setting_func_types<int>::set set_func,
785    setting_func_types<int>::get get_func, show_value_ftype *show_func,
786    cmd_list_element **set_list, cmd_list_element **show_list);
787 
788 extern set_show_commands add_setshow_zuinteger_cmd
789   (const char *name, command_class theclass, unsigned int *var,
790    const char *set_doc, const char *show_doc, const char *help_doc,
791    cmd_func_ftype *set_func, show_value_ftype *show_func,
792    cmd_list_element **set_list, cmd_list_element **show_list);
793 
794 extern set_show_commands add_setshow_zuinteger_cmd
795   (const char *name, command_class theclass, const char *set_doc,
796    const char *show_doc, const char *help_doc,
797    setting_func_types<unsigned int>::set set_func,
798    setting_func_types<unsigned int>::get get_func, show_value_ftype *show_func,
799    cmd_list_element **set_list, cmd_list_element **show_list);
800 
801 extern set_show_commands add_setshow_zuinteger_unlimited_cmd
802   (const char *name, command_class theclass, int *var, const char *set_doc,
803    const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
804    show_value_ftype *show_func, cmd_list_element **set_list,
805    cmd_list_element **show_list);
806 
807 extern set_show_commands add_setshow_zuinteger_unlimited_cmd
808   (const char *name, command_class theclass, const char *set_doc,
809    const char *show_doc, const char *help_doc,
810    setting_func_types<int>::set set_func, setting_func_types<int>::get get_func,
811    show_value_ftype *show_func, cmd_list_element **set_list,
812    cmd_list_element **show_list);
813 
814 /* Do a "show" command for each thing on a command list.  */
815 
816 extern void cmd_show_list (struct cmd_list_element *, int);
817 
818 /* Used everywhere whenever at least one parameter is required and
819    none is specified.  */
820 
821 extern void error_no_arg (const char *) ATTRIBUTE_NORETURN;
822 
823 
824 /* Command line saving and repetition.
825    Each input line executed is saved to possibly be repeated either
826    when the user types an empty line, or be repeated by a command
827    that wants to repeat the previously executed command.  The below
828    functions control command repetition.  */
829 
830 /* Commands call dont_repeat if they do not want to be repeated by null
831    lines or by repeat_previous ().  */
832 
833 extern void dont_repeat ();
834 
835 /* Commands call repeat_previous if they want to repeat the previous
836    command.  Such commands that repeat the previous command must
837    indicate to not repeat themselves, to avoid recursive repeat.
838    repeat_previous marks the current command as not repeating, and
839    ensures get_saved_command_line returns the previous command, so
840    that the currently executing command can repeat it.  If there's no
841    previous command, throws an error.  Otherwise, returns the result
842    of get_saved_command_line, which now points at the command to
843    repeat.  */
844 
845 extern const char *repeat_previous ();
846 
847 /* Prevent dont_repeat from working, and return a cleanup that
848    restores the previous state.  */
849 
850 extern scoped_restore_tmpl<int> prevent_dont_repeat (void);
851 
852 /* Set the arguments that will be passed if the current command is
853    repeated.  Note that the passed-in string must be a constant.  */
854 
855 extern void set_repeat_arguments (const char *args);
856 
857 /* Returns the saved command line to repeat.
858    When a command is being executed, this is the currently executing
859    command line, unless the currently executing command has called
860    repeat_previous (): in this case, get_saved_command_line returns
861    the previously saved command line.  */
862 
863 extern char *get_saved_command_line ();
864 
865 /* Takes a copy of CMD, for possible repetition.  */
866 
867 extern void save_command_line (const char *cmd);
868 
869 /* Used to mark commands that don't do anything.  If we just leave the
870    function field NULL, the command is interpreted as a help topic, or
871    as a class of commands.  */
872 
873 extern void not_just_help_class_command (const char *, int);
874 
875 /* Call the command function.  */
876 extern void cmd_func (struct cmd_list_element *cmd,
877 		      const char *args, int from_tty);
878 
879 #endif /* !defined (COMMAND_H) */
880