1 /* Header file for command creation.
3 Copyright (C) 1986-2023 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 all_classes
= -2, /* help without <classname> */
50 all_commands
= -1, /* all */
52 /* Classes of commands */
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 */
64 class_obscure
, /* obscure */
65 class_maintenance
, /* internals */
66 class_tui
, /* text-user-interface */
67 class_user
, /* user-defined */
69 /* Used for "show" commands that have no corresponding "set" command. */
73 /* Types of "set" or "show" command. */
76 /* "on" or "off". *VAR is a bool which is true for on,
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
87 /* Unsigned Integer. *VAR is an unsigned int. In the Guile and Python
88 APIs 0 means unlimited, which is stored in *VAR as UINT_MAX. */
91 /* Like var_uinteger but signed. *VAR is an int. In the Guile and
92 Python APIs 0 means unlimited, which is stored in *VAR as INT_MAX. */
95 /* Like var_integer but negative numbers are not allowed,
96 except for special values. *VAR is an int. */
99 /* String which the user enters with escapes (e.g. the user types
100 \n and it is a real newline in the stored string).
101 *VAR is a std::string, "" if the string is empty. */
103 /* String which stores what the user types verbatim.
104 *VAR is std::string, "" if the string is empty. */
106 /* String which stores a filename. (*VAR) is a std::string,
107 "" if the string was empty. */
108 var_optional_filename
,
109 /* String which stores a filename. (*VAR) is a std::string. */
111 /* Enumerated type. Can only have one of the specified values.
112 *VAR is a char pointer to the name of the element that we
117 /* A structure describing an extra literal accepted and shown in place
121 /* The literal to define, e.g. "unlimited". */
124 /* The number to substitute internally for LITERAL or VAL;
125 the use of this number is not allowed (unless the same as VAL). */
128 /* An optional number accepted that stands for the literal. */
129 gdb::optional
<LONGEST
> val
;
132 /* Return true if a setting of type VAR_TYPE is backed with type T.
134 This function is left without definition intentionally. This template is
135 specialized for all valid types that are used to back var_types. Therefore
136 if one tries to instantiate this un-specialized template it means the T
137 parameter is not a type used to back a var_type and it is most likely a
138 programming error. */
140 bool var_type_uses (var_types var_type
) = delete;
142 /* Return true if a setting of type T is backed by a bool variable. */
144 inline bool var_type_uses
<bool> (var_types t
)
146 return t
== var_boolean
;
149 /* Return true if a setting of type T is backed by a auto_boolean variable.
152 inline bool var_type_uses
<enum auto_boolean
> (var_types t
)
154 return t
== var_auto_boolean
;
157 /* Return true if a setting of type T is backed by an unsigned int variable.
160 inline bool var_type_uses
<unsigned int> (var_types t
)
162 return t
== var_uinteger
;
165 /* Return true if a setting of type T is backed by an int variable. */
167 inline bool var_type_uses
<int> (var_types t
)
169 return t
== var_integer
|| t
== var_pinteger
;
172 /* Return true if a setting of type T is backed by a std::string variable. */
174 inline bool var_type_uses
<std::string
> (var_types t
)
176 return (t
== var_string
|| t
== var_string_noescape
177 || t
== var_optional_filename
|| t
== var_filename
);
180 /* Return true if a setting of type T is backed by a const char * variable.
183 inline bool var_type_uses
<const char *> (var_types t
)
185 return t
== var_enum
;
188 template<bool is_scalar
, typename T
> struct setting_func_types_1
;
191 struct setting_func_types_1
<true, T
>
194 using set
= void (*) (type
);
195 using get
= type (*) ();
199 struct setting_func_types_1
<false, T
>
201 using type
= const T
&;
202 using set
= void (*) (type
);
203 using get
= type (*) ();
207 struct setting_func_types
209 using type
= typename setting_func_types_1
<std::is_scalar
<T
>::value
, T
>::type
;
210 using set
= typename setting_func_types_1
<std::is_scalar
<T
>::value
, T
>::set
;
211 using get
= typename setting_func_types_1
<std::is_scalar
<T
>::value
, T
>::get
;
214 /* Generic/type-erased function pointer. */
216 using erased_func
= void (*) ();
218 /* Interface for getting and setting a setting's value.
220 The underlying data can be of any VAR_TYPES type. */
223 /* Create a setting backed by a variable of type T.
225 Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */
227 setting (var_types var_type
, T
*var
,
228 const literal_def
*extra_literals
= nullptr)
229 : m_var_type (var_type
), m_var (var
), m_extra_literals (extra_literals
)
231 gdb_assert (var
!= nullptr);
232 gdb_assert (var_type_uses
<T
> (var_type
));
235 /* A setting can also be constructed with a pre-validated
236 type-erased variable. Use the following function to
237 validate & type-erase said variable/function pointers. */
247 static erased_args
erase_args (var_types var_type
,
249 typename setting_func_types
<T
>::set set_setting_func
,
250 typename setting_func_types
<T
>::get get_setting_func
)
252 gdb_assert (var_type_uses
<T
> (var_type
));
253 /* The getter and the setter must be both provided or both omitted. */
255 ((set_setting_func
== nullptr) == (get_setting_func
== nullptr));
257 /* The caller must provide a pointer to a variable or get/set functions, but
259 gdb_assert ((set_setting_func
== nullptr) != (var
== nullptr));
263 reinterpret_cast<erased_func
> (set_setting_func
),
264 reinterpret_cast<erased_func
> (get_setting_func
)
268 /* Create a setting backed by pre-validated type-erased args and using
269 EXTRA_LITERALS. ERASED_VAR's fields' real types must match the var
270 type VAR_TYPE (see VAR_TYPE_USES). */
271 setting (var_types var_type
, const literal_def
*extra_literals
,
272 const erased_args
&args
)
273 : m_var_type (var_type
),
275 m_extra_literals (extra_literals
),
276 m_getter (args
.getter
),
277 m_setter (args
.setter
)
281 /* Create a setting backed by setter and getter functions.
283 Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */
285 setting (var_types var_type
,
286 typename setting_func_types
<T
>::set setter
,
287 typename setting_func_types
<T
>::get getter
)
288 : m_var_type (var_type
)
290 gdb_assert (var_type_uses
<T
> (var_type
));
292 /* Getters and setters are cast to and from the arbitrary `void (*) ()`
293 function pointer type. Make sure that the two types are really of the
295 gdb_static_assert (sizeof (m_getter
) == sizeof (getter
));
296 gdb_static_assert (sizeof (m_setter
) == sizeof (setter
));
298 m_getter
= reinterpret_cast<erased_func
> (getter
);
299 m_setter
= reinterpret_cast<erased_func
> (setter
);
302 /* Access the type of the current setting. */
303 var_types
type () const
304 { return m_var_type
; }
306 /* Access any extra literals accepted. */
307 const literal_def
*extra_literals () const
308 { return m_extra_literals
; }
310 /* Return the current value.
312 The template parameter T is the type of the variable used to store the
315 typename setting_func_types
<T
>::type
get () const
317 gdb_assert (var_type_uses
<T
> (m_var_type
));
319 if (m_var
== nullptr)
321 gdb_assert (m_getter
!= nullptr);
322 auto getter
= reinterpret_cast<typename setting_func_types
<T
>::get
> (m_getter
);
326 return *static_cast<const T
*> (m_var
);
329 /* Sets the value of the setting to V. Returns true if the setting was
330 effectively changed, false if the update failed and the setting is left
333 If we have a user-provided setter, use it to set the setting. Otherwise
334 copy the value V to the internally referenced buffer.
336 The template parameter T indicates the type of the variable used to store
339 The var_type of the setting must match T. */
341 bool set (const T
&v
)
343 /* Check that the current instance is of one of the supported types for
344 this instantiation. */
345 gdb_assert (var_type_uses
<T
> (m_var_type
));
347 const T old_value
= this->get
<T
> ();
349 if (m_var
== nullptr)
351 gdb_assert (m_setter
!= nullptr);
352 auto setter
= reinterpret_cast<typename setting_func_types
<T
>::set
> (m_setter
);
356 *static_cast<T
*> (m_var
) = v
;
358 return old_value
!= this->get
<T
> ();
362 /* The type of the variable M_VAR is pointing to, or that M_GETTER / M_SETTER
364 var_types m_var_type
;
366 /* Pointer to the enclosed variable
368 Either M_VAR is non-nullptr, or both M_GETTER and M_SETTER are
370 void *m_var
= nullptr;
372 /* Any extra literals accepted. */
373 const literal_def
*m_extra_literals
= nullptr;
375 /* Pointer to a user provided getter. */
376 erased_func m_getter
= nullptr;
378 /* Pointer to a user provided setter. */
379 erased_func m_setter
= nullptr;
382 /* This structure records one command'd definition. */
383 struct cmd_list_element
;
385 /* The "simple" signature of command callbacks, which doesn't include a
386 cmd_list_element parameter. */
388 typedef void cmd_simple_func_ftype (const char *args
, int from_tty
);
390 /* This structure specifies notifications to be suppressed by a cli
391 command interpreter. */
393 struct cli_suppress_notification
395 /* Inferior, thread, frame selected notification suppressed? */
396 bool user_selected_context
= false;
398 /* Normal stop event suppressed? */
399 bool normal_stop
= false;
402 extern struct cli_suppress_notification cli_suppress_notification
;
404 /* Forward-declarations of the entry-points of cli/cli-decode.c. */
406 /* API to the manipulation of command lists. */
408 /* Return TRUE if NAME is a valid user-defined command name.
409 This is a stricter subset of all gdb commands,
410 see find_command_name_length. */
412 extern bool valid_user_defined_cmd_name_p (const char *name
);
414 /* Return TRUE if C is a valid command character. */
416 extern bool valid_cmd_char_p (int c
);
418 /* Return value type for the add_setshow_* functions. */
420 struct set_show_commands
422 cmd_list_element
*set
, *show
;
425 /* Const-correct variant of the above. */
427 extern struct cmd_list_element
*add_cmd (const char *, enum command_class
,
428 cmd_simple_func_ftype
*fun
,
430 struct cmd_list_element
**);
432 /* Like add_cmd, but no command function is specified. */
434 extern struct cmd_list_element
*add_cmd (const char *, enum command_class
,
436 struct cmd_list_element
**);
438 extern struct cmd_list_element
*add_cmd_suppress_notification
439 (const char *name
, enum command_class theclass
,
440 cmd_simple_func_ftype
*fun
, const char *doc
,
441 struct cmd_list_element
**list
,
442 bool *suppress_notification
);
444 extern struct cmd_list_element
*add_alias_cmd (const char *,
446 enum command_class
, int,
447 struct cmd_list_element
**);
450 extern struct cmd_list_element
*add_prefix_cmd (const char *, enum command_class
,
451 cmd_simple_func_ftype
*fun
,
453 struct cmd_list_element
**,
455 struct cmd_list_element
**);
457 /* Like add_prefix_cmd, but sets the callback to a function that
458 simply calls help_list. */
460 extern struct cmd_list_element
*add_basic_prefix_cmd
461 (const char *, enum command_class
, const char *, struct cmd_list_element
**,
462 int, struct cmd_list_element
**);
464 /* Like add_prefix_cmd, but useful for "show" prefixes. This sets the
465 callback to a function that simply calls cmd_show_list. */
467 extern struct cmd_list_element
*add_show_prefix_cmd
468 (const char *, enum command_class
, const char *, struct cmd_list_element
**,
469 int, struct cmd_list_element
**);
471 /* Add matching set and show commands using add_basic_prefix_cmd and
472 add_show_prefix_cmd. */
474 extern set_show_commands add_setshow_prefix_cmd
475 (const char *name
, command_class theclass
, const char *set_doc
,
476 const char *show_doc
,
477 cmd_list_element
**set_subcommands_list
,
478 cmd_list_element
**show_subcommands_list
,
479 cmd_list_element
**set_list
,
480 cmd_list_element
**show_list
);
482 extern struct cmd_list_element
*add_prefix_cmd_suppress_notification
483 (const char *name
, enum command_class theclass
,
484 cmd_simple_func_ftype
*fun
,
485 const char *doc
, struct cmd_list_element
**subcommands
,
487 struct cmd_list_element
**list
,
488 bool *suppress_notification
);
490 extern struct cmd_list_element
*add_abbrev_prefix_cmd (const char *,
492 cmd_simple_func_ftype
*fun
,
494 struct cmd_list_element
496 struct cmd_list_element
499 typedef void cmd_func_ftype (const char *args
, int from_tty
,
500 cmd_list_element
*c
);
502 /* A completion routine. Add possible completions to tracker.
504 TEXT is the text beyond what was matched for the command itself
505 (leading whitespace is skipped). It stops where we are supposed to
506 stop completing (rl_point) and is '\0' terminated. WORD points in
507 the same buffer as TEXT, and completions should be returned
508 relative to this position. For example, suppose TEXT is "foo" and
509 we want to complete to "foobar". If WORD is "oo", return "oobar";
510 if WORD is "baz/foo", return "baz/foobar". */
511 typedef void completer_ftype (struct cmd_list_element
*,
512 completion_tracker
&tracker
,
513 const char *text
, const char *word
);
515 /* Same, but for set_cmd_completer_handle_brkchars. */
516 typedef void completer_handle_brkchars_ftype (struct cmd_list_element
*,
517 completion_tracker
&tracker
,
518 const char *text
, const char *word
);
520 extern void set_cmd_completer (struct cmd_list_element
*, completer_ftype
*);
522 /* Set the completer_handle_brkchars callback. */
524 extern void set_cmd_completer_handle_brkchars (struct cmd_list_element
*,
525 completer_handle_brkchars_ftype
*);
527 /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
528 around in cmd objects to test the value of the commands sfunc(). */
529 extern int cmd_simple_func_eq (struct cmd_list_element
*cmd
,
530 cmd_simple_func_ftype
*cfun
);
532 /* Execute CMD's pre/post hook. Throw an error if the command fails.
533 If already executing this pre/post hook, or there is no pre/post
534 hook, the call is silently ignored. */
535 extern void execute_cmd_pre_hook (struct cmd_list_element
*cmd
);
536 extern void execute_cmd_post_hook (struct cmd_list_element
*cmd
);
538 /* Flag for an ambiguous cmd_list result. */
539 #define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1)
541 extern struct cmd_list_element
*lookup_cmd (const char **,
542 struct cmd_list_element
*,
547 /* This routine takes a line of TEXT and a CLIST in which to start the
548 lookup. When it returns it will have incremented the text pointer past
549 the section of text it matched, set *RESULT_LIST to point to the list in
550 which the last word was matched, and will return a pointer to the cmd
551 list element which the text matches. It will return NULL if no match at
552 all was possible. It will return -1 (cast appropriately, ick) if ambigous
553 matches are possible; in this case *RESULT_LIST will be set to point to
554 the list in which there are ambiguous choices (and *TEXT will be set to
555 the ambiguous text string).
557 if DEFAULT_ARGS is not null, *DEFAULT_ARGS is set to the found command
558 default args (possibly empty).
560 If the located command was an abbreviation, this routine returns the base
561 command of the abbreviation. Note that *DEFAULT_ARGS will contain the
562 default args defined for the alias.
564 It does no error reporting whatsoever; control will always return
565 to the superior routine.
567 In the case of an ambiguous return (-1), *RESULT_LIST will be set to point
568 at the prefix_command (ie. the best match) *or* (special case) will be NULL
569 if no prefix command was ever found. For example, in the case of "info a",
570 "info" matches without ambiguity, but "a" could be "args" or "address", so
571 *RESULT_LIST is set to the cmd_list_element for "info". So in this case
572 RESULT_LIST should not be interpreted as a pointer to the beginning of a
573 list; it simply points to a specific command. In the case of an ambiguous
574 return *TEXT is advanced past the last non-ambiguous prefix (e.g.
575 "info t" can be "info types" or "info target"; upon return *TEXT has been
576 advanced past "info ").
578 If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise
579 affect the operation).
581 This routine does *not* modify the text pointed to by TEXT.
583 If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which
584 are actually help classes rather than commands (i.e. the function field of
585 the struct cmd_list_element is NULL).
587 When LOOKUP_FOR_COMPLETION_P is true the completion is being requested
588 for the completion engine, no warnings should be printed. */
590 extern struct cmd_list_element
*lookup_cmd_1
591 (const char **text
, struct cmd_list_element
*clist
,
592 struct cmd_list_element
**result_list
, std::string
*default_args
,
593 int ignore_help_classes
, bool lookup_for_completion_p
= false);
595 /* Look up the command called NAME in the command list LIST.
597 Unlike LOOKUP_CMD, partial matches are ignored and only exact matches
598 on NAME are considered.
600 LIST is a chain of struct cmd_list_element's.
602 If IGNORE_HELP_CLASSES is true (the default), ignore any command list
603 elements which are actually help classes rather than commands (i.e.
604 the function field of the struct cmd_list_element is null).
606 If found, return the struct cmd_list_element for that command,
607 otherwise return NULLPTR. */
609 extern struct cmd_list_element
*lookup_cmd_exact
611 struct cmd_list_element
*list
,
612 bool ignore_help_classes
= true);
614 extern struct cmd_list_element
*deprecate_cmd (struct cmd_list_element
*,
617 extern void deprecated_cmd_warning (const char *, struct cmd_list_element
*);
619 extern int lookup_cmd_composition (const char *text
,
620 struct cmd_list_element
**alias
,
621 struct cmd_list_element
**prefix_cmd
,
622 struct cmd_list_element
**cmd
);
624 extern struct cmd_list_element
*add_com (const char *, enum command_class
,
625 cmd_simple_func_ftype
*fun
,
628 extern cmd_list_element
*add_com_alias (const char *name
,
629 cmd_list_element
*target
,
630 command_class theclass
,
633 extern struct cmd_list_element
*add_com_suppress_notification
634 (const char *name
, enum command_class theclass
,
635 cmd_simple_func_ftype
*fun
, const char *doc
,
636 bool *supress_notification
);
638 extern struct cmd_list_element
*add_info (const char *,
639 cmd_simple_func_ftype
*fun
,
642 extern cmd_list_element
*add_info_alias (const char *name
,
643 cmd_list_element
*target
,
646 extern void complete_on_cmdlist (struct cmd_list_element
*,
647 completion_tracker
&tracker
,
648 const char *, const char *, int);
650 extern void complete_on_enum (completion_tracker
&tracker
,
651 const char *const *enumlist
,
652 const char *, const char *);
654 /* Functions that implement commands about CLI commands. */
656 extern void help_list (struct cmd_list_element
*, const char *,
657 enum command_class
, struct ui_file
*);
659 /* Method for show a set/show variable's VALUE on FILE. */
660 typedef void (show_value_ftype
) (struct ui_file
*file
,
662 struct cmd_list_element
*cmd
,
665 /* Various sets of extra literals accepted. */
666 extern const literal_def integer_unlimited_literals
[];
667 extern const literal_def uinteger_unlimited_literals
[];
668 extern const literal_def pinteger_unlimited_literals
[];
670 extern set_show_commands add_setshow_enum_cmd
671 (const char *name
, command_class theclass
, const char *const *enumlist
,
672 const char **var
, const char *set_doc
, const char *show_doc
,
673 const char *help_doc
, cmd_func_ftype
*set_func
,
674 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
675 cmd_list_element
**show_list
);
677 extern set_show_commands add_setshow_enum_cmd
678 (const char *name
, command_class theclass
, const char *const *enumlist
,
679 const char *set_doc
, const char *show_doc
,
680 const char *help_doc
, setting_func_types
<const char *>::set set_func
,
681 setting_func_types
<const char *>::get get_func
, show_value_ftype
*show_func
,
682 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
684 extern set_show_commands add_setshow_auto_boolean_cmd
685 (const char *name
, command_class theclass
, auto_boolean
*var
,
686 const char *set_doc
, const char *show_doc
, const char *help_doc
,
687 cmd_func_ftype
*set_func
, show_value_ftype
*show_func
,
688 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
690 extern set_show_commands add_setshow_auto_boolean_cmd
691 (const char *name
, command_class theclass
, const char *set_doc
,
692 const char *show_doc
, const char *help_doc
,
693 setting_func_types
<enum auto_boolean
>::set set_func
,
694 setting_func_types
<enum auto_boolean
>::get get_func
,
695 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
696 cmd_list_element
**show_list
);
698 extern set_show_commands add_setshow_boolean_cmd
699 (const char *name
, command_class theclass
, bool *var
, const char *set_doc
,
700 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
701 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
702 cmd_list_element
**show_list
);
704 extern set_show_commands add_setshow_boolean_cmd
705 (const char *name
, command_class theclass
, const char *set_doc
,
706 const char *show_doc
, const char *help_doc
,
707 setting_func_types
<bool>::set set_func
,
708 setting_func_types
<bool>::get get_func
, show_value_ftype
*show_func
,
709 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
711 extern set_show_commands add_setshow_filename_cmd
712 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
713 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
714 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
715 cmd_list_element
**show_list
);
717 extern set_show_commands add_setshow_filename_cmd
718 (const char *name
, command_class theclass
, const char *set_doc
,
719 const char *show_doc
, const char *help_doc
,
720 setting_func_types
<std::string
>::set set_func
,
721 setting_func_types
<std::string
>::get get_func
, show_value_ftype
*show_func
,
722 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
724 extern set_show_commands add_setshow_string_cmd
725 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
726 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
727 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
728 cmd_list_element
**show_list
);
730 extern set_show_commands add_setshow_string_cmd
731 (const char *name
, command_class theclass
, const char *set_doc
,
732 const char *show_doc
, const char *help_doc
,
733 setting_func_types
<std::string
>::set set_func
,
734 setting_func_types
<std::string
>::get get_func
,
735 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
736 cmd_list_element
**show_list
);
738 extern set_show_commands add_setshow_string_noescape_cmd
739 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
740 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
741 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
742 cmd_list_element
**show_list
);
744 extern set_show_commands add_setshow_string_noescape_cmd
745 (const char *name
, command_class theclass
, const char *set_doc
,
746 const char *show_doc
, const char *help_doc
,
747 setting_func_types
<std::string
>::set set_func
,
748 setting_func_types
<std::string
>::get get_func
, show_value_ftype
*show_func
,
749 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
751 extern set_show_commands add_setshow_optional_filename_cmd
752 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
753 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
754 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
755 cmd_list_element
**show_list
);
757 extern set_show_commands add_setshow_optional_filename_cmd
758 (const char *name
, command_class theclass
, const char *set_doc
,
759 const char *show_doc
, const char *help_doc
,
760 setting_func_types
<std::string
>::set set_func
,
761 setting_func_types
<std::string
>::get get_func
,
762 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
763 cmd_list_element
**show_list
);
765 extern set_show_commands add_setshow_integer_cmd
766 (const char *name
, command_class theclass
, int *var
,
767 const literal_def
*extra_literals
, const char *set_doc
,
768 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
769 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
770 cmd_list_element
**show_list
);
772 extern set_show_commands add_setshow_integer_cmd
773 (const char *name
, command_class theclass
, const literal_def
*extra_literals
,
774 const char *set_doc
, const char *show_doc
, const char *help_doc
,
775 setting_func_types
<int>::set set_func
,
776 setting_func_types
<int>::get get_func
, show_value_ftype
*show_func
,
777 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
779 extern set_show_commands add_setshow_integer_cmd
780 (const char *name
, command_class theclass
, int *var
, const char *set_doc
,
781 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
782 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
783 cmd_list_element
**show_list
);
785 extern set_show_commands add_setshow_integer_cmd
786 (const char *name
, command_class theclass
, const char *set_doc
,
787 const char *show_doc
, const char *help_doc
,
788 setting_func_types
<int>::set set_func
,
789 setting_func_types
<int>::get get_func
, show_value_ftype
*show_func
,
790 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
792 extern set_show_commands add_setshow_pinteger_cmd
793 (const char *name
, command_class theclass
, int *var
,
794 const literal_def
*extra_literals
, const char *set_doc
,
795 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
796 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
797 cmd_list_element
**show_list
);
799 extern set_show_commands add_setshow_pinteger_cmd
800 (const char *name
, command_class theclass
, const literal_def
*extra_literals
,
801 const char *set_doc
, const char *show_doc
, const char *help_doc
,
802 setting_func_types
<int>::set set_func
,
803 setting_func_types
<int>::get get_func
, show_value_ftype
*show_func
,
804 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
806 extern set_show_commands add_setshow_uinteger_cmd
807 (const char *name
, command_class theclass
, unsigned int *var
,
808 const literal_def
*extra_literals
,
809 const char *set_doc
, const char *show_doc
, const char *help_doc
,
810 cmd_func_ftype
*set_func
, show_value_ftype
*show_func
,
811 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
813 extern set_show_commands add_setshow_uinteger_cmd
814 (const char *name
, command_class theclass
, const literal_def
*extra_literals
,
815 const char *set_doc
, const char *show_doc
, const char *help_doc
,
816 setting_func_types
<unsigned int>::set set_func
,
817 setting_func_types
<unsigned int>::get get_func
, show_value_ftype
*show_func
,
818 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
820 extern set_show_commands add_setshow_uinteger_cmd
821 (const char *name
, command_class theclass
, unsigned int *var
,
822 const char *set_doc
, const char *show_doc
, const char *help_doc
,
823 cmd_func_ftype
*set_func
, show_value_ftype
*show_func
,
824 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
826 extern set_show_commands add_setshow_uinteger_cmd
827 (const char *name
, command_class theclass
, const char *set_doc
,
828 const char *show_doc
, const char *help_doc
,
829 setting_func_types
<unsigned int>::set set_func
,
830 setting_func_types
<unsigned int>::get get_func
, show_value_ftype
*show_func
,
831 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
833 extern set_show_commands add_setshow_zinteger_cmd
834 (const char *name
, command_class theclass
, int *var
, const char *set_doc
,
835 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
836 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
837 cmd_list_element
**show_list
);
839 extern set_show_commands add_setshow_zinteger_cmd
840 (const char *name
, command_class theclass
, const char *set_doc
,
841 const char *show_doc
, const char *help_doc
,
842 setting_func_types
<int>::set set_func
,
843 setting_func_types
<int>::get get_func
, show_value_ftype
*show_func
,
844 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
846 extern set_show_commands add_setshow_zuinteger_cmd
847 (const char *name
, command_class theclass
, unsigned int *var
,
848 const char *set_doc
, const char *show_doc
, const char *help_doc
,
849 cmd_func_ftype
*set_func
, show_value_ftype
*show_func
,
850 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
852 extern set_show_commands add_setshow_zuinteger_cmd
853 (const char *name
, command_class theclass
, const char *set_doc
,
854 const char *show_doc
, const char *help_doc
,
855 setting_func_types
<unsigned int>::set set_func
,
856 setting_func_types
<unsigned int>::get get_func
, show_value_ftype
*show_func
,
857 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
859 extern set_show_commands add_setshow_zuinteger_unlimited_cmd
860 (const char *name
, command_class theclass
, int *var
, const char *set_doc
,
861 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
862 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
863 cmd_list_element
**show_list
);
865 extern set_show_commands add_setshow_zuinteger_unlimited_cmd
866 (const char *name
, command_class theclass
, const char *set_doc
,
867 const char *show_doc
, const char *help_doc
,
868 setting_func_types
<int>::set set_func
, setting_func_types
<int>::get get_func
,
869 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
870 cmd_list_element
**show_list
);
872 /* Do a "show" command for each thing on a command list. */
874 extern void cmd_show_list (struct cmd_list_element
*, int);
876 /* Used everywhere whenever at least one parameter is required and
877 none is specified. */
879 extern void error_no_arg (const char *) ATTRIBUTE_NORETURN
;
882 /* Command line saving and repetition.
883 Each input line executed is saved to possibly be repeated either
884 when the user types an empty line, or be repeated by a command
885 that wants to repeat the previously executed command. The below
886 functions control command repetition. */
888 /* Commands call dont_repeat if they do not want to be repeated by null
889 lines or by repeat_previous (). */
891 extern void dont_repeat ();
893 /* Commands call repeat_previous if they want to repeat the previous
894 command. Such commands that repeat the previous command must
895 indicate to not repeat themselves, to avoid recursive repeat.
896 repeat_previous marks the current command as not repeating, and
897 ensures get_saved_command_line returns the previous command, so
898 that the currently executing command can repeat it. If there's no
899 previous command, throws an error. Otherwise, returns the result
900 of get_saved_command_line, which now points at the command to
903 extern const char *repeat_previous ();
905 /* Prevent dont_repeat from working, and return a cleanup that
906 restores the previous state. */
908 extern scoped_restore_tmpl
<int> prevent_dont_repeat (void);
910 /* Set the arguments that will be passed if the current command is
911 repeated. Note that the passed-in string must be a constant. */
913 extern void set_repeat_arguments (const char *args
);
915 /* Returns the saved command line to repeat.
916 When a command is being executed, this is the currently executing
917 command line, unless the currently executing command has called
918 repeat_previous (): in this case, get_saved_command_line returns
919 the previously saved command line. */
921 extern char *get_saved_command_line ();
923 /* Takes a copy of CMD, for possible repetition. */
925 extern void save_command_line (const char *cmd
);
927 /* Used to mark commands that don't do anything. If we just leave the
928 function field NULL, the command is interpreted as a help topic, or
929 as a class of commands. */
931 extern void not_just_help_class_command (const char *, int);
933 /* Call the command function. */
934 extern void cmd_func (struct cmd_list_element
*cmd
,
935 const char *args
, int from_tty
);
937 #endif /* !defined (COMMAND_H) */