GDB (xrefs)
Loading...
Searching...
No Matches
/tmp/gdb-13.1/gdb/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. The user can type
88 0 to mean "unlimited", which is stored in *VAR as UINT_MAX. */
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. */
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. */
101 /* String which stores what the user types verbatim.
102 *VAR is std::string, "" if the string is empty. */
104 /* String which stores a filename. (*VAR) is a std::string,
105 "" if the string was empty. */
107 /* String which stores a filename. (*VAR) is a std::string. */
109 /* ZeroableInteger. *VAR is an int. Like var_integer except
110 that zero really means zero. */
112 /* ZeroableUnsignedInteger. *VAR is an unsigned int. Zero really
113 means zero. */
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. */
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. */
123 };
124
125/* Return true if a setting of type VAR_TYPE is backed with type T.
126
127 This function is left without definition intentionally. This template is
128 specialized for all valid types that are used to back var_types. Therefore
129 if one tries to instantiate this un-specialized template it means the T
130 parameter is not a type used to back a var_type and it is most likely a
131 programming error. */
132template<typename T>
133bool var_type_uses (var_types var_type) = delete;
134
135/* Return true if a setting of type T is backed by a bool variable. */
136template<>
138{
139 return t == var_boolean;
140};
141
142/* Return true if a setting of type T is backed by a auto_boolean variable.
143*/
144template<>
146{
147 return t == var_auto_boolean;
148}
149
150/* Return true if a setting of type T is backed by an unsigned int variable.
151*/
152template<>
154{
155 return (t == var_uinteger || t == var_zinteger || t == var_zuinteger);
156}
157
158/* Return true if a setting of type T is backed by an int variable. */
159template<>
161{
162 return (t == var_integer || t == var_zinteger
164}
165
166/* Return true if a setting of type T is backed by a std::string variable. */
167template<>
169{
170 return (t == var_string || t == var_string_noescape
171 || t == var_optional_filename || t == var_filename);
172}
173
174/* Return true if a setting of type T is backed by a const char * variable.
175*/
176template<>
178{
179 return t == var_enum;
180}
181
182template<bool is_scalar, typename T> struct setting_func_types_1;
183
184template<typename T>
186{
187 using type = T;
188 using set = void (*) (type);
189 using get = type (*) ();
190};
191
192template<typename T>
194{
195 using type = const T &;
196 using set = void (*) (type);
197 using get = type (*) ();
198};
199
200template<typename T>
202{
206};
207
208/* Generic/type-erased function pointer. */
209
210using erased_func = void (*) ();
211
212/* Interface for getting and setting a setting's value.
213
214 The underlying data can be of any VAR_TYPES type. */
216{
217 /* Create a setting backed by a variable of type T.
218
219 Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */
220 template<typename T>
221 setting (var_types var_type, T *var)
222 : m_var_type (var_type), m_var (var)
223 {
224 gdb_assert (var != nullptr);
225 gdb_assert (var_type_uses<T> (var_type));
226 }
227
228 /* A setting can also be constructed with a pre-validated
229 type-erased variable. Use the following function to
230 validate & type-erase said variable/function pointers. */
231
233 {
234 void *var;
237 };
238
239 template<typename T>
241 T *var,
242 typename setting_func_types<T>::set set_setting_func,
243 typename setting_func_types<T>::get get_setting_func)
244 {
245 gdb_assert (var_type_uses<T> (var_type));
246 /* The getter and the setter must be both provided or both omitted. */
247 gdb_assert
248 ((set_setting_func == nullptr) == (get_setting_func == nullptr));
249
250 /* The caller must provide a pointer to a variable or get/set functions, but
251 not both. */
252 gdb_assert ((set_setting_func == nullptr) != (var == nullptr));
253
254 return {
255 var,
256 reinterpret_cast<erased_func> (set_setting_func),
257 reinterpret_cast<erased_func> (get_setting_func)
258 };
259 }
260
261 /* Create a setting backed by pre-validated type-erased args.
262 ERASED_VAR's fields' real types must match the var type VAR_TYPE
263 (see VAR_TYPE_USES). */
264 setting (var_types var_type, const erased_args &args)
265 : m_var_type (var_type),
266 m_var (args.var),
267 m_getter (args.getter),
268 m_setter (args.setter)
269 {
270 }
271
272 /* Create a setting backed by setter and getter functions.
273
274 Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */
275 template<typename T>
277 typename setting_func_types<T>::set setter,
278 typename setting_func_types<T>::get getter)
279 : m_var_type (var_type)
280 {
281 gdb_assert (var_type_uses<T> (var_type));
282
283 /* Getters and setters are cast to and from the arbitrary `void (*) ()`
284 function pointer type. Make sure that the two types are really of the
285 same size. */
286 gdb_static_assert (sizeof (m_getter) == sizeof (getter));
287 gdb_static_assert (sizeof (m_setter) == sizeof (setter));
288
289 m_getter = reinterpret_cast<erased_func> (getter);
290 m_setter = reinterpret_cast<erased_func> (setter);
291 }
292
293 /* Access the type of the current setting. */
295 { return m_var_type; }
296
297 /* Return the current value.
298
299 The template parameter T is the type of the variable used to store the
300 setting. */
301 template<typename T>
303 {
304 gdb_assert (var_type_uses<T> (m_var_type));
305
306 if (m_var == nullptr)
307 {
308 gdb_assert (m_getter != nullptr);
309 auto getter = reinterpret_cast<typename setting_func_types<T>::get> (m_getter);
310 return getter ();
311 }
312 else
313 return *static_cast<const T *> (m_var);
314 }
315
316 /* Sets the value of the setting to V. Returns true if the setting was
317 effectively changed, false if the update failed and the setting is left
318 unchanged.
319
320 If we have a user-provided setter, use it to set the setting. Otherwise
321 copy the value V to the internally referenced buffer.
322
323 The template parameter T indicates the type of the variable used to store
324 the setting.
325
326 The var_type of the setting must match T. */
327 template<typename T>
328 bool set (const T &v)
329 {
330 /* Check that the current instance is of one of the supported types for
331 this instantiation. */
332 gdb_assert (var_type_uses<T> (m_var_type));
333
334 const T old_value = this->get<T> ();
335
336 if (m_var == nullptr)
337 {
338 gdb_assert (m_setter != nullptr);
339 auto setter = reinterpret_cast<typename setting_func_types<T>::set> (m_setter);
340 setter (v);
341 }
342 else
343 *static_cast<T *> (m_var) = v;
344
345 return old_value != this->get<T> ();
346 }
347
348private:
349 /* The type of the variable M_VAR is pointing to, or that M_GETTER / M_SETTER
350 get or set. */
352
353 /* Pointer to the enclosed variable
354
355 Either M_VAR is non-nullptr, or both M_GETTER and M_SETTER are
356 non-nullptr. */
357 void *m_var = nullptr;
358
359 /* Pointer to a user provided getter. */
361
362 /* Pointer to a user provided setter. */
364};
365
366/* This structure records one command'd definition. */
367struct cmd_list_element;
368
369/* The "simple" signature of command callbacks, which doesn't include a
370 cmd_list_element parameter. */
371
372typedef void cmd_simple_func_ftype (const char *args, int from_tty);
373
374/* This structure specifies notifications to be suppressed by a cli
375 command interpreter. */
376
378{
379 /* Inferior, thread, frame selected notification suppressed? */
381
382 /* Normal stop event suppressed? */
383 bool normal_stop = false;
384};
385
387
388/* Forward-declarations of the entry-points of cli/cli-decode.c. */
389
390/* API to the manipulation of command lists. */
391
392/* Return TRUE if NAME is a valid user-defined command name.
393 This is a stricter subset of all gdb commands,
394 see find_command_name_length. */
395
396extern bool valid_user_defined_cmd_name_p (const char *name);
397
398/* Return TRUE if C is a valid command character. */
399
400extern bool valid_cmd_char_p (int c);
401
402/* Return value type for the add_setshow_* functions. */
403
405{
407};
408
409/* Const-correct variant of the above. */
410
411extern struct cmd_list_element *add_cmd (const char *, enum command_class,
413 const char *,
414 struct cmd_list_element **);
415
416/* Like add_cmd, but no command function is specified. */
417
418extern struct cmd_list_element *add_cmd (const char *, enum command_class,
419 const char *,
420 struct cmd_list_element **);
421
423 (const char *name, enum command_class theclass,
424 cmd_simple_func_ftype *fun, const char *doc,
425 struct cmd_list_element **list,
427
428extern struct cmd_list_element *add_alias_cmd (const char *,
430 enum command_class, int,
431 struct cmd_list_element **);
432
433
434extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class,
436 const char *,
437 struct cmd_list_element **,
438 int,
439 struct cmd_list_element **);
440
441/* Like add_prefix_cmd, but sets the callback to a function that
442 simply calls help_list. */
443
445 (const char *, enum command_class, const char *, struct cmd_list_element **,
446 int, struct cmd_list_element **);
447
448/* Like add_prefix_cmd, but useful for "show" prefixes. This sets the
449 callback to a function that simply calls cmd_show_list. */
450
452 (const char *, enum command_class, const char *, struct cmd_list_element **,
453 int, struct cmd_list_element **);
454
455/* Add matching set and show commands using add_basic_prefix_cmd and
456 add_show_prefix_cmd. */
457
459 (const char *name, command_class theclass, const char *set_doc,
460 const char *show_doc,
461 cmd_list_element **set_subcommands_list,
462 cmd_list_element **show_subcommands_list,
463 cmd_list_element **set_list,
464 cmd_list_element **show_list);
465
467 (const char *name, enum command_class theclass,
469 const char *doc, struct cmd_list_element **subcommands,
470 int allow_unknown,
471 struct cmd_list_element **list,
473
474extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
475 enum command_class,
477 const char *,
478 struct cmd_list_element
479 **, int,
480 struct cmd_list_element
481 **);
482
483typedef void cmd_func_ftype (const char *args, int from_tty,
485
486/* A completion routine. Add possible completions to tracker.
487
488 TEXT is the text beyond what was matched for the command itself
489 (leading whitespace is skipped). It stops where we are supposed to
490 stop completing (rl_point) and is '\0' terminated. WORD points in
491 the same buffer as TEXT, and completions should be returned
492 relative to this position. For example, suppose TEXT is "foo" and
493 we want to complete to "foobar". If WORD is "oo", return "oobar";
494 if WORD is "baz/foo", return "baz/foobar". */
495typedef void completer_ftype (struct cmd_list_element *,
496 completion_tracker &tracker,
497 const char *text, const char *word);
498
499/* Same, but for set_cmd_completer_handle_brkchars. */
501 completion_tracker &tracker,
502 const char *text, const char *word);
503
504extern void set_cmd_completer (struct cmd_list_element *, completer_ftype *);
505
506/* Set the completer_handle_brkchars callback. */
507
510
511/* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
512 around in cmd objects to test the value of the commands sfunc(). */
513extern int cmd_simple_func_eq (struct cmd_list_element *cmd,
515
516/* Execute CMD's pre/post hook. Throw an error if the command fails.
517 If already executing this pre/post hook, or there is no pre/post
518 hook, the call is silently ignored. */
519extern void execute_cmd_pre_hook (struct cmd_list_element *cmd);
520extern void execute_cmd_post_hook (struct cmd_list_element *cmd);
521
522/* Flag for an ambiguous cmd_list result. */
523#define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1)
524
525extern struct cmd_list_element *lookup_cmd (const char **,
526 struct cmd_list_element *,
527 const char *,
528 std::string *,
529 int, int);
530
531/* This routine takes a line of TEXT and a CLIST in which to start the
532 lookup. When it returns it will have incremented the text pointer past
533 the section of text it matched, set *RESULT_LIST to point to the list in
534 which the last word was matched, and will return a pointer to the cmd
535 list element which the text matches. It will return NULL if no match at
536 all was possible. It will return -1 (cast appropriately, ick) if ambigous
537 matches are possible; in this case *RESULT_LIST will be set to point to
538 the list in which there are ambiguous choices (and *TEXT will be set to
539 the ambiguous text string).
540
541 if DEFAULT_ARGS is not null, *DEFAULT_ARGS is set to the found command
542 default args (possibly empty).
543
544 If the located command was an abbreviation, this routine returns the base
545 command of the abbreviation. Note that *DEFAULT_ARGS will contain the
546 default args defined for the alias.
547
548 It does no error reporting whatsoever; control will always return
549 to the superior routine.
550
551 In the case of an ambiguous return (-1), *RESULT_LIST will be set to point
552 at the prefix_command (ie. the best match) *or* (special case) will be NULL
553 if no prefix command was ever found. For example, in the case of "info a",
554 "info" matches without ambiguity, but "a" could be "args" or "address", so
555 *RESULT_LIST is set to the cmd_list_element for "info". So in this case
556 RESULT_LIST should not be interpreted as a pointer to the beginning of a
557 list; it simply points to a specific command. In the case of an ambiguous
558 return *TEXT is advanced past the last non-ambiguous prefix (e.g.
559 "info t" can be "info types" or "info target"; upon return *TEXT has been
560 advanced past "info ").
561
562 If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise
563 affect the operation).
564
565 This routine does *not* modify the text pointed to by TEXT.
566
567 If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which
568 are actually help classes rather than commands (i.e. the function field of
569 the struct cmd_list_element is NULL).
570
571 When LOOKUP_FOR_COMPLETION_P is true the completion is being requested
572 for the completion engine, no warnings should be printed. */
573
574extern struct cmd_list_element *lookup_cmd_1
575 (const char **text, struct cmd_list_element *clist,
576 struct cmd_list_element **result_list, std::string *default_args,
577 int ignore_help_classes, bool lookup_for_completion_p = false);
578
579/* Look up the command called NAME in the command list LIST.
580
581 Unlike LOOKUP_CMD, partial matches are ignored and only exact matches
582 on NAME are considered.
583
584 LIST is a chain of struct cmd_list_element's.
585
586 If IGNORE_HELP_CLASSES is true (the default), ignore any command list
587 elements which are actually help classes rather than commands (i.e.
588 the function field of the struct cmd_list_element is null).
589
590 If found, return the struct cmd_list_element for that command,
591 otherwise return NULLPTR. */
592
594 (const char *name,
595 struct cmd_list_element *list,
596 bool ignore_help_classes = true);
597
598extern struct cmd_list_element *deprecate_cmd (struct cmd_list_element *,
599 const char * );
600
601extern void deprecated_cmd_warning (const char *, struct cmd_list_element *);
602
603extern int lookup_cmd_composition (const char *text,
604 struct cmd_list_element **alias,
605 struct cmd_list_element **prefix_cmd,
606 struct cmd_list_element **cmd);
607
608extern struct cmd_list_element *add_com (const char *, enum command_class,
610 const char *);
611
612extern cmd_list_element *add_com_alias (const char *name,
613 cmd_list_element *target,
615 int abbrev_flag);
616
618 (const char *name, enum command_class theclass,
619 cmd_simple_func_ftype *fun, const char *doc,
620 bool *supress_notification);
621
622extern struct cmd_list_element *add_info (const char *,
624 const char *);
625
626extern cmd_list_element *add_info_alias (const char *name,
627 cmd_list_element *target,
628 int abbrev_flag);
629
630extern void complete_on_cmdlist (struct cmd_list_element *,
631 completion_tracker &tracker,
632 const char *, const char *, int);
633
634extern void complete_on_enum (completion_tracker &tracker,
635 const char *const *enumlist,
636 const char *, const char *);
637
638/* Functions that implement commands about CLI commands. */
639
640extern void help_list (struct cmd_list_element *, const char *,
641 enum command_class, struct ui_file *);
642
643/* Method for show a set/show variable's VALUE on FILE. If this
644 method isn't supplied deprecated_show_value_hack() is called (which
645 is not good). */
646typedef void (show_value_ftype) (struct ui_file *file,
647 int from_tty,
648 struct cmd_list_element *cmd,
649 const char *value);
650/* NOTE: i18n: This function is not i18n friendly. Callers should
651 instead print the value out directly. */
653
655 (const char *name, command_class theclass, const char *const *enumlist,
656 const char **var, const char *set_doc, const char *show_doc,
657 const char *help_doc, cmd_func_ftype *set_func,
658 show_value_ftype *show_func, cmd_list_element **set_list,
659 cmd_list_element **show_list);
660
662 (const char *name, command_class theclass, const char *const *enumlist,
663 const char *set_doc, const char *show_doc,
664 const char *help_doc, setting_func_types<const char *>::set set_func,
666 cmd_list_element **set_list, cmd_list_element **show_list);
667
670 const char *set_doc, const char *show_doc, const char *help_doc,
671 cmd_func_ftype *set_func, show_value_ftype *show_func,
672 cmd_list_element **set_list, cmd_list_element **show_list);
673
675 (const char *name, command_class theclass, const char *set_doc,
676 const char *show_doc, const char *help_doc,
679 show_value_ftype *show_func, cmd_list_element **set_list,
680 cmd_list_element **show_list);
681
683 (const char *name, command_class theclass, bool *var, const char *set_doc,
684 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
685 show_value_ftype *show_func, cmd_list_element **set_list,
686 cmd_list_element **show_list);
687
689 (const char *name, command_class theclass, const char *set_doc,
690 const char *show_doc, const char *help_doc,
693 cmd_list_element **set_list, cmd_list_element **show_list);
694
696 (const char *name, command_class theclass, std::string *var, const char *set_doc,
697 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
698 show_value_ftype *show_func, cmd_list_element **set_list,
699 cmd_list_element **show_list);
700
702 (const char *name, command_class theclass, const char *set_doc,
703 const char *show_doc, const char *help_doc,
706 cmd_list_element **set_list, cmd_list_element **show_list);
707
709 (const char *name, command_class theclass, std::string *var, const char *set_doc,
710 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
711 show_value_ftype *show_func, cmd_list_element **set_list,
712 cmd_list_element **show_list);
713
715 (const char *name, command_class theclass, const char *set_doc,
716 const char *show_doc, const char *help_doc,
719 show_value_ftype *show_func, cmd_list_element **set_list,
720 cmd_list_element **show_list);
721
723 (const char *name, command_class theclass, std::string *var, const char *set_doc,
724 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
725 show_value_ftype *show_func, cmd_list_element **set_list,
726 cmd_list_element **show_list);
727
729 (const char *name, command_class theclass, const char *set_doc,
730 const char *show_doc, const char *help_doc,
733 cmd_list_element **set_list, cmd_list_element **show_list);
734
736 (const char *name, command_class theclass, std::string *var, const char *set_doc,
737 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
738 show_value_ftype *show_func, cmd_list_element **set_list,
739 cmd_list_element **show_list);
740
742 (const char *name, command_class theclass, const char *set_doc,
743 const char *show_doc, const char *help_doc,
746 show_value_ftype *show_func, cmd_list_element **set_list,
747 cmd_list_element **show_list);
748
750 (const char *name, command_class theclass, int *var, const char *set_doc,
751 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
752 show_value_ftype *show_func, cmd_list_element **set_list,
753 cmd_list_element **show_list);
754
756 (const char *name, command_class theclass, const char *set_doc,
757 const char *show_doc, const char *help_doc,
760 cmd_list_element **set_list, cmd_list_element **show_list);
761
763 (const char *name, command_class theclass, unsigned int *var,
764 const char *set_doc, const char *show_doc, const char *help_doc,
765 cmd_func_ftype *set_func, show_value_ftype *show_func,
766 cmd_list_element **set_list, cmd_list_element **show_list);
767
769 (const char *name, command_class theclass, const char *set_doc,
770 const char *show_doc, const char *help_doc,
773 cmd_list_element **set_list, cmd_list_element **show_list);
774
776 (const char *name, command_class theclass, int *var, const char *set_doc,
777 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
778 show_value_ftype *show_func, cmd_list_element **set_list,
779 cmd_list_element **show_list);
780
782 (const char *name, command_class theclass, const char *set_doc,
783 const char *show_doc, const char *help_doc,
786 cmd_list_element **set_list, cmd_list_element **show_list);
787
789 (const char *name, command_class theclass, unsigned int *var,
790 const char *set_doc, const char *show_doc, const char *help_doc,
791 cmd_func_ftype *set_func, show_value_ftype *show_func,
792 cmd_list_element **set_list, cmd_list_element **show_list);
793
795 (const char *name, command_class theclass, const char *set_doc,
796 const char *show_doc, const char *help_doc,
799 cmd_list_element **set_list, cmd_list_element **show_list);
800
802 (const char *name, command_class theclass, int *var, const char *set_doc,
803 const char *show_doc, const char *help_doc, cmd_func_ftype *set_func,
804 show_value_ftype *show_func, cmd_list_element **set_list,
805 cmd_list_element **show_list);
806
808 (const char *name, command_class theclass, const char *set_doc,
809 const char *show_doc, const char *help_doc,
811 show_value_ftype *show_func, cmd_list_element **set_list,
812 cmd_list_element **show_list);
813
814/* Do a "show" command for each thing on a command list. */
815
816extern void cmd_show_list (struct cmd_list_element *, int);
817
818/* Used everywhere whenever at least one parameter is required and
819 none is specified. */
820
821extern void error_no_arg (const char *) ATTRIBUTE_NORETURN;
822
823
824/* Command line saving and repetition.
825 Each input line executed is saved to possibly be repeated either
826 when the user types an empty line, or be repeated by a command
827 that wants to repeat the previously executed command. The below
828 functions control command repetition. */
829
830/* Commands call dont_repeat if they do not want to be repeated by null
831 lines or by repeat_previous (). */
832
833extern void dont_repeat ();
834
835/* Commands call repeat_previous if they want to repeat the previous
836 command. Such commands that repeat the previous command must
837 indicate to not repeat themselves, to avoid recursive repeat.
838 repeat_previous marks the current command as not repeating, and
839 ensures get_saved_command_line returns the previous command, so
840 that the currently executing command can repeat it. If there's no
841 previous command, throws an error. Otherwise, returns the result
842 of get_saved_command_line, which now points at the command to
843 repeat. */
844
845extern const char *repeat_previous ();
846
847/* Prevent dont_repeat from working, and return a cleanup that
848 restores the previous state. */
849
850extern scoped_restore_tmpl<int> prevent_dont_repeat (void);
851
852/* Set the arguments that will be passed if the current command is
853 repeated. Note that the passed-in string must be a constant. */
854
855extern void set_repeat_arguments (const char *args);
856
857/* Returns the saved command line to repeat.
858 When a command is being executed, this is the currently executing
859 command line, unless the currently executing command has called
860 repeat_previous (): in this case, get_saved_command_line returns
861 the previously saved command line. */
862
863extern char *get_saved_command_line ();
864
865/* Takes a copy of CMD, for possible repetition. */
866
867extern void save_command_line (const char *cmd);
868
869/* Used to mark commands that don't do anything. If we just leave the
870 function field NULL, the command is interpreted as a help topic, or
871 as a class of commands. */
872
873extern void not_just_help_class_command (const char *, int);
874
875/* Call the command function. */
876extern void cmd_func (struct cmd_list_element *cmd,
877 const char *args, int from_tty);
878
879#endif /* !defined (COMMAND_H) */
const char *const name
Definition: aarch64-tdep.c:67
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)
Definition: cli-decode.c:1980
struct cmd_list_element * add_com_suppress_notification(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc, bool *supress_notification)
Definition: cli-decode.c:1332
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
set_show_commands add_setshow_integer_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)
Definition: cli-decode.c:1004
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:389
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:739
void(*)() erased_func
Definition: command.h:210
struct cmd_list_element * add_com(const char *, enum command_class, cmd_simple_func_ftype *fun, const char *)
Definition: cli-decode.c:1310
scoped_restore_tmpl< int > prevent_dont_repeat(void)
Definition: top.c:848
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)
Definition: cli-decode.c:1190
struct cmd_list_element * lookup_cmd_exact(const char *name, struct cmd_list_element *list, bool ignore_help_classes=true)
Definition: cli-decode.c:2237
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:682
void completer_ftype(struct cmd_list_element *, completion_tracker &tracker, const char *text, const char *word)
Definition: command.h:495
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:883
void deprecated_cmd_warning(const char *, struct cmd_list_element *)
Definition: cli-decode.c:2272
bool var_type_uses< bool >(var_types t)
Definition: command.h:137
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:785
struct cmd_list_element * deprecate_cmd(struct cmd_list_element *, const char *)
Definition: cli-decode.c:280
bool valid_cmd_char_p(int c)
Definition: cli-decode.c:1948
set_show_commands add_setshow_uinteger_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)
Definition: cli-decode.c:1053
bool var_type_uses< enum auto_boolean >(var_types t)
Definition: command.h:145
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 *)
Definition: cli-decode.c:1294
cmd_list_element * add_com_alias(const char *name, cmd_list_element *target, command_class theclass, int abbrev_flag)
Definition: cli-decode.c:1323
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:618
void cmd_simple_func_ftype(const char *args, int from_tty)
Definition: command.h:372
void set_cmd_completer_handle_brkchars(struct cmd_list_element *, completer_handle_brkchars_ftype *)
Definition: cli-decode.c:125
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)
Definition: cli-decode.c:1138
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:833
void cmd_show_list(struct cmd_list_element *, int)
Definition: cli-setshow.c:700
void save_command_line(const char *cmd)
Definition: top.c:864
void complete_on_enum(completion_tracker &tracker, const char *const *enumlist, const char *, const char *)
Definition: cli-decode.c:2519
const char * repeat_previous()
Definition: top.c:829
void cmd_func(struct cmd_list_element *cmd, const char *args, int from_tty)
Definition: cli-decode.c:2534
void() show_value_ftype(struct ui_file *file, int from_tty, struct cmd_list_element *cmd, const char *value)
Definition: command.h:646
struct cmd_list_element * lookup_cmd(const char **, struct cmd_list_element *, const char *, std::string *, int, int)
Definition: cli-decode.c:2133
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)
Definition: cli-decode.c:934
void dont_repeat()
Definition: top.c:809
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:204
show_value_ftype deprecated_show_value_hack
void complete_on_cmdlist(struct cmd_list_element *, completion_tracker &tracker, const char *, const char *, int)
Definition: cli-decode.c:2461
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)
Definition: cli-decode.c:1959
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)
Definition: cli-decode.c:1302
var_types
Definition: command.h:75
@ var_optional_filename
Definition: command.h:106
@ var_integer
Definition: command.h:95
@ var_string
Definition: command.h:100
@ var_boolean
Definition: command.h:78
@ var_auto_boolean
Definition: command.h:85
@ var_zuinteger_unlimited
Definition: command.h:118
@ var_string_noescape
Definition: command.h:103
@ var_zuinteger
Definition: command.h:114
@ var_filename
Definition: command.h:108
@ var_zinteger
Definition: command.h:111
@ var_uinteger
Definition: command.h:89
@ var_enum
Definition: command.h:122
char * get_saved_command_line()
Definition: top.c:856
void completer_handle_brkchars_ftype(struct cmd_list_element *, completion_tracker &tracker, const char *text, const char *word)
Definition: command.h:500
void cmd_func_ftype(const char *args, int from_tty, cmd_list_element *c)
Definition: command.h:483
bool var_type_uses< std::string >(var_types t)
Definition: command.h:168
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)
Definition: cli-decode.c:2442
bool var_type_uses< int >(var_types t)
Definition: command.h:160
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:177
bool var_type_uses< unsigned int >(var_types t)
Definition: command.h:153
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)
Definition: cli-decode.c:1103
void set_repeat_arguments(const char *args)
Definition: top.c:565
void help_list(struct cmd_list_element *, const char *, enum command_class, struct ui_file *)
Definition: cli-decode.c:1649
void execute_cmd_pre_hook(struct cmd_list_element *cmd)
Definition: cli-script.c:378
auto_boolean
Definition: defs.h:248
const char * alias
Definition: nds32-tdep.c:114
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:274
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
cmd_list_element * set
Definition: command.h:406
cmd_list_element * show
Definition: command.h:406
erased_func getter
Definition: command.h:236
erased_func setter
Definition: command.h:235
typename setting_func_types_1< std::is_scalar< T >::value, T >::get get
Definition: command.h:205
typename setting_func_types_1< std::is_scalar< T >::value, T >::type type
Definition: command.h:203
typename setting_func_types_1< std::is_scalar< T >::value, T >::set set
Definition: command.h:204
setting(var_types var_type, const erased_args &args)
Definition: command.h:264
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:240
bool set(const T &v)
Definition: command.h:328
erased_func m_setter
Definition: command.h:363
setting(var_types var_type, T *var)
Definition: command.h:221
setting(var_types var_type, typename setting_func_types< T >::set setter, typename setting_func_types< T >::get getter)
Definition: command.h:276
var_types m_var_type
Definition: command.h:351
setting_func_types< T >::type get() const
Definition: command.h:302
void * m_var
Definition: command.h:357
erased_func m_getter
Definition: command.h:360
var_types type() const
Definition: command.h:294
Definition: gdbtypes.h:922
Definition: value.c:181