1 /* Header file for command creation.
3 Copyright (C) 1986-2021 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 #if !defined (COMMAND_H)
21 #include "gdbsupport/gdb_vecs.h"
22 #include "gdbsupport/scoped_restore.h"
24 struct completion_tracker
;
26 /* This file defines the public interface for any code wanting to
29 /* Command classes are top-level categories into which commands are
30 broken down for "help" purposes.
32 The class_alias is used for the user-defined aliases, defined
33 using the "alias" command.
35 Aliases pre-defined by GDB (e.g. the alias "bt" of the "backtrace" command)
36 are not using the class_alias.
37 Different pre-defined aliases of the same command do not necessarily
38 have the same classes. For example, class_stack is used for the
39 "backtrace" and its "bt" alias", while "info stack" (also an alias
40 of "backtrace" uses class_info. */
44 /* Classes of commands followed by a comment giving the name
45 to use in "help <classname>".
46 Note that help accepts unambiguous abbreviated class names. */
48 /* Special classes to help_list */
49 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 /* Function signature for a callback used to get a value from a setting. */
186 using setting_getter_ftype
= const T
&(*) ();
188 /* Function signature for a callback used to set a value to a setting. */
191 using setting_setter_ftype
= void (*) (const T
&);
193 /* Generic/type-erased function pointer. */
195 using erased_func
= void (*) ();
197 /* Interface for getting and setting a setting's value.
199 The underlying data can be of any VAR_TYPES type. */
202 /* Create a setting backed by a variable of type T.
204 Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */
206 setting (var_types var_type
, T
*var
)
207 : m_var_type (var_type
), m_var (var
)
209 gdb_assert (var
!= nullptr);
210 gdb_assert (var_type_uses
<T
> (var_type
));
213 /* A setting can also be constructed with a pre-validated
214 type-erased variable. Use the following function to
215 validate & type-erase said variable/function pointers. */
225 static erased_args
erase_args (var_types var_type
,
227 setting_setter_ftype
<T
> set_setting_func
,
228 setting_getter_ftype
<T
> get_setting_func
)
230 gdb_assert (var_type_uses
<T
> (var_type
));
231 /* The getter and the setter must be both provided or both omitted. */
233 ((set_setting_func
== nullptr) == (get_setting_func
== nullptr));
235 /* The caller must provide a pointer to a variable or get/set functions, but
237 gdb_assert ((set_setting_func
== nullptr) != (var
== nullptr));
241 reinterpret_cast<erased_func
> (set_setting_func
),
242 reinterpret_cast<erased_func
> (get_setting_func
)
246 /* Create a setting backed by pre-validated type-erased args.
247 ERASED_VAR's fields' real types must match the var type VAR_TYPE
248 (see VAR_TYPE_USES). */
249 setting (var_types var_type
, const erased_args
&args
)
250 : m_var_type (var_type
),
252 m_getter (args
.getter
),
253 m_setter (args
.setter
)
257 /* Create a setting backed by setter and getter functions.
259 Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */
261 setting (var_types var_type
,
262 setting_setter_ftype
<T
> setter
,
263 setting_getter_ftype
<T
> getter
)
264 : m_var_type (var_type
)
266 gdb_assert (var_type_uses
<T
> (var_type
));
268 /* Getters and setters are cast to and from the arbitrary `void (*) ()`
269 function pointer type. Make sure that the two types are really of the
271 gdb_static_assert (sizeof (m_getter
) == sizeof (getter
));
272 gdb_static_assert (sizeof (m_setter
) == sizeof (setter
));
274 m_getter
= reinterpret_cast<erased_func
> (getter
);
275 m_setter
= reinterpret_cast<erased_func
> (setter
);
278 /* Access the type of the current setting. */
279 var_types
type () const
280 { return m_var_type
; }
282 /* Return the current value.
284 The template parameter T is the type of the variable used to store the
287 const T
&get () const
289 gdb_assert (var_type_uses
<T
> (m_var_type
));
291 if (m_var
== nullptr)
293 gdb_assert (m_getter
!= nullptr);
294 auto getter
= reinterpret_cast<setting_getter_ftype
<T
>> (m_getter
);
298 return *static_cast<const T
*> (m_var
);
301 /* Sets the value of the setting to V. Returns true if the setting was
302 effectively changed, false if the update failed and the setting is left
305 If we have a user-provided setter, use it to set the setting. Otherwise
306 copy the value V to the internally referenced buffer.
308 The template parameter T indicates the type of the variable used to store
311 The var_type of the setting must match T. */
313 bool set (const T
&v
)
315 /* Check that the current instance is of one of the supported types for
316 this instantiation. */
317 gdb_assert (var_type_uses
<T
> (m_var_type
));
319 const T old_value
= this->get
<T
> ();
321 if (m_var
== nullptr)
323 gdb_assert (m_setter
!= nullptr);
324 auto setter
= reinterpret_cast<setting_setter_ftype
<T
>> (m_setter
);
328 *static_cast<T
*> (m_var
) = v
;
330 return old_value
!= this->get
<T
> ();
334 /* The type of the variable M_VAR is pointing to, or that M_GETTER / M_SETTER
336 var_types m_var_type
;
338 /* Pointer to the enclosed variable
340 Either M_VAR is non-nullptr, or both M_GETTER and M_SETTER are
342 void *m_var
= nullptr;
344 /* Pointer to a user provided getter. */
345 erased_func m_getter
= nullptr;
347 /* Pointer to a user provided setter. */
348 erased_func m_setter
= nullptr;
351 /* This structure records one command'd definition. */
352 struct cmd_list_element
;
354 /* The "simple" signature of command callbacks, which doesn't include a
355 cmd_list_element parameter. */
357 typedef void cmd_simple_func_ftype (const char *args
, int from_tty
);
359 /* This structure specifies notifications to be suppressed by a cli
360 command interpreter. */
362 struct cli_suppress_notification
364 /* Inferior, thread, frame selected notification suppressed? */
365 int user_selected_context
;
368 extern struct cli_suppress_notification cli_suppress_notification
;
370 /* Forward-declarations of the entry-points of cli/cli-decode.c. */
372 /* API to the manipulation of command lists. */
374 /* Return TRUE if NAME is a valid user-defined command name.
375 This is a stricter subset of all gdb commands,
376 see find_command_name_length. */
378 extern bool valid_user_defined_cmd_name_p (const char *name
);
380 /* Return TRUE if C is a valid command character. */
382 extern bool valid_cmd_char_p (int c
);
384 /* Return value type for the add_setshow_* functions. */
386 struct set_show_commands
388 cmd_list_element
*set
, *show
;
391 /* Const-correct variant of the above. */
393 extern struct cmd_list_element
*add_cmd (const char *, enum command_class
,
394 cmd_simple_func_ftype
*fun
,
396 struct cmd_list_element
**);
398 /* Like add_cmd, but no command function is specified. */
400 extern struct cmd_list_element
*add_cmd (const char *, enum command_class
,
402 struct cmd_list_element
**);
404 extern struct cmd_list_element
*add_cmd_suppress_notification
405 (const char *name
, enum command_class theclass
,
406 cmd_simple_func_ftype
*fun
, const char *doc
,
407 struct cmd_list_element
**list
,
408 int *suppress_notification
);
410 extern struct cmd_list_element
*add_alias_cmd (const char *,
412 enum command_class
, int,
413 struct cmd_list_element
**);
416 extern struct cmd_list_element
*add_prefix_cmd (const char *, enum command_class
,
417 cmd_simple_func_ftype
*fun
,
419 struct cmd_list_element
**,
421 struct cmd_list_element
**);
423 /* Like add_prefix_cmd, but sets the callback to a function that
424 simply calls help_list. */
426 extern struct cmd_list_element
*add_basic_prefix_cmd
427 (const char *, enum command_class
, const char *, struct cmd_list_element
**,
428 int, struct cmd_list_element
**);
430 /* Like add_prefix_cmd, but useful for "show" prefixes. This sets the
431 callback to a function that simply calls cmd_show_list. */
433 extern struct cmd_list_element
*add_show_prefix_cmd
434 (const char *, enum command_class
, const char *, struct cmd_list_element
**,
435 int, struct cmd_list_element
**);
437 /* Add matching set and show commands using add_basic_prefix_cmd and
438 add_show_prefix_cmd. */
440 extern set_show_commands add_setshow_prefix_cmd
441 (const char *name
, command_class theclass
, const char *set_doc
,
442 const char *show_doc
,
443 cmd_list_element
**set_subcommands_list
,
444 cmd_list_element
**show_subcommands_list
,
445 cmd_list_element
**set_list
,
446 cmd_list_element
**show_list
);
448 extern struct cmd_list_element
*add_prefix_cmd_suppress_notification
449 (const char *name
, enum command_class theclass
,
450 cmd_simple_func_ftype
*fun
,
451 const char *doc
, struct cmd_list_element
**subcommands
,
453 struct cmd_list_element
**list
,
454 int *suppress_notification
);
456 extern struct cmd_list_element
*add_abbrev_prefix_cmd (const char *,
458 cmd_simple_func_ftype
*fun
,
460 struct cmd_list_element
462 struct cmd_list_element
465 typedef void cmd_func_ftype (const char *args
, int from_tty
,
466 cmd_list_element
*c
);
468 /* A completion routine. Add possible completions to tracker.
470 TEXT is the text beyond what was matched for the command itself
471 (leading whitespace is skipped). It stops where we are supposed to
472 stop completing (rl_point) and is '\0' terminated. WORD points in
473 the same buffer as TEXT, and completions should be returned
474 relative to this position. For example, suppose TEXT is "foo" and
475 we want to complete to "foobar". If WORD is "oo", return "oobar";
476 if WORD is "baz/foo", return "baz/foobar". */
477 typedef void completer_ftype (struct cmd_list_element
*,
478 completion_tracker
&tracker
,
479 const char *text
, const char *word
);
481 /* Same, but for set_cmd_completer_handle_brkchars. */
482 typedef void completer_handle_brkchars_ftype (struct cmd_list_element
*,
483 completion_tracker
&tracker
,
484 const char *text
, const char *word
);
486 extern void set_cmd_completer (struct cmd_list_element
*, completer_ftype
*);
488 /* Set the completer_handle_brkchars callback. */
490 extern void set_cmd_completer_handle_brkchars (struct cmd_list_element
*,
491 completer_handle_brkchars_ftype
*);
493 /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
494 around in cmd objects to test the value of the commands sfunc(). */
495 extern int cmd_simple_func_eq (struct cmd_list_element
*cmd
,
496 cmd_simple_func_ftype
*cfun
);
498 /* Execute CMD's pre/post hook. Throw an error if the command fails.
499 If already executing this pre/post hook, or there is no pre/post
500 hook, the call is silently ignored. */
501 extern void execute_cmd_pre_hook (struct cmd_list_element
*cmd
);
502 extern void execute_cmd_post_hook (struct cmd_list_element
*cmd
);
504 /* Flag for an ambiguous cmd_list result. */
505 #define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1)
507 extern struct cmd_list_element
*lookup_cmd (const char **,
508 struct cmd_list_element
*,
513 /* This routine takes a line of TEXT and a CLIST in which to start the
514 lookup. When it returns it will have incremented the text pointer past
515 the section of text it matched, set *RESULT_LIST to point to the list in
516 which the last word was matched, and will return a pointer to the cmd
517 list element which the text matches. It will return NULL if no match at
518 all was possible. It will return -1 (cast appropriately, ick) if ambigous
519 matches are possible; in this case *RESULT_LIST will be set to point to
520 the list in which there are ambiguous choices (and *TEXT will be set to
521 the ambiguous text string).
523 if DEFAULT_ARGS is not null, *DEFAULT_ARGS is set to the found command
524 default args (possibly empty).
526 If the located command was an abbreviation, this routine returns the base
527 command of the abbreviation. Note that *DEFAULT_ARGS will contain the
528 default args defined for the alias.
530 It does no error reporting whatsoever; control will always return
531 to the superior routine.
533 In the case of an ambiguous return (-1), *RESULT_LIST will be set to point
534 at the prefix_command (ie. the best match) *or* (special case) will be NULL
535 if no prefix command was ever found. For example, in the case of "info a",
536 "info" matches without ambiguity, but "a" could be "args" or "address", so
537 *RESULT_LIST is set to the cmd_list_element for "info". So in this case
538 RESULT_LIST should not be interpreted as a pointer to the beginning of a
539 list; it simply points to a specific command. In the case of an ambiguous
540 return *TEXT is advanced past the last non-ambiguous prefix (e.g.
541 "info t" can be "info types" or "info target"; upon return *TEXT has been
542 advanced past "info ").
544 If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise
545 affect the operation).
547 This routine does *not* modify the text pointed to by TEXT.
549 If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which
550 are actually help classes rather than commands (i.e. the function field of
551 the struct cmd_list_element is NULL).
553 When LOOKUP_FOR_COMPLETION_P is true the completion is being requested
554 for the completion engine, no warnings should be printed. */
556 extern struct cmd_list_element
*lookup_cmd_1
557 (const char **text
, struct cmd_list_element
*clist
,
558 struct cmd_list_element
**result_list
, std::string
*default_args
,
559 int ignore_help_classes
, bool lookup_for_completion_p
= false);
561 /* Look up the command called NAME in the command list LIST.
563 Unlike LOOKUP_CMD, partial matches are ignored and only exact matches
564 on NAME are considered.
566 LIST is a chain of struct cmd_list_element's.
568 If IGNORE_HELP_CLASSES is true (the default), ignore any command list
569 elements which are actually help classes rather than commands (i.e.
570 the function field of the struct cmd_list_element is null).
572 If found, return the struct cmd_list_element for that command,
573 otherwise return NULLPTR. */
575 extern struct cmd_list_element
*lookup_cmd_exact
577 struct cmd_list_element
*list
,
578 bool ignore_help_classes
= true);
580 extern struct cmd_list_element
*deprecate_cmd (struct cmd_list_element
*,
583 extern void deprecated_cmd_warning (const char *, struct cmd_list_element
*);
585 extern int lookup_cmd_composition (const char *text
,
586 struct cmd_list_element
**alias
,
587 struct cmd_list_element
**prefix_cmd
,
588 struct cmd_list_element
**cmd
);
590 extern struct cmd_list_element
*add_com (const char *, enum command_class
,
591 cmd_simple_func_ftype
*fun
,
594 extern cmd_list_element
*add_com_alias (const char *name
,
595 cmd_list_element
*target
,
596 command_class theclass
,
599 extern struct cmd_list_element
*add_com_suppress_notification
600 (const char *name
, enum command_class theclass
,
601 cmd_simple_func_ftype
*fun
, const char *doc
,
602 int *supress_notification
);
604 extern struct cmd_list_element
*add_info (const char *,
605 cmd_simple_func_ftype
*fun
,
608 extern cmd_list_element
*add_info_alias (const char *name
,
609 cmd_list_element
*target
,
612 extern void complete_on_cmdlist (struct cmd_list_element
*,
613 completion_tracker
&tracker
,
614 const char *, const char *, int);
616 extern void complete_on_enum (completion_tracker
&tracker
,
617 const char *const *enumlist
,
618 const char *, const char *);
620 /* Functions that implement commands about CLI commands. */
622 extern void help_list (struct cmd_list_element
*, const char *,
623 enum command_class
, struct ui_file
*);
625 /* Method for show a set/show variable's VALUE on FILE. If this
626 method isn't supplied deprecated_show_value_hack() is called (which
628 typedef void (show_value_ftype
) (struct ui_file
*file
,
630 struct cmd_list_element
*cmd
,
632 /* NOTE: i18n: This function is not i18n friendly. Callers should
633 instead print the value out directly. */
634 extern show_value_ftype deprecated_show_value_hack
;
636 extern set_show_commands add_setshow_enum_cmd
637 (const char *name
, command_class theclass
, const char *const *enumlist
,
638 const char **var
, const char *set_doc
, const char *show_doc
,
639 const char *help_doc
, cmd_func_ftype
*set_func
,
640 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
641 cmd_list_element
**show_list
);
643 extern set_show_commands add_setshow_enum_cmd
644 (const char *name
, command_class theclass
, const char *const *enumlist
,
645 const char *set_doc
, const char *show_doc
,
646 const char *help_doc
, setting_setter_ftype
<const char *> set_func
,
647 setting_getter_ftype
<const char *> get_func
, show_value_ftype
*show_func
,
648 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
650 extern set_show_commands add_setshow_auto_boolean_cmd
651 (const char *name
, command_class theclass
, auto_boolean
*var
,
652 const char *set_doc
, const char *show_doc
, const char *help_doc
,
653 cmd_func_ftype
*set_func
, show_value_ftype
*show_func
,
654 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
656 extern set_show_commands add_setshow_auto_boolean_cmd
657 (const char *name
, command_class theclass
, const char *set_doc
,
658 const char *show_doc
, const char *help_doc
,
659 setting_setter_ftype
<enum auto_boolean
> set_func
,
660 setting_getter_ftype
<enum auto_boolean
> get_func
,
661 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
662 cmd_list_element
**show_list
);
664 extern set_show_commands add_setshow_boolean_cmd
665 (const char *name
, command_class theclass
, bool *var
, const char *set_doc
,
666 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
667 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
668 cmd_list_element
**show_list
);
670 extern set_show_commands add_setshow_boolean_cmd
671 (const char *name
, command_class theclass
, const char *set_doc
,
672 const char *show_doc
, const char *help_doc
,
673 setting_setter_ftype
<bool> set_func
,
674 setting_getter_ftype
<bool> get_func
, show_value_ftype
*show_func
,
675 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
677 extern set_show_commands add_setshow_filename_cmd
678 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
679 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_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_filename_cmd
684 (const char *name
, command_class theclass
, const char *set_doc
,
685 const char *show_doc
, const char *help_doc
,
686 setting_setter_ftype
<std::string
> set_func
,
687 setting_getter_ftype
<std::string
> get_func
, show_value_ftype
*show_func
,
688 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
690 extern set_show_commands add_setshow_string_cmd
691 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
692 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
693 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
694 cmd_list_element
**show_list
);
696 extern set_show_commands add_setshow_string_cmd
697 (const char *name
, command_class theclass
, const char *set_doc
,
698 const char *show_doc
, const char *help_doc
,
699 setting_setter_ftype
<std::string
> set_func
,
700 setting_getter_ftype
<std::string
> get_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_string_noescape_cmd
705 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
706 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
707 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
708 cmd_list_element
**show_list
);
710 extern set_show_commands add_setshow_string_noescape_cmd
711 (const char *name
, command_class theclass
, const char *set_doc
,
712 const char *show_doc
, const char *help_doc
,
713 setting_setter_ftype
<std::string
> set_func
,
714 setting_getter_ftype
<std::string
> get_func
, show_value_ftype
*show_func
,
715 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
717 extern set_show_commands add_setshow_optional_filename_cmd
718 (const char *name
, command_class theclass
, std::string
*var
, const char *set_doc
,
719 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_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_optional_filename_cmd
724 (const char *name
, command_class theclass
, const char *set_doc
,
725 const char *show_doc
, const char *help_doc
,
726 setting_setter_ftype
<std::string
> set_func
,
727 setting_getter_ftype
<std::string
> get_func
,
728 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
729 cmd_list_element
**show_list
);
731 extern set_show_commands add_setshow_integer_cmd
732 (const char *name
, command_class theclass
, int *var
, const char *set_doc
,
733 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
734 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
735 cmd_list_element
**show_list
);
737 extern set_show_commands add_setshow_integer_cmd
738 (const char *name
, command_class theclass
, const char *set_doc
,
739 const char *show_doc
, const char *help_doc
,
740 setting_setter_ftype
<int> set_func
,
741 setting_getter_ftype
<int> get_func
, show_value_ftype
*show_func
,
742 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
744 extern set_show_commands add_setshow_uinteger_cmd
745 (const char *name
, command_class theclass
, unsigned int *var
,
746 const char *set_doc
, const char *show_doc
, const char *help_doc
,
747 cmd_func_ftype
*set_func
, show_value_ftype
*show_func
,
748 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
750 extern set_show_commands add_setshow_uinteger_cmd
751 (const char *name
, command_class theclass
, const char *set_doc
,
752 const char *show_doc
, const char *help_doc
,
753 setting_setter_ftype
<unsigned int> set_func
,
754 setting_getter_ftype
<unsigned int> get_func
, show_value_ftype
*show_func
,
755 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
757 extern set_show_commands add_setshow_zinteger_cmd
758 (const char *name
, command_class theclass
, int *var
, const char *set_doc
,
759 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
760 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
761 cmd_list_element
**show_list
);
763 extern set_show_commands add_setshow_zinteger_cmd
764 (const char *name
, command_class theclass
, const char *set_doc
,
765 const char *show_doc
, const char *help_doc
,
766 setting_setter_ftype
<int> set_func
,
767 setting_getter_ftype
<int> get_func
, show_value_ftype
*show_func
,
768 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
770 extern set_show_commands add_setshow_zuinteger_cmd
771 (const char *name
, command_class theclass
, unsigned int *var
,
772 const char *set_doc
, const char *show_doc
, const char *help_doc
,
773 cmd_func_ftype
*set_func
, show_value_ftype
*show_func
,
774 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
776 extern set_show_commands add_setshow_zuinteger_cmd
777 (const char *name
, command_class theclass
, const char *set_doc
,
778 const char *show_doc
, const char *help_doc
,
779 setting_setter_ftype
<unsigned int> set_func
,
780 setting_getter_ftype
<unsigned int> get_func
, show_value_ftype
*show_func
,
781 cmd_list_element
**set_list
, cmd_list_element
**show_list
);
783 extern set_show_commands add_setshow_zuinteger_unlimited_cmd
784 (const char *name
, command_class theclass
, int *var
, const char *set_doc
,
785 const char *show_doc
, const char *help_doc
, cmd_func_ftype
*set_func
,
786 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
787 cmd_list_element
**show_list
);
789 extern set_show_commands add_setshow_zuinteger_unlimited_cmd
790 (const char *name
, command_class theclass
, const char *set_doc
,
791 const char *show_doc
, const char *help_doc
,
792 setting_setter_ftype
<int> set_func
, setting_getter_ftype
<int> get_func
,
793 show_value_ftype
*show_func
, cmd_list_element
**set_list
,
794 cmd_list_element
**show_list
);
796 /* Do a "show" command for each thing on a command list. */
798 extern void cmd_show_list (struct cmd_list_element
*, int);
800 /* Used everywhere whenever at least one parameter is required and
801 none is specified. */
803 extern void error_no_arg (const char *) ATTRIBUTE_NORETURN
;
806 /* Command line saving and repetition.
807 Each input line executed is saved to possibly be repeated either
808 when the user types an empty line, or be repeated by a command
809 that wants to repeat the previously executed command. The below
810 functions control command repetition. */
812 /* Commands call dont_repeat if they do not want to be repeated by null
813 lines or by repeat_previous (). */
815 extern void dont_repeat ();
817 /* Commands call repeat_previous if they want to repeat the previous
818 command. Such commands that repeat the previous command must
819 indicate to not repeat themselves, to avoid recursive repeat.
820 repeat_previous marks the current command as not repeating, and
821 ensures get_saved_command_line returns the previous command, so
822 that the currently executing command can repeat it. If there's no
823 previous command, throws an error. Otherwise, returns the result
824 of get_saved_command_line, which now points at the command to
827 extern const char *repeat_previous ();
829 /* Prevent dont_repeat from working, and return a cleanup that
830 restores the previous state. */
832 extern scoped_restore_tmpl
<int> prevent_dont_repeat (void);
834 /* Set the arguments that will be passed if the current command is
835 repeated. Note that the passed-in string must be a constant. */
837 extern void set_repeat_arguments (const char *args
);
839 /* Returns the saved command line to repeat.
840 When a command is being executed, this is the currently executing
841 command line, unless the currently executing command has called
842 repeat_previous (): in this case, get_saved_command_line returns
843 the previously saved command line. */
845 extern char *get_saved_command_line ();
847 /* Takes a copy of CMD, for possible repetition. */
849 extern void save_command_line (const char *cmd
);
851 /* Used to mark commands that don't do anything. If we just leave the
852 function field NULL, the command is interpreted as a help topic, or
853 as a class of commands. */
855 extern void not_just_help_class_command (const char *, int);
857 /* Call the command function. */
858 extern void cmd_func (struct cmd_list_element
*cmd
,
859 const char *args
, int from_tty
);
861 #endif /* !defined (COMMAND_H) */