gdb: remove command_class enum class_deprecated
[binutils-gdb.git] / gdb / command.h
1 /* Header file for command creation.
2
3 Copyright (C) 1986-2021 Free Software Foundation, Inc.
4
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.
9
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.
14
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/>. */
17
18 #if !defined (COMMAND_H)
19 #define COMMAND_H 1
20
21 #include "gdbsupport/gdb_vecs.h"
22 #include "gdbsupport/scoped_restore.h"
23
24 struct completion_tracker;
25
26 /* This file defines the public interface for any code wanting to
27 create commands. */
28
29 /* Command classes are top-level categories into which commands are
30 broken down for "help" purposes.
31
32 The class_alias is used for the user-defined aliases, defined
33 using the "alias" command.
34
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. */
41
42 enum command_class
43 {
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. */
47
48 /* Special classes to help_list */
49 all_classes = -2, /* help without <classname> */
50 all_commands = -1, /* all */
51
52 /* Classes of commands */
53 no_class = -1,
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 */
63 class_bookmark,
64 class_obscure, /* obscure */
65 class_maintenance, /* internals */
66 class_tui, /* text-user-interface */
67 class_user, /* user-defined */
68
69 /* Used for "show" commands that have no corresponding "set" command. */
70 no_set_class
71 };
72
73 /* Types of "set" or "show" command. */
74 typedef enum var_types
75 {
76 /* "on" or "off". *VAR is a bool which is true for on,
77 false for off. */
78 var_boolean,
79
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
84 value. */
85 var_auto_boolean,
86
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. */
89 var_uinteger,
90
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. */
95 var_integer,
96
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. */
100 var_string,
101 /* String which stores what the user types verbatim.
102 *VAR is std::string, "" if the string is empty. */
103 var_string_noescape,
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. */
108 var_filename,
109 /* ZeroableInteger. *VAR is an int. Like var_integer except
110 that zero really means zero. */
111 var_zinteger,
112 /* ZeroableUnsignedInteger. *VAR is an unsigned int. Zero really
113 means zero. */
114 var_zuinteger,
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
121 find. */
122 var_enum
123 }
124 var_types;
125
126 /* Return true if a setting of type VAR_TYPE is backed with type T.
127
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. */
133 template<typename T>
134 bool var_type_uses (var_types var_type) = delete;
135
136 /* Return true if a setting of type T is backed by a bool variable. */
137 template<>
138 inline bool var_type_uses<bool> (var_types t)
139 {
140 return t == var_boolean;
141 };
142
143 /* Return true if a setting of type T is backed by a auto_boolean variable.
144 */
145 template<>
146 inline bool var_type_uses<enum auto_boolean> (var_types t)
147 {
148 return t == var_auto_boolean;
149 }
150
151 /* Return true if a setting of type T is backed by an unsigned int variable.
152 */
153 template<>
154 inline bool var_type_uses<unsigned int> (var_types t)
155 {
156 return (t == var_uinteger || t == var_zinteger || t == var_zuinteger);
157 }
158
159 /* Return true if a setting of type T is backed by an int variable. */
160 template<>
161 inline bool var_type_uses<int> (var_types t)
162 {
163 return (t == var_integer || t == var_zinteger
164 || t == var_zuinteger_unlimited);
165 }
166
167 /* Return true if a setting of type T is backed by a std::string variable. */
168 template<>
169 inline bool var_type_uses<std::string> (var_types t)
170 {
171 return (t == var_string || t == var_string_noescape
172 || t == var_optional_filename || t == var_filename);
173 }
174
175 /* Return true if a setting of type T is backed by a const char * variable.
176 */
177 template<>
178 inline bool var_type_uses<const char *> (var_types t)
179 {
180 return t == var_enum;
181 }
182
183 /* Function signature for a callback used to get a value from a setting. */
184
185 template<typename T>
186 using setting_getter_ftype = const T &(*) ();
187
188 /* Function signature for a callback used to set a value to a setting. */
189
190 template<typename T>
191 using setting_setter_ftype = void (*) (const T &);
192
193 /* Generic/type-erased function pointer. */
194
195 using erased_func = void (*) ();
196
197 /* Interface for getting and setting a setting's value.
198
199 The underlying data can be of any VAR_TYPES type. */
200 struct setting
201 {
202 /* Create a setting backed by a variable of type T.
203
204 Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */
205 template<typename T>
206 setting (var_types var_type, T *var)
207 : m_var_type (var_type), m_var (var)
208 {
209 gdb_assert (var != nullptr);
210 gdb_assert (var_type_uses<T> (var_type));
211 }
212
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. */
216
217 struct erased_args
218 {
219 void *var;
220 erased_func setter;
221 erased_func getter;
222 };
223
224 template<typename T>
225 static erased_args erase_args (var_types var_type,
226 T *var,
227 setting_setter_ftype<T> set_setting_func,
228 setting_getter_ftype<T> get_setting_func)
229 {
230 gdb_assert (var_type_uses<T> (var_type));
231 /* The getter and the setter must be both provided or both omitted. */
232 gdb_assert
233 ((set_setting_func == nullptr) == (get_setting_func == nullptr));
234
235 /* The caller must provide a pointer to a variable or get/set functions, but
236 not both. */
237 gdb_assert ((set_setting_func == nullptr) != (var == nullptr));
238
239 return {
240 var,
241 reinterpret_cast<erased_func> (set_setting_func),
242 reinterpret_cast<erased_func> (get_setting_func)
243 };
244 }
245
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),
251 m_var (args.var),
252 m_getter (args.getter),
253 m_setter (args.setter)
254 {
255 }
256
257 /* Create a setting backed by setter and getter functions.
258
259 Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */
260 template<typename T>
261 setting (var_types var_type,
262 setting_setter_ftype<T> setter,
263 setting_getter_ftype<T> getter)
264 : m_var_type (var_type)
265 {
266 gdb_assert (var_type_uses<T> (var_type));
267
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
270 same size. */
271 gdb_static_assert (sizeof (m_getter) == sizeof (getter));
272 gdb_static_assert (sizeof (m_setter) == sizeof (setter));
273
274 m_getter = reinterpret_cast<erased_func> (getter);
275 m_setter = reinterpret_cast<erased_func> (setter);
276 }
277
278 /* Access the type of the current setting. */
279 var_types type () const
280 { return m_var_type; }
281
282 /* Return the current value.
283
284 The template parameter T is the type of the variable used to store the
285 setting. */
286 template<typename T>
287 const T &get () const
288 {
289 gdb_assert (var_type_uses<T> (m_var_type));
290
291 if (m_var == nullptr)
292 {
293 gdb_assert (m_getter != nullptr);
294 auto getter = reinterpret_cast<setting_getter_ftype<T>> (m_getter);
295 return getter ();
296 }
297 else
298 return *static_cast<const T *> (m_var);
299 }
300
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
303 unchanged.
304
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.
307
308 The template parameter T indicates the type of the variable used to store
309 the setting.
310
311 The var_type of the setting must match T. */
312 template<typename T>
313 bool set (const T &v)
314 {
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));
318
319 const T old_value = this->get<T> ();
320
321 if (m_var == nullptr)
322 {
323 gdb_assert (m_setter != nullptr);
324 auto setter = reinterpret_cast<setting_setter_ftype<T>> (m_setter);
325 setter (v);
326 }
327 else
328 *static_cast<T *> (m_var) = v;
329
330 return old_value != this->get<T> ();
331 }
332
333 private:
334 /* The type of the variable M_VAR is pointing to, or that M_GETTER / M_SETTER
335 get or set. */
336 var_types m_var_type;
337
338 /* Pointer to the enclosed variable
339
340 Either M_VAR is non-nullptr, or both M_GETTER and M_SETTER are
341 non-nullptr. */
342 void *m_var = nullptr;
343
344 /* Pointer to a user provided getter. */
345 erased_func m_getter = nullptr;
346
347 /* Pointer to a user provided setter. */
348 erased_func m_setter = nullptr;
349 };
350
351 /* This structure records one command'd definition. */
352 struct cmd_list_element;
353
354 /* The "simple" signature of command callbacks, which doesn't include a
355 cmd_list_element parameter. */
356
357 typedef void cmd_simple_func_ftype (const char *args, int from_tty);
358
359 /* This structure specifies notifications to be suppressed by a cli
360 command interpreter. */
361
362 struct cli_suppress_notification
363 {
364 /* Inferior, thread, frame selected notification suppressed? */
365 int user_selected_context;
366 };
367
368 extern struct cli_suppress_notification cli_suppress_notification;
369
370 /* Forward-declarations of the entry-points of cli/cli-decode.c. */
371
372 /* API to the manipulation of command lists. */
373
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. */
377
378 extern bool valid_user_defined_cmd_name_p (const char *name);
379
380 /* Return TRUE if C is a valid command character. */
381
382 extern bool valid_cmd_char_p (int c);
383
384 /* Return value type for the add_setshow_* functions. */
385
386 struct set_show_commands
387 {
388 cmd_list_element *set, *show;
389 };
390
391 /* Const-correct variant of the above. */
392
393 extern struct cmd_list_element *add_cmd (const char *, enum command_class,
394 cmd_simple_func_ftype *fun,
395 const char *,
396 struct cmd_list_element **);
397
398 /* Like add_cmd, but no command function is specified. */
399
400 extern struct cmd_list_element *add_cmd (const char *, enum command_class,
401 const char *,
402 struct cmd_list_element **);
403
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);
409
410 extern struct cmd_list_element *add_alias_cmd (const char *,
411 cmd_list_element *,
412 enum command_class, int,
413 struct cmd_list_element **);
414
415
416 extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class,
417 cmd_simple_func_ftype *fun,
418 const char *,
419 struct cmd_list_element **,
420 int,
421 struct cmd_list_element **);
422
423 /* Like add_prefix_cmd, but sets the callback to a function that
424 simply calls help_list. */
425
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 **);
429
430 /* Like add_prefix_cmd, but useful for "show" prefixes. This sets the
431 callback to a function that simply calls cmd_show_list. */
432
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 **);
436
437 /* Add matching set and show commands using add_basic_prefix_cmd and
438 add_show_prefix_cmd. */
439
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);
447
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,
452 int allow_unknown,
453 struct cmd_list_element **list,
454 int *suppress_notification);
455
456 extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
457 enum command_class,
458 cmd_simple_func_ftype *fun,
459 const char *,
460 struct cmd_list_element
461 **, int,
462 struct cmd_list_element
463 **);
464
465 typedef void cmd_func_ftype (const char *args, int from_tty,
466 cmd_list_element *c);
467
468 /* A completion routine. Add possible completions to tracker.
469
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);
480
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);
485
486 extern void set_cmd_completer (struct cmd_list_element *, completer_ftype *);
487
488 /* Set the completer_handle_brkchars callback. */
489
490 extern void set_cmd_completer_handle_brkchars (struct cmd_list_element *,
491 completer_handle_brkchars_ftype *);
492
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);
497
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);
503
504 /* Flag for an ambiguous cmd_list result. */
505 #define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1)
506
507 extern struct cmd_list_element *lookup_cmd (const char **,
508 struct cmd_list_element *,
509 const char *,
510 std::string *,
511 int, int);
512
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).
522
523 if DEFAULT_ARGS is not null, *DEFAULT_ARGS is set to the found command
524 default args (possibly empty).
525
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.
529
530 It does no error reporting whatsoever; control will always return
531 to the superior routine.
532
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 ").
543
544 If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise
545 affect the operation).
546
547 This routine does *not* modify the text pointed to by TEXT.
548
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).
552
553 When LOOKUP_FOR_COMPLETION_P is true the completion is being requested
554 for the completion engine, no warnings should be printed. */
555
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);
560
561 /* Look up the command called NAME in the command list LIST.
562
563 Unlike LOOKUP_CMD, partial matches are ignored and only exact matches
564 on NAME are considered.
565
566 LIST is a chain of struct cmd_list_element's.
567
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).
571
572 If found, return the struct cmd_list_element for that command,
573 otherwise return NULLPTR. */
574
575 extern struct cmd_list_element *lookup_cmd_exact
576 (const char *name,
577 struct cmd_list_element *list,
578 bool ignore_help_classes = true);
579
580 extern struct cmd_list_element *deprecate_cmd (struct cmd_list_element *,
581 const char * );
582
583 extern void deprecated_cmd_warning (const char *, struct cmd_list_element *);
584
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);
589
590 extern struct cmd_list_element *add_com (const char *, enum command_class,
591 cmd_simple_func_ftype *fun,
592 const char *);
593
594 extern cmd_list_element *add_com_alias (const char *name,
595 cmd_list_element *target,
596 command_class theclass,
597 int abbrev_flag);
598
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);
603
604 extern struct cmd_list_element *add_info (const char *,
605 cmd_simple_func_ftype *fun,
606 const char *);
607
608 extern cmd_list_element *add_info_alias (const char *name,
609 cmd_list_element *target,
610 int abbrev_flag);
611
612 extern void complete_on_cmdlist (struct cmd_list_element *,
613 completion_tracker &tracker,
614 const char *, const char *, int);
615
616 extern void complete_on_enum (completion_tracker &tracker,
617 const char *const *enumlist,
618 const char *, const char *);
619
620 /* Functions that implement commands about CLI commands. */
621
622 extern void help_list (struct cmd_list_element *, const char *,
623 enum command_class, struct ui_file *);
624
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
627 is not good). */
628 typedef void (show_value_ftype) (struct ui_file *file,
629 int from_tty,
630 struct cmd_list_element *cmd,
631 const char *value);
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;
635
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);
642
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);
649
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);
655
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);
663
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);
669
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);
676
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);
682
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);
689
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);
695
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);
703
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);
709
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);
716
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);
722
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);
730
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);
736
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);
743
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);
749
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);
756
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);
762
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);
769
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);
775
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);
782
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);
788
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);
795
796 /* Do a "show" command for each thing on a command list. */
797
798 extern void cmd_show_list (struct cmd_list_element *, int);
799
800 /* Used everywhere whenever at least one parameter is required and
801 none is specified. */
802
803 extern void error_no_arg (const char *) ATTRIBUTE_NORETURN;
804
805
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. */
811
812 /* Commands call dont_repeat if they do not want to be repeated by null
813 lines or by repeat_previous (). */
814
815 extern void dont_repeat ();
816
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
825 repeat. */
826
827 extern const char *repeat_previous ();
828
829 /* Prevent dont_repeat from working, and return a cleanup that
830 restores the previous state. */
831
832 extern scoped_restore_tmpl<int> prevent_dont_repeat (void);
833
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. */
836
837 extern void set_repeat_arguments (const char *args);
838
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. */
844
845 extern char *get_saved_command_line ();
846
847 /* Takes a copy of CMD, for possible repetition. */
848
849 extern void save_command_line (const char *cmd);
850
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. */
854
855 extern void not_just_help_class_command (const char *, int);
856
857 /* Call the command function. */
858 extern void cmd_func (struct cmd_list_element *cmd,
859 const char *args, int from_tty);
860
861 #endif /* !defined (COMMAND_H) */