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