1 /* Header file for command creation.
3 Copyright (C) 1986-2021 Free Software Foundation, Inc.
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.
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.
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/>. */
18 #if !defined (COMMAND_H)
21 #include "gdbsupport/gdb_vecs.h"
22 #include "gdbsupport/scoped_restore.h"
24 struct completion_tracker
;
26 /* This file defines the public interface for any code wanting to
29 /* Command classes are top-level categories into which commands are
30 broken down for "help" purposes.
32 The class_alias is used for the user-defined aliases, defined
33 using the "alias" command.
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. */
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. */
48 /* Special classes to help_list */
49 class_deprecated
= -3,
50 all_classes
= -2, /* help without <classname> */
51 all_commands
= -1, /* all */
53 /* Classes of commands */
55 class_run
= 0, /* running */
56 class_vars
, /* data */
57 class_stack
, /* stack */
58 class_files
, /* files */
59 class_support
, /* support */
60 class_info
, /* status */
61 class_breakpoint
, /* breakpoints */
62 class_trace
, /* tracepoints */
63 class_alias
, /* aliases */
65 class_obscure
, /* obscure */
66 class_maintenance
, /* internals */
67 class_tui
, /* text-user-interface */
68 class_user
, /* user-defined */
70 /* Used for "show" commands that have no corresponding "set" command. */
74 /* Types of "set" or "show" command. */
75 typedef enum var_types
77 /* "on" or "off". *VAR is a bool which is true for on,
81 /* "on" / "true" / "enable" or "off" / "false" / "disable" or
82 "auto. *VAR is an ``enum auto_boolean''. NOTE: In general a
83 custom show command will need to be implemented - one that for
84 "auto" prints both the "auto" and the current auto-selected
88 /* Unsigned Integer. *VAR is an unsigned int. The user can type
89 0 to mean "unlimited", which is stored in *VAR as UINT_MAX. */
92 /* Like var_uinteger but signed. *VAR is an int. The user can
93 type 0 to mean "unlimited", which is stored in *VAR as
94 INT_MAX. The only remaining use of it is the Python API.
95 Don't use it elsewhere. */
98 /* String which the user enters with escapes (e.g. the user types
99 \n and it is a real newline in the stored string).
100 *VAR is a std::string, "" if the string is empty. */
102 /* String which stores what the user types verbatim.
103 *VAR is std::string, "" if the string is empty. */
105 /* String which stores a filename. (*VAR) is a std::string,
106 "" if the string was empty. */
107 var_optional_filename
,
108 /* String which stores a filename. (*VAR) is a std::string. */
110 /* ZeroableInteger. *VAR is an int. Like var_integer except
111 that zero really means zero. */
113 /* ZeroableUnsignedInteger. *VAR is an unsigned int. Zero really
116 /* ZeroableUnsignedInteger with unlimited value. *VAR is an int,
117 but its range is [0, INT_MAX]. -1 stands for unlimited and
118 other negative numbers are not allowed. */
119 var_zuinteger_unlimited
,
120 /* Enumerated type. Can only have one of the specified values.
121 *VAR is a char pointer to the name of the element that we
127 /* Return true if a setting of type VAR_TYPE is backed with type T.
129 This function is left without definition intentionally. This template is
130 specialized for all valid types that are used to back var_types. Therefore
131 if one tries to instantiate this un-specialized template it means the T
132 parameter is not a type used to back a var_type and it is most likely a
133 programming error. */
135 bool var_type_uses (var_types var_type
) = delete;
137 /* Return true if a setting of type T is backed by a bool variable. */
139 inline bool var_type_uses
<bool> (var_types t
)
141 return t
== var_boolean
;
144 /* Return true if a setting of type T is backed by a auto_boolean variable.
147 inline bool var_type_uses
<enum auto_boolean
> (var_types t
)
149 return t
== var_auto_boolean
;
152 /* Return true if a setting of type T is backed by an unsigned int variable.
155 inline bool var_type_uses
<unsigned int> (var_types t
)
157 return (t
== var_uinteger
|| t
== var_zinteger
|| t
== var_zuinteger
);
160 /* Return true if a setting of type T is backed by an int variable. */
162 inline bool var_type_uses
<int> (var_types t
)
164 return (t
== var_integer
|| t
== var_zinteger
165 || t
== var_zuinteger_unlimited
);
168 /* Return true if a setting of type T is backed by a std::string variable. */
170 inline bool var_type_uses
<std::string
> (var_types t
)
172 return (t
== var_string
|| t
== var_string_noescape
173 || t
== var_optional_filename
|| t
== var_filename
);
176 /* Return true if a setting of type T is backed by a const char * variable.
179 inline bool var_type_uses
<const char *> (var_types t
)
181 return t
== var_enum
;
184 /* Function signature for a callback used to get a value from a setting. */
187 using setting_getter_ftype
= const T
&(*) ();
189 /* Function signature for a callback used to set a value to a setting. */
192 using setting_setter_ftype
= void (*) (const T
&);
194 /* Generic/type-erased function pointer. */
196 using erased_func
= void (*) ();
198 /* Interface for getting and setting a setting's value.
200 The underlying data can be of any VAR_TYPES type. */
203 /* Create a setting backed by a variable of type T.
205 Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */
207 setting (var_types var_type
, T
*var
)
208 : m_var_type (var_type
), m_var (var
)
210 gdb_assert (var
!= nullptr);
211 gdb_assert (var_type_uses
<T
> (var_type
));
214 /* A setting can also be constructed with a pre-validated
215 type-erased variable. Use the following function to
216 validate & type-erase said variable/function pointers. */
226 static erased_args
erase_args (var_types var_type
,
228 setting_setter_ftype
<T
> set_setting_func
,
229 setting_getter_ftype
<T
> get_setting_func
)
231 gdb_assert (var_type_uses
<T
> (var_type
));
232 /* The getter and the setter must be both provided or both omitted. */
234 ((set_setting_func
== nullptr) == (get_setting_func
== nullptr));
236 /* The caller must provide a pointer to a variable or get/set functions, but
238 gdb_assert ((set_setting_func
== nullptr) != (var
== nullptr));
242 reinterpret_cast<erased_func
> (set_setting_func
),
243 reinterpret_cast<erased_func
> (get_setting_func
)
247 /* Create a setting backed by pre-validated type-erased args.
248 ERASED_VAR's fields' real types must match the var type VAR_TYPE
249 (see VAR_TYPE_USES). */
250 setting (var_types var_type
, const erased_args
&args
)
251 : m_var_type (var_type
),
253 m_getter (args
.getter
),
254 m_setter (args
.setter
)
258 /* Create a setting backed by setter and getter functions.
260 Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */
262 setting (var_types var_type
,
263 setting_setter_ftype
<T
> setter
,
264 setting_getter_ftype
<T
> getter
)
265 : m_var_type (var_type
)
267 gdb_assert (var_type_uses
<T
> (var_type
));
269 /* Getters and setters are cast to and from the arbitrary `void (*) ()`
270 function pointer type. Make sure that the two types are really of the
272 gdb_static_assert (sizeof (m_getter
) == sizeof (getter
));
273 gdb_static_assert (sizeof (m_setter
) == sizeof (setter
));
275 m_getter
= reinterpret_cast<erased_func
> (getter
);
276 m_setter
= reinterpret_cast<erased_func
> (setter
);
279 /* Access the type of the current setting. */
280 var_types
type () const
281 { return m_var_type
; }
283 /* Return the current value.
285 The template parameter T is the type of the variable used to store the
288 const T
&get () const
290 gdb_assert (var_type_uses
<T
> (m_var_type
));
291 gdb_assert (m_var
!= nullptr);
293 if (m_var
== nullptr)
295 gdb_assert (m_getter
!= nullptr);
296 auto getter
= reinterpret_cast<setting_getter_ftype
<T
>> (m_getter
);
300 return *static_cast<const T
*> (m_var
);
303 /* Sets the value of the setting to V.
305 If we have a user-provided setter, use it to set the setting. Otherwise
306 copy the value V to the internally referenced buffer.
308 The template parameter T indicates the type of the variable used to store
311 The var_type of the setting must match T. */
313 void set (const T
&v
)
315 /* Check that the current instance is of one of the supported types for
316 this instantiation. */
317 gdb_assert (var_type_uses
<T
> (m_var_type
));
319 if (m_var
== nullptr)
321 gdb_assert (m_setter
!= nullptr);
322 auto setter
= reinterpret_cast<setting_setter_ftype
<T
>> (m_setter
);
326 *static_cast<T
*> (m_var
) = v
;
330 /* The type of the variable M_VAR is pointing to, or that M_GETTER / M_SETTER
332 var_types m_var_type
;
334 /* Pointer to the enclosed variable
336 Either M_VAR is non-nullptr, or both M_GETTER and M_SETTER are
338 void *m_var
= nullptr;
340 /* Pointer to a user provided getter. */
341 erased_func m_getter
= nullptr;
343 /* Pointer to a user provided setter. */
344 erased_func m_setter
= nullptr;
347 /* This structure records one command'd definition. */
348 struct cmd_list_element
;
350 /* The "simple" signature of command callbacks, which doesn't include a
351 cmd_list_element parameter. */
353 typedef void cmd_simple_func_ftype (const char *args
, int from_tty
);
355 /* This structure specifies notifications to be suppressed by a cli
356 command interpreter. */
358 struct cli_suppress_notification
360 /* Inferior, thread, frame selected notification suppressed? */
361 int user_selected_context
;
364 extern struct cli_suppress_notification cli_suppress_notification
;
366 /* Forward-declarations of the entry-points of cli/cli-decode.c. */
368 /* API to the manipulation of command lists. */
370 /* Return TRUE if NAME is a valid user-defined command name.
371 This is a stricter subset of all gdb commands,
372 see find_command_name_length. */
374 extern bool valid_user_defined_cmd_name_p (const char *name
);
376 /* Return TRUE if C is a valid command character. */
378 extern bool valid_cmd_char_p (int c
);
380 /* Const-correct variant of the above. */
382 extern struct cmd_list_element
*add_cmd (const char *, enum command_class
,
383 cmd_simple_func_ftype
*fun
,
385 struct cmd_list_element
**);
387 /* Like add_cmd, but no command function is specified. */
389 extern struct cmd_list_element
*add_cmd (const char *, enum command_class
,
391 struct cmd_list_element
**);
393 extern struct cmd_list_element
*add_cmd_suppress_notification
394 (const char *name
, enum command_class theclass
,
395 cmd_simple_func_ftype
*fun
, const char *doc
,
396 struct cmd_list_element
**list
,
397 int *suppress_notification
);
399 extern struct cmd_list_element
*add_alias_cmd (const char *,
401 enum command_class
, int,
402 struct cmd_list_element
**);
405 extern struct cmd_list_element
*add_prefix_cmd (const char *, enum command_class
,
406 cmd_simple_func_ftype
*fun
,
408 struct cmd_list_element
**,
410 struct cmd_list_element
**);
412 /* Like add_prefix_cmd, but sets the callback to a function that
413 simply calls help_list. */
415 extern struct cmd_list_element
*add_basic_prefix_cmd
416 (const char *, enum command_class
, const char *, struct cmd_list_element
**,
417 int, struct cmd_list_element
**);
419 /* Like add_prefix_cmd, but useful for "show" prefixes. This sets the
420 callback to a function that simply calls cmd_show_list. */
422 extern struct cmd_list_element
*add_show_prefix_cmd
423 (const char *, enum command_class
, const char *, struct cmd_list_element
**,
424 int, struct cmd_list_element
**);
426 extern struct cmd_list_element
*add_prefix_cmd_suppress_notification
427 (const char *name
, enum command_class theclass
,
428 cmd_simple_func_ftype
*fun
,
429 const char *doc
, struct cmd_list_element
**subcommands
,
431 struct cmd_list_element
**list
,
432 int *suppress_notification
);
434 extern struct cmd_list_element
*add_abbrev_prefix_cmd (const char *,
436 cmd_simple_func_ftype
*fun
,
438 struct cmd_list_element
440 struct cmd_list_element
443 typedef void cmd_func_ftype (const char *args
, int from_tty
,
444 cmd_list_element
*c
);
446 /* A completion routine. Add possible completions to tracker.
448 TEXT is the text beyond what was matched for the command itself
449 (leading whitespace is skipped). It stops where we are supposed to
450 stop completing (rl_point) and is '\0' terminated. WORD points in
451 the same buffer as TEXT, and completions should be returned
452 relative to this position. For example, suppose TEXT is "foo" and
453 we want to complete to "foobar". If WORD is "oo", return "oobar";
454 if WORD is "baz/foo", return "baz/foobar". */
455 typedef void completer_ftype (struct cmd_list_element
*,
456 completion_tracker
&tracker
,
457 const char *text
, const char *word
);
459 /* Same, but for set_cmd_completer_handle_brkchars. */
460 typedef void completer_handle_brkchars_ftype (struct cmd_list_element
*,
461 completion_tracker
&tracker
,
462 const char *text
, const char *word
);
464 extern void set_cmd_completer (struct cmd_list_element
*, completer_ftype
*);
466 /* Set the completer_handle_brkchars callback. */
468 extern void set_cmd_completer_handle_brkchars (struct cmd_list_element
*,
469 completer_handle_brkchars_ftype
*);
471 /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
472 around in cmd objects to test the value of the commands sfunc(). */
473 extern int cmd_simple_func_eq (struct cmd_list_element
*cmd
,
474 cmd_simple_func_ftype
*cfun
);
476 /* Execute CMD's pre/post hook. Throw an error if the command fails.
477 If already executing this pre/post hook, or there is no pre/post
478 hook, the call is silently ignored. */
479 extern void execute_cmd_pre_hook (struct cmd_list_element
*cmd
);
480 extern void execute_cmd_post_hook (struct cmd_list_element
*cmd
);
482 /* Flag for an ambiguous cmd_list result. */
483 #define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1)
485 extern struct cmd_list_element
*lookup_cmd (const char **,
486 struct cmd_list_element
*,
491 /* This routine takes a line of TEXT and a CLIST in which to start the
492 lookup. When it returns it will have incremented the text pointer past
493 the section of text it matched, set *RESULT_LIST to point to the list in
494 which the last word was matched, and will return a pointer to the cmd
495 list element which the text matches. It will return NULL if no match at
496 all was possible. It will return -1 (cast appropriately, ick) if ambigous
497 matches are possible; in this case *RESULT_LIST will be set to point to
498 the list in which there are ambiguous choices (and *TEXT will be set to
499 the ambiguous text string).
501 if DEFAULT_ARGS is not null, *DEFAULT_ARGS is set to the found command
502 default args (possibly empty).
504 If the located command was an abbreviation, this routine returns the base
505 command of the abbreviation. Note that *DEFAULT_ARGS will contain the
506 default args defined for the alias.
508 It does no error reporting whatsoever; control will always return
509 to the superior routine.
511 In the case of an ambiguous return (-1), *RESULT_LIST will be set to point
512 at the prefix_command (ie. the best match) *or* (special case) will be NULL
513 if no prefix command was ever found. For example, in the case of "info a",
514 "info" matches without ambiguity, but "a" could be "args" or "address", so
515 *RESULT_LIST is set to the cmd_list_element for "info". So in this case
516 RESULT_LIST should not be interpreted as a pointer to the beginning of a
517 list; it simply points to a specific command. In the case of an ambiguous
518 return *TEXT is advanced past the last non-ambiguous prefix (e.g.
519 "info t" can be "info types" or "info target"; upon return *TEXT has been
520 advanced past "info ").
522 If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise
523 affect the operation).
525 This routine does *not* modify the text pointed to by TEXT.
527 If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which
528 are actually help classes rather than commands (i.e. the function field of
529 the struct cmd_list_element is NULL).
531 When LOOKUP_FOR_COMPLETION_P is true the completion is being requested
532 for the completion engine, no warnings should be printed. */
534 extern struct cmd_list_element
*lookup_cmd_1
535 (const char **text
, struct cmd_list_element
*clist
,
536 struct cmd_list_element
**result_list
, std::string
*default_args
,
537 int ignore_help_classes
, bool lookup_for_completion_p
= false);
539 /* Look up the command called NAME in the command list LIST.
541 Unlike LOOKUP_CMD, partial matches are ignored and only exact matches
542 on NAME are considered.
544 LIST is a chain of struct cmd_list_element's.
546 If IGNORE_HELP_CLASSES is true (the default), ignore any command list
547 elements which are actually help classes rather than commands (i.e.
548 the function field of the struct cmd_list_element is null).
550 If found, return the struct cmd_list_element for that command,
551 otherwise return NULLPTR. */
553 extern struct cmd_list_element
*lookup_cmd_exact
555 struct cmd_list_element
*list
,
556 bool ignore_help_classes
= true);
558 extern struct cmd_list_element
*deprecate_cmd (struct cmd_list_element
*,
561 extern void deprecated_cmd_warning (const char *, struct cmd_list_element
*);
563 extern int lookup_cmd_composition (const char *text
,
564 struct cmd_list_element
**alias
,
565 struct cmd_list_element
**prefix_cmd
,
566 struct cmd_list_element
**cmd
);
568 extern struct cmd_list_element
*add_com (const char *, enum command_class
,
569 cmd_simple_func_ftype
*fun
,
572 extern cmd_list_element
*add_com_alias (const char *name
,
573 cmd_list_element
*target
,
574 command_class theclass
,
577 extern struct cmd_list_element
*add_com_suppress_notification
578 (const char *name
, enum command_class theclass
,
579 cmd_simple_func_ftype
*fun
, const char *doc
,
580 int *supress_notification
);
582 extern struct cmd_list_element
*add_info (const char *,
583 cmd_simple_func_ftype
*fun
,
586 extern cmd_list_element
*add_info_alias (const char *name
,
587 cmd_list_element
*target
,
590 extern void complete_on_cmdlist (struct cmd_list_element
*,
591 completion_tracker
&tracker
,
592 const char *, const char *, int);
594 extern void complete_on_enum (completion_tracker
&tracker
,
595 const char *const *enumlist
,
596 const char *, const char *);
598 /* Functions that implement commands about CLI commands. */
600 extern void help_list (struct cmd_list_element
*, const char *,
601 enum command_class
, struct ui_file
*);
603 /* Method for show a set/show variable's VALUE on FILE. If this
604 method isn't supplied deprecated_show_value_hack() is called (which
606 typedef void (show_value_ftype
) (struct ui_file
*file
,
608 struct cmd_list_element
*cmd
,
610 /* NOTE: i18n: This function is not i18n friendly. Callers should
611 instead print the value out directly. */
612 extern show_value_ftype deprecated_show_value_hack
;
614 /* Return value type for the add_setshow_* functions. */
616 struct set_show_commands
618 cmd_list_element
*set
, *show
;
621 extern set_show_commands add_setshow_enum_cmd
622 (const char *name
, command_class theclass
, const char *const *enumlist
,
623 const char **var
, const char *set_doc
, const char *show_doc
,
624 const char *help_doc
, cmd_func_ftype
*set_func
,
625 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
626 cmd_list_element
**show_list
);
628 extern set_show_commands add_setshow_enum_cmd
629 (const char *name
, command_class theclass
, const char *const *enumlist
,
630 const char *set_doc
, const char *show_doc
,
631 const char *help_doc
, setting_setter_ftype
<const char *> set_func
,
632 setting_getter_ftype
<const char *> get_func
, show_value_ftype
*show_func
,
633 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
635 extern set_show_commands add_setshow_auto_boolean_cmd
636 (const char *name
, command_class theclass
, auto_boolean
*var
,
637 const char *set_doc
, const char *show_doc
, const char *help_doc
,
638 cmd_func_ftype
*set_func
, show_value_ftype
*show_func
,
639 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
641 extern set_show_commands add_setshow_auto_boolean_cmd
642 (const char *name
, command_class theclass
, const char *set_doc
,
643 const char *show_doc
, const char *help_doc
,
644 setting_setter_ftype
<enum auto_boolean
> set_func
,
645 setting_getter_ftype
<enum auto_boolean
> get_func
,
646 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
647 cmd_list_element
**show_list
);
649 extern set_show_commands add_setshow_boolean_cmd
650 (const char *name
, command_class theclass
, bool *var
, const char *set_doc
,
651 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
652 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
653 cmd_list_element
**show_list
);
655 extern set_show_commands add_setshow_boolean_cmd
656 (const char *name
, command_class theclass
, const char *set_doc
,
657 const char *show_doc
, const char *help_doc
,
658 setting_setter_ftype
<bool> set_func
,
659 setting_getter_ftype
<bool> get_func
, show_value_ftype
*show_func
,
660 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
662 extern set_show_commands add_setshow_filename_cmd
663 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
664 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
665 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
666 cmd_list_element
**show_list
);
668 extern set_show_commands add_setshow_filename_cmd
669 (const char *name
, command_class theclass
, const char *set_doc
,
670 const char *show_doc
, const char *help_doc
,
671 setting_setter_ftype
<std::string
> set_func
,
672 setting_getter_ftype
<std::string
> get_func
, show_value_ftype
*show_func
,
673 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
675 extern set_show_commands add_setshow_string_cmd
676 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
677 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
678 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
679 cmd_list_element
**show_list
);
681 extern set_show_commands add_setshow_string_cmd
682 (const char *name
, command_class theclass
, const char *set_doc
,
683 const char *show_doc
, const char *help_doc
,
684 setting_setter_ftype
<std::string
> set_func
,
685 setting_getter_ftype
<std::string
> get_func
,
686 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
687 cmd_list_element
**show_list
);
689 extern set_show_commands add_setshow_string_noescape_cmd
690 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
691 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
692 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
693 cmd_list_element
**show_list
);
695 extern set_show_commands add_setshow_string_noescape_cmd
696 (const char *name
, command_class theclass
, const char *set_doc
,
697 const char *show_doc
, const char *help_doc
,
698 setting_setter_ftype
<std::string
> set_func
,
699 setting_getter_ftype
<std::string
> get_func
, show_value_ftype
*show_func
,
700 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
702 extern set_show_commands add_setshow_optional_filename_cmd
703 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
704 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
705 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
706 cmd_list_element
**show_list
);
708 extern set_show_commands add_setshow_optional_filename_cmd
709 (const char *name
, command_class theclass
, const char *set_doc
,
710 const char *show_doc
, const char *help_doc
,
711 setting_setter_ftype
<std::string
> set_func
,
712 setting_getter_ftype
<std::string
> get_func
,
713 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
714 cmd_list_element
**show_list
);
716 extern set_show_commands add_setshow_integer_cmd
717 (const char *name
, command_class theclass
, int *var
, const char *set_doc
,
718 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
719 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
720 cmd_list_element
**show_list
);
722 extern set_show_commands add_setshow_integer_cmd
723 (const char *name
, command_class theclass
, const char *set_doc
,
724 const char *show_doc
, const char *help_doc
,
725 setting_setter_ftype
<int> set_func
,
726 setting_getter_ftype
<int> get_func
, show_value_ftype
*show_func
,
727 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
729 extern set_show_commands add_setshow_uinteger_cmd
730 (const char *name
, command_class theclass
, unsigned int *var
,
731 const char *set_doc
, const char *show_doc
, const char *help_doc
,
732 cmd_func_ftype
*set_func
, show_value_ftype
*show_func
,
733 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
735 extern set_show_commands add_setshow_uinteger_cmd
736 (const char *name
, command_class theclass
, const char *set_doc
,
737 const char *show_doc
, const char *help_doc
,
738 setting_setter_ftype
<unsigned int> set_func
,
739 setting_getter_ftype
<unsigned int> get_func
, show_value_ftype
*show_func
,
740 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
742 extern set_show_commands add_setshow_zinteger_cmd
743 (const char *name
, command_class theclass
, int *var
, const char *set_doc
,
744 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
745 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
746 cmd_list_element
**show_list
);
748 extern set_show_commands add_setshow_zinteger_cmd
749 (const char *name
, command_class theclass
, const char *set_doc
,
750 const char *show_doc
, const char *help_doc
,
751 setting_setter_ftype
<int> set_func
,
752 setting_getter_ftype
<int> get_func
, show_value_ftype
*show_func
,
753 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
755 extern set_show_commands add_setshow_zuinteger_cmd
756 (const char *name
, command_class theclass
, unsigned int *var
,
757 const char *set_doc
, const char *show_doc
, const char *help_doc
,
758 cmd_func_ftype
*set_func
, show_value_ftype
*show_func
,
759 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
761 extern set_show_commands add_setshow_zuinteger_cmd
762 (const char *name
, command_class theclass
, const char *set_doc
,
763 const char *show_doc
, const char *help_doc
,
764 setting_setter_ftype
<unsigned int> set_func
,
765 setting_getter_ftype
<unsigned int> get_func
, show_value_ftype
*show_func
,
766 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
768 extern set_show_commands add_setshow_zuinteger_unlimited_cmd
769 (const char *name
, command_class theclass
, int *var
, const char *set_doc
,
770 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
771 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
772 cmd_list_element
**show_list
);
774 extern set_show_commands add_setshow_zuinteger_unlimited_cmd
775 (const char *name
, command_class theclass
, const char *set_doc
,
776 const char *show_doc
, const char *help_doc
,
777 setting_setter_ftype
<int> set_func
, setting_getter_ftype
<int> get_func
,
778 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
779 cmd_list_element
**show_list
);
781 /* Do a "show" command for each thing on a command list. */
783 extern void cmd_show_list (struct cmd_list_element
*, int);
785 /* Used everywhere whenever at least one parameter is required and
786 none is specified. */
788 extern void error_no_arg (const char *) ATTRIBUTE_NORETURN
;
791 /* Command line saving and repetition.
792 Each input line executed is saved to possibly be repeated either
793 when the user types an empty line, or be repeated by a command
794 that wants to repeat the previously executed command. The below
795 functions control command repetition. */
797 /* Commands call dont_repeat if they do not want to be repeated by null
798 lines or by repeat_previous (). */
800 extern void dont_repeat ();
802 /* Commands call repeat_previous if they want to repeat the previous
803 command. Such commands that repeat the previous command must
804 indicate to not repeat themselves, to avoid recursive repeat.
805 repeat_previous marks the current command as not repeating, and
806 ensures get_saved_command_line returns the previous command, so
807 that the currently executing command can repeat it. If there's no
808 previous command, throws an error. Otherwise, returns the result
809 of get_saved_command_line, which now points at the command to
812 extern const char *repeat_previous ();
814 /* Prevent dont_repeat from working, and return a cleanup that
815 restores the previous state. */
817 extern scoped_restore_tmpl
<int> prevent_dont_repeat (void);
819 /* Set the arguments that will be passed if the current command is
820 repeated. Note that the passed-in string must be a constant. */
822 extern void set_repeat_arguments (const char *args
);
824 /* Returns the saved command line to repeat.
825 When a command is being executed, this is the currently executing
826 command line, unless the currently executing command has called
827 repeat_previous (): in this case, get_saved_command_line returns
828 the previously saved command line. */
830 extern char *get_saved_command_line ();
832 /* Takes a copy of CMD, for possible repetition. */
834 extern void save_command_line (const char *cmd
);
836 /* Used to mark commands that don't do anything. If we just leave the
837 function field NULL, the command is interpreted as a help topic, or
838 as a class of commands. */
840 extern void not_just_help_class_command (const char *, int);
842 /* Call the command function. */
843 extern void cmd_func (struct cmd_list_element
*cmd
,
844 const char *args
, int from_tty
);
846 #endif /* !defined (COMMAND_H) */