Add accessors for symbol's artificial field
[binutils-gdb.git] / gdb / command.h
1 /* Header file for command creation.
2
3 Copyright (C) 1986-2022 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 template<bool is_scalar, typename T> struct setting_func_types_1;
184
185 template<typename T>
186 struct setting_func_types_1<true, T>
187 {
188 using type = T;
189 using set = void (*) (type);
190 using get = type (*) ();
191 };
192
193 template<typename T>
194 struct setting_func_types_1<false, T>
195 {
196 using type = const T &;
197 using set = void (*) (type);
198 using get = type (*) ();
199 };
200
201 template<typename T>
202 struct setting_func_types
203 {
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;
207 };
208
209 /* Generic/type-erased function pointer. */
210
211 using erased_func = void (*) ();
212
213 /* Interface for getting and setting a setting's value.
214
215 The underlying data can be of any VAR_TYPES type. */
216 struct setting
217 {
218 /* Create a setting backed by a variable of type T.
219
220 Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */
221 template<typename T>
222 setting (var_types var_type, T *var)
223 : m_var_type (var_type), m_var (var)
224 {
225 gdb_assert (var != nullptr);
226 gdb_assert (var_type_uses<T> (var_type));
227 }
228
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. */
232
233 struct erased_args
234 {
235 void *var;
236 erased_func setter;
237 erased_func getter;
238 };
239
240 template<typename T>
241 static erased_args erase_args (var_types var_type,
242 T *var,
243 typename setting_func_types<T>::set set_setting_func,
244 typename setting_func_types<T>::get get_setting_func)
245 {
246 gdb_assert (var_type_uses<T> (var_type));
247 /* The getter and the setter must be both provided or both omitted. */
248 gdb_assert
249 ((set_setting_func == nullptr) == (get_setting_func == nullptr));
250
251 /* The caller must provide a pointer to a variable or get/set functions, but
252 not both. */
253 gdb_assert ((set_setting_func == nullptr) != (var == nullptr));
254
255 return {
256 var,
257 reinterpret_cast<erased_func> (set_setting_func),
258 reinterpret_cast<erased_func> (get_setting_func)
259 };
260 }
261
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),
267 m_var (args.var),
268 m_getter (args.getter),
269 m_setter (args.setter)
270 {
271 }
272
273 /* Create a setting backed by setter and getter functions.
274
275 Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */
276 template<typename T>
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)
281 {
282 gdb_assert (var_type_uses<T> (var_type));
283
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
286 same size. */
287 gdb_static_assert (sizeof (m_getter) == sizeof (getter));
288 gdb_static_assert (sizeof (m_setter) == sizeof (setter));
289
290 m_getter = reinterpret_cast<erased_func> (getter);
291 m_setter = reinterpret_cast<erased_func> (setter);
292 }
293
294 /* Access the type of the current setting. */
295 var_types type () const
296 { return m_var_type; }
297
298 /* Return the current value.
299
300 The template parameter T is the type of the variable used to store the
301 setting. */
302 template<typename T>
303 typename setting_func_types<T>::type get () const
304 {
305 gdb_assert (var_type_uses<T> (m_var_type));
306
307 if (m_var == nullptr)
308 {
309 gdb_assert (m_getter != nullptr);
310 auto getter = reinterpret_cast<typename setting_func_types<T>::get> (m_getter);
311 return getter ();
312 }
313 else
314 return *static_cast<const T *> (m_var);
315 }
316
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
319 unchanged.
320
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.
323
324 The template parameter T indicates the type of the variable used to store
325 the setting.
326
327 The var_type of the setting must match T. */
328 template<typename T>
329 bool set (const T &v)
330 {
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));
334
335 const T old_value = this->get<T> ();
336
337 if (m_var == nullptr)
338 {
339 gdb_assert (m_setter != nullptr);
340 auto setter = reinterpret_cast<typename setting_func_types<T>::set> (m_setter);
341 setter (v);
342 }
343 else
344 *static_cast<T *> (m_var) = v;
345
346 return old_value != this->get<T> ();
347 }
348
349 private:
350 /* The type of the variable M_VAR is pointing to, or that M_GETTER / M_SETTER
351 get or set. */
352 var_types m_var_type;
353
354 /* Pointer to the enclosed variable
355
356 Either M_VAR is non-nullptr, or both M_GETTER and M_SETTER are
357 non-nullptr. */
358 void *m_var = nullptr;
359
360 /* Pointer to a user provided getter. */
361 erased_func m_getter = nullptr;
362
363 /* Pointer to a user provided setter. */
364 erased_func m_setter = nullptr;
365 };
366
367 /* This structure records one command'd definition. */
368 struct cmd_list_element;
369
370 /* The "simple" signature of command callbacks, which doesn't include a
371 cmd_list_element parameter. */
372
373 typedef void cmd_simple_func_ftype (const char *args, int from_tty);
374
375 /* This structure specifies notifications to be suppressed by a cli
376 command interpreter. */
377
378 struct cli_suppress_notification
379 {
380 /* Inferior, thread, frame selected notification suppressed? */
381 bool user_selected_context = false;
382
383 /* Normal stop event suppressed? */
384 bool normal_stop = false;
385 };
386
387 extern struct cli_suppress_notification cli_suppress_notification;
388
389 /* Forward-declarations of the entry-points of cli/cli-decode.c. */
390
391 /* API to the manipulation of command lists. */
392
393 /* Return TRUE if NAME is a valid user-defined command name.
394 This is a stricter subset of all gdb commands,
395 see find_command_name_length. */
396
397 extern bool valid_user_defined_cmd_name_p (const char *name);
398
399 /* Return TRUE if C is a valid command character. */
400
401 extern bool valid_cmd_char_p (int c);
402
403 /* Return value type for the add_setshow_* functions. */
404
405 struct set_show_commands
406 {
407 cmd_list_element *set, *show;
408 };
409
410 /* Const-correct variant of the above. */
411
412 extern struct cmd_list_element *add_cmd (const char *, enum command_class,
413 cmd_simple_func_ftype *fun,
414 const char *,
415 struct cmd_list_element **);
416
417 /* Like add_cmd, but no command function is specified. */
418
419 extern struct cmd_list_element *add_cmd (const char *, enum command_class,
420 const char *,
421 struct cmd_list_element **);
422
423 extern struct cmd_list_element *add_cmd_suppress_notification
424 (const char *name, enum command_class theclass,
425 cmd_simple_func_ftype *fun, const char *doc,
426 struct cmd_list_element **list,
427 bool *suppress_notification);
428
429 extern struct cmd_list_element *add_alias_cmd (const char *,
430 cmd_list_element *,
431 enum command_class, int,
432 struct cmd_list_element **);
433
434
435 extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class,
436 cmd_simple_func_ftype *fun,
437 const char *,
438 struct cmd_list_element **,
439 int,
440 struct cmd_list_element **);
441
442 /* Like add_prefix_cmd, but sets the callback to a function that
443 simply calls help_list. */
444
445 extern struct cmd_list_element *add_basic_prefix_cmd
446 (const char *, enum command_class, const char *, struct cmd_list_element **,
447 int, struct cmd_list_element **);
448
449 /* Like add_prefix_cmd, but useful for "show" prefixes. This sets the
450 callback to a function that simply calls cmd_show_list. */
451
452 extern struct cmd_list_element *add_show_prefix_cmd
453 (const char *, enum command_class, const char *, struct cmd_list_element **,
454 int, struct cmd_list_element **);
455
456 /* Add matching set and show commands using add_basic_prefix_cmd and
457 add_show_prefix_cmd. */
458
459 extern set_show_commands add_setshow_prefix_cmd
460 (const char *name, command_class theclass, const char *set_doc,
461 const char *show_doc,
462 cmd_list_element **set_subcommands_list,
463 cmd_list_element **show_subcommands_list,
464 cmd_list_element **set_list,
465 cmd_list_element **show_list);
466
467 extern struct cmd_list_element *add_prefix_cmd_suppress_notification
468 (const char *name, enum command_class theclass,
469 cmd_simple_func_ftype *fun,
470 const char *doc, struct cmd_list_element **subcommands,
471 int allow_unknown,
472 struct cmd_list_element **list,
473 bool *suppress_notification);
474
475 extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
476 enum command_class,
477 cmd_simple_func_ftype *fun,
478 const char *,
479 struct cmd_list_element
480 **, int,
481 struct cmd_list_element
482 **);
483
484 typedef void cmd_func_ftype (const char *args, int from_tty,
485 cmd_list_element *c);
486
487 /* A completion routine. Add possible completions to tracker.
488
489 TEXT is the text beyond what was matched for the command itself
490 (leading whitespace is skipped). It stops where we are supposed to
491 stop completing (rl_point) and is '\0' terminated. WORD points in
492 the same buffer as TEXT, and completions should be returned
493 relative to this position. For example, suppose TEXT is "foo" and
494 we want to complete to "foobar". If WORD is "oo", return "oobar";
495 if WORD is "baz/foo", return "baz/foobar". */
496 typedef void completer_ftype (struct cmd_list_element *,
497 completion_tracker &tracker,
498 const char *text, const char *word);
499
500 /* Same, but for set_cmd_completer_handle_brkchars. */
501 typedef void completer_handle_brkchars_ftype (struct cmd_list_element *,
502 completion_tracker &tracker,
503 const char *text, const char *word);
504
505 extern void set_cmd_completer (struct cmd_list_element *, completer_ftype *);
506
507 /* Set the completer_handle_brkchars callback. */
508
509 extern void set_cmd_completer_handle_brkchars (struct cmd_list_element *,
510 completer_handle_brkchars_ftype *);
511
512 /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
513 around in cmd objects to test the value of the commands sfunc(). */
514 extern int cmd_simple_func_eq (struct cmd_list_element *cmd,
515 cmd_simple_func_ftype *cfun);
516
517 /* Execute CMD's pre/post hook. Throw an error if the command fails.
518 If already executing this pre/post hook, or there is no pre/post
519 hook, the call is silently ignored. */
520 extern void execute_cmd_pre_hook (struct cmd_list_element *cmd);
521 extern void execute_cmd_post_hook (struct cmd_list_element *cmd);
522
523 /* Flag for an ambiguous cmd_list result. */
524 #define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1)
525
526 extern struct cmd_list_element *lookup_cmd (const char **,
527 struct cmd_list_element *,
528 const char *,
529 std::string *,
530 int, int);
531
532 /* This routine takes a line of TEXT and a CLIST in which to start the
533 lookup. When it returns it will have incremented the text pointer past
534 the section of text it matched, set *RESULT_LIST to point to the list in
535 which the last word was matched, and will return a pointer to the cmd
536 list element which the text matches. It will return NULL if no match at
537 all was possible. It will return -1 (cast appropriately, ick) if ambigous
538 matches are possible; in this case *RESULT_LIST will be set to point to
539 the list in which there are ambiguous choices (and *TEXT will be set to
540 the ambiguous text string).
541
542 if DEFAULT_ARGS is not null, *DEFAULT_ARGS is set to the found command
543 default args (possibly empty).
544
545 If the located command was an abbreviation, this routine returns the base
546 command of the abbreviation. Note that *DEFAULT_ARGS will contain the
547 default args defined for the alias.
548
549 It does no error reporting whatsoever; control will always return
550 to the superior routine.
551
552 In the case of an ambiguous return (-1), *RESULT_LIST will be set to point
553 at the prefix_command (ie. the best match) *or* (special case) will be NULL
554 if no prefix command was ever found. For example, in the case of "info a",
555 "info" matches without ambiguity, but "a" could be "args" or "address", so
556 *RESULT_LIST is set to the cmd_list_element for "info". So in this case
557 RESULT_LIST should not be interpreted as a pointer to the beginning of a
558 list; it simply points to a specific command. In the case of an ambiguous
559 return *TEXT is advanced past the last non-ambiguous prefix (e.g.
560 "info t" can be "info types" or "info target"; upon return *TEXT has been
561 advanced past "info ").
562
563 If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise
564 affect the operation).
565
566 This routine does *not* modify the text pointed to by TEXT.
567
568 If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which
569 are actually help classes rather than commands (i.e. the function field of
570 the struct cmd_list_element is NULL).
571
572 When LOOKUP_FOR_COMPLETION_P is true the completion is being requested
573 for the completion engine, no warnings should be printed. */
574
575 extern struct cmd_list_element *lookup_cmd_1
576 (const char **text, struct cmd_list_element *clist,
577 struct cmd_list_element **result_list, std::string *default_args,
578 int ignore_help_classes, bool lookup_for_completion_p = false);
579
580 /* Look up the command called NAME in the command list LIST.
581
582 Unlike LOOKUP_CMD, partial matches are ignored and only exact matches
583 on NAME are considered.
584
585 LIST is a chain of struct cmd_list_element's.
586
587 If IGNORE_HELP_CLASSES is true (the default), ignore any command list
588 elements which are actually help classes rather than commands (i.e.
589 the function field of the struct cmd_list_element is null).
590
591 If found, return the struct cmd_list_element for that command,
592 otherwise return NULLPTR. */
593
594 extern struct cmd_list_element *lookup_cmd_exact
595 (const char *name,
596 struct cmd_list_element *list,
597 bool ignore_help_classes = true);
598
599 extern struct cmd_list_element *deprecate_cmd (struct cmd_list_element *,
600 const char * );
601
602 extern void deprecated_cmd_warning (const char *, struct cmd_list_element *);
603
604 extern int lookup_cmd_composition (const char *text,
605 struct cmd_list_element **alias,
606 struct cmd_list_element **prefix_cmd,
607 struct cmd_list_element **cmd);
608
609 extern struct cmd_list_element *add_com (const char *, enum command_class,
610 cmd_simple_func_ftype *fun,
611 const char *);
612
613 extern cmd_list_element *add_com_alias (const char *name,
614 cmd_list_element *target,
615 command_class theclass,
616 int abbrev_flag);
617
618 extern struct cmd_list_element *add_com_suppress_notification
619 (const char *name, enum command_class theclass,
620 cmd_simple_func_ftype *fun, const char *doc,
621 bool *supress_notification);
622
623 extern struct cmd_list_element *add_info (const char *,
624 cmd_simple_func_ftype *fun,
625 const char *);
626
627 extern cmd_list_element *add_info_alias (const char *name,
628 cmd_list_element *target,
629 int abbrev_flag);
630
631 extern void complete_on_cmdlist (struct cmd_list_element *,
632 completion_tracker &tracker,
633 const char *, const char *, int);
634
635 extern void complete_on_enum (completion_tracker &tracker,
636 const char *const *enumlist,
637 const char *, const char *);
638
639 /* Functions that implement commands about CLI commands. */
640
641 extern void help_list (struct cmd_list_element *, const char *,
642 enum command_class, struct ui_file *);
643
644 /* Method for show a set/show variable's VALUE on FILE. If this
645 method isn't supplied deprecated_show_value_hack() is called (which
646 is not good). */
647 typedef void (show_value_ftype) (struct ui_file *file,
648 int from_tty,
649 struct cmd_list_element *cmd,
650 const char *value);
651 /* NOTE: i18n: This function is not i18n friendly. Callers should
652 instead print the value out directly. */
653 extern show_value_ftype deprecated_show_value_hack;
654
655 extern set_show_commands add_setshow_enum_cmd
656 (const char *name, command_class theclass, const char *const *enumlist,
657 const char **var, const char *set_doc, const char *show_doc,
658 const char *help_doc, cmd_func_ftype *set_func,
659 show_value_ftype *show_func, cmd_list_element **set_list,
660 cmd_list_element **show_list);
661
662 extern set_show_commands add_setshow_enum_cmd
663 (const char *name, command_class theclass, const char *const *enumlist,
664 const char *set_doc, const char *show_doc,
665 const char *help_doc, setting_func_types<const char *>::set set_func,
666 setting_func_types<const char *>::get get_func, show_value_ftype *show_func,
667 cmd_list_element **set_list, cmd_list_element **show_list);
668
669 extern set_show_commands add_setshow_auto_boolean_cmd
670 (const char *name, command_class theclass, auto_boolean *var,
671 const char *set_doc, const char *show_doc, const char *help_doc,
672 cmd_func_ftype *set_func, show_value_ftype *show_func,
673 cmd_list_element **set_list, cmd_list_element **show_list);
674
675 extern set_show_commands add_setshow_auto_boolean_cmd
676 (const char *name, command_class theclass, const char *set_doc,
677 const char *show_doc, const char *help_doc,
678 setting_func_types<enum auto_boolean>::set set_func,
679 setting_func_types<enum auto_boolean>::get get_func,
680 show_value_ftype *show_func, cmd_list_element **set_list,
681 cmd_list_element **show_list);
682
683 extern set_show_commands add_setshow_boolean_cmd
684 (const char *name, command_class theclass, bool *var, const char *set_doc,
685 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
686 show_value_ftype *show_func, cmd_list_element **set_list,
687 cmd_list_element **show_list);
688
689 extern set_show_commands add_setshow_boolean_cmd
690 (const char *name, command_class theclass, const char *set_doc,
691 const char *show_doc, const char *help_doc,
692 setting_func_types<bool>::set set_func,
693 setting_func_types<bool>::get get_func, show_value_ftype *show_func,
694 cmd_list_element **set_list, cmd_list_element **show_list);
695
696 extern set_show_commands add_setshow_filename_cmd
697 (const char *name, command_class theclass, std::string *var, const char *set_doc,
698 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
699 show_value_ftype *show_func, cmd_list_element **set_list,
700 cmd_list_element **show_list);
701
702 extern set_show_commands add_setshow_filename_cmd
703 (const char *name, command_class theclass, const char *set_doc,
704 const char *show_doc, const char *help_doc,
705 setting_func_types<std::string>::set set_func,
706 setting_func_types<std::string>::get get_func, show_value_ftype *show_func,
707 cmd_list_element **set_list, cmd_list_element **show_list);
708
709 extern set_show_commands add_setshow_string_cmd
710 (const char *name, command_class theclass, std::string *var, const char *set_doc,
711 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
712 show_value_ftype *show_func, cmd_list_element **set_list,
713 cmd_list_element **show_list);
714
715 extern set_show_commands add_setshow_string_cmd
716 (const char *name, command_class theclass, const char *set_doc,
717 const char *show_doc, const char *help_doc,
718 setting_func_types<std::string>::set set_func,
719 setting_func_types<std::string>::get get_func,
720 show_value_ftype *show_func, cmd_list_element **set_list,
721 cmd_list_element **show_list);
722
723 extern set_show_commands add_setshow_string_noescape_cmd
724 (const char *name, command_class theclass, std::string *var, const char *set_doc,
725 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
726 show_value_ftype *show_func, cmd_list_element **set_list,
727 cmd_list_element **show_list);
728
729 extern set_show_commands add_setshow_string_noescape_cmd
730 (const char *name, command_class theclass, const char *set_doc,
731 const char *show_doc, const char *help_doc,
732 setting_func_types<std::string>::set set_func,
733 setting_func_types<std::string>::get get_func, show_value_ftype *show_func,
734 cmd_list_element **set_list, cmd_list_element **show_list);
735
736 extern set_show_commands add_setshow_optional_filename_cmd
737 (const char *name, command_class theclass, std::string *var, const char *set_doc,
738 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
739 show_value_ftype *show_func, cmd_list_element **set_list,
740 cmd_list_element **show_list);
741
742 extern set_show_commands add_setshow_optional_filename_cmd
743 (const char *name, command_class theclass, const char *set_doc,
744 const char *show_doc, const char *help_doc,
745 setting_func_types<std::string>::set set_func,
746 setting_func_types<std::string>::get get_func,
747 show_value_ftype *show_func, cmd_list_element **set_list,
748 cmd_list_element **show_list);
749
750 extern set_show_commands add_setshow_integer_cmd
751 (const char *name, command_class theclass, int *var, const char *set_doc,
752 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
753 show_value_ftype *show_func, cmd_list_element **set_list,
754 cmd_list_element **show_list);
755
756 extern set_show_commands add_setshow_integer_cmd
757 (const char *name, command_class theclass, const char *set_doc,
758 const char *show_doc, const char *help_doc,
759 setting_func_types<int>::set set_func,
760 setting_func_types<int>::get get_func, show_value_ftype *show_func,
761 cmd_list_element **set_list, cmd_list_element **show_list);
762
763 extern set_show_commands add_setshow_uinteger_cmd
764 (const char *name, command_class theclass, unsigned int *var,
765 const char *set_doc, const char *show_doc, const char *help_doc,
766 cmd_func_ftype *set_func, show_value_ftype *show_func,
767 cmd_list_element **set_list, cmd_list_element **show_list);
768
769 extern set_show_commands add_setshow_uinteger_cmd
770 (const char *name, command_class theclass, const char *set_doc,
771 const char *show_doc, const char *help_doc,
772 setting_func_types<unsigned int>::set set_func,
773 setting_func_types<unsigned int>::get get_func, show_value_ftype *show_func,
774 cmd_list_element **set_list, cmd_list_element **show_list);
775
776 extern set_show_commands add_setshow_zinteger_cmd
777 (const char *name, command_class theclass, int *var, const char *set_doc,
778 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
779 show_value_ftype *show_func, cmd_list_element **set_list,
780 cmd_list_element **show_list);
781
782 extern set_show_commands add_setshow_zinteger_cmd
783 (const char *name, command_class theclass, const char *set_doc,
784 const char *show_doc, const char *help_doc,
785 setting_func_types<int>::set set_func,
786 setting_func_types<int>::get get_func, show_value_ftype *show_func,
787 cmd_list_element **set_list, cmd_list_element **show_list);
788
789 extern set_show_commands add_setshow_zuinteger_cmd
790 (const char *name, command_class theclass, unsigned int *var,
791 const char *set_doc, const char *show_doc, const char *help_doc,
792 cmd_func_ftype *set_func, show_value_ftype *show_func,
793 cmd_list_element **set_list, cmd_list_element **show_list);
794
795 extern set_show_commands add_setshow_zuinteger_cmd
796 (const char *name, command_class theclass, const char *set_doc,
797 const char *show_doc, const char *help_doc,
798 setting_func_types<unsigned int>::set set_func,
799 setting_func_types<unsigned int>::get get_func, show_value_ftype *show_func,
800 cmd_list_element **set_list, cmd_list_element **show_list);
801
802 extern set_show_commands add_setshow_zuinteger_unlimited_cmd
803 (const char *name, command_class theclass, int *var, const char *set_doc,
804 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
805 show_value_ftype *show_func, cmd_list_element **set_list,
806 cmd_list_element **show_list);
807
808 extern set_show_commands add_setshow_zuinteger_unlimited_cmd
809 (const char *name, command_class theclass, const char *set_doc,
810 const char *show_doc, const char *help_doc,
811 setting_func_types<int>::set set_func, setting_func_types<int>::get get_func,
812 show_value_ftype *show_func, cmd_list_element **set_list,
813 cmd_list_element **show_list);
814
815 /* Do a "show" command for each thing on a command list. */
816
817 extern void cmd_show_list (struct cmd_list_element *, int);
818
819 /* Used everywhere whenever at least one parameter is required and
820 none is specified. */
821
822 extern void error_no_arg (const char *) ATTRIBUTE_NORETURN;
823
824
825 /* Command line saving and repetition.
826 Each input line executed is saved to possibly be repeated either
827 when the user types an empty line, or be repeated by a command
828 that wants to repeat the previously executed command. The below
829 functions control command repetition. */
830
831 /* Commands call dont_repeat if they do not want to be repeated by null
832 lines or by repeat_previous (). */
833
834 extern void dont_repeat ();
835
836 /* Commands call repeat_previous if they want to repeat the previous
837 command. Such commands that repeat the previous command must
838 indicate to not repeat themselves, to avoid recursive repeat.
839 repeat_previous marks the current command as not repeating, and
840 ensures get_saved_command_line returns the previous command, so
841 that the currently executing command can repeat it. If there's no
842 previous command, throws an error. Otherwise, returns the result
843 of get_saved_command_line, which now points at the command to
844 repeat. */
845
846 extern const char *repeat_previous ();
847
848 /* Prevent dont_repeat from working, and return a cleanup that
849 restores the previous state. */
850
851 extern scoped_restore_tmpl<int> prevent_dont_repeat (void);
852
853 /* Set the arguments that will be passed if the current command is
854 repeated. Note that the passed-in string must be a constant. */
855
856 extern void set_repeat_arguments (const char *args);
857
858 /* Returns the saved command line to repeat.
859 When a command is being executed, this is the currently executing
860 command line, unless the currently executing command has called
861 repeat_previous (): in this case, get_saved_command_line returns
862 the previously saved command line. */
863
864 extern char *get_saved_command_line ();
865
866 /* Takes a copy of CMD, for possible repetition. */
867
868 extern void save_command_line (const char *cmd);
869
870 /* Used to mark commands that don't do anything. If we just leave the
871 function field NULL, the command is interpreted as a help topic, or
872 as a class of commands. */
873
874 extern void not_just_help_class_command (const char *, int);
875
876 /* Call the command function. */
877 extern void cmd_func (struct cmd_list_element *cmd,
878 const char *args, int from_tty);
879
880 #endif /* !defined (COMMAND_H) */