1 /* Header file for command creation.
3 Copyright (C) 1986-2022 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. */
74 typedef enum var_types
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. The user can type
88 0 to mean "unlimited", which is stored in *VAR as UINT_MAX. */
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. */
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. */
101 /* String which stores what the user types verbatim.
102 *VAR is std::string, "" if the string is empty. */
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. */
109 /* ZeroableInteger. *VAR is an int. Like var_integer except
110 that zero really means zero. */
112 /* ZeroableUnsignedInteger. *VAR is an unsigned int. Zero really
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
126 /* Return true if a setting of type VAR_TYPE is backed with type T.
128 This function is left without definition intentionally. This template is
129 specialized for all valid types that are used to back var_types. Therefore
130 if one tries to instantiate this un-specialized template it means the T
131 parameter is not a type used to back a var_type and it is most likely a
132 programming error. */
134 bool var_type_uses (var_types var_type
) = delete;
136 /* Return true if a setting of type T is backed by a bool variable. */
138 inline bool var_type_uses
<bool> (var_types t
)
140 return t
== var_boolean
;
143 /* Return true if a setting of type T is backed by a auto_boolean variable.
146 inline bool var_type_uses
<enum auto_boolean
> (var_types t
)
148 return t
== var_auto_boolean
;
151 /* Return true if a setting of type T is backed by an unsigned int variable.
154 inline bool var_type_uses
<unsigned int> (var_types t
)
156 return (t
== var_uinteger
|| t
== var_zinteger
|| t
== var_zuinteger
);
159 /* Return true if a setting of type T is backed by an int variable. */
161 inline bool var_type_uses
<int> (var_types t
)
163 return (t
== var_integer
|| t
== var_zinteger
164 || t
== var_zuinteger_unlimited
);
167 /* Return true if a setting of type T is backed by a std::string variable. */
169 inline bool var_type_uses
<std::string
> (var_types t
)
171 return (t
== var_string
|| t
== var_string_noescape
172 || t
== var_optional_filename
|| t
== var_filename
);
175 /* Return true if a setting of type T is backed by a const char * variable.
178 inline bool var_type_uses
<const char *> (var_types t
)
180 return t
== var_enum
;
183 template<bool is_scalar
, typename T
> struct setting_func_types_1
;
186 struct setting_func_types_1
<true, T
>
189 using set
= void (*) (type
);
190 using get
= type (*) ();
194 struct setting_func_types_1
<false, T
>
196 using type
= const T
&;
197 using set
= void (*) (type
);
198 using get
= type (*) ();
202 struct setting_func_types
204 using type
= typename setting_func_types_1
<std::is_scalar
<T
>::value
, T
>::type
;
205 using set
= typename setting_func_types_1
<std::is_scalar
<T
>::value
, T
>::set
;
206 using get
= typename setting_func_types_1
<std::is_scalar
<T
>::value
, T
>::get
;
209 /* Generic/type-erased function pointer. */
211 using erased_func
= void (*) ();
213 /* Interface for getting and setting a setting's value.
215 The underlying data can be of any VAR_TYPES type. */
218 /* Create a setting backed by a variable of type T.
220 Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */
222 setting (var_types var_type
, T
*var
)
223 : m_var_type (var_type
), m_var (var
)
225 gdb_assert (var
!= nullptr);
226 gdb_assert (var_type_uses
<T
> (var_type
));
229 /* A setting can also be constructed with a pre-validated
230 type-erased variable. Use the following function to
231 validate & type-erase said variable/function pointers. */
241 static erased_args
erase_args (var_types var_type
,
243 typename setting_func_types
<T
>::set set_setting_func
,
244 typename setting_func_types
<T
>::get get_setting_func
)
246 gdb_assert (var_type_uses
<T
> (var_type
));
247 /* The getter and the setter must be both provided or both omitted. */
249 ((set_setting_func
== nullptr) == (get_setting_func
== nullptr));
251 /* The caller must provide a pointer to a variable or get/set functions, but
253 gdb_assert ((set_setting_func
== nullptr) != (var
== nullptr));
257 reinterpret_cast<erased_func
> (set_setting_func
),
258 reinterpret_cast<erased_func
> (get_setting_func
)
262 /* Create a setting backed by pre-validated type-erased args.
263 ERASED_VAR's fields' real types must match the var type VAR_TYPE
264 (see VAR_TYPE_USES). */
265 setting (var_types var_type
, const erased_args
&args
)
266 : m_var_type (var_type
),
268 m_getter (args
.getter
),
269 m_setter (args
.setter
)
273 /* Create a setting backed by setter and getter functions.
275 Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */
277 setting (var_types var_type
,
278 typename setting_func_types
<T
>::set setter
,
279 typename setting_func_types
<T
>::get getter
)
280 : m_var_type (var_type
)
282 gdb_assert (var_type_uses
<T
> (var_type
));
284 /* Getters and setters are cast to and from the arbitrary `void (*) ()`
285 function pointer type. Make sure that the two types are really of the
287 gdb_static_assert (sizeof (m_getter
) == sizeof (getter
));
288 gdb_static_assert (sizeof (m_setter
) == sizeof (setter
));
290 m_getter
= reinterpret_cast<erased_func
> (getter
);
291 m_setter
= reinterpret_cast<erased_func
> (setter
);
294 /* Access the type of the current setting. */
295 var_types
type () const
296 { return m_var_type
; }
298 /* Return the current value.
300 The template parameter T is the type of the variable used to store the
303 typename setting_func_types
<T
>::type
get () const
305 gdb_assert (var_type_uses
<T
> (m_var_type
));
307 if (m_var
== nullptr)
309 gdb_assert (m_getter
!= nullptr);
310 auto getter
= reinterpret_cast<typename setting_func_types
<T
>::get
> (m_getter
);
314 return *static_cast<const T
*> (m_var
);
317 /* Sets the value of the setting to V. Returns true if the setting was
318 effectively changed, false if the update failed and the setting is left
321 If we have a user-provided setter, use it to set the setting. Otherwise
322 copy the value V to the internally referenced buffer.
324 The template parameter T indicates the type of the variable used to store
327 The var_type of the setting must match T. */
329 bool set (const T
&v
)
331 /* Check that the current instance is of one of the supported types for
332 this instantiation. */
333 gdb_assert (var_type_uses
<T
> (m_var_type
));
335 const T old_value
= this->get
<T
> ();
337 if (m_var
== nullptr)
339 gdb_assert (m_setter
!= nullptr);
340 auto setter
= reinterpret_cast<typename setting_func_types
<T
>::set
> (m_setter
);
344 *static_cast<T
*> (m_var
) = v
;
346 return old_value
!= this->get
<T
> ();
350 /* The type of the variable M_VAR is pointing to, or that M_GETTER / M_SETTER
352 var_types m_var_type
;
354 /* Pointer to the enclosed variable
356 Either M_VAR is non-nullptr, or both M_GETTER and M_SETTER are
358 void *m_var
= nullptr;
360 /* Pointer to a user provided getter. */
361 erased_func m_getter
= nullptr;
363 /* Pointer to a user provided setter. */
364 erased_func m_setter
= nullptr;
367 /* This structure records one command'd definition. */
368 struct cmd_list_element
;
370 /* The "simple" signature of command callbacks, which doesn't include a
371 cmd_list_element parameter. */
373 typedef void cmd_simple_func_ftype (const char *args
, int from_tty
);
375 /* This structure specifies notifications to be suppressed by a cli
376 command interpreter. */
378 struct cli_suppress_notification
380 /* Inferior, thread, frame selected notification suppressed? */
381 bool user_selected_context
= false;
383 /* Normal stop event suppressed? */
384 bool normal_stop
= false;
387 extern struct cli_suppress_notification cli_suppress_notification
;
389 /* Forward-declarations of the entry-points of cli/cli-decode.c. */
391 /* API to the manipulation of command lists. */
393 /* Return TRUE if NAME is a valid user-defined command name.
394 This is a stricter subset of all gdb commands,
395 see find_command_name_length. */
397 extern bool valid_user_defined_cmd_name_p (const char *name
);
399 /* Return TRUE if C is a valid command character. */
401 extern bool valid_cmd_char_p (int c
);
403 /* Return value type for the add_setshow_* functions. */
405 struct set_show_commands
407 cmd_list_element
*set
, *show
;
410 /* Const-correct variant of the above. */
412 extern struct cmd_list_element
*add_cmd (const char *, enum command_class
,
413 cmd_simple_func_ftype
*fun
,
415 struct cmd_list_element
**);
417 /* Like add_cmd, but no command function is specified. */
419 extern struct cmd_list_element
*add_cmd (const char *, enum command_class
,
421 struct cmd_list_element
**);
423 extern struct cmd_list_element
*add_cmd_suppress_notification
424 (const char *name
, enum command_class theclass
,
425 cmd_simple_func_ftype
*fun
, const char *doc
,
426 struct cmd_list_element
**list
,
427 bool *suppress_notification
);
429 extern struct cmd_list_element
*add_alias_cmd (const char *,
431 enum command_class
, int,
432 struct cmd_list_element
**);
435 extern struct cmd_list_element
*add_prefix_cmd (const char *, enum command_class
,
436 cmd_simple_func_ftype
*fun
,
438 struct cmd_list_element
**,
440 struct cmd_list_element
**);
442 /* Like add_prefix_cmd, but sets the callback to a function that
443 simply calls help_list. */
445 extern struct cmd_list_element
*add_basic_prefix_cmd
446 (const char *, enum command_class
, const char *, struct cmd_list_element
**,
447 int, struct cmd_list_element
**);
449 /* Like add_prefix_cmd, but useful for "show" prefixes. This sets the
450 callback to a function that simply calls cmd_show_list. */
452 extern struct cmd_list_element
*add_show_prefix_cmd
453 (const char *, enum command_class
, const char *, struct cmd_list_element
**,
454 int, struct cmd_list_element
**);
456 /* Add matching set and show commands using add_basic_prefix_cmd and
457 add_show_prefix_cmd. */
459 extern set_show_commands add_setshow_prefix_cmd
460 (const char *name
, command_class theclass
, const char *set_doc
,
461 const char *show_doc
,
462 cmd_list_element
**set_subcommands_list
,
463 cmd_list_element
**show_subcommands_list
,
464 cmd_list_element
**set_list
,
465 cmd_list_element
**show_list
);
467 extern struct cmd_list_element
*add_prefix_cmd_suppress_notification
468 (const char *name
, enum command_class theclass
,
469 cmd_simple_func_ftype
*fun
,
470 const char *doc
, struct cmd_list_element
**subcommands
,
472 struct cmd_list_element
**list
,
473 bool *suppress_notification
);
475 extern struct cmd_list_element
*add_abbrev_prefix_cmd (const char *,
477 cmd_simple_func_ftype
*fun
,
479 struct cmd_list_element
481 struct cmd_list_element
484 typedef void cmd_func_ftype (const char *args
, int from_tty
,
485 cmd_list_element
*c
);
487 /* A completion routine. Add possible completions to tracker.
489 TEXT is the text beyond what was matched for the command itself
490 (leading whitespace is skipped). It stops where we are supposed to
491 stop completing (rl_point) and is '\0' terminated. WORD points in
492 the same buffer as TEXT, and completions should be returned
493 relative to this position. For example, suppose TEXT is "foo" and
494 we want to complete to "foobar". If WORD is "oo", return "oobar";
495 if WORD is "baz/foo", return "baz/foobar". */
496 typedef void completer_ftype (struct cmd_list_element
*,
497 completion_tracker
&tracker
,
498 const char *text
, const char *word
);
500 /* Same, but for set_cmd_completer_handle_brkchars. */
501 typedef void completer_handle_brkchars_ftype (struct cmd_list_element
*,
502 completion_tracker
&tracker
,
503 const char *text
, const char *word
);
505 extern void set_cmd_completer (struct cmd_list_element
*, completer_ftype
*);
507 /* Set the completer_handle_brkchars callback. */
509 extern void set_cmd_completer_handle_brkchars (struct cmd_list_element
*,
510 completer_handle_brkchars_ftype
*);
512 /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
513 around in cmd objects to test the value of the commands sfunc(). */
514 extern int cmd_simple_func_eq (struct cmd_list_element
*cmd
,
515 cmd_simple_func_ftype
*cfun
);
517 /* Execute CMD's pre/post hook. Throw an error if the command fails.
518 If already executing this pre/post hook, or there is no pre/post
519 hook, the call is silently ignored. */
520 extern void execute_cmd_pre_hook (struct cmd_list_element
*cmd
);
521 extern void execute_cmd_post_hook (struct cmd_list_element
*cmd
);
523 /* Flag for an ambiguous cmd_list result. */
524 #define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1)
526 extern struct cmd_list_element
*lookup_cmd (const char **,
527 struct cmd_list_element
*,
532 /* This routine takes a line of TEXT and a CLIST in which to start the
533 lookup. When it returns it will have incremented the text pointer past
534 the section of text it matched, set *RESULT_LIST to point to the list in
535 which the last word was matched, and will return a pointer to the cmd
536 list element which the text matches. It will return NULL if no match at
537 all was possible. It will return -1 (cast appropriately, ick) if ambigous
538 matches are possible; in this case *RESULT_LIST will be set to point to
539 the list in which there are ambiguous choices (and *TEXT will be set to
540 the ambiguous text string).
542 if DEFAULT_ARGS is not null, *DEFAULT_ARGS is set to the found command
543 default args (possibly empty).
545 If the located command was an abbreviation, this routine returns the base
546 command of the abbreviation. Note that *DEFAULT_ARGS will contain the
547 default args defined for the alias.
549 It does no error reporting whatsoever; control will always return
550 to the superior routine.
552 In the case of an ambiguous return (-1), *RESULT_LIST will be set to point
553 at the prefix_command (ie. the best match) *or* (special case) will be NULL
554 if no prefix command was ever found. For example, in the case of "info a",
555 "info" matches without ambiguity, but "a" could be "args" or "address", so
556 *RESULT_LIST is set to the cmd_list_element for "info". So in this case
557 RESULT_LIST should not be interpreted as a pointer to the beginning of a
558 list; it simply points to a specific command. In the case of an ambiguous
559 return *TEXT is advanced past the last non-ambiguous prefix (e.g.
560 "info t" can be "info types" or "info target"; upon return *TEXT has been
561 advanced past "info ").
563 If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise
564 affect the operation).
566 This routine does *not* modify the text pointed to by TEXT.
568 If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which
569 are actually help classes rather than commands (i.e. the function field of
570 the struct cmd_list_element is NULL).
572 When LOOKUP_FOR_COMPLETION_P is true the completion is being requested
573 for the completion engine, no warnings should be printed. */
575 extern struct cmd_list_element
*lookup_cmd_1
576 (const char **text
, struct cmd_list_element
*clist
,
577 struct cmd_list_element
**result_list
, std::string
*default_args
,
578 int ignore_help_classes
, bool lookup_for_completion_p
= false);
580 /* Look up the command called NAME in the command list LIST.
582 Unlike LOOKUP_CMD, partial matches are ignored and only exact matches
583 on NAME are considered.
585 LIST is a chain of struct cmd_list_element's.
587 If IGNORE_HELP_CLASSES is true (the default), ignore any command list
588 elements which are actually help classes rather than commands (i.e.
589 the function field of the struct cmd_list_element is null).
591 If found, return the struct cmd_list_element for that command,
592 otherwise return NULLPTR. */
594 extern struct cmd_list_element
*lookup_cmd_exact
596 struct cmd_list_element
*list
,
597 bool ignore_help_classes
= true);
599 extern struct cmd_list_element
*deprecate_cmd (struct cmd_list_element
*,
602 extern void deprecated_cmd_warning (const char *, struct cmd_list_element
*);
604 extern int lookup_cmd_composition (const char *text
,
605 struct cmd_list_element
**alias
,
606 struct cmd_list_element
**prefix_cmd
,
607 struct cmd_list_element
**cmd
);
609 extern struct cmd_list_element
*add_com (const char *, enum command_class
,
610 cmd_simple_func_ftype
*fun
,
613 extern cmd_list_element
*add_com_alias (const char *name
,
614 cmd_list_element
*target
,
615 command_class theclass
,
618 extern struct cmd_list_element
*add_com_suppress_notification
619 (const char *name
, enum command_class theclass
,
620 cmd_simple_func_ftype
*fun
, const char *doc
,
621 bool *supress_notification
);
623 extern struct cmd_list_element
*add_info (const char *,
624 cmd_simple_func_ftype
*fun
,
627 extern cmd_list_element
*add_info_alias (const char *name
,
628 cmd_list_element
*target
,
631 extern void complete_on_cmdlist (struct cmd_list_element
*,
632 completion_tracker
&tracker
,
633 const char *, const char *, int);
635 extern void complete_on_enum (completion_tracker
&tracker
,
636 const char *const *enumlist
,
637 const char *, const char *);
639 /* Functions that implement commands about CLI commands. */
641 extern void help_list (struct cmd_list_element
*, const char *,
642 enum command_class
, struct ui_file
*);
644 /* Method for show a set/show variable's VALUE on FILE. If this
645 method isn't supplied deprecated_show_value_hack() is called (which
647 typedef void (show_value_ftype
) (struct ui_file
*file
,
649 struct cmd_list_element
*cmd
,
651 /* NOTE: i18n: This function is not i18n friendly. Callers should
652 instead print the value out directly. */
653 extern show_value_ftype deprecated_show_value_hack
;
655 extern set_show_commands add_setshow_enum_cmd
656 (const char *name
, command_class theclass
, const char *const *enumlist
,
657 const char **var
, const char *set_doc
, const char *show_doc
,
658 const char *help_doc
, cmd_func_ftype
*set_func
,
659 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
660 cmd_list_element
**show_list
);
662 extern set_show_commands add_setshow_enum_cmd
663 (const char *name
, command_class theclass
, const char *const *enumlist
,
664 const char *set_doc
, const char *show_doc
,
665 const char *help_doc
, setting_func_types
<const char *>::set set_func
,
666 setting_func_types
<const char *>::get get_func
, show_value_ftype
*show_func
,
667 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
669 extern set_show_commands add_setshow_auto_boolean_cmd
670 (const char *name
, command_class theclass
, auto_boolean
*var
,
671 const char *set_doc
, const char *show_doc
, const char *help_doc
,
672 cmd_func_ftype
*set_func
, show_value_ftype
*show_func
,
673 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
675 extern set_show_commands add_setshow_auto_boolean_cmd
676 (const char *name
, command_class theclass
, const char *set_doc
,
677 const char *show_doc
, const char *help_doc
,
678 setting_func_types
<enum auto_boolean
>::set set_func
,
679 setting_func_types
<enum auto_boolean
>::get get_func
,
680 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
681 cmd_list_element
**show_list
);
683 extern set_show_commands add_setshow_boolean_cmd
684 (const char *name
, command_class theclass
, bool *var
, const char *set_doc
,
685 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_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_boolean_cmd
690 (const char *name
, command_class theclass
, const char *set_doc
,
691 const char *show_doc
, const char *help_doc
,
692 setting_func_types
<bool>::set set_func
,
693 setting_func_types
<bool>::get get_func
, show_value_ftype
*show_func
,
694 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
696 extern set_show_commands add_setshow_filename_cmd
697 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
698 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
699 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
700 cmd_list_element
**show_list
);
702 extern set_show_commands add_setshow_filename_cmd
703 (const char *name
, command_class theclass
, const char *set_doc
,
704 const char *show_doc
, const char *help_doc
,
705 setting_func_types
<std::string
>::set set_func
,
706 setting_func_types
<std::string
>::get get_func
, show_value_ftype
*show_func
,
707 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
709 extern set_show_commands add_setshow_string_cmd
710 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
711 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
712 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
713 cmd_list_element
**show_list
);
715 extern set_show_commands add_setshow_string_cmd
716 (const char *name
, command_class theclass
, const char *set_doc
,
717 const char *show_doc
, const char *help_doc
,
718 setting_func_types
<std::string
>::set set_func
,
719 setting_func_types
<std::string
>::get get_func
,
720 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
721 cmd_list_element
**show_list
);
723 extern set_show_commands add_setshow_string_noescape_cmd
724 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
725 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
726 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
727 cmd_list_element
**show_list
);
729 extern set_show_commands add_setshow_string_noescape_cmd
730 (const char *name
, command_class theclass
, const char *set_doc
,
731 const char *show_doc
, const char *help_doc
,
732 setting_func_types
<std::string
>::set set_func
,
733 setting_func_types
<std::string
>::get get_func
, show_value_ftype
*show_func
,
734 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
736 extern set_show_commands add_setshow_optional_filename_cmd
737 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
738 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
739 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
740 cmd_list_element
**show_list
);
742 extern set_show_commands add_setshow_optional_filename_cmd
743 (const char *name
, command_class theclass
, const char *set_doc
,
744 const char *show_doc
, const char *help_doc
,
745 setting_func_types
<std::string
>::set set_func
,
746 setting_func_types
<std::string
>::get get_func
,
747 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
748 cmd_list_element
**show_list
);
750 extern set_show_commands add_setshow_integer_cmd
751 (const char *name
, command_class theclass
, int *var
, const char *set_doc
,
752 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
753 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
754 cmd_list_element
**show_list
);
756 extern set_show_commands add_setshow_integer_cmd
757 (const char *name
, command_class theclass
, const char *set_doc
,
758 const char *show_doc
, const char *help_doc
,
759 setting_func_types
<int>::set set_func
,
760 setting_func_types
<int>::get get_func
, show_value_ftype
*show_func
,
761 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
763 extern set_show_commands add_setshow_uinteger_cmd
764 (const char *name
, command_class theclass
, unsigned int *var
,
765 const char *set_doc
, const char *show_doc
, const char *help_doc
,
766 cmd_func_ftype
*set_func
, show_value_ftype
*show_func
,
767 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
769 extern set_show_commands add_setshow_uinteger_cmd
770 (const char *name
, command_class theclass
, const char *set_doc
,
771 const char *show_doc
, const char *help_doc
,
772 setting_func_types
<unsigned int>::set set_func
,
773 setting_func_types
<unsigned int>::get get_func
, show_value_ftype
*show_func
,
774 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
776 extern set_show_commands add_setshow_zinteger_cmd
777 (const char *name
, command_class theclass
, int *var
, const char *set_doc
,
778 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
779 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
780 cmd_list_element
**show_list
);
782 extern set_show_commands add_setshow_zinteger_cmd
783 (const char *name
, command_class theclass
, const char *set_doc
,
784 const char *show_doc
, const char *help_doc
,
785 setting_func_types
<int>::set set_func
,
786 setting_func_types
<int>::get get_func
, show_value_ftype
*show_func
,
787 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
789 extern set_show_commands add_setshow_zuinteger_cmd
790 (const char *name
, command_class theclass
, unsigned int *var
,
791 const char *set_doc
, const char *show_doc
, const char *help_doc
,
792 cmd_func_ftype
*set_func
, show_value_ftype
*show_func
,
793 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
795 extern set_show_commands add_setshow_zuinteger_cmd
796 (const char *name
, command_class theclass
, const char *set_doc
,
797 const char *show_doc
, const char *help_doc
,
798 setting_func_types
<unsigned int>::set set_func
,
799 setting_func_types
<unsigned int>::get get_func
, show_value_ftype
*show_func
,
800 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
802 extern set_show_commands add_setshow_zuinteger_unlimited_cmd
803 (const char *name
, command_class theclass
, int *var
, const char *set_doc
,
804 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
805 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
806 cmd_list_element
**show_list
);
808 extern set_show_commands add_setshow_zuinteger_unlimited_cmd
809 (const char *name
, command_class theclass
, const char *set_doc
,
810 const char *show_doc
, const char *help_doc
,
811 setting_func_types
<int>::set set_func
, setting_func_types
<int>::get get_func
,
812 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
813 cmd_list_element
**show_list
);
815 /* Do a "show" command for each thing on a command list. */
817 extern void cmd_show_list (struct cmd_list_element
*, int);
819 /* Used everywhere whenever at least one parameter is required and
820 none is specified. */
822 extern void error_no_arg (const char *) ATTRIBUTE_NORETURN
;
825 /* Command line saving and repetition.
826 Each input line executed is saved to possibly be repeated either
827 when the user types an empty line, or be repeated by a command
828 that wants to repeat the previously executed command. The below
829 functions control command repetition. */
831 /* Commands call dont_repeat if they do not want to be repeated by null
832 lines or by repeat_previous (). */
834 extern void dont_repeat ();
836 /* Commands call repeat_previous if they want to repeat the previous
837 command. Such commands that repeat the previous command must
838 indicate to not repeat themselves, to avoid recursive repeat.
839 repeat_previous marks the current command as not repeating, and
840 ensures get_saved_command_line returns the previous command, so
841 that the currently executing command can repeat it. If there's no
842 previous command, throws an error. Otherwise, returns the result
843 of get_saved_command_line, which now points at the command to
846 extern const char *repeat_previous ();
848 /* Prevent dont_repeat from working, and return a cleanup that
849 restores the previous state. */
851 extern scoped_restore_tmpl
<int> prevent_dont_repeat (void);
853 /* Set the arguments that will be passed if the current command is
854 repeated. Note that the passed-in string must be a constant. */
856 extern void set_repeat_arguments (const char *args
);
858 /* Returns the saved command line to repeat.
859 When a command is being executed, this is the currently executing
860 command line, unless the currently executing command has called
861 repeat_previous (): in this case, get_saved_command_line returns
862 the previously saved command line. */
864 extern char *get_saved_command_line ();
866 /* Takes a copy of CMD, for possible repetition. */
868 extern void save_command_line (const char *cmd
);
870 /* Used to mark commands that don't do anything. If we just leave the
871 function field NULL, the command is interpreted as a help topic, or
872 as a class of commands. */
874 extern void not_just_help_class_command (const char *, int);
876 /* Call the command function. */
877 extern void cmd_func (struct cmd_list_element
*cmd
,
878 const char *args
, int from_tty
);
880 #endif /* !defined (COMMAND_H) */