GDB (xrefs)
Loading...
Searching...
No Matches
command.h
Go to the documentation of this file.
1/* Header file for command creation.
2
3 Copyright (C) 1986-2023 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
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
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 */
54 class_run = 0, /* running */
55 class_vars, /* data */
56 class_stack, /* stack */
57 class_files, /* files */
58 class_support, /* support */
59 class_info, /* status */
60 class_breakpoint, /* breakpoints */
61 class_trace, /* tracepoints */
62 class_alias, /* aliases */
64 class_obscure, /* obscure */
65 class_maintenance, /* internals */
66 class_tui, /* text-user-interface */
67 class_user, /* user-defined */
68
69 /* Used for "show" commands that have no corresponding "set" command. */
71};
72
73/* Types of "set" or "show" command. */
75 {
76 /* "on" or "off". *VAR is a bool which is true for on,
77 false for off. */
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. */
86
87 /* Unsigned Integer. *VAR is an unsigned int. In the Guile and Python
88 APIs 0 means unlimited, which is stored in *VAR as UINT_MAX. */
90
91 /* Like var_uinteger but signed. *VAR is an int. In the Guile and
92 Python APIs 0 means unlimited, which is stored in *VAR as INT_MAX. */
94
95 /* Like var_integer but negative numbers are not allowed,
96 except for special values. *VAR is an int. */
98
99 /* String which the user enters with escapes (e.g. the user types
100 \n and it is a real newline in the stored string).
101 *VAR is a std::string, "" if the string is empty. */
103 /* String which stores what the user types verbatim.
104 *VAR is std::string, "" if the string is empty. */
106 /* String which stores a filename. (*VAR) is a std::string,
107 "" if the string was empty. */
109 /* String which stores a filename. (*VAR) is a std::string. */
111 /* Enumerated type. Can only have one of the specified values.
112 *VAR is a char pointer to the name of the element that we
113 find. */
115 };
116
117/* A structure describing an extra literal accepted and shown in place
118 of a number. */
120{
121 /* The literal to define, e.g. "unlimited". */
122 const char *literal;
123
124 /* The number to substitute internally for LITERAL or VAL;
125 the use of this number is not allowed (unless the same as VAL). */
126 LONGEST use;
127
128 /* An optional number accepted that stands for the literal. */
129 gdb::optional<LONGEST> val;
130};
131
132/* Return true if a setting of type VAR_TYPE is backed with type T.
133
134 This function is left without definition intentionally. This template is
135 specialized for all valid types that are used to back var_types. Therefore
136 if one tries to instantiate this un-specialized template it means the T
137 parameter is not a type used to back a var_type and it is most likely a
138 programming error. */
139template<typename T>
140bool var_type_uses (var_types var_type) = delete;
141
142/* Return true if a setting of type T is backed by a bool variable. */
143template<>
145{
146 return t == var_boolean;
147};
148
149/* Return true if a setting of type T is backed by a auto_boolean variable.
150*/
151template<>
153{
154 return t == var_auto_boolean;
155}
156
157/* Return true if a setting of type T is backed by an unsigned int variable.
158*/
159template<>
161{
162 return t == var_uinteger;
163}
164
165/* Return true if a setting of type T is backed by an int variable. */
166template<>
168{
169 return t == var_integer || t == var_pinteger;
170}
171
172/* Return true if a setting of type T is backed by a std::string variable. */
173template<>
175{
176 return (t == var_string || t == var_string_noescape
177 || t == var_optional_filename || t == var_filename);
178}
179
180/* Return true if a setting of type T is backed by a const char * variable.
181*/
182template<>
184{
185 return t == var_enum;
186}
187
188template<bool is_scalar, typename T> struct setting_func_types_1;
189
190template<typename T>
192{
193 using type = T;
194 using set = void (*) (type);
195 using get = type (*) ();
196};
197
198template<typename T>
200{
201 using type = const T &;
202 using set = void (*) (type);
203 using get = type (*) ();
204};
205
206template<typename T>
213
214/* Generic/type-erased function pointer. */
215
216using erased_func = void (*) ();
217
218/* Interface for getting and setting a setting's value.
219
220 The underlying data can be of any VAR_TYPES type. */
222{
223 /* Create a setting backed by a variable of type T.
224
225 Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */
226 template<typename T>
227 setting (var_types var_type, T *var,
228 const literal_def *extra_literals = nullptr)
229 : m_var_type (var_type), m_var (var), m_extra_literals (extra_literals)
230 {
231 gdb_assert (var != nullptr);
232 gdb_assert (var_type_uses<T> (var_type));
233 }
234
235 /* A setting can also be constructed with a pre-validated
236 type-erased variable. Use the following function to
237 validate & type-erase said variable/function pointers. */
238
245
246 template<typename T>
248 T *var,
249 typename setting_func_types<T>::set set_setting_func,
250 typename setting_func_types<T>::get get_setting_func)
251 {
252 gdb_assert (var_type_uses<T> (var_type));
253 /* The getter and the setter must be both provided or both omitted. */
254 gdb_assert
255 ((set_setting_func == nullptr) == (get_setting_func == nullptr));
256
257 /* The caller must provide a pointer to a variable or get/set functions, but
258 not both. */
259 gdb_assert ((set_setting_func == nullptr) != (var == nullptr));
260
261 return {
262 var,
263 reinterpret_cast<erased_func> (set_setting_func),
264 reinterpret_cast<erased_func> (get_setting_func)
265 };
266 }
267
268 /* Create a setting backed by pre-validated type-erased args and using
269 EXTRA_LITERALS. ERASED_VAR's fields' real types must match the var
270 type VAR_TYPE (see VAR_TYPE_USES). */
272 const erased_args &args)
273 : m_var_type (var_type),
274 m_var (args.var),
276 m_getter (args.getter),
277 m_setter (args.setter)
278 {
279 }
280
281 /* Create a setting backed by setter and getter functions.
282
283 Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */
284 template<typename T>
286 typename setting_func_types<T>::set setter,
287 typename setting_func_types<T>::get getter)
288 : m_var_type (var_type)
289 {
290 gdb_assert (var_type_uses<T> (var_type));
291
292 /* Getters and setters are cast to and from the arbitrary `void (*) ()`
293 function pointer type. Make sure that the two types are really of the
294 same size. */
295 gdb_static_assert (sizeof (m_getter) == sizeof (getter));
296 gdb_static_assert (sizeof (m_setter) == sizeof (setter));
297
298 m_getter = reinterpret_cast<erased_func> (getter);
299 m_setter = reinterpret_cast<erased_func> (setter);
300 }
301
302 /* Access the type of the current setting. */
304 { return m_var_type; }
305
306 /* Access any extra literals accepted. */
308 { return m_extra_literals; }
309
310 /* Return the current value.
311
312 The template parameter T is the type of the variable used to store the
313 setting. */
314 template<typename T>
316 {
317 gdb_assert (var_type_uses<T> (m_var_type));
318
319 if (m_var == nullptr)
320 {
321 gdb_assert (m_getter != nullptr);
322 auto getter = reinterpret_cast<typename setting_func_types<T>::get> (m_getter);
323 return getter ();
324 }
325 else
326 return *static_cast<const T *> (m_var);
327 }
328
329 /* Sets the value of the setting to V. Returns true if the setting was
330 effectively changed, false if the update failed and the setting is left
331 unchanged.
332
333 If we have a user-provided setter, use it to set the setting. Otherwise
334 copy the value V to the internally referenced buffer.
335
336 The template parameter T indicates the type of the variable used to store
337 the setting.
338
339 The var_type of the setting must match T. */
340 template<typename T>
341 bool set (const T &v)
342 {
343 /* Check that the current instance is of one of the supported types for
344 this instantiation. */
345 gdb_assert (var_type_uses<T> (m_var_type));
346
347 const T old_value = this->get<T> ();
348
349 if (m_var == nullptr)
350 {
351 gdb_assert (m_setter != nullptr);
352 auto setter = reinterpret_cast<typename setting_func_types<T>::set> (m_setter);
353 setter (v);
354 }
355 else
356 *static_cast<T *> (m_var) = v;
357
358 return old_value != this->get<T> ();
359 }
360
361private:
362 /* The type of the variable M_VAR is pointing to, or that M_GETTER / M_SETTER
363 get or set. */
365
366 /* Pointer to the enclosed variable
367
368 Either M_VAR is non-nullptr, or both M_GETTER and M_SETTER are
369 non-nullptr. */
370 void *m_var = nullptr;
371
372 /* Any extra literals accepted. */
374
375 /* Pointer to a user provided getter. */
377
378 /* Pointer to a user provided setter. */
380};
381
382/* This structure records one command'd definition. */
383struct cmd_list_element;
384
385/* The "simple" signature of command callbacks, which doesn't include a
386 cmd_list_element parameter. */
387
388typedef void cmd_simple_func_ftype (const char *args, int from_tty);
389
390/* This structure specifies notifications to be suppressed by a cli
391 command interpreter. */
392
394{
395 /* Inferior, thread, frame selected notification suppressed? */
397
398 /* Normal stop event suppressed? */
399 bool normal_stop = false;
400};
401
403
404/* Forward-declarations of the entry-points of cli/cli-decode.c. */
405
406/* API to the manipulation of command lists. */
407
408/* Return TRUE if NAME is a valid user-defined command name.
409 This is a stricter subset of all gdb commands,
410 see find_command_name_length. */
411
412extern bool valid_user_defined_cmd_name_p (const char *name);
413
414/* Return TRUE if C is a valid command character. */
415
416extern bool valid_cmd_char_p (int c);
417
418/* Return value type for the add_setshow_* functions. */
419
424
425/* Const-correct variant of the above. */
426
427extern struct cmd_list_element *add_cmd (const char *, enum command_class,
429 const char *,
430 struct cmd_list_element **);
431
432/* Like add_cmd, but no command function is specified. */
433
434extern struct cmd_list_element *add_cmd (const char *, enum command_class,
435 const char *,
436 struct cmd_list_element **);
437
439 (const char *name, enum command_class theclass,
440 cmd_simple_func_ftype *fun, const char *doc,
441 struct cmd_list_element **list,
443
444extern struct cmd_list_element *add_alias_cmd (const char *,
446 enum command_class, int,
447 struct cmd_list_element **);
448
449
450extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class,
452 const char *,
453 struct cmd_list_element **,
454 int,
455 struct cmd_list_element **);
456
457/* Like add_prefix_cmd, but sets the callback to a function that
458 simply calls help_list. */
459
461 (const char *, enum command_class, const char *, struct cmd_list_element **,
462 int, struct cmd_list_element **);
463
464/* Like add_prefix_cmd, but useful for "show" prefixes. This sets the
465 callback to a function that simply calls cmd_show_list. */
466
468 (const char *, enum command_class, const char *, struct cmd_list_element **,
469 int, struct cmd_list_element **);
470
471/* Add matching set and show commands using add_basic_prefix_cmd and
472 add_show_prefix_cmd. */
473
475 (const char *name, command_class theclass, const char *set_doc,
476 const char *show_doc,
477 cmd_list_element **set_subcommands_list,
478 cmd_list_element **show_subcommands_list,
479 cmd_list_element **set_list,
480 cmd_list_element **show_list);
481
483 (const char *name, enum command_class theclass,
485 const char *doc, struct cmd_list_element **subcommands,
486 int allow_unknown,
487 struct cmd_list_element **list,
489
490extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
491 enum command_class,
493 const char *,
494 struct cmd_list_element
495 **, int,
496 struct cmd_list_element
497 **);
498
499typedef void cmd_func_ftype (const char *args, int from_tty,
501
502/* A completion routine. Add possible completions to tracker.
503
504 TEXT is the text beyond what was matched for the command itself
505 (leading whitespace is skipped). It stops where we are supposed to
506 stop completing (rl_point) and is '\0' terminated. WORD points in
507 the same buffer as TEXT, and completions should be returned
508 relative to this position. For example, suppose TEXT is "foo" and
509 we want to complete to "foobar". If WORD is "oo", return "oobar";
510 if WORD is "baz/foo", return "baz/foobar". */
511typedef void completer_ftype (struct cmd_list_element *,
512 completion_tracker &tracker,
513 const char *text, const char *word);
514
515/* Same, but for set_cmd_completer_handle_brkchars. */
517 completion_tracker &tracker,
518 const char *text, const char *word);
519
520extern void set_cmd_completer (struct cmd_list_element *, completer_ftype *);
521
522/* Set the completer_handle_brkchars callback. */
523
526
527/* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
528 around in cmd objects to test the value of the commands sfunc(). */
529extern int cmd_simple_func_eq (struct cmd_list_element *cmd,
531
532/* Execute CMD's pre/post hook. Throw an error if the command fails.
533 If already executing this pre/post hook, or there is no pre/post
534 hook, the call is silently ignored. */
535extern void execute_cmd_pre_hook (struct cmd_list_element *cmd);
536extern void execute_cmd_post_hook (struct cmd_list_element *cmd);
537
538/* Flag for an ambiguous cmd_list result. */
539#define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1)
540
541extern struct cmd_list_element *lookup_cmd (const char **,
542 struct cmd_list_element *,
543 const char *,
544 std::string *,
545 int, int);
546
547/* This routine takes a line of TEXT and a CLIST in which to start the
548 lookup. When it returns it will have incremented the text pointer past
549 the section of text it matched, set *RESULT_LIST to point to the list in
550 which the last word was matched, and will return a pointer to the cmd
551 list element which the text matches. It will return NULL if no match at
552 all was possible. It will return -1 (cast appropriately, ick) if ambigous
553 matches are possible; in this case *RESULT_LIST will be set to point to
554 the list in which there are ambiguous choices (and *TEXT will be set to
555 the ambiguous text string).
556
557 if DEFAULT_ARGS is not null, *DEFAULT_ARGS is set to the found command
558 default args (possibly empty).
559
560 If the located command was an abbreviation, this routine returns the base
561 command of the abbreviation. Note that *DEFAULT_ARGS will contain the
562 default args defined for the alias.
563
564 It does no error reporting whatsoever; control will always return
565 to the superior routine.
566
567 In the case of an ambiguous return (-1), *RESULT_LIST will be set to point
568 at the prefix_command (ie. the best match) *or* (special case) will be NULL
569 if no prefix command was ever found. For example, in the case of "info a",
570 "info" matches without ambiguity, but "a" could be "args" or "address", so
571 *RESULT_LIST is set to the cmd_list_element for "info". So in this case
572 RESULT_LIST should not be interpreted as a pointer to the beginning of a
573 list; it simply points to a specific command. In the case of an ambiguous
574 return *TEXT is advanced past the last non-ambiguous prefix (e.g.
575 "info t" can be "info types" or "info target"; upon return *TEXT has been
576 advanced past "info ").
577
578 If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise
579 affect the operation).
580
581 This routine does *not* modify the text pointed to by TEXT.
582
583 If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which
584 are actually help classes rather than commands (i.e. the function field of
585 the struct cmd_list_element is NULL).
586
587 When LOOKUP_FOR_COMPLETION_P is true the completion is being requested
588 for the completion engine, no warnings should be printed. */
589
590extern struct cmd_list_element *lookup_cmd_1
591 (const char **text, struct cmd_list_element *clist,
592 struct cmd_list_element **result_list, std::string *default_args,
593 int ignore_help_classes, bool lookup_for_completion_p = false);
594
595/* Look up the command called NAME in the command list LIST.
596
597 Unlike LOOKUP_CMD, partial matches are ignored and only exact matches
598 on NAME are considered.
599
600 LIST is a chain of struct cmd_list_element's.
601
602 If IGNORE_HELP_CLASSES is true (the default), ignore any command list
603 elements which are actually help classes rather than commands (i.e.
604 the function field of the struct cmd_list_element is null).
605
606 If found, return the struct cmd_list_element for that command,
607 otherwise return NULLPTR. */
608
610 (const char *name,
611 struct cmd_list_element *list,
612 bool ignore_help_classes = true);
613
614extern struct cmd_list_element *deprecate_cmd (struct cmd_list_element *,
615 const char * );
616
617extern void deprecated_cmd_warning (const char *, struct cmd_list_element *);
618
619extern int lookup_cmd_composition (const char *text,
620 struct cmd_list_element **alias,
621 struct cmd_list_element **prefix_cmd,
622 struct cmd_list_element **cmd);
623
624extern struct cmd_list_element *add_com (const char *, enum command_class,
626 const char *);
627
628extern cmd_list_element *add_com_alias (const char *name,
629 cmd_list_element *target,
631 int abbrev_flag);
632
634 (const char *name, enum command_class theclass,
635 cmd_simple_func_ftype *fun, const char *doc,
637
638extern struct cmd_list_element *add_info (const char *,
640 const char *);
641
642extern cmd_list_element *add_info_alias (const char *name,
643 cmd_list_element *target,
644 int abbrev_flag);
645
646extern void complete_on_cmdlist (struct cmd_list_element *,
647 completion_tracker &tracker,
648 const char *, const char *, int);
649
650extern void complete_on_enum (completion_tracker &tracker,
651 const char *const *enumlist,
652 const char *, const char *);
653
654/* Functions that implement commands about CLI commands. */
655
656extern void help_list (struct cmd_list_element *, const char *,
657 enum command_class, struct ui_file *);
658
659/* Method for show a set/show variable's VALUE on FILE. */
660typedef void (show_value_ftype) (struct ui_file *file,
661 int from_tty,
662 struct cmd_list_element *cmd,
663 const char *value);
664
665/* Various sets of extra literals accepted. */
669
671 (const char *name, command_class theclass, const char *const *enumlist,
672 const char **var, const char *set_doc, const char *show_doc,
673 const char *help_doc, cmd_func_ftype *set_func,
674 show_value_ftype *show_func, cmd_list_element **set_list,
675 cmd_list_element **show_list);
676
678 (const char *name, command_class theclass, const char *const *enumlist,
679 const char *set_doc, const char *show_doc,
680 const char *help_doc, setting_func_types<const char *>::set set_func,
682 cmd_list_element **set_list, cmd_list_element **show_list);
683
686 const char *set_doc, const char *show_doc, const char *help_doc,
687 cmd_func_ftype *set_func, show_value_ftype *show_func,
688 cmd_list_element **set_list, cmd_list_element **show_list);
689
691 (const char *name, command_class theclass, const char *set_doc,
692 const char *show_doc, const char *help_doc,
695 show_value_ftype *show_func, cmd_list_element **set_list,
696 cmd_list_element **show_list);
697
699 (const char *name, command_class theclass, bool *var, const char *set_doc,
700 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
701 show_value_ftype *show_func, cmd_list_element **set_list,
702 cmd_list_element **show_list);
703
705 (const char *name, command_class theclass, const char *set_doc,
706 const char *show_doc, const char *help_doc,
709 cmd_list_element **set_list, cmd_list_element **show_list);
710
712 (const char *name, command_class theclass, std::string *var, const char *set_doc,
713 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
714 show_value_ftype *show_func, cmd_list_element **set_list,
715 cmd_list_element **show_list);
716
718 (const char *name, command_class theclass, const char *set_doc,
719 const char *show_doc, const char *help_doc,
722 cmd_list_element **set_list, cmd_list_element **show_list);
723
725 (const char *name, command_class theclass, std::string *var, const char *set_doc,
726 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
727 show_value_ftype *show_func, cmd_list_element **set_list,
728 cmd_list_element **show_list);
729
731 (const char *name, command_class theclass, const char *set_doc,
732 const char *show_doc, const char *help_doc,
735 show_value_ftype *show_func, cmd_list_element **set_list,
736 cmd_list_element **show_list);
737
739 (const char *name, command_class theclass, std::string *var, const char *set_doc,
740 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
741 show_value_ftype *show_func, cmd_list_element **set_list,
742 cmd_list_element **show_list);
743
745 (const char *name, command_class theclass, const char *set_doc,
746 const char *show_doc, const char *help_doc,
749 cmd_list_element **set_list, cmd_list_element **show_list);
750
752 (const char *name, command_class theclass, std::string *var, const char *set_doc,
753 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
754 show_value_ftype *show_func, cmd_list_element **set_list,
755 cmd_list_element **show_list);
756
758 (const char *name, command_class theclass, const char *set_doc,
759 const char *show_doc, const char *help_doc,
762 show_value_ftype *show_func, cmd_list_element **set_list,
763 cmd_list_element **show_list);
764
766 (const char *name, command_class theclass, int *var,
767 const literal_def *extra_literals, const char *set_doc,
768 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
769 show_value_ftype *show_func, cmd_list_element **set_list,
770 cmd_list_element **show_list);
771
774 const char *set_doc, const char *show_doc, const char *help_doc,
777 cmd_list_element **set_list, cmd_list_element **show_list);
778
780 (const char *name, command_class theclass, int *var, const char *set_doc,
781 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
782 show_value_ftype *show_func, cmd_list_element **set_list,
783 cmd_list_element **show_list);
784
786 (const char *name, command_class theclass, const char *set_doc,
787 const char *show_doc, const char *help_doc,
790 cmd_list_element **set_list, cmd_list_element **show_list);
791
793 (const char *name, command_class theclass, int *var,
794 const literal_def *extra_literals, const char *set_doc,
795 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
796 show_value_ftype *show_func, cmd_list_element **set_list,
797 cmd_list_element **show_list);
798
801 const char *set_doc, const char *show_doc, const char *help_doc,
804 cmd_list_element **set_list, cmd_list_element **show_list);
805
807 (const char *name, command_class theclass, unsigned int *var,
809 const char *set_doc, const char *show_doc, const char *help_doc,
810 cmd_func_ftype *set_func, show_value_ftype *show_func,
811 cmd_list_element **set_list, cmd_list_element **show_list);
812
815 const char *set_doc, const char *show_doc, const char *help_doc,
818 cmd_list_element **set_list, cmd_list_element **show_list);
819
821 (const char *name, command_class theclass, unsigned int *var,
822 const char *set_doc, const char *show_doc, const char *help_doc,
823 cmd_func_ftype *set_func, show_value_ftype *show_func,
824 cmd_list_element **set_list, cmd_list_element **show_list);
825
827 (const char *name, command_class theclass, const char *set_doc,
828 const char *show_doc, const char *help_doc,
831 cmd_list_element **set_list, cmd_list_element **show_list);
832
834 (const char *name, command_class theclass, int *var, const char *set_doc,
835 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
836 show_value_ftype *show_func, cmd_list_element **set_list,
837 cmd_list_element **show_list);
838
840 (const char *name, command_class theclass, const char *set_doc,
841 const char *show_doc, const char *help_doc,
844 cmd_list_element **set_list, cmd_list_element **show_list);
845
847 (const char *name, command_class theclass, unsigned int *var,
848 const char *set_doc, const char *show_doc, const char *help_doc,
849 cmd_func_ftype *set_func, show_value_ftype *show_func,
850 cmd_list_element **set_list, cmd_list_element **show_list);
851
853 (const char *name, command_class theclass, const char *set_doc,
854 const char *show_doc, const char *help_doc,
857 cmd_list_element **set_list, cmd_list_element **show_list);
858
860 (const char *name, command_class theclass, int *var, const char *set_doc,
861 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
862 show_value_ftype *show_func, cmd_list_element **set_list,
863 cmd_list_element **show_list);
864
866 (const char *name, command_class theclass, const char *set_doc,
867 const char *show_doc, const char *help_doc,
869 show_value_ftype *show_func, cmd_list_element **set_list,
870 cmd_list_element **show_list);
871
872/* Do a "show" command for each thing on a command list. */
873
874extern void cmd_show_list (struct cmd_list_element *, int);
875
876/* Used everywhere whenever at least one parameter is required and
877 none is specified. */
878
879extern void error_no_arg (const char *) ATTRIBUTE_NORETURN;
880
881
882/* Command line saving and repetition.
883 Each input line executed is saved to possibly be repeated either
884 when the user types an empty line, or be repeated by a command
885 that wants to repeat the previously executed command. The below
886 functions control command repetition. */
887
888/* Commands call dont_repeat if they do not want to be repeated by null
889 lines or by repeat_previous (). */
890
891extern void dont_repeat ();
892
893/* Commands call repeat_previous if they want to repeat the previous
894 command. Such commands that repeat the previous command must
895 indicate to not repeat themselves, to avoid recursive repeat.
896 repeat_previous marks the current command as not repeating, and
897 ensures get_saved_command_line returns the previous command, so
898 that the currently executing command can repeat it. If there's no
899 previous command, throws an error. Otherwise, returns the result
900 of get_saved_command_line, which now points at the command to
901 repeat. */
902
903extern const char *repeat_previous ();
904
905/* Prevent dont_repeat from working, and return a cleanup that
906 restores the previous state. */
907
908extern scoped_restore_tmpl<int> prevent_dont_repeat (void);
909
910/* Set the arguments that will be passed if the current command is
911 repeated. Note that the passed-in string must be a constant. */
912
913extern void set_repeat_arguments (const char *args);
914
915/* Returns the saved command line to repeat.
916 When a command is being executed, this is the currently executing
917 command line, unless the currently executing command has called
918 repeat_previous (): in this case, get_saved_command_line returns
919 the previously saved command line. */
920
921extern char *get_saved_command_line ();
922
923/* Takes a copy of CMD, for possible repetition. */
924
925extern void save_command_line (const char *cmd);
926
927/* Used to mark commands that don't do anything. If we just leave the
928 function field NULL, the command is interpreted as a help topic, or
929 as a class of commands. */
930
931extern void not_just_help_class_command (const char *, int);
932
933/* Call the command function. */
934extern void cmd_func (struct cmd_list_element *cmd,
935 const char *args, int from_tty);
936
937#endif /* !defined (COMMAND_H) */
const char *const name
gdb_static_assert(sizeof(splay_tree_key) >=sizeof(CORE_ADDR *))
struct cmd_list_element * lookup_cmd_1(const char **text, struct cmd_list_element *clist, struct cmd_list_element **result_list, std::string *default_args, int ignore_help_classes, bool lookup_for_completion_p=false)
struct cmd_list_element * add_cmd_suppress_notification(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **list, bool *suppress_notification)
Definition cli-decode.c:255
const literal_def pinteger_unlimited_literals[]
void not_just_help_class_command(const char *, int)
Definition cli-decode.c:483
struct cmd_list_element * add_alias_cmd(const char *, cmd_list_element *, enum command_class, int, struct cmd_list_element **)
Definition cli-decode.c:294
void execute_cmd_post_hook(struct cmd_list_element *cmd)
Definition cli-script.c:390
set_show_commands add_setshow_boolean_cmd(const char *name, command_class theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list)
Definition cli-decode.c:809
void(*)() erased_func
Definition command.h:216
struct cmd_list_element * add_com(const char *, enum command_class, cmd_simple_func_ftype *fun, const char *)
scoped_restore_tmpl< int > prevent_dont_repeat(void)
Definition top.c:735
set_show_commands add_setshow_zuinteger_cmd(const char *name, command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list)
struct cmd_list_element * lookup_cmd_exact(const char *name, struct cmd_list_element *list, bool ignore_help_classes=true)
set_show_commands add_setshow_auto_boolean_cmd(const char *name, command_class theclass, auto_boolean *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list)
Definition cli-decode.c:752
void completer_ftype(struct cmd_list_element *, completion_tracker &tracker, const char *text, const char *word)
Definition command.h:511
set_show_commands add_setshow_string_noescape_cmd(const char *name, command_class theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list)
Definition cli-decode.c:953
void deprecated_cmd_warning(const char *, struct cmd_list_element *)
bool var_type_uses< bool >(var_types t)
Definition command.h:144
struct cmd_list_element * add_com_suppress_notification(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc, bool *suppress_notification)
set_show_commands add_setshow_filename_cmd(const char *name, command_class theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list)
Definition cli-decode.c:855
set_show_commands add_setshow_integer_cmd(const char *name, command_class theclass, int *var, const literal_def *extra_literals, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list)
struct cmd_list_element * deprecate_cmd(struct cmd_list_element *, const char *)
Definition cli-decode.c:280
bool valid_cmd_char_p(int c)
set_show_commands add_setshow_pinteger_cmd(const char *name, command_class theclass, int *var, const literal_def *extra_literals, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list)
bool var_type_uses< enum auto_boolean >(var_types t)
Definition command.h:152
struct cmd_list_element * add_cmd(const char *, enum command_class, cmd_simple_func_ftype *fun, const char *, struct cmd_list_element **)
Definition cli-decode.c:243
struct cmd_list_element * add_info(const char *, cmd_simple_func_ftype *fun, const char *)
cmd_list_element * add_com_alias(const char *name, cmd_list_element *target, command_class theclass, int abbrev_flag)
set_show_commands add_setshow_enum_cmd(const char *name, command_class theclass, const char *const *enumlist, const char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list)
Definition cli-decode.c:688
void cmd_simple_func_ftype(const char *args, int from_tty)
Definition command.h:388
void set_cmd_completer_handle_brkchars(struct cmd_list_element *, completer_handle_brkchars_ftype *)
Definition cli-decode.c:125
const literal_def integer_unlimited_literals[]
set_show_commands add_setshow_zuinteger_unlimited_cmd(const char *name, command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list)
void show_value_ftype(struct ui_file *file, int from_tty, struct cmd_list_element *cmd, const char *value)
Definition command.h:660
struct cmd_list_element * add_basic_prefix_cmd(const char *, enum command_class, const char *, struct cmd_list_element **, int, struct cmd_list_element **)
Definition cli-decode.c:391
set_show_commands add_setshow_string_cmd(const char *name, command_class theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list)
Definition cli-decode.c:903
void cmd_show_list(struct cmd_list_element *, int)
void save_command_line(const char *cmd)
Definition top.c:751
void complete_on_enum(completion_tracker &tracker, const char *const *enumlist, const char *, const char *)
const char * repeat_previous()
Definition top.c:716
void cmd_func(struct cmd_list_element *cmd, const char *args, int from_tty)
struct cmd_list_element * lookup_cmd(const char **, struct cmd_list_element *, const char *, std::string *, int, int)
struct cmd_list_element * add_abbrev_prefix_cmd(const char *, enum command_class, cmd_simple_func_ftype *fun, const char *, struct cmd_list_element **, int, struct cmd_list_element **)
Definition cli-decode.c:468
set_show_commands add_setshow_optional_filename_cmd(const char *name, command_class theclass, std::string *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list)
void dont_repeat()
Definition top.c:696
struct cmd_list_element * add_prefix_cmd_suppress_notification(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list, bool *suppress_notification)
Definition cli-decode.c:452
set_show_commands add_setshow_prefix_cmd(const char *name, command_class theclass, const char *set_doc, const char *show_doc, cmd_list_element **set_subcommands_list, cmd_list_element **show_subcommands_list, cmd_list_element **set_list, cmd_list_element **show_list)
Definition cli-decode.c:428
void error_no_arg(const char *) ATTRIBUTE_NORETURN
Definition cli-cmds.c:206
void complete_on_cmdlist(struct cmd_list_element *, completion_tracker &tracker, const char *, const char *, int)
struct cmd_list_element * add_show_prefix_cmd(const char *, enum command_class, const char *, struct cmd_list_element **, int, struct cmd_list_element **)
Definition cli-decode.c:414
bool valid_user_defined_cmd_name_p(const char *name)
int cmd_simple_func_eq(struct cmd_list_element *cmd, cmd_simple_func_ftype *cfun)
Definition cli-decode.c:110
cmd_list_element * add_info_alias(const char *name, cmd_list_element *target, int abbrev_flag)
var_types
Definition command.h:75
@ var_optional_filename
Definition command.h:108
@ var_pinteger
Definition command.h:97
@ var_integer
Definition command.h:93
@ var_string
Definition command.h:102
@ var_boolean
Definition command.h:78
@ var_auto_boolean
Definition command.h:85
@ var_string_noescape
Definition command.h:105
@ var_filename
Definition command.h:110
@ var_uinteger
Definition command.h:89
@ var_enum
Definition command.h:114
char * get_saved_command_line()
Definition top.c:743
const literal_def uinteger_unlimited_literals[]
set_show_commands add_setshow_uinteger_cmd(const char *name, command_class theclass, unsigned int *var, const literal_def *extra_literals, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list)
void completer_handle_brkchars_ftype(struct cmd_list_element *, completion_tracker &tracker, const char *text, const char *word)
Definition command.h:516
void cmd_func_ftype(const char *args, int from_tty, cmd_list_element *c)
Definition command.h:499
bool var_type_uses< std::string >(var_types t)
Definition command.h:174
command_class
Definition command.h:43
@ class_tui
Definition command.h:66
@ class_bookmark
Definition command.h:63
@ class_user
Definition command.h:67
@ all_commands
Definition command.h:50
@ class_obscure
Definition command.h:64
@ class_maintenance
Definition command.h:65
@ class_breakpoint
Definition command.h:60
@ class_vars
Definition command.h:55
@ class_support
Definition command.h:58
@ no_set_class
Definition command.h:70
@ class_alias
Definition command.h:62
@ class_stack
Definition command.h:56
@ class_trace
Definition command.h:61
@ class_run
Definition command.h:54
@ class_files
Definition command.h:57
@ all_classes
Definition command.h:49
@ no_class
Definition command.h:53
@ class_info
Definition command.h:59
bool var_type_uses(var_types var_type)=delete
int lookup_cmd_composition(const char *text, struct cmd_list_element **alias, struct cmd_list_element **prefix_cmd, struct cmd_list_element **cmd)
bool var_type_uses< int >(var_types t)
Definition command.h:167
void set_cmd_completer(struct cmd_list_element *, completer_ftype *)
Definition cli-decode.c:117
bool var_type_uses< const char * >(var_types t)
Definition command.h:183
bool var_type_uses< unsigned int >(var_types t)
Definition command.h:160
struct cmd_list_element * add_prefix_cmd(const char *, enum command_class, cmd_simple_func_ftype *fun, const char *, struct cmd_list_element **, int, struct cmd_list_element **)
Definition cli-decode.c:357
set_show_commands add_setshow_zinteger_cmd(const char *name, command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, cmd_list_element **set_list, cmd_list_element **show_list)
void set_repeat_arguments(const char *args)
Definition top.c:450
void help_list(struct cmd_list_element *, const char *, enum command_class, struct ui_file *)
void execute_cmd_pre_hook(struct cmd_list_element *cmd)
Definition cli-script.c:379
auto_boolean
Definition defs.h:247
const char * alias
Definition nds32-tdep.c:114
int value
Definition py-param.c:79
enum var_types type
Definition scm-param.c:142
const literal_def * extra_literals
Definition scm-param.c:145
Definition 1.cc:26
unsigned int abbrev_flag
Definition cli-decode.h:164
const char * doc
Definition cli-decode.h:193
bool * suppress_notification
Definition cli-decode.h:271
gdb::optional< setting > var
Definition cli-decode.h:236
std::string default_args
Definition cli-decode.h:210
struct cmd_list_element ** subcommands
Definition cli-decode.h:214
unsigned int allow_unknown
Definition cli-decode.h:158
enum command_class theclass
Definition cli-decode.h:119
const char * literal
Definition command.h:122
LONGEST use
Definition command.h:126
gdb::optional< LONGEST > val
Definition command.h:129
cmd_list_element * set
Definition command.h:422
cmd_list_element * show
Definition command.h:422
erased_func getter
Definition command.h:243
erased_func setter
Definition command.h:242
typename setting_func_types_1< std::is_scalar< T >::value, T >::get get
Definition command.h:211
typename setting_func_types_1< std::is_scalar< T >::value, T >::type type
Definition command.h:209
typename setting_func_types_1< std::is_scalar< T >::value, T >::set set
Definition command.h:210
setting(var_types var_type, T *var, const literal_def *extra_literals=nullptr)
Definition command.h:227
static erased_args erase_args(var_types var_type, T *var, typename setting_func_types< T >::set set_setting_func, typename setting_func_types< T >::get get_setting_func)
Definition command.h:247
const literal_def * m_extra_literals
Definition command.h:373
const literal_def * extra_literals() const
Definition command.h:307
bool set(const T &v)
Definition command.h:341
setting(var_types var_type, const literal_def *extra_literals, const erased_args &args)
Definition command.h:271
erased_func m_setter
Definition command.h:379
setting(var_types var_type, typename setting_func_types< T >::set setter, typename setting_func_types< T >::get getter)
Definition command.h:285
var_types m_var_type
Definition command.h:364
setting_func_types< T >::type get() const
Definition command.h:315
void * m_var
Definition command.h:370
erased_func m_getter
Definition command.h:376
var_types type() const
Definition command.h:303