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;
384 extern struct cli_suppress_notification cli_suppress_notification
;
386 /* Forward-declarations of the entry-points of cli/cli-decode.c. */
388 /* API to the manipulation of command lists. */
390 /* Return TRUE if NAME is a valid user-defined command name.
391 This is a stricter subset of all gdb commands,
392 see find_command_name_length. */
394 extern bool valid_user_defined_cmd_name_p (const char *name
);
396 /* Return TRUE if C is a valid command character. */
398 extern bool valid_cmd_char_p (int c
);
400 /* Return value type for the add_setshow_* functions. */
402 struct set_show_commands
404 cmd_list_element
*set
, *show
;
407 /* Const-correct variant of the above. */
409 extern struct cmd_list_element
*add_cmd (const char *, enum command_class
,
410 cmd_simple_func_ftype
*fun
,
412 struct cmd_list_element
**);
414 /* Like add_cmd, but no command function is specified. */
416 extern struct cmd_list_element
*add_cmd (const char *, enum command_class
,
418 struct cmd_list_element
**);
420 extern struct cmd_list_element
*add_cmd_suppress_notification
421 (const char *name
, enum command_class theclass
,
422 cmd_simple_func_ftype
*fun
, const char *doc
,
423 struct cmd_list_element
**list
,
424 bool *suppress_notification
);
426 extern struct cmd_list_element
*add_alias_cmd (const char *,
428 enum command_class
, int,
429 struct cmd_list_element
**);
432 extern struct cmd_list_element
*add_prefix_cmd (const char *, enum command_class
,
433 cmd_simple_func_ftype
*fun
,
435 struct cmd_list_element
**,
437 struct cmd_list_element
**);
439 /* Like add_prefix_cmd, but sets the callback to a function that
440 simply calls help_list. */
442 extern struct cmd_list_element
*add_basic_prefix_cmd
443 (const char *, enum command_class
, const char *, struct cmd_list_element
**,
444 int, struct cmd_list_element
**);
446 /* Like add_prefix_cmd, but useful for "show" prefixes. This sets the
447 callback to a function that simply calls cmd_show_list. */
449 extern struct cmd_list_element
*add_show_prefix_cmd
450 (const char *, enum command_class
, const char *, struct cmd_list_element
**,
451 int, struct cmd_list_element
**);
453 /* Add matching set and show commands using add_basic_prefix_cmd and
454 add_show_prefix_cmd. */
456 extern set_show_commands add_setshow_prefix_cmd
457 (const char *name
, command_class theclass
, const char *set_doc
,
458 const char *show_doc
,
459 cmd_list_element
**set_subcommands_list
,
460 cmd_list_element
**show_subcommands_list
,
461 cmd_list_element
**set_list
,
462 cmd_list_element
**show_list
);
464 extern struct cmd_list_element
*add_prefix_cmd_suppress_notification
465 (const char *name
, enum command_class theclass
,
466 cmd_simple_func_ftype
*fun
,
467 const char *doc
, struct cmd_list_element
**subcommands
,
469 struct cmd_list_element
**list
,
470 bool *suppress_notification
);
472 extern struct cmd_list_element
*add_abbrev_prefix_cmd (const char *,
474 cmd_simple_func_ftype
*fun
,
476 struct cmd_list_element
478 struct cmd_list_element
481 typedef void cmd_func_ftype (const char *args
, int from_tty
,
482 cmd_list_element
*c
);
484 /* A completion routine. Add possible completions to tracker.
486 TEXT is the text beyond what was matched for the command itself
487 (leading whitespace is skipped). It stops where we are supposed to
488 stop completing (rl_point) and is '\0' terminated. WORD points in
489 the same buffer as TEXT, and completions should be returned
490 relative to this position. For example, suppose TEXT is "foo" and
491 we want to complete to "foobar". If WORD is "oo", return "oobar";
492 if WORD is "baz/foo", return "baz/foobar". */
493 typedef void completer_ftype (struct cmd_list_element
*,
494 completion_tracker
&tracker
,
495 const char *text
, const char *word
);
497 /* Same, but for set_cmd_completer_handle_brkchars. */
498 typedef void completer_handle_brkchars_ftype (struct cmd_list_element
*,
499 completion_tracker
&tracker
,
500 const char *text
, const char *word
);
502 extern void set_cmd_completer (struct cmd_list_element
*, completer_ftype
*);
504 /* Set the completer_handle_brkchars callback. */
506 extern void set_cmd_completer_handle_brkchars (struct cmd_list_element
*,
507 completer_handle_brkchars_ftype
*);
509 /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
510 around in cmd objects to test the value of the commands sfunc(). */
511 extern int cmd_simple_func_eq (struct cmd_list_element
*cmd
,
512 cmd_simple_func_ftype
*cfun
);
514 /* Execute CMD's pre/post hook. Throw an error if the command fails.
515 If already executing this pre/post hook, or there is no pre/post
516 hook, the call is silently ignored. */
517 extern void execute_cmd_pre_hook (struct cmd_list_element
*cmd
);
518 extern void execute_cmd_post_hook (struct cmd_list_element
*cmd
);
520 /* Flag for an ambiguous cmd_list result. */
521 #define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1)
523 extern struct cmd_list_element
*lookup_cmd (const char **,
524 struct cmd_list_element
*,
529 /* This routine takes a line of TEXT and a CLIST in which to start the
530 lookup. When it returns it will have incremented the text pointer past
531 the section of text it matched, set *RESULT_LIST to point to the list in
532 which the last word was matched, and will return a pointer to the cmd
533 list element which the text matches. It will return NULL if no match at
534 all was possible. It will return -1 (cast appropriately, ick) if ambigous
535 matches are possible; in this case *RESULT_LIST will be set to point to
536 the list in which there are ambiguous choices (and *TEXT will be set to
537 the ambiguous text string).
539 if DEFAULT_ARGS is not null, *DEFAULT_ARGS is set to the found command
540 default args (possibly empty).
542 If the located command was an abbreviation, this routine returns the base
543 command of the abbreviation. Note that *DEFAULT_ARGS will contain the
544 default args defined for the alias.
546 It does no error reporting whatsoever; control will always return
547 to the superior routine.
549 In the case of an ambiguous return (-1), *RESULT_LIST will be set to point
550 at the prefix_command (ie. the best match) *or* (special case) will be NULL
551 if no prefix command was ever found. For example, in the case of "info a",
552 "info" matches without ambiguity, but "a" could be "args" or "address", so
553 *RESULT_LIST is set to the cmd_list_element for "info". So in this case
554 RESULT_LIST should not be interpreted as a pointer to the beginning of a
555 list; it simply points to a specific command. In the case of an ambiguous
556 return *TEXT is advanced past the last non-ambiguous prefix (e.g.
557 "info t" can be "info types" or "info target"; upon return *TEXT has been
558 advanced past "info ").
560 If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise
561 affect the operation).
563 This routine does *not* modify the text pointed to by TEXT.
565 If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which
566 are actually help classes rather than commands (i.e. the function field of
567 the struct cmd_list_element is NULL).
569 When LOOKUP_FOR_COMPLETION_P is true the completion is being requested
570 for the completion engine, no warnings should be printed. */
572 extern struct cmd_list_element
*lookup_cmd_1
573 (const char **text
, struct cmd_list_element
*clist
,
574 struct cmd_list_element
**result_list
, std::string
*default_args
,
575 int ignore_help_classes
, bool lookup_for_completion_p
= false);
577 /* Look up the command called NAME in the command list LIST.
579 Unlike LOOKUP_CMD, partial matches are ignored and only exact matches
580 on NAME are considered.
582 LIST is a chain of struct cmd_list_element's.
584 If IGNORE_HELP_CLASSES is true (the default), ignore any command list
585 elements which are actually help classes rather than commands (i.e.
586 the function field of the struct cmd_list_element is null).
588 If found, return the struct cmd_list_element for that command,
589 otherwise return NULLPTR. */
591 extern struct cmd_list_element
*lookup_cmd_exact
593 struct cmd_list_element
*list
,
594 bool ignore_help_classes
= true);
596 extern struct cmd_list_element
*deprecate_cmd (struct cmd_list_element
*,
599 extern void deprecated_cmd_warning (const char *, struct cmd_list_element
*);
601 extern int lookup_cmd_composition (const char *text
,
602 struct cmd_list_element
**alias
,
603 struct cmd_list_element
**prefix_cmd
,
604 struct cmd_list_element
**cmd
);
606 extern struct cmd_list_element
*add_com (const char *, enum command_class
,
607 cmd_simple_func_ftype
*fun
,
610 extern cmd_list_element
*add_com_alias (const char *name
,
611 cmd_list_element
*target
,
612 command_class theclass
,
615 extern struct cmd_list_element
*add_com_suppress_notification
616 (const char *name
, enum command_class theclass
,
617 cmd_simple_func_ftype
*fun
, const char *doc
,
618 bool *supress_notification
);
620 extern struct cmd_list_element
*add_info (const char *,
621 cmd_simple_func_ftype
*fun
,
624 extern cmd_list_element
*add_info_alias (const char *name
,
625 cmd_list_element
*target
,
628 extern void complete_on_cmdlist (struct cmd_list_element
*,
629 completion_tracker
&tracker
,
630 const char *, const char *, int);
632 extern void complete_on_enum (completion_tracker
&tracker
,
633 const char *const *enumlist
,
634 const char *, const char *);
636 /* Functions that implement commands about CLI commands. */
638 extern void help_list (struct cmd_list_element
*, const char *,
639 enum command_class
, struct ui_file
*);
641 /* Method for show a set/show variable's VALUE on FILE. If this
642 method isn't supplied deprecated_show_value_hack() is called (which
644 typedef void (show_value_ftype
) (struct ui_file
*file
,
646 struct cmd_list_element
*cmd
,
648 /* NOTE: i18n: This function is not i18n friendly. Callers should
649 instead print the value out directly. */
650 extern show_value_ftype deprecated_show_value_hack
;
652 extern set_show_commands add_setshow_enum_cmd
653 (const char *name
, command_class theclass
, const char *const *enumlist
,
654 const char **var
, const char *set_doc
, const char *show_doc
,
655 const char *help_doc
, cmd_func_ftype
*set_func
,
656 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
657 cmd_list_element
**show_list
);
659 extern set_show_commands add_setshow_enum_cmd
660 (const char *name
, command_class theclass
, const char *const *enumlist
,
661 const char *set_doc
, const char *show_doc
,
662 const char *help_doc
, setting_func_types
<const char *>::set set_func
,
663 setting_func_types
<const char *>::get get_func
, show_value_ftype
*show_func
,
664 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
666 extern set_show_commands add_setshow_auto_boolean_cmd
667 (const char *name
, command_class theclass
, auto_boolean
*var
,
668 const char *set_doc
, const char *show_doc
, const char *help_doc
,
669 cmd_func_ftype
*set_func
, show_value_ftype
*show_func
,
670 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
672 extern set_show_commands add_setshow_auto_boolean_cmd
673 (const char *name
, command_class theclass
, const char *set_doc
,
674 const char *show_doc
, const char *help_doc
,
675 setting_func_types
<enum auto_boolean
>::set set_func
,
676 setting_func_types
<enum auto_boolean
>::get get_func
,
677 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
678 cmd_list_element
**show_list
);
680 extern set_show_commands add_setshow_boolean_cmd
681 (const char *name
, command_class theclass
, bool *var
, const char *set_doc
,
682 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
683 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
684 cmd_list_element
**show_list
);
686 extern set_show_commands add_setshow_boolean_cmd
687 (const char *name
, command_class theclass
, const char *set_doc
,
688 const char *show_doc
, const char *help_doc
,
689 setting_func_types
<bool>::set set_func
,
690 setting_func_types
<bool>::get get_func
, show_value_ftype
*show_func
,
691 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
693 extern set_show_commands add_setshow_filename_cmd
694 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
695 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
696 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
697 cmd_list_element
**show_list
);
699 extern set_show_commands add_setshow_filename_cmd
700 (const char *name
, command_class theclass
, const char *set_doc
,
701 const char *show_doc
, const char *help_doc
,
702 setting_func_types
<std::string
>::set set_func
,
703 setting_func_types
<std::string
>::get get_func
, show_value_ftype
*show_func
,
704 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
706 extern set_show_commands add_setshow_string_cmd
707 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
708 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
709 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
710 cmd_list_element
**show_list
);
712 extern set_show_commands add_setshow_string_cmd
713 (const char *name
, command_class theclass
, const char *set_doc
,
714 const char *show_doc
, const char *help_doc
,
715 setting_func_types
<std::string
>::set set_func
,
716 setting_func_types
<std::string
>::get get_func
,
717 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
718 cmd_list_element
**show_list
);
720 extern set_show_commands add_setshow_string_noescape_cmd
721 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
722 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
723 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
724 cmd_list_element
**show_list
);
726 extern set_show_commands add_setshow_string_noescape_cmd
727 (const char *name
, command_class theclass
, const char *set_doc
,
728 const char *show_doc
, const char *help_doc
,
729 setting_func_types
<std::string
>::set set_func
,
730 setting_func_types
<std::string
>::get get_func
, show_value_ftype
*show_func
,
731 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
733 extern set_show_commands add_setshow_optional_filename_cmd
734 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
735 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
736 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
737 cmd_list_element
**show_list
);
739 extern set_show_commands add_setshow_optional_filename_cmd
740 (const char *name
, command_class theclass
, const char *set_doc
,
741 const char *show_doc
, const char *help_doc
,
742 setting_func_types
<std::string
>::set set_func
,
743 setting_func_types
<std::string
>::get get_func
,
744 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
745 cmd_list_element
**show_list
);
747 extern set_show_commands add_setshow_integer_cmd
748 (const char *name
, command_class theclass
, int *var
, const char *set_doc
,
749 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
750 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
751 cmd_list_element
**show_list
);
753 extern set_show_commands add_setshow_integer_cmd
754 (const char *name
, command_class theclass
, const char *set_doc
,
755 const char *show_doc
, const char *help_doc
,
756 setting_func_types
<int>::set set_func
,
757 setting_func_types
<int>::get get_func
, show_value_ftype
*show_func
,
758 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
760 extern set_show_commands add_setshow_uinteger_cmd
761 (const char *name
, command_class theclass
, unsigned int *var
,
762 const char *set_doc
, const char *show_doc
, const char *help_doc
,
763 cmd_func_ftype
*set_func
, show_value_ftype
*show_func
,
764 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
766 extern set_show_commands add_setshow_uinteger_cmd
767 (const char *name
, command_class theclass
, const char *set_doc
,
768 const char *show_doc
, const char *help_doc
,
769 setting_func_types
<unsigned int>::set set_func
,
770 setting_func_types
<unsigned int>::get get_func
, show_value_ftype
*show_func
,
771 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
773 extern set_show_commands add_setshow_zinteger_cmd
774 (const char *name
, command_class theclass
, int *var
, const char *set_doc
,
775 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
776 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
777 cmd_list_element
**show_list
);
779 extern set_show_commands add_setshow_zinteger_cmd
780 (const char *name
, command_class theclass
, const char *set_doc
,
781 const char *show_doc
, const char *help_doc
,
782 setting_func_types
<int>::set set_func
,
783 setting_func_types
<int>::get get_func
, show_value_ftype
*show_func
,
784 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
786 extern set_show_commands add_setshow_zuinteger_cmd
787 (const char *name
, command_class theclass
, unsigned int *var
,
788 const char *set_doc
, const char *show_doc
, const char *help_doc
,
789 cmd_func_ftype
*set_func
, show_value_ftype
*show_func
,
790 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
792 extern set_show_commands add_setshow_zuinteger_cmd
793 (const char *name
, command_class theclass
, const char *set_doc
,
794 const char *show_doc
, const char *help_doc
,
795 setting_func_types
<unsigned int>::set set_func
,
796 setting_func_types
<unsigned int>::get get_func
, show_value_ftype
*show_func
,
797 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
799 extern set_show_commands add_setshow_zuinteger_unlimited_cmd
800 (const char *name
, command_class theclass
, int *var
, const char *set_doc
,
801 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
802 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
803 cmd_list_element
**show_list
);
805 extern set_show_commands add_setshow_zuinteger_unlimited_cmd
806 (const char *name
, command_class theclass
, const char *set_doc
,
807 const char *show_doc
, const char *help_doc
,
808 setting_func_types
<int>::set set_func
, setting_func_types
<int>::get get_func
,
809 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
810 cmd_list_element
**show_list
);
812 /* Do a "show" command for each thing on a command list. */
814 extern void cmd_show_list (struct cmd_list_element
*, int);
816 /* Used everywhere whenever at least one parameter is required and
817 none is specified. */
819 extern void error_no_arg (const char *) ATTRIBUTE_NORETURN
;
822 /* Command line saving and repetition.
823 Each input line executed is saved to possibly be repeated either
824 when the user types an empty line, or be repeated by a command
825 that wants to repeat the previously executed command. The below
826 functions control command repetition. */
828 /* Commands call dont_repeat if they do not want to be repeated by null
829 lines or by repeat_previous (). */
831 extern void dont_repeat ();
833 /* Commands call repeat_previous if they want to repeat the previous
834 command. Such commands that repeat the previous command must
835 indicate to not repeat themselves, to avoid recursive repeat.
836 repeat_previous marks the current command as not repeating, and
837 ensures get_saved_command_line returns the previous command, so
838 that the currently executing command can repeat it. If there's no
839 previous command, throws an error. Otherwise, returns the result
840 of get_saved_command_line, which now points at the command to
843 extern const char *repeat_previous ();
845 /* Prevent dont_repeat from working, and return a cleanup that
846 restores the previous state. */
848 extern scoped_restore_tmpl
<int> prevent_dont_repeat (void);
850 /* Set the arguments that will be passed if the current command is
851 repeated. Note that the passed-in string must be a constant. */
853 extern void set_repeat_arguments (const char *args
);
855 /* Returns the saved command line to repeat.
856 When a command is being executed, this is the currently executing
857 command line, unless the currently executing command has called
858 repeat_previous (): in this case, get_saved_command_line returns
859 the previously saved command line. */
861 extern char *get_saved_command_line ();
863 /* Takes a copy of CMD, for possible repetition. */
865 extern void save_command_line (const char *cmd
);
867 /* Used to mark commands that don't do anything. If we just leave the
868 function field NULL, the command is interpreted as a help topic, or
869 as a class of commands. */
871 extern void not_just_help_class_command (const char *, int);
873 /* Call the command function. */
874 extern void cmd_func (struct cmd_list_element
*cmd
,
875 const char *args
, int from_tty
);
877 #endif /* !defined (COMMAND_H) */