GDB (xrefs)
Loading...
Searching...
No Matches
cli-decode.c
Go to the documentation of this file.
1/* Handle lists of commands, their decoding and documentation, for GDB.
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#include "defs.h"
19#include "symtab.h"
20#include <ctype.h>
21#include "gdbsupport/gdb_regex.h"
22#include "completer.h"
23#include "ui-out.h"
24#include "cli/cli-cmds.h"
25#include "cli/cli-decode.h"
26#include "cli/cli-style.h"
27#include "gdbsupport/gdb_optional.h"
28
29/* Prototypes for local functions. */
30
31static void undef_cmd_error (const char *, const char *);
32
34 (const char *name, cmd_list_element **list, cmd_list_element **prehook,
35 cmd_list_element **prehookee, cmd_list_element **posthook,
36 cmd_list_element **posthookee);
37
38static struct cmd_list_element *find_cmd (const char *command,
39 int len,
40 struct cmd_list_element *clist,
41 int ignore_help_classes,
42 int *nfound);
43
44static void help_cmd_list (struct cmd_list_element *list,
46 bool recurse,
47 struct ui_file *stream);
48
49static void help_all (struct ui_file *stream);
50
51static int lookup_cmd_composition_1 (const char *text,
52 struct cmd_list_element **alias,
53 struct cmd_list_element **prefix_cmd,
54 struct cmd_list_element **cmd,
55 struct cmd_list_element *cur_list);
56
57/* Look up a command whose 'subcommands' field is SUBCOMMANDS. Return the
58 command if found, otherwise return NULL. */
59
60static struct cmd_list_element *
62 cmd_list_element *list)
63{
64 struct cmd_list_element *p = NULL;
65
66 for (p = list; p != NULL; p = p->next)
67 {
68 struct cmd_list_element *q;
69
70 if (!p->is_prefix ())
71 continue;
72
73 else if (p->subcommands == subcommands)
74 {
75 /* If we found an alias, we must return the aliased
76 command. */
77 return p->is_alias () ? p->alias_target : p;
78 }
79
81 if (q != NULL)
82 return q;
83 }
84
85 return NULL;
86}
87
88static void
90 bool recurse, struct ui_file *stream);
91
92static void
93do_simple_func (const char *args, int from_tty, cmd_list_element *c)
94{
95 c->function.simple_func (args, from_tty);
96}
97
98static void
100{
101 if (simple_func == NULL)
102 cmd->func = NULL;
103 else
104 cmd->func = do_simple_func;
105
107}
108
109int
115
116void
118{
119 cmd->completer = completer; /* Ok. */
120}
121
122/* See definition in commands.h. */
123
124void
130
131std::string
133{
134 if (!this->is_prefix ())
135 /* Not a prefix command. */
136 return "";
137
138 std::string prefixname;
139 if (this->prefix != nullptr)
140 prefixname = this->prefix->prefixname ();
141
142 prefixname += this->name;
143 prefixname += " ";
144
145 return prefixname;
146}
147
148/* See cli/cli-decode.h. */
149
150std::vector<std::string>
152{
153 std::vector<std::string> result;
154
155 if (this->prefix != nullptr)
156 result = this->prefix->command_components ();
157
158 result.emplace_back (this->name);
159 return result;
160}
161
162/* Add element named NAME.
163 Space for NAME and DOC must be allocated by the caller.
164 THECLASS is the top level category into which commands are broken down
165 for "help" purposes.
166 FUN should be the function to execute the command;
167 it will get a character string as argument, with leading
168 and trailing blanks already eliminated.
169
170 DOC is a documentation string for the command.
171 Its first line should be a complete sentence.
172 It should start with ? for a command that is an abbreviation
173 or with * for a command that most users don't need to know about.
174
175 Add this command to command list *LIST.
176
177 Returns a pointer to the added command (not necessarily the head
178 of *LIST). */
179
180static struct cmd_list_element *
182 const char *doc, struct cmd_list_element **list)
183{
184 struct cmd_list_element *c = new struct cmd_list_element (name, theclass,
185 doc);
186
187 /* Turn each alias of the old command into an alias of the new
188 command. */
189 c->aliases = delete_cmd (name, list, &c->hook_pre, &c->hookee_pre,
190 &c->hook_post, &c->hookee_post);
191
192 for (cmd_list_element &alias : c->aliases)
193 alias.alias_target = c;
194
195 if (c->hook_pre)
196 c->hook_pre->hookee_pre = c;
197
198 if (c->hookee_pre)
199 c->hookee_pre->hook_pre = c;
200
201 if (c->hook_post)
202 c->hook_post->hookee_post = c;
203
204 if (c->hookee_post)
205 c->hookee_post->hook_post = c;
206
207 if (*list == NULL || strcmp ((*list)->name, name) >= 0)
208 {
209 c->next = *list;
210 *list = c;
211 }
212 else
213 {
214 cmd_list_element *p = *list;
215 while (p->next && strcmp (p->next->name, name) <= 0)
216 {
217 p = p->next;
218 }
219 c->next = p->next;
220 p->next = c;
221 }
222
223 /* Search the prefix cmd of C, and assigns it to C->prefix.
224 See also add_prefix_cmd and update_prefix_field_of_prefixed_commands. */
226 c->prefix = prefixcmd;
227
228
229 return c;
230}
231
232struct cmd_list_element *
234 const char *doc, struct cmd_list_element **list)
235{
236 cmd_list_element *result = do_add_cmd (name, theclass, doc, list);
237 result->func = NULL;
238 result->function.simple_func = NULL;
239 return result;
240}
241
242struct cmd_list_element *
245 const char *doc, struct cmd_list_element **list)
246{
247 cmd_list_element *result = do_add_cmd (name, theclass, doc, list);
248 set_cmd_simple_func (result, fun);
249 return result;
250}
251
252/* Add an element with a suppress notification to the LIST of commands. */
253
254struct cmd_list_element *
256 cmd_simple_func_ftype *fun, const char *doc,
257 struct cmd_list_element **list,
259{
260 struct cmd_list_element *element;
261
262 element = add_cmd (name, theclass, fun, doc, list);
264
265 return element;
266}
267
268
269/* Deprecates a command CMD.
270 REPLACEMENT is the name of the command which should be used in
271 place of this command, or NULL if no such command exists.
272
273 This function does not check to see if command REPLACEMENT exists
274 since gdb may not have gotten around to adding REPLACEMENT when
275 this function is called.
276
277 Returns a pointer to the deprecated command. */
278
279struct cmd_list_element *
281{
282 cmd->cmd_deprecated = 1;
283 cmd->deprecated_warn_user = 1;
284
285 if (replacement != NULL)
287 else
288 cmd->replacement = NULL;
289
290 return cmd;
291}
292
293struct cmd_list_element *
294add_alias_cmd (const char *name, cmd_list_element *target,
296 struct cmd_list_element **list)
297{
298 gdb_assert (target != nullptr);
299
300 struct cmd_list_element *c = add_cmd (name, theclass, target->doc, list);
301
302 /* If TARGET->DOC can be freed, we should make another copy. */
303 if (target->doc_allocated)
304 {
305 c->doc = xstrdup (target->doc);
306 c->doc_allocated = 1;
307 }
308 /* NOTE: Both FUNC and all the FUNCTIONs need to be copied. */
309 c->func = target->func;
310 c->function = target->function;
311 c->subcommands = target->subcommands;
312 c->allow_unknown = target->allow_unknown;
314 c->alias_target = target;
315 target->aliases.push_front (*c);
316
317 return c;
318}
319
320/* Update the prefix field of all sub-commands of the prefix command C.
321 We must do this when a prefix command is defined as the GDB init sequence
322 does not guarantee that a prefix command is created before its sub-commands.
323 For example, break-catch-sig.c initialization runs before breakpoint.c
324 initialization, but it is breakpoint.c that creates the "catch" command used
325 by the "catch signal" command created by break-catch-sig.c. */
326
327static void
329{
330 for (cmd_list_element *p = *c->subcommands; p != NULL; p = p->next)
331 {
332 p->prefix = c;
333
334 /* We must recursively update the prefix field to cover
335 e.g. 'info auto-load libthread-db' where the creation
336 order was:
337 libthread-db
338 auto-load
339 info
340 In such a case, when 'auto-load' was created by do_add_cmd,
341 the 'libthread-db' prefix field could not be updated, as the
342 'auto-load' command was not yet reachable by
343 lookup_cmd_for_subcommands (list, cmdlist)
344 that searches from the top level 'cmdlist'. */
345 if (p->is_prefix ())
347 }
348}
349
350
351/* Like add_cmd but adds an element for a command prefix: a name that
352 should be followed by a subcommand to be looked up in another
353 command list. SUBCOMMANDS should be the address of the variable
354 containing that list. */
355
356struct cmd_list_element *
359 const char *doc, struct cmd_list_element **subcommands,
360 int allow_unknown, struct cmd_list_element **list)
361{
362 struct cmd_list_element *c = add_cmd (name, theclass, fun, doc, list);
363
366
367 /* Now that prefix command C is defined, we need to set the prefix field
368 of all prefixed commands that were defined before C itself was defined. */
370
371 return c;
372}
373
374/* A helper function for add_basic_prefix_cmd. This is a command
375 function that just forwards to help_list. */
376
377static void
378do_prefix_cmd (const char *args, int from_tty, struct cmd_list_element *c)
379{
380 /* Look past all aliases. */
381 while (c->is_alias ())
382 c = c->alias_target;
383
384 help_list (*c->subcommands, c->prefixname ().c_str (),
386}
387
388/* See command.h. */
389
390struct cmd_list_element *
392 const char *doc, struct cmd_list_element **subcommands,
393 int allow_unknown, struct cmd_list_element **list)
394{
395 struct cmd_list_element *cmd = add_prefix_cmd (name, theclass, nullptr,
397 allow_unknown, list);
398 cmd->func = do_prefix_cmd;
399 return cmd;
400}
401
402/* A helper function for add_show_prefix_cmd. This is a command
403 function that just forwards to cmd_show_list. */
404
405static void
406do_show_prefix_cmd (const char *args, int from_tty, struct cmd_list_element *c)
407{
408 cmd_show_list (*c->subcommands, from_tty);
409}
410
411/* See command.h. */
412
413struct cmd_list_element *
415 const char *doc, struct cmd_list_element **subcommands,
416 int allow_unknown, struct cmd_list_element **list)
417{
418 struct cmd_list_element *cmd = add_prefix_cmd (name, theclass, nullptr,
420 allow_unknown, list);
422 return cmd;
423}
424
425/* See command.h. */
426
429 const char *set_doc, const char *show_doc,
430 cmd_list_element **set_subcommands_list,
431 cmd_list_element **show_subcommands_list,
432 cmd_list_element **set_list,
433 cmd_list_element **show_list)
434{
436
437 cmds.set = add_basic_prefix_cmd (name, theclass, set_doc,
438 set_subcommands_list, 0,
439 set_list);
440 cmds.show = add_show_prefix_cmd (name, theclass, show_doc,
441 show_subcommands_list, 0,
442 show_list);
443
444 return cmds;
445}
446
447/* Like ADD_PREFIX_CMD but sets the suppress_notification pointer on the
448 new command list element. */
449
450struct cmd_list_element *
452 (const char *name, enum command_class theclass,
454 const char *doc, struct cmd_list_element **subcommands,
455 int allow_unknown, struct cmd_list_element **list,
457{
458 struct cmd_list_element *element
460 allow_unknown, list);
462 return element;
463}
464
465/* Like add_prefix_cmd but sets the abbrev_flag on the new command. */
466
467struct cmd_list_element *
469 cmd_simple_func_ftype *fun, const char *doc,
471 int allow_unknown, struct cmd_list_element **list)
472{
473 struct cmd_list_element *c = add_cmd (name, theclass, fun, doc, list);
474
477 c->abbrev_flag = 1;
478 return c;
479}
480
481/* This is an empty "simple func". */
482void
483not_just_help_class_command (const char *args, int from_tty)
484{
485}
486
487/* This is an empty cmd func. */
488
489static void
490empty_func (const char *args, int from_tty, cmd_list_element *c)
491{
492}
493
494/* Add element named NAME to command list LIST (the list for set/show
495 or some sublist thereof).
496 TYPE is set_cmd or show_cmd.
497 THECLASS is as in add_cmd.
498 VAR_TYPE is the kind of thing we are setting.
499 EXTRA_LITERALS if non-NULL define extra literals to be accepted in lieu of
500 a number for integer variables.
501 ARGS is a pre-validated type-erased reference to the variable being
502 controlled by this command.
503 DOC is the documentation string. */
504
505static struct cmd_list_element *
507 enum cmd_types type,
509 var_types var_type,
511 const setting::erased_args &arg,
512 const char *doc,
513 struct cmd_list_element **list)
514{
515 struct cmd_list_element *c = add_cmd (name, theclass, doc, list);
516
517 gdb_assert (type == set_cmd || type == show_cmd);
518 c->type = type;
519 c->var.emplace (var_type, extra_literals, arg);
520
521 /* This needs to be something besides NULL so that this isn't
522 treated as a help class. */
523 c->func = empty_func;
524 return c;
525}
526
527/* Add element named NAME to both command lists SET_LIST and SHOW_LIST.
528 THECLASS is as in add_cmd. VAR_TYPE is the kind of thing we are
529 setting. EXTRA_LITERALS if non-NULL define extra literals to be
530 accepted in lieu of a number for integer variables. ARGS is a
531 pre-validated type-erased reference to the variable being controlled
532 by this command. SET_FUNC and SHOW_FUNC are the callback functions
533 (if non-NULL). SET_DOC, SHOW_DOC and HELP_DOC are the documentation
534 strings.
535
536 Return the newly created set and show commands. */
537
541 var_types var_type,
543 const setting::erased_args &args,
544 const char *set_doc, const char *show_doc,
545 const char *help_doc,
546 cmd_func_ftype *set_func,
547 show_value_ftype *show_func,
548 struct cmd_list_element **set_list,
549 struct cmd_list_element **show_list)
550{
551 struct cmd_list_element *set;
552 struct cmd_list_element *show;
553 gdb::unique_xmalloc_ptr<char> full_set_doc;
554 gdb::unique_xmalloc_ptr<char> full_show_doc;
555
556 if (help_doc != NULL)
557 {
558 full_set_doc = xstrprintf ("%s\n%s", set_doc, help_doc);
559 full_show_doc = xstrprintf ("%s\n%s", show_doc, help_doc);
560 }
561 else
562 {
563 full_set_doc = make_unique_xstrdup (set_doc);
564 full_show_doc = make_unique_xstrdup (show_doc);
565 }
566 set = add_set_or_show_cmd (name, set_cmd, theclass, var_type,
567 extra_literals, args,
568 full_set_doc.release (), set_list);
569 set->doc_allocated = 1;
570
571 if (set_func != NULL)
572 set->func = set_func;
573
574 show = add_set_or_show_cmd (name, show_cmd, theclass, var_type,
575 extra_literals, args,
576 full_show_doc.release (), show_list);
577 show->doc_allocated = 1;
578 show->show_value_func = show_func;
579 /* Disable the default symbol completer. Doesn't make much sense
580 for the "show" command to complete on anything. */
581 set_cmd_completer (show, nullptr);
582
583 return {set, show};
584}
585
586/* Completes on integer commands that support extra literals. */
587
588static void
590 completion_tracker &tracker,
591 const char *text, const char *word)
592{
593 const literal_def *extra_literals = c->var->extra_literals ();
594
595 if (*text == '\0')
596 {
597 tracker.add_completion (make_unique_xstrdup ("NUMBER"));
598 for (const literal_def *l = extra_literals;
599 l->literal != nullptr;
600 l++)
601 tracker.add_completion (make_unique_xstrdup (l->literal));
602 }
603 else
604 for (const literal_def *l = extra_literals;
605 l->literal != nullptr;
606 l++)
607 if (startswith (l->literal, text))
608 tracker.add_completion (make_unique_xstrdup (l->literal));
609}
610
611/* Add element named NAME to both command lists SET_LIST and SHOW_LIST.
612 THECLASS is as in add_cmd. VAR_TYPE is the kind of thing we are
613 setting. VAR is address of the variable being controlled by this
614 command. EXTRA_LITERALS if non-NULL define extra literals to be
615 accepted in lieu of a number for integer variables. If nullptr is
616 given as VAR, then both SET_SETTING_FUNC and GET_SETTING_FUNC must
617 be provided. SET_SETTING_FUNC and GET_SETTING_FUNC are callbacks
618 used to access and modify the underlying property, whatever its
619 storage is. SET_FUNC and SHOW_FUNC are the callback functions
620 (if non-NULL). SET_DOC, SHOW_DOC and HELP_DOC are the
621 documentation strings.
622
623 Return the newly created set and show commands. */
624
625template<typename T>
629 var_types var_type, T *var,
631 const char *set_doc, const char *show_doc,
632 const char *help_doc,
633 typename setting_func_types<T>::set set_setting_func,
634 typename setting_func_types<T>::get get_setting_func,
635 cmd_func_ftype *set_func,
636 show_value_ftype *show_func,
637 struct cmd_list_element **set_list,
638 struct cmd_list_element **show_list)
639{
640 auto erased_args
641 = setting::erase_args (var_type, var,
642 set_setting_func, get_setting_func);
644 theclass,
645 var_type, extra_literals,
646 erased_args,
647 set_doc, show_doc,
648 help_doc,
649 set_func,
650 show_func,
651 set_list,
652 show_list);
653
654 if (extra_literals != nullptr)
656
657 return cmds;
658}
659
660/* Same as above but omitting EXTRA_LITERALS. */
661
662template<typename T>
666 var_types var_type, T *var,
667 const char *set_doc, const char *show_doc,
668 const char *help_doc,
669 typename setting_func_types<T>::set set_setting_func,
670 typename setting_func_types<T>::get get_setting_func,
671 cmd_func_ftype *set_func,
672 show_value_ftype *show_func,
673 struct cmd_list_element **set_list,
674 struct cmd_list_element **show_list)
675{
676 return add_setshow_cmd_full (name, theclass, var_type, var, nullptr,
677 set_doc, show_doc, help_doc,
678 set_setting_func, get_setting_func,
679 set_func, show_func, set_list, show_list);
680}
681
682/* Add element named NAME to command list LIST (the list for set or
683 some sublist thereof). THECLASS is as in add_cmd. ENUMLIST is a list
684 of strings which may follow NAME. VAR is address of the variable
685 which will contain the matching string (from ENUMLIST). */
686
690 const char *const *enumlist,
691 const char **var,
692 const char *set_doc,
693 const char *show_doc,
694 const char *help_doc,
695 cmd_func_ftype *set_func,
696 show_value_ftype *show_func,
697 struct cmd_list_element **set_list,
698 struct cmd_list_element **show_list)
699{
700 /* We require *VAR to be initialized before this call, and
701 furthermore it must be == to one of the values in ENUMLIST. */
702 gdb_assert (var != nullptr && *var != nullptr);
703 for (int i = 0; ; ++i)
704 {
705 gdb_assert (enumlist[i] != nullptr);
706 if (*var == enumlist[i])
707 break;
708 }
709
710 set_show_commands commands
711 = add_setshow_cmd_full<const char *> (name, theclass, var_enum, var,
712 set_doc, show_doc, help_doc,
713 nullptr, nullptr, set_func,
714 show_func, set_list, show_list);
715 commands.set->enums = enumlist;
716 return commands;
717}
718
719/* Same as above but using a getter and a setter function instead of a pointer
720 to a global storage buffer. */
721
724 const char *const *enumlist, const char *set_doc,
725 const char *show_doc, const char *help_doc,
728 show_value_ftype *show_func,
729 cmd_list_element **set_list,
730 cmd_list_element **show_list)
731{
732 auto cmds = add_setshow_cmd_full<const char *> (name, theclass, var_enum,
733 nullptr, set_doc, show_doc,
734 help_doc, set_func, get_func,
735 nullptr, show_func, set_list,
736 show_list);
737
738 cmds.set->enums = enumlist;
739
740 return cmds;
741}
742
743/* See cli-decode.h. */
744const char * const auto_boolean_enums[] = { "on", "off", "auto", NULL };
745
746/* Add an auto-boolean command named NAME to both the set and show
747 command list lists. THECLASS is as in add_cmd. VAR is address of the
748 variable which will contain the value. DOC is the documentation
749 string. FUNC is the corresponding callback. */
750
754 enum auto_boolean *var,
755 const char *set_doc, const char *show_doc,
756 const char *help_doc,
757 cmd_func_ftype *set_func,
758 show_value_ftype *show_func,
759 struct cmd_list_element **set_list,
760 struct cmd_list_element **show_list)
761{
762 set_show_commands commands
763 = add_setshow_cmd_full<enum auto_boolean> (name, theclass, var_auto_boolean,
764 var, set_doc, show_doc, help_doc,
765 nullptr, nullptr, set_func,
766 show_func, set_list, show_list);
767
768 commands.set->enums = auto_boolean_enums;
769
770 return commands;
771}
772
773/* Same as above but using a getter and a setter function instead of a pointer
774 to a global storage buffer. */
775
778 const char *set_doc, const char *show_doc,
779 const char *help_doc,
782 show_value_ftype *show_func,
783 cmd_list_element **set_list,
784 cmd_list_element **show_list)
785{
786 auto cmds = add_setshow_cmd_full<enum auto_boolean> (name, theclass,
788 nullptr, set_doc,
789 show_doc, help_doc,
790 set_func, get_func,
791 nullptr, show_func,
792 set_list, show_list);
793
794 cmds.set->enums = auto_boolean_enums;
795
796 return cmds;
797}
798
799/* See cli-decode.h. */
800const char * const boolean_enums[] = { "on", "off", NULL };
801
802/* Add element named NAME to both the set and show command LISTs (the
803 list for set/show or some sublist thereof). THECLASS is as in
804 add_cmd. VAR is address of the variable which will contain the
805 value. SET_DOC and SHOW_DOC are the documentation strings.
806 Returns the new command element. */
807
810 const char *set_doc, const char *show_doc,
811 const char *help_doc,
812 cmd_func_ftype *set_func,
813 show_value_ftype *show_func,
814 struct cmd_list_element **set_list,
815 struct cmd_list_element **show_list)
816{
817 set_show_commands commands
818 = add_setshow_cmd_full<bool> (name, theclass, var_boolean, var,
819 set_doc, show_doc, help_doc,
820 nullptr, nullptr, set_func, show_func,
821 set_list, show_list);
822
823 commands.set->enums = boolean_enums;
824
825 return commands;
826}
827
828/* Same as above but using a getter and a setter function instead of a pointer
829 to a global storage buffer. */
830
833 const char *set_doc, const char *show_doc,
834 const char *help_doc,
837 show_value_ftype *show_func,
838 cmd_list_element **set_list,
839 cmd_list_element **show_list)
840{
841 auto cmds = add_setshow_cmd_full<bool> (name, theclass, var_boolean, nullptr,
842 set_doc, show_doc, help_doc,
843 set_func, get_func, nullptr,
844 show_func, set_list, show_list);
845
846 cmds.set->enums = boolean_enums;
847
848 return cmds;
849}
850
851/* Add element named NAME to both the set and show command LISTs (the
852 list for set/show or some sublist thereof). */
853
856 std::string *var,
857 const char *set_doc, const char *show_doc,
858 const char *help_doc,
859 cmd_func_ftype *set_func,
860 show_value_ftype *show_func,
861 struct cmd_list_element **set_list,
862 struct cmd_list_element **show_list)
863{
864 set_show_commands commands
865 = add_setshow_cmd_full<std::string> (name, theclass, var_filename, var,
866 set_doc, show_doc, help_doc,
867 nullptr, nullptr, set_func,
868 show_func, set_list, show_list);
869
871
872 return commands;
873}
874
875/* Same as above but using a getter and a setter function instead of a pointer
876 to a global storage buffer. */
877
880 const char *set_doc, const char *show_doc,
881 const char *help_doc,
884 show_value_ftype *show_func,
885 cmd_list_element **set_list,
886 cmd_list_element **show_list)
887{
888 auto cmds = add_setshow_cmd_full<std::string> (name, theclass, var_filename,
889 nullptr, set_doc, show_doc,
890 help_doc, set_func, get_func,
891 nullptr, show_func, set_list,
892 show_list);
893
895
896 return cmds;
897}
898
899/* Add element named NAME to both the set and show command LISTs (the
900 list for set/show or some sublist thereof). */
901
904 std::string *var,
905 const char *set_doc, const char *show_doc,
906 const char *help_doc,
907 cmd_func_ftype *set_func,
908 show_value_ftype *show_func,
909 struct cmd_list_element **set_list,
910 struct cmd_list_element **show_list)
911{
912 set_show_commands commands
913 = add_setshow_cmd_full<std::string> (name, theclass, var_string, var,
914 set_doc, show_doc, help_doc,
915 nullptr, nullptr, set_func,
916 show_func, set_list, show_list);
917
918 /* Disable the default symbol completer. */
919 set_cmd_completer (commands.set, nullptr);
920
921 return commands;
922}
923
924/* Same as above but using a getter and a setter function instead of a pointer
925 to a global storage buffer. */
926
929 const char *set_doc, const char *show_doc,
930 const char *help_doc,
933 show_value_ftype *show_func,
934 cmd_list_element **set_list,
935 cmd_list_element **show_list)
936{
937 auto cmds = add_setshow_cmd_full<std::string> (name, theclass, var_string,
938 nullptr, set_doc, show_doc,
939 help_doc, set_func, get_func,
940 nullptr, show_func, set_list,
941 show_list);
942
943 /* Disable the default symbol completer. */
944 set_cmd_completer (cmds.set, nullptr);
945
946 return cmds;
947}
948
949/* Add element named NAME to both the set and show command LISTs (the
950 list for set/show or some sublist thereof). */
951
954 std::string *var,
955 const char *set_doc, const char *show_doc,
956 const char *help_doc,
957 cmd_func_ftype *set_func,
958 show_value_ftype *show_func,
959 struct cmd_list_element **set_list,
960 struct cmd_list_element **show_list)
961{
962 set_show_commands commands
963 = add_setshow_cmd_full<std::string> (name, theclass, var_string_noescape,
964 var, set_doc, show_doc, help_doc,
965 nullptr, nullptr, set_func, show_func,
966 set_list, show_list);
967
968 /* Disable the default symbol completer. */
969 set_cmd_completer (commands.set, nullptr);
970
971 return commands;
972}
973
974/* Same as above but using a getter and a setter function instead of a pointer
975 to a global storage buffer. */
976
979 const char *set_doc, const char *show_doc,
980 const char *help_doc,
983 show_value_ftype *show_func,
984 cmd_list_element **set_list,
985 cmd_list_element **show_list)
986{
987 auto cmds = add_setshow_cmd_full<std::string> (name, theclass,
988 var_string_noescape, nullptr,
989 set_doc, show_doc, help_doc,
990 set_func, get_func,
991 nullptr, show_func, set_list,
992 show_list);
993
994 /* Disable the default symbol completer. */
995 set_cmd_completer (cmds.set, nullptr);
996
997 return cmds;
998}
999
1000/* Add element named NAME to both the set and show command LISTs (the
1001 list for set/show or some sublist thereof). */
1002
1005 std::string *var,
1006 const char *set_doc, const char *show_doc,
1007 const char *help_doc,
1008 cmd_func_ftype *set_func,
1009 show_value_ftype *show_func,
1010 struct cmd_list_element **set_list,
1011 struct cmd_list_element **show_list)
1012{
1013 set_show_commands commands
1014 = add_setshow_cmd_full<std::string> (name, theclass, var_optional_filename,
1015 var, set_doc, show_doc, help_doc,
1016 nullptr, nullptr, set_func, show_func,
1017 set_list, show_list);
1018
1020
1021 return commands;
1022}
1023
1024/* Same as above but using a getter and a setter function instead of a pointer
1025 to a global storage buffer. */
1026
1029 const char *set_doc, const char *show_doc,
1030 const char *help_doc,
1033 show_value_ftype *show_func,
1034 cmd_list_element **set_list,
1035 cmd_list_element **show_list)
1036{
1037 auto cmds =
1038 add_setshow_cmd_full<std::string> (name, theclass, var_optional_filename,
1039 nullptr, set_doc, show_doc, help_doc,
1040 set_func, get_func, nullptr, show_func,
1041 set_list,show_list);
1042
1044
1045 return cmds;
1046}
1047
1048/* Add element named NAME to both the set and show command LISTs (the
1049 list for set/show or some sublist thereof). THECLASS is as in
1050 add_cmd. VAR is address of the variable which will contain the
1051 value. SET_DOC and SHOW_DOC are the documentation strings. This
1052 function is only used in Python API. Please don't use it elsewhere. */
1053
1056 int *var, const literal_def *extra_literals,
1057 const char *set_doc, const char *show_doc,
1058 const char *help_doc,
1059 cmd_func_ftype *set_func,
1060 show_value_ftype *show_func,
1061 struct cmd_list_element **set_list,
1062 struct cmd_list_element **show_list)
1063{
1064 set_show_commands commands
1065 = add_setshow_cmd_full<int> (name, theclass, var_integer, var,
1066 extra_literals, set_doc, show_doc,
1067 help_doc, nullptr, nullptr, set_func,
1068 show_func, set_list, show_list);
1069 return commands;
1070}
1071
1072/* Same as above but using a getter and a setter function instead of a pointer
1073 to a global storage buffer. */
1074
1078 const char *set_doc, const char *show_doc,
1079 const char *help_doc,
1082 show_value_ftype *show_func,
1083 cmd_list_element **set_list,
1084 cmd_list_element **show_list)
1085{
1086 auto cmds = add_setshow_cmd_full<int> (name, theclass, var_integer, nullptr,
1087 extra_literals, set_doc, show_doc,
1088 help_doc, set_func, get_func, nullptr,
1089 show_func, set_list, show_list);
1090 return cmds;
1091}
1092
1093/* Accept `unlimited' or 0, translated internally to INT_MAX. */
1095 {
1096 { "unlimited", INT_MAX, 0 },
1097 { nullptr }
1098 };
1099
1100/* Same as above but using `integer_unlimited_literals', with a pointer
1101 to a global storage buffer. */
1102
1105 int *var,
1106 const char *set_doc, const char *show_doc,
1107 const char *help_doc,
1108 cmd_func_ftype *set_func,
1109 show_value_ftype *show_func,
1110 struct cmd_list_element **set_list,
1111 struct cmd_list_element **show_list)
1112{
1113 set_show_commands commands
1114 = add_setshow_cmd_full<int> (name, theclass, var_integer, var,
1116 set_doc, show_doc, help_doc,
1117 nullptr, nullptr, set_func,
1118 show_func, set_list, show_list);
1119 return commands;
1120}
1121
1122/* Same as above but using a getter and a setter function instead of a pointer
1123 to a global storage buffer. */
1124
1127 const char *set_doc, const char *show_doc,
1128 const char *help_doc,
1131 show_value_ftype *show_func,
1132 cmd_list_element **set_list,
1133 cmd_list_element **show_list)
1134{
1135 auto cmds = add_setshow_cmd_full<int> (name, theclass, var_integer, nullptr,
1137 set_doc, show_doc, help_doc, set_func,
1138 get_func, nullptr, show_func, set_list,
1139 show_list);
1140 return cmds;
1141}
1142
1143/* Add element named NAME to both the set and show command LISTs (the
1144 list for set/show or some sublist thereof). CLASS is as in
1145 add_cmd. VAR is address of the variable which will contain the
1146 value. SET_DOC and SHOW_DOC are the documentation strings. */
1147
1150 int *var, const literal_def *extra_literals,
1151 const char *set_doc, const char *show_doc,
1152 const char *help_doc,
1153 cmd_func_ftype *set_func,
1154 show_value_ftype *show_func,
1155 struct cmd_list_element **set_list,
1156 struct cmd_list_element **show_list)
1157{
1158 set_show_commands commands
1159 = add_setshow_cmd_full<int> (name, theclass, var_pinteger, var,
1160 extra_literals, set_doc, show_doc,
1161 help_doc, nullptr, nullptr, set_func,
1162 show_func, set_list, show_list);
1163 return commands;
1164}
1165
1166/* Same as above but using a getter and a setter function instead of a pointer
1167 to a global storage buffer. */
1168
1172 const char *set_doc, const char *show_doc,
1173 const char *help_doc,
1176 show_value_ftype *show_func,
1177 cmd_list_element **set_list,
1178 cmd_list_element **show_list)
1179{
1180 auto cmds = add_setshow_cmd_full<int> (name, theclass, var_pinteger, nullptr,
1181 extra_literals, set_doc, show_doc,
1182 help_doc, set_func, get_func, nullptr,
1183 show_func, set_list, show_list);
1184 return cmds;
1185}
1186
1187/* Add element named NAME to both the set and show command LISTs (the
1188 list for set/show or some sublist thereof). THECLASS is as in
1189 add_cmd. VAR is address of the variable which will contain the
1190 value. SET_DOC and SHOW_DOC are the documentation strings. */
1191
1194 unsigned int *var, const literal_def *extra_literals,
1195 const char *set_doc, const char *show_doc,
1196 const char *help_doc,
1197 cmd_func_ftype *set_func,
1198 show_value_ftype *show_func,
1199 struct cmd_list_element **set_list,
1200 struct cmd_list_element **show_list)
1201{
1202 set_show_commands commands
1203 = add_setshow_cmd_full<unsigned int> (name, theclass, var_uinteger, var,
1204 extra_literals, set_doc, show_doc,
1205 help_doc, nullptr, nullptr, set_func,
1206 show_func, set_list, show_list);
1207 return commands;
1208}
1209
1210/* Same as above but using a getter and a setter function instead of a pointer
1211 to a global storage buffer. */
1212
1216 const char *set_doc, const char *show_doc,
1217 const char *help_doc,
1220 show_value_ftype *show_func,
1221 cmd_list_element **set_list,
1222 cmd_list_element **show_list)
1223{
1224 auto cmds = add_setshow_cmd_full<unsigned int> (name, theclass, var_uinteger,
1225 nullptr, extra_literals,
1226 set_doc, show_doc, help_doc,
1227 set_func, get_func, nullptr,
1228 show_func, set_list,
1229 show_list);
1230 return cmds;
1231}
1232
1233/* Accept `unlimited' or 0, translated internally to UINT_MAX. */
1235 {
1236 { "unlimited", UINT_MAX, 0 },
1237 { nullptr }
1238 };
1239
1240/* Same as above but using `uinteger_unlimited_literals', with a pointer
1241 to a global storage buffer. */
1242
1245 unsigned int *var,
1246 const char *set_doc, const char *show_doc,
1247 const char *help_doc,
1248 cmd_func_ftype *set_func,
1249 show_value_ftype *show_func,
1250 struct cmd_list_element **set_list,
1251 struct cmd_list_element **show_list)
1252{
1253 set_show_commands commands
1254 = add_setshow_cmd_full<unsigned int> (name, theclass, var_uinteger, var,
1256 set_doc, show_doc, help_doc, nullptr,
1257 nullptr, set_func, show_func,
1258 set_list, show_list);
1259 return commands;
1260}
1261
1262/* Same as above but using a getter and a setter function instead of a pointer
1263 to a global storage buffer. */
1264
1267 const char *set_doc, const char *show_doc,
1268 const char *help_doc,
1271 show_value_ftype *show_func,
1272 cmd_list_element **set_list,
1273 cmd_list_element **show_list)
1274{
1275 auto cmds = add_setshow_cmd_full<unsigned int> (name, theclass, var_uinteger,
1276 nullptr,
1278 set_doc, show_doc, help_doc,
1279 set_func, get_func, nullptr,
1280 show_func, set_list,
1281 show_list);
1282 return cmds;
1283}
1284
1285/* Add element named NAME to both the set and show command LISTs (the
1286 list for set/show or some sublist thereof). THECLASS is as in
1287 add_cmd. VAR is address of the variable which will contain the
1288 value. SET_DOC and SHOW_DOC are the documentation strings. */
1289
1292 int *var,
1293 const char *set_doc, const char *show_doc,
1294 const char *help_doc,
1295 cmd_func_ftype *set_func,
1296 show_value_ftype *show_func,
1297 struct cmd_list_element **set_list,
1298 struct cmd_list_element **show_list)
1299{
1300 return add_setshow_cmd_full<int> (name, theclass, var_integer, var,
1301 set_doc, show_doc, help_doc,
1302 nullptr, nullptr, set_func,
1303 show_func, set_list, show_list);
1304}
1305
1306/* Same as above but using a getter and a setter function instead of a pointer
1307 to a global storage buffer. */
1308
1311 const char *set_doc, const char *show_doc,
1312 const char *help_doc,
1315 show_value_ftype *show_func,
1316 cmd_list_element **set_list,
1317 cmd_list_element **show_list)
1318{
1319 return add_setshow_cmd_full<int> (name, theclass, var_integer, nullptr,
1320 set_doc, show_doc, help_doc, set_func,
1321 get_func, nullptr, show_func, set_list,
1322 show_list);
1323}
1324
1325/* Accept `unlimited' or -1, using -1 internally. */
1327 {
1328 { "unlimited", -1, -1 },
1329 { nullptr }
1330 };
1331
1332/* Same as above but using `pinteger_unlimited_literals', with a pointer
1333 to a global storage buffer. */
1334
1338 int *var,
1339 const char *set_doc,
1340 const char *show_doc,
1341 const char *help_doc,
1342 cmd_func_ftype *set_func,
1343 show_value_ftype *show_func,
1344 struct cmd_list_element **set_list,
1345 struct cmd_list_element **show_list)
1346{
1347 set_show_commands commands
1348 = add_setshow_cmd_full<int> (name, theclass, var_pinteger, var,
1350 set_doc, show_doc, help_doc, nullptr,
1351 nullptr, set_func, show_func, set_list,
1352 show_list);
1353 return commands;
1354}
1355
1356/* Same as above but using a getter and a setter function instead of a pointer
1357 to a global storage buffer. */
1358
1361 const char *set_doc, const char *show_doc,
1362 const char *help_doc,
1365 show_value_ftype *show_func,
1366 cmd_list_element **set_list,
1367 cmd_list_element **show_list)
1368{
1369 auto cmds
1370 = add_setshow_cmd_full<int> (name, theclass, var_pinteger, nullptr,
1372 set_doc, show_doc, help_doc, set_func,
1373 get_func, nullptr, show_func, set_list,
1374 show_list);
1375 return cmds;
1376}
1377
1378/* Add element named NAME to both the set and show command LISTs (the
1379 list for set/show or some sublist thereof). THECLASS is as in
1380 add_cmd. VAR is address of the variable which will contain the
1381 value. SET_DOC and SHOW_DOC are the documentation strings. */
1382
1385 unsigned int *var,
1386 const char *set_doc, const char *show_doc,
1387 const char *help_doc,
1388 cmd_func_ftype *set_func,
1389 show_value_ftype *show_func,
1390 struct cmd_list_element **set_list,
1391 struct cmd_list_element **show_list)
1392{
1393 return add_setshow_cmd_full<unsigned int> (name, theclass, var_uinteger,
1394 var, set_doc, show_doc, help_doc,
1395 nullptr, nullptr, set_func,
1396 show_func, set_list, show_list);
1397}
1398
1399/* Same as above but using a getter and a setter function instead of a pointer
1400 to a global storage buffer. */
1401
1404 const char *set_doc, const char *show_doc,
1405 const char *help_doc,
1408 show_value_ftype *show_func,
1409 cmd_list_element **set_list,
1410 cmd_list_element **show_list)
1411{
1412 return add_setshow_cmd_full<unsigned int> (name, theclass, var_uinteger,
1413 nullptr, set_doc, show_doc,
1414 help_doc, set_func, get_func,
1415 nullptr, show_func, set_list,
1416 show_list);
1417}
1418
1419/* Remove the command named NAME from the command list. Return the list
1420 commands which were aliased to the deleted command. The various *HOOKs are
1421 set to the pre- and post-hook commands for the deleted command. If the
1422 command does not have a hook, the corresponding out parameter is set to
1423 NULL. */
1424
1426delete_cmd (const char *name, struct cmd_list_element **list,
1427 struct cmd_list_element **prehook,
1428 struct cmd_list_element **prehookee,
1429 struct cmd_list_element **posthook,
1430 struct cmd_list_element **posthookee)
1431{
1432 struct cmd_list_element *iter;
1433 struct cmd_list_element **previous_chain_ptr;
1435
1436 *prehook = NULL;
1437 *prehookee = NULL;
1438 *posthook = NULL;
1439 *posthookee = NULL;
1440 previous_chain_ptr = list;
1441
1442 for (iter = *previous_chain_ptr; iter; iter = *previous_chain_ptr)
1443 {
1444 if (strcmp (iter->name, name) == 0)
1445 {
1446 if (iter->destroyer)
1447 iter->destroyer (iter, iter->context ());
1448
1449 if (iter->hookee_pre)
1450 iter->hookee_pre->hook_pre = 0;
1451 *prehook = iter->hook_pre;
1452 *prehookee = iter->hookee_pre;
1453 if (iter->hookee_post)
1454 iter->hookee_post->hook_post = 0;
1455 *posthook = iter->hook_post;
1456 *posthookee = iter->hookee_post;
1457
1458 /* Update the link. */
1459 *previous_chain_ptr = iter->next;
1460
1461 aliases = std::move (iter->aliases);
1462
1463 /* If this command was an alias, remove it from the list of
1464 aliases. */
1465 if (iter->is_alias ())
1466 {
1467 auto it = iter->alias_target->aliases.iterator_to (*iter);
1468 iter->alias_target->aliases.erase (it);
1469 }
1470
1471 delete iter;
1472
1473 /* We won't see another command with the same name. */
1474 break;
1475 }
1476 else
1477 previous_chain_ptr = &iter->next;
1478 }
1479
1480 return aliases;
1481}
1482
1483/* Shorthands to the commands above. */
1484
1485/* Add an element to the list of info subcommands. */
1486
1487struct cmd_list_element *
1488add_info (const char *name, cmd_simple_func_ftype *fun, const char *doc)
1489{
1490 return add_cmd (name, class_info, fun, doc, &infolist);
1491}
1492
1493/* Add an alias to the list of info subcommands. */
1494
1497{
1498 return add_alias_cmd (name, target, class_run, abbrev_flag, &infolist);
1499}
1500
1501/* Add an element to the list of commands. */
1502
1503struct cmd_list_element *
1506 const char *doc)
1507{
1508 return add_cmd (name, theclass, fun, doc, &cmdlist);
1509}
1510
1511/* Add an alias or abbreviation command to the list of commands.
1512 For aliases predefined by GDB (such as bt), THECLASS must be
1513 different of class_alias, as class_alias is used to identify
1514 user defined aliases. */
1515
1519{
1520 return add_alias_cmd (name, target, theclass, abbrev_flag, &cmdlist);
1521}
1522
1523/* Add an element with a suppress notification to the list of commands. */
1524
1525struct cmd_list_element *
1533
1534/* Print the prefix of C followed by name of C in title style. */
1535
1536static void
1538{
1539 std::string prefixname
1540 = c.prefix == nullptr ? "" : c.prefix->prefixname ();
1541
1542 fprintf_styled (stream, title_style.style (), "%s%s",
1543 prefixname.c_str (), c.name);
1544}
1545
1546/* True if ALIAS has a user-defined documentation. */
1547
1548static bool
1550{
1551 gdb_assert (alias.is_alias ());
1552 /* Alias is user documented if it has an allocated documentation
1553 that differs from the aliased command. */
1554 return (alias.doc_allocated
1555 && strcmp (alias.doc, alias.alias_target->doc) != 0);
1556}
1557
1558/* Print the definition of alias C using title style for alias
1559 and aliased command. */
1560
1561static void
1563 struct ui_file *stream)
1564{
1565 gdb_assert (c.is_alias ());
1566 gdb_puts (" alias ", stream);
1567 fput_command_name_styled (c, stream);
1568 gdb_printf (stream, " = ");
1570 gdb_printf (stream, " %s\n", c.default_args.c_str ());
1571}
1572
1573/* Print the definition of CMD aliases not deprecated and having default args
1574 and not specifically documented by the user. */
1575
1576static void
1578 struct ui_file *stream)
1579{
1580 for (const cmd_list_element &alias : cmd.aliases)
1581 if (!alias.cmd_deprecated
1583 && !alias.default_args.empty ())
1585}
1586
1587/* If C has one or more aliases, style print the name of C and the name of its
1588 aliases not documented specifically by the user, separated by commas.
1589 If ALWAYS_FPUT_C_NAME, print the name of C even if it has no aliases.
1590 If one or more names are printed, POSTFIX is printed after the last name.
1591*/
1592
1593static void
1595 bool always_fput_c_name, const char *postfix,
1596 struct ui_file *stream)
1597{
1598 /* First, check if we are going to print something. That is, either if
1599 ALWAYS_FPUT_C_NAME is true or if there exists at least one non-deprecated
1600 alias not documented specifically by the user. */
1601
1602 auto print_alias = [] (const cmd_list_element &alias)
1603 {
1604 return !alias.cmd_deprecated && !user_documented_alias (alias);
1605 };
1606
1607 bool print_something = always_fput_c_name;
1608 if (!print_something)
1609 for (const cmd_list_element &alias : c.aliases)
1610 {
1611 if (!print_alias (alias))
1612 continue;
1613
1614 print_something = true;
1615 break;
1616 }
1617
1618 if (print_something)
1619 fput_command_name_styled (c, stream);
1620
1621 for (const cmd_list_element &alias : c.aliases)
1622 {
1623 if (!print_alias (alias))
1624 continue;
1625
1626 gdb_puts (", ", stream);
1627 stream->wrap_here (3);
1629 }
1630
1631 if (print_something)
1632 gdb_puts (postfix, stream);
1633}
1634
1635/* If VERBOSE, print the full help for command C and highlight the
1636 documentation parts matching HIGHLIGHT,
1637 otherwise print only one-line help for command C. */
1638
1639static void
1641 compiled_regex &highlight, struct ui_file *stream)
1642{
1643 /* When printing the full documentation, add a line to separate
1644 this documentation from the previous command help, in the likely
1645 case that apropos finds several commands. */
1646 if (verbose)
1647 gdb_puts ("\n", stream);
1648
1650 verbose ? "" : " -- ", stream);
1651 if (verbose)
1652 {
1653 gdb_puts ("\n", stream);
1655 fputs_highlighted (c.doc, highlight, stream);
1656 gdb_puts ("\n", stream);
1657 }
1658 else
1659 {
1660 print_doc_line (stream, c.doc, false);
1661 gdb_puts ("\n", stream);
1663 }
1664}
1665
1666/* Recursively walk the commandlist structures, and print out the
1667 documentation of commands that match our regex in either their
1668 name, or their documentation.
1669 If VERBOSE, prints the complete documentation and highlight the
1670 documentation parts matching REGEX, otherwise prints only
1671 the first line.
1672*/
1673void
1674apropos_cmd (struct ui_file *stream,
1675 struct cmd_list_element *commandlist,
1676 bool verbose, compiled_regex &regex)
1677{
1678 struct cmd_list_element *c;
1679 int returnvalue;
1680
1681 /* Walk through the commands. */
1682 for (c=commandlist;c;c=c->next)
1683 {
1684 if (c->is_alias () && !user_documented_alias (*c))
1685 {
1686 /* Command aliases/abbreviations not specifically documented by the
1687 user are skipped to ensure we print the doc of a command only once,
1688 when encountering the aliased command. */
1689 continue;
1690 }
1691
1692 returnvalue = -1; /* Needed to avoid double printing. */
1693 if (c->name != NULL)
1694 {
1695 size_t name_len = strlen (c->name);
1696
1697 /* Try to match against the name. */
1698 returnvalue = regex.search (c->name, name_len, 0, name_len, NULL);
1699 if (returnvalue >= 0)
1700 print_doc_of_command (*c, verbose, regex, stream);
1701
1702 /* Try to match against the name of the aliases. */
1703 for (const cmd_list_element &alias : c->aliases)
1704 {
1705 name_len = strlen (alias.name);
1706 returnvalue = regex.search (alias.name, name_len, 0, name_len, NULL);
1707 if (returnvalue >= 0)
1708 {
1709 print_doc_of_command (*c, verbose, regex, stream);
1710 break;
1711 }
1712 }
1713 }
1714 if (c->doc != NULL && returnvalue < 0)
1715 {
1716 size_t doc_len = strlen (c->doc);
1717
1718 /* Try to match against documentation. */
1719 if (regex.search (c->doc, doc_len, 0, doc_len, NULL) >= 0)
1720 print_doc_of_command (*c, verbose, regex, stream);
1721 }
1722 /* Check if this command has subcommands. */
1723 if (c->is_prefix ())
1724 {
1725 /* Recursively call ourselves on the subcommand list,
1726 passing the right prefix in. */
1727 apropos_cmd (stream, *c->subcommands, verbose, regex);
1728 }
1729 }
1730}
1731
1732/* This command really has to deal with two things:
1733 1) I want documentation on *this string* (usually called by
1734 "help commandname").
1735
1736 2) I want documentation on *this list* (usually called by giving a
1737 command that requires subcommands. Also called by saying just
1738 "help".)
1739
1740 I am going to split this into two separate commands, help_cmd and
1741 help_list. */
1742
1743void
1744help_cmd (const char *command, struct ui_file *stream)
1745{
1746 struct cmd_list_element *c, *alias, *prefix_cmd, *c_cmd;
1747
1748 if (!command)
1749 {
1750 help_list (cmdlist, "", all_classes, stream);
1751 return;
1752 }
1753
1754 if (strcmp (command, "all") == 0)
1755 {
1756 help_all (stream);
1757 return;
1758 }
1759
1760 const char *orig_command = command;
1761 c = lookup_cmd (&command, cmdlist, "", NULL, 0, 0);
1762
1763 if (c == 0)
1764 return;
1765
1766 lookup_cmd_composition (orig_command, &alias, &prefix_cmd, &c_cmd);
1767
1768 /* There are three cases here.
1769 If c->subcommands is nonzero, we have a prefix command.
1770 Print its documentation, then list its subcommands.
1771
1772 If c->func is non NULL, we really have a command. Print its
1773 documentation and return.
1774
1775 If c->func is NULL, we have a class name. Print its
1776 documentation (as if it were a command) and then set class to the
1777 number of this class so that the commands in the class will be
1778 listed. */
1779
1780 if (alias == nullptr || !user_documented_alias (*alias))
1781 {
1782 /* Case of a normal command, or an alias not explicitly
1783 documented by the user. */
1784 /* If the user asked 'help somecommand' and there is no alias,
1785 the false indicates to not output the (single) command name. */
1786 fput_command_names_styled (*c, false, "\n", stream);
1787 fput_aliases_definition_styled (*c, stream);
1788 gdb_puts (c->doc, stream);
1789 }
1790 else
1791 {
1792 /* Case of an alias explicitly documented by the user.
1793 Only output the alias definition and its explicit documentation. */
1795 fput_command_names_styled (*alias, false, "\n", stream);
1796 gdb_puts (alias->doc, stream);
1797 }
1798 gdb_puts ("\n", stream);
1799
1800 if (!c->is_prefix () && !c->is_command_class_help ())
1801 return;
1802
1803 gdb_printf (stream, "\n");
1804
1805 /* If this is a prefix command, print it's subcommands. */
1806 if (c->is_prefix ())
1807 help_list (*c->subcommands, c->prefixname ().c_str (),
1808 all_commands, stream);
1809
1810 /* If this is a class name, print all of the commands in the class. */
1811 if (c->is_command_class_help ())
1812 help_list (cmdlist, "", c->theclass, stream);
1813
1814 if (c->hook_pre || c->hook_post)
1815 gdb_printf (stream,
1816 "\nThis command has a hook (or hooks) defined:\n");
1817
1818 if (c->hook_pre)
1819 gdb_printf (stream,
1820 "\tThis command is run after : %s (pre hook)\n",
1821 c->hook_pre->name);
1822 if (c->hook_post)
1823 gdb_printf (stream,
1824 "\tThis command is run before : %s (post hook)\n",
1825 c->hook_post->name);
1826}
1827
1828/*
1829 * Get a specific kind of help on a command list.
1830 *
1831 * LIST is the list.
1832 * CMDTYPE is the prefix to use in the title string.
1833 * THECLASS is the class with which to list the nodes of this list (see
1834 * documentation for help_cmd_list below), As usual, ALL_COMMANDS for
1835 * everything, ALL_CLASSES for just classes, and non-negative for only things
1836 * in a specific class.
1837 * and STREAM is the output stream on which to print things.
1838 * If you call this routine with a class >= 0, it recurses.
1839 */
1840void
1841help_list (struct cmd_list_element *list, const char *cmdtype,
1842 enum command_class theclass, struct ui_file *stream)
1843{
1844 int len;
1845 char *cmdtype1, *cmdtype2;
1846
1847 /* If CMDTYPE is "foo ", CMDTYPE1 gets " foo" and CMDTYPE2 gets "foo sub".
1848 */
1849 len = strlen (cmdtype);
1850 cmdtype1 = (char *) alloca (len + 1);
1851 cmdtype1[0] = 0;
1852 cmdtype2 = (char *) alloca (len + 4);
1853 cmdtype2[0] = 0;
1854 if (len)
1855 {
1856 cmdtype1[0] = ' ';
1857 memcpy (cmdtype1 + 1, cmdtype, len - 1);
1858 cmdtype1[len] = 0;
1859 memcpy (cmdtype2, cmdtype, len - 1);
1860 strcpy (cmdtype2 + len - 1, " sub");
1861 }
1862
1863 if (theclass == all_classes)
1864 gdb_printf (stream, "List of classes of %scommands:\n\n", cmdtype2);
1865 else
1866 gdb_printf (stream, "List of %scommands:\n\n", cmdtype2);
1867
1868 help_cmd_list (list, theclass, theclass >= 0, stream);
1869
1870 if (theclass == all_classes)
1871 {
1872 gdb_printf (stream, "\n\
1873Type \"help%s\" followed by a class name for a list of commands in ",
1874 cmdtype1);
1875 stream->wrap_here (0);
1876 gdb_printf (stream, "that class.");
1877
1878 gdb_printf (stream, "\n\
1879Type \"help all\" for the list of all commands.");
1880 }
1881
1882 gdb_printf (stream, "\nType \"help%s\" followed by %scommand name ",
1883 cmdtype1, cmdtype2);
1884 stream->wrap_here (0);
1885 gdb_puts ("for ", stream);
1886 stream->wrap_here (0);
1887 gdb_puts ("full ", stream);
1888 stream->wrap_here (0);
1889 gdb_puts ("documentation.\n", stream);
1890 gdb_puts ("Type \"apropos word\" to search "
1891 "for commands related to \"word\".\n", stream);
1892 gdb_puts ("Type \"apropos -v word\" for full documentation", stream);
1893 stream->wrap_here (0);
1894 gdb_puts (" of commands related to \"word\".\n", stream);
1895 gdb_puts ("Command name abbreviations are allowed if unambiguous.\n",
1896 stream);
1897}
1898
1899static void
1900help_all (struct ui_file *stream)
1901{
1902 struct cmd_list_element *c;
1903 int seen_unclassified = 0;
1904
1905 for (c = cmdlist; c; c = c->next)
1906 {
1907 if (c->abbrev_flag)
1908 continue;
1909 /* If this is a class name, print all of the commands in the
1910 class. */
1911
1912 if (c->is_command_class_help ())
1913 {
1914 gdb_printf (stream, "\nCommand class: %s\n\n", c->name);
1915 help_cmd_list (cmdlist, c->theclass, true, stream);
1916 }
1917 }
1918
1919 /* While it's expected that all commands are in some class,
1920 as a safety measure, we'll print commands outside of any
1921 class at the end. */
1922
1923 for (c = cmdlist; c; c = c->next)
1924 {
1925 if (c->abbrev_flag)
1926 continue;
1927
1928 if (c->theclass == no_class)
1929 {
1930 if (!seen_unclassified)
1931 {
1932 gdb_printf (stream, "\nUnclassified commands\n\n");
1933 seen_unclassified = 1;
1934 }
1935 print_help_for_command (*c, true, stream);
1936 }
1937 }
1938
1939}
1940
1941/* See cli-decode.h. */
1942
1943void
1944print_doc_line (struct ui_file *stream, const char *str,
1945 bool for_value_prefix)
1946{
1947 static char *line_buffer = 0;
1948 static int line_size;
1949 const char *p;
1950
1951 if (!line_buffer)
1952 {
1953 line_size = 80;
1954 line_buffer = (char *) xmalloc (line_size);
1955 }
1956
1957 /* Searches for the first end of line or the end of STR. */
1958 p = str;
1959 while (*p && *p != '\n')
1960 p++;
1961 if (p - str > line_size - 1)
1962 {
1963 line_size = p - str + 1;
1964 xfree (line_buffer);
1965 line_buffer = (char *) xmalloc (line_size);
1966 }
1967 strncpy (line_buffer, str, p - str);
1968 if (for_value_prefix)
1969 {
1970 if (islower (line_buffer[0]))
1971 line_buffer[0] = toupper (line_buffer[0]);
1972 gdb_assert (p > str);
1973 if (line_buffer[p - str - 1] == '.')
1974 line_buffer[p - str - 1] = '\0';
1975 else
1976 line_buffer[p - str] = '\0';
1977 }
1978 else
1979 line_buffer[p - str] = '\0';
1980 gdb_puts (line_buffer, stream);
1981}
1982
1983/* Print one-line help for command C.
1984 If RECURSE is non-zero, also print one-line descriptions
1985 of all prefixed subcommands. */
1986static void
1988 bool recurse, struct ui_file *stream)
1989{
1990 fput_command_names_styled (c, true, " -- ", stream);
1991 print_doc_line (stream, c.doc, false);
1992 gdb_puts ("\n", stream);
1993 if (!c.default_args.empty ())
1994 fput_alias_definition_styled (c, stream);
1996
1997 if (recurse
1998 && c.is_prefix ()
1999 && c.abbrev_flag == 0)
2000 /* Subcommands of a prefix command typically have 'all_commands'
2001 as class. If we pass CLASS to recursive invocation,
2002 most often we won't see anything. */
2003 help_cmd_list (*c.subcommands, all_commands, true, stream);
2004}
2005
2006/*
2007 * Implement a help command on command list LIST.
2008 * RECURSE should be non-zero if this should be done recursively on
2009 * all sublists of LIST.
2010 * STREAM is the stream upon which the output should be written.
2011 * THECLASS should be:
2012 * A non-negative class number to list only commands in that
2013 * ALL_COMMANDS to list all commands in list.
2014 * ALL_CLASSES to list all classes in list.
2015 *
2016 * Note that aliases are only shown when THECLASS is class_alias.
2017 * In the other cases, the aliases will be shown together with their
2018 * aliased command.
2019 *
2020 * Note that RECURSE will be active on *all* sublists, not just the
2021 * ones selected by the criteria above (ie. the selection mechanism
2022 * is at the low level, not the high-level).
2023 */
2024
2025static void
2027 bool recurse, struct ui_file *stream)
2028{
2029 struct cmd_list_element *c;
2030
2031 for (c = list; c; c = c->next)
2032 {
2033 if (c->abbrev_flag == 1 || c->cmd_deprecated)
2034 {
2035 /* Do not show abbreviations or deprecated commands. */
2036 continue;
2037 }
2038
2039 if (c->is_alias () && theclass != class_alias)
2040 {
2041 /* Do not show an alias, unless specifically showing the
2042 list of aliases: for all other classes, an alias is
2043 shown (if needed) together with its aliased command. */
2044 continue;
2045 }
2046
2047 if (theclass == all_commands
2049 || (theclass == c->theclass && !c->is_command_class_help ()))
2050 {
2051 /* show C when
2052 - showing all commands
2053 - showing all classes and C is a help class
2054 - showing commands of THECLASS and C is not the help class */
2055
2056 /* If we show the class_alias and C is an alias, do not recurse,
2057 as this would show the (possibly very long) not very useful
2058 list of sub-commands of the aliased command. */
2060 (*c,
2061 recurse && (theclass != class_alias || !c->is_alias ()),
2062 stream);
2063 continue;
2064 }
2065
2066 if (recurse
2068 && c->is_prefix ())
2069 {
2070 /* User-defined commands or aliases may be subcommands. */
2071 help_cmd_list (*c->subcommands, theclass, recurse, stream);
2072 continue;
2073 }
2074
2075 /* Do not show C or recurse on C, e.g. because C does not belong to
2076 THECLASS or because C is a help class. */
2077 }
2078}
2079
2080
2081/* Search the input clist for 'command'. Return the command if
2082 found (or NULL if not), and return the number of commands
2083 found in nfound. */
2084
2085static struct cmd_list_element *
2086find_cmd (const char *command, int len, struct cmd_list_element *clist,
2087 int ignore_help_classes, int *nfound)
2088{
2089 struct cmd_list_element *found, *c;
2090
2091 found = NULL;
2092 *nfound = 0;
2093 for (c = clist; c; c = c->next)
2094 if (!strncmp (command, c->name, len)
2095 && (!ignore_help_classes || !c->is_command_class_help ()))
2096 {
2097 found = c;
2098 (*nfound)++;
2099 if (c->name[len] == '\0')
2100 {
2101 *nfound = 1;
2102 break;
2103 }
2104 }
2105 return found;
2106}
2107
2108/* Return the length of command name in TEXT. */
2109
2110int
2112{
2113 const char *p = text;
2114
2115 /* Treating underscores as part of command words is important
2116 so that "set args_foo()" doesn't get interpreted as
2117 "set args _foo()". */
2118 /* Some characters are only used for TUI specific commands.
2119 However, they are always allowed for the sake of consistency.
2120
2121 Note that this is larger than the character set allowed when
2122 creating user-defined commands. */
2123
2124 /* Recognize the single character commands so that, e.g., "!ls"
2125 works as expected. */
2126 if (*p == '!' || *p == '|')
2127 return 1;
2128
2129 while (valid_cmd_char_p (*p)
2130 /* Characters used by TUI specific commands. */
2131 || *p == '+' || *p == '<' || *p == '>' || *p == '$')
2132 p++;
2133
2134 return p - text;
2135}
2136
2137/* See command.h. */
2138
2139bool
2141{
2142 /* Alas "42" is a legitimate user-defined command.
2143 In the interests of not breaking anything we preserve that. */
2144
2145 return isalnum (c) || c == '-' || c == '_' || c == '.';
2146}
2147
2148/* See command.h. */
2149
2150bool
2152{
2153 const char *p;
2154
2155 if (*name == '\0')
2156 return false;
2157
2158 for (p = name; *p != '\0'; ++p)
2159 {
2160 if (valid_cmd_char_p (*p))
2161 ; /* Ok. */
2162 else
2163 return false;
2164 }
2165
2166 return true;
2167}
2168
2169/* See command.h. */
2170
2171struct cmd_list_element *
2172lookup_cmd_1 (const char **text, struct cmd_list_element *clist,
2173 struct cmd_list_element **result_list, std::string *default_args,
2174 int ignore_help_classes, bool lookup_for_completion_p)
2175{
2176 char *command;
2177 int len, nfound;
2178 struct cmd_list_element *found, *c;
2179 bool found_alias = false;
2180 const char *line = *text;
2181
2182 while (**text == ' ' || **text == '\t')
2183 (*text)++;
2184
2185 /* Identify the name of the command. */
2186 len = find_command_name_length (*text);
2187
2188 /* If nothing but whitespace, return 0. */
2189 if (len == 0)
2190 return 0;
2191
2192 /* *text and p now bracket the first command word to lookup (and
2193 it's length is len). We copy this into a local temporary. */
2194
2195
2196 command = (char *) alloca (len + 1);
2197 memcpy (command, *text, len);
2198 command[len] = '\0';
2199
2200 /* Look it up. */
2201 found = 0;
2202 nfound = 0;
2203 found = find_cmd (command, len, clist, ignore_help_classes, &nfound);
2204
2205 /* If nothing matches, we have a simple failure. */
2206 if (nfound == 0)
2207 return 0;
2208
2209 if (nfound > 1)
2210 {
2211 if (result_list != nullptr)
2212 /* Will be modified in calling routine
2213 if we know what the prefix command is. */
2214 *result_list = 0;
2215 if (default_args != nullptr)
2216 *default_args = std::string ();
2217 return CMD_LIST_AMBIGUOUS; /* Ambiguous. */
2218 }
2219
2220 /* We've matched something on this list. Move text pointer forward. */
2221
2222 *text += len;
2223
2224 if (found->is_alias ())
2225 {
2226 /* We drop the alias (abbreviation) in favor of the command it
2227 is pointing to. If the alias is deprecated, though, we need to
2228 warn the user about it before we drop it. Note that while we
2229 are warning about the alias, we may also warn about the command
2230 itself and we will adjust the appropriate DEPRECATED_WARN_USER
2231 flags. */
2232
2233 if (found->deprecated_warn_user && !lookup_for_completion_p)
2234 deprecated_cmd_warning (line, clist);
2235
2236
2237 /* Return the default_args of the alias, not the default_args
2238 of the command it is pointing to. */
2239 if (default_args != nullptr)
2240 *default_args = found->default_args;
2241 found = found->alias_target;
2242 found_alias = true;
2243 }
2244 /* If we found a prefix command, keep looking. */
2245
2246 if (found->is_prefix ())
2247 {
2248 c = lookup_cmd_1 (text, *found->subcommands, result_list, default_args,
2249 ignore_help_classes, lookup_for_completion_p);
2250 if (!c)
2251 {
2252 /* Didn't find anything; this is as far as we got. */
2253 if (result_list != nullptr)
2254 *result_list = clist;
2255 if (!found_alias && default_args != nullptr)
2256 *default_args = found->default_args;
2257 return found;
2258 }
2259 else if (c == CMD_LIST_AMBIGUOUS)
2260 {
2261 /* We've gotten this far properly, but the next step is
2262 ambiguous. We need to set the result list to the best
2263 we've found (if an inferior hasn't already set it). */
2264 if (result_list != nullptr)
2265 if (!*result_list)
2266 /* This used to say *result_list = *found->subcommands.
2267 If that was correct, need to modify the documentation
2268 at the top of this function to clarify what is
2269 supposed to be going on. */
2270 *result_list = found;
2271 /* For ambiguous commands, do not return any default_args args. */
2272 if (default_args != nullptr)
2273 *default_args = std::string ();
2274 return c;
2275 }
2276 else
2277 {
2278 /* We matched! */
2279 return c;
2280 }
2281 }
2282 else
2283 {
2284 if (result_list != nullptr)
2285 *result_list = clist;
2286 if (!found_alias && default_args != nullptr)
2287 *default_args = found->default_args;
2288 return found;
2289 }
2290}
2291
2292/* All this hair to move the space to the front of cmdtype */
2293
2294static void
2295undef_cmd_error (const char *cmdtype, const char *q)
2296{
2297 error (_("Undefined %scommand: \"%s\". Try \"help%s%.*s\"."),
2298 cmdtype,
2299 q,
2300 *cmdtype ? " " : "",
2301 (int) strlen (cmdtype) - 1,
2302 cmdtype);
2303}
2304
2305/* Look up the contents of *LINE as a command in the command list LIST.
2306 LIST is a chain of struct cmd_list_element's.
2307 If it is found, return the struct cmd_list_element for that command,
2308 update *LINE to point after the command name, at the first argument
2309 and update *DEFAULT_ARGS (if DEFAULT_ARGS is not null) to the default
2310 args to prepend to the user provided args when running the command.
2311 Note that if the found cmd_list_element is found via an alias,
2312 the default args of the alias are returned.
2313
2314 If not found, call error if ALLOW_UNKNOWN is zero
2315 otherwise (or if error returns) return zero.
2316 Call error if specified command is ambiguous,
2317 unless ALLOW_UNKNOWN is negative.
2318 CMDTYPE precedes the word "command" in the error message.
2319
2320 If IGNORE_HELP_CLASSES is nonzero, ignore any command list
2321 elements which are actually help classes rather than commands (i.e.
2322 the function field of the struct cmd_list_element is 0). */
2323
2324struct cmd_list_element *
2325lookup_cmd (const char **line, struct cmd_list_element *list,
2326 const char *cmdtype,
2327 std::string *default_args,
2328 int allow_unknown, int ignore_help_classes)
2329{
2330 struct cmd_list_element *last_list = 0;
2331 struct cmd_list_element *c;
2332
2333 /* Note: Do not remove trailing whitespace here because this
2334 would be wrong for complete_command. Jim Kingdon */
2335
2336 if (!*line)
2337 error (_("Lack of needed %scommand"), cmdtype);
2338
2339 c = lookup_cmd_1 (line, list, &last_list, default_args, ignore_help_classes);
2340
2341 if (!c)
2342 {
2343 if (!allow_unknown)
2344 {
2345 char *q;
2346 int len = find_command_name_length (*line);
2347
2348 q = (char *) alloca (len + 1);
2349 strncpy (q, *line, len);
2350 q[len] = '\0';
2351 undef_cmd_error (cmdtype, q);
2352 }
2353 else
2354 return 0;
2355 }
2356 else if (c == CMD_LIST_AMBIGUOUS)
2357 {
2358 /* Ambigous. Local values should be off subcommands or called
2359 values. */
2360 int local_allow_unknown = (last_list ? last_list->allow_unknown :
2362 std::string local_cmdtype
2363 = last_list ? last_list->prefixname () : cmdtype;
2364 struct cmd_list_element *local_list =
2365 (last_list ? *(last_list->subcommands) : list);
2366
2367 if (local_allow_unknown < 0)
2368 {
2369 if (last_list)
2370 return last_list; /* Found something. */
2371 else
2372 return 0; /* Found nothing. */
2373 }
2374 else
2375 {
2376 /* Report as error. */
2377 int amb_len;
2378 char ambbuf[100];
2379
2380 for (amb_len = 0;
2381 ((*line)[amb_len] && (*line)[amb_len] != ' '
2382 && (*line)[amb_len] != '\t');
2383 amb_len++)
2384 ;
2385
2386 ambbuf[0] = 0;
2387 for (c = local_list; c; c = c->next)
2388 if (!strncmp (*line, c->name, amb_len))
2389 {
2390 if (strlen (ambbuf) + strlen (c->name) + 6
2391 < (int) sizeof ambbuf)
2392 {
2393 if (strlen (ambbuf))
2394 strcat (ambbuf, ", ");
2395 strcat (ambbuf, c->name);
2396 }
2397 else
2398 {
2399 strcat (ambbuf, "..");
2400 break;
2401 }
2402 }
2403 error (_("Ambiguous %scommand \"%s\": %s."),
2404 local_cmdtype.c_str (), *line, ambbuf);
2405 }
2406 }
2407 else
2408 {
2409 if (c->type == set_cmd && **line != '\0' && !isspace (**line))
2410 error (_("Argument must be preceded by space."));
2411
2412 /* We've got something. It may still not be what the caller
2413 wants (if this command *needs* a subcommand). */
2414 while (**line == ' ' || **line == '\t')
2415 (*line)++;
2416
2417 if (c->is_prefix () && **line && !c->allow_unknown)
2418 undef_cmd_error (c->prefixname ().c_str (), *line);
2419
2420 /* Seems to be what he wants. Return it. */
2421 return c;
2422 }
2423 return 0;
2424}
2425
2426/* See command.h. */
2427
2428struct cmd_list_element *
2430 struct cmd_list_element *list,
2431 bool ignore_help_classes)
2432{
2433 const char *tem = name;
2434 struct cmd_list_element *cmd = lookup_cmd (&tem, list, "", NULL, -1,
2435 ignore_help_classes);
2436 if (cmd != nullptr && strcmp (name, cmd->name) != 0)
2437 cmd = nullptr;
2438 return cmd;
2439}
2440
2441/* We are here presumably because an alias or command in TEXT is
2442 deprecated and a warning message should be generated. This
2443 function decodes TEXT and potentially generates a warning message
2444 as outlined below.
2445
2446 Example for 'set endian big' which has a fictitious alias 'seb'.
2447
2448 If alias wasn't used in TEXT, and the command is deprecated:
2449 "warning: 'set endian big' is deprecated."
2450
2451 If alias was used, and only the alias is deprecated:
2452 "warning: 'seb' an alias for the command 'set endian big' is deprecated."
2453
2454 If alias was used and command is deprecated (regardless of whether
2455 the alias itself is deprecated:
2456
2457 "warning: 'set endian big' (seb) is deprecated."
2458
2459 After the message has been sent, clear the appropriate flags in the
2460 command and/or the alias so the user is no longer bothered.
2461
2462*/
2463void
2464deprecated_cmd_warning (const char *text, struct cmd_list_element *list)
2465{
2466 struct cmd_list_element *alias = nullptr;
2467 struct cmd_list_element *cmd = nullptr;
2468
2469 /* Return if text doesn't evaluate to a command. We place this lookup
2470 within its own scope so that the PREFIX_CMD local is not visible
2471 later in this function. The value returned in PREFIX_CMD is based on
2472 the prefix found in TEXT, and is our case this prefix can be missing
2473 in some situations (when LIST is not the global CMDLIST).
2474
2475 It is better for our purposes to use the prefix commands directly from
2476 the ALIAS and CMD results. */
2477 {
2478 struct cmd_list_element *prefix_cmd = nullptr;
2479 if (!lookup_cmd_composition_1 (text, &alias, &prefix_cmd, &cmd, list))
2480 return;
2481 }
2482
2483 /* Return if nothing is deprecated. */
2484 if (!((alias != nullptr ? alias->deprecated_warn_user : 0)
2485 || cmd->deprecated_warn_user))
2486 return;
2487
2488 /* Join command prefix (if any) and the command name. */
2489 std::string tmp_cmd_str;
2490 if (cmd->prefix != nullptr)
2491 tmp_cmd_str += cmd->prefix->prefixname ();
2492 tmp_cmd_str += std::string (cmd->name);
2493
2494 /* Display the appropriate first line, this warns that the thing the user
2495 entered is deprecated. */
2496 if (alias != nullptr)
2497 {
2498 /* Join the alias prefix (if any) and the alias name. */
2499 std::string tmp_alias_str;
2500 if (alias->prefix != nullptr)
2501 tmp_alias_str += alias->prefix->prefixname ();
2502 tmp_alias_str += std::string (alias->name);
2503
2504 if (cmd->cmd_deprecated)
2505 gdb_printf (_("Warning: command '%ps' (%ps) is deprecated.\n"),
2507 tmp_cmd_str.c_str ()),
2509 tmp_alias_str.c_str ()));
2510 else
2511 gdb_printf (_("Warning: '%ps', an alias for the command '%ps', "
2512 "is deprecated.\n"),
2514 tmp_alias_str.c_str ()),
2516 tmp_cmd_str.c_str ()));
2517 }
2518 else
2519 gdb_printf (_("Warning: command '%ps' is deprecated.\n"),
2521 tmp_cmd_str.c_str ()));
2522
2523 /* Now display a second line indicating what the user should use instead.
2524 If it is only the alias that is deprecated, we want to indicate the
2525 new alias, otherwise we'll indicate the new command. */
2526 const char *replacement;
2527 if (alias != nullptr && !cmd->cmd_deprecated)
2528 replacement = alias->replacement;
2529 else
2530 replacement = cmd->replacement;
2531 if (replacement != nullptr)
2532 gdb_printf (_("Use '%ps'.\n\n"),
2534 replacement));
2535 else
2536 gdb_printf (_("No alternative known.\n\n"));
2537
2538 /* We've warned you, now we'll keep quiet. */
2539 if (alias != nullptr)
2540 alias->deprecated_warn_user = 0;
2541 cmd->deprecated_warn_user = 0;
2542}
2543
2544/* Look up the contents of TEXT as a command in the command list CUR_LIST.
2545 Return 1 on success, 0 on failure.
2546
2547 If TEXT refers to an alias, *ALIAS will point to that alias.
2548
2549 If TEXT is a subcommand (i.e. one that is preceded by a prefix
2550 command) set *PREFIX_CMD.
2551
2552 Set *CMD to point to the command TEXT indicates.
2553
2554 If any of *ALIAS, *PREFIX_CMD, or *CMD cannot be determined or do not
2555 exist, they are NULL when we return.
2556
2557*/
2558
2559static int
2561 struct cmd_list_element **alias,
2562 struct cmd_list_element **prefix_cmd,
2563 struct cmd_list_element **cmd,
2564 struct cmd_list_element *cur_list)
2565{
2566 *alias = nullptr;
2567 *prefix_cmd = cur_list->prefix;
2568 *cmd = nullptr;
2569
2570 text = skip_spaces (text);
2571
2572 /* Go through as many command lists as we need to, to find the command
2573 TEXT refers to. */
2574 while (1)
2575 {
2576 /* Identify the name of the command. */
2577 int len = find_command_name_length (text);
2578
2579 /* If nothing but whitespace, return. */
2580 if (len == 0)
2581 return 0;
2582
2583 /* TEXT is the start of the first command word to lookup (and
2584 it's length is LEN). We copy this into a local temporary. */
2585 std::string command (text, len);
2586
2587 /* Look it up. */
2588 int nfound = 0;
2589 *cmd = find_cmd (command.c_str (), len, cur_list, 1, &nfound);
2590
2591 /* We only handle the case where a single command was found. */
2592 if (*cmd == CMD_LIST_AMBIGUOUS || *cmd == nullptr)
2593 return 0;
2594 else
2595 {
2596 if ((*cmd)->is_alias ())
2597 {
2598 /* If the command was actually an alias, we note that an
2599 alias was used (by assigning *ALIAS) and we set *CMD. */
2600 *alias = *cmd;
2601 *cmd = (*cmd)->alias_target;
2602 }
2603 }
2604
2605 text += len;
2606 text = skip_spaces (text);
2607
2608 if ((*cmd)->is_prefix () && *text != '\0')
2609 {
2610 cur_list = *(*cmd)->subcommands;
2611 *prefix_cmd = *cmd;
2612 }
2613 else
2614 return 1;
2615 }
2616}
2617
2618/* Look up the contents of TEXT as a command in the command list 'cmdlist'.
2619 Return 1 on success, 0 on failure.
2620
2621 If TEXT refers to an alias, *ALIAS will point to that alias.
2622
2623 If TEXT is a subcommand (i.e. one that is preceded by a prefix
2624 command) set *PREFIX_CMD.
2625
2626 Set *CMD to point to the command TEXT indicates.
2627
2628 If any of *ALIAS, *PREFIX_CMD, or *CMD cannot be determined or do not
2629 exist, they are NULL when we return.
2630
2631*/
2632
2633int
2634lookup_cmd_composition (const char *text,
2635 struct cmd_list_element **alias,
2636 struct cmd_list_element **prefix_cmd,
2637 struct cmd_list_element **cmd)
2638{
2639 return lookup_cmd_composition_1 (text, alias, prefix_cmd, cmd, cmdlist);
2640}
2641
2642/* Helper function for SYMBOL_COMPLETION_FUNCTION. */
2643
2644/* Return a vector of char pointers which point to the different
2645 possible completions in LIST of TEXT.
2646
2647 WORD points in the same buffer as TEXT, and completions should be
2648 returned relative to this position. For example, suppose TEXT is
2649 "foo" and we want to complete to "foobar". If WORD is "oo", return
2650 "oobar"; if WORD is "baz/foo", return "baz/foobar". */
2651
2652void
2654 completion_tracker &tracker,
2655 const char *text, const char *word,
2656 int ignore_help_classes)
2657{
2658 struct cmd_list_element *ptr;
2659 int textlen = strlen (text);
2660 int pass;
2661 int saw_deprecated_match = 0;
2662
2663 /* We do one or two passes. In the first pass, we skip deprecated
2664 commands. If we see no matching commands in the first pass, and
2665 if we did happen to see a matching deprecated command, we do
2666 another loop to collect those. */
2667 for (pass = 0; pass < 2; ++pass)
2668 {
2669 bool got_matches = false;
2670
2671 for (ptr = list; ptr; ptr = ptr->next)
2672 if (!strncmp (ptr->name, text, textlen)
2673 && !ptr->abbrev_flag
2674 && (!ignore_help_classes || !ptr->is_command_class_help ()
2675 || ptr->is_prefix ()))
2676 {
2677 if (pass == 0)
2678 {
2679 if (ptr->cmd_deprecated)
2680 {
2681 saw_deprecated_match = 1;
2682 continue;
2683 }
2684 }
2685
2686 tracker.add_completion
2687 (make_completion_match_str (ptr->name, text, word));
2688 got_matches = true;
2689 }
2690
2691 if (got_matches)
2692 break;
2693
2694 /* If we saw no matching deprecated commands in the first pass,
2695 just bail out. */
2696 if (!saw_deprecated_match)
2697 break;
2698 }
2699}
2700
2701/* Helper function for SYMBOL_COMPLETION_FUNCTION. */
2702
2703/* Add the different possible completions in ENUMLIST of TEXT.
2704
2705 WORD points in the same buffer as TEXT, and completions should be
2706 returned relative to this position. For example, suppose TEXT is "foo"
2707 and we want to complete to "foobar". If WORD is "oo", return
2708 "oobar"; if WORD is "baz/foo", return "baz/foobar". */
2709
2710void
2712 const char *const *enumlist,
2713 const char *text, const char *word)
2714{
2715 int textlen = strlen (text);
2716 int i;
2717 const char *name;
2718
2719 for (i = 0; (name = enumlist[i]) != NULL; i++)
2720 if (strncmp (name, text, textlen) == 0)
2721 tracker.add_completion (make_completion_match_str (name, text, word));
2722}
2723
2724/* Call the command function. */
2725void
2726cmd_func (struct cmd_list_element *cmd, const char *args, int from_tty)
2727{
2728 if (!cmd->is_command_class_help ())
2729 {
2730 gdb::optional<scoped_restore_tmpl<bool>> restore_suppress;
2731
2732 if (cmd->suppress_notification != NULL)
2733 restore_suppress.emplace (cmd->suppress_notification, true);
2734
2735 cmd->func (args, from_tty, cmd);
2736 }
2737 else
2738 error (_("Invalid command"));
2739}
2740
2741int
2743{
2744 return cmd->theclass == class_user && cmd->func == do_simple_func;
2745}
const char *const name
void * xmalloc(YYSIZE_T)
void xfree(void *)
ui_file_style style() const
Definition cli-style.c:169
void add_completion(gdb::unique_xmalloc_ptr< char > name, completion_match_for_lcd *match_for_lcd=NULL, const char *text=NULL, const char *word=NULL)
Definition completer.c:1579
virtual void wrap_here(int indent)
Definition ui-file.h:119
struct cmd_list_element * infolist
Definition cli-cmds.c:91
struct cmd_list_element * cmdlist
Definition cli-cmds.c:87
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[]
static void empty_func(const char *args, int from_tty, cmd_list_element *c)
Definition cli-decode.c:490
set_show_commands add_setshow_filename_cmd(const char *name, enum 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, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-decode.c:855
static void fput_aliases_definition_styled(const cmd_list_element &cmd, struct ui_file *stream)
static int lookup_cmd_composition_1(const char *text, struct cmd_list_element **alias, struct cmd_list_element **prefix_cmd, struct cmd_list_element **cmd, struct cmd_list_element *cur_list)
static void help_all(struct ui_file *stream)
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *target, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
Definition cli-decode.c:294
struct cmd_list_element * lookup_cmd(const char **line, struct cmd_list_element *list, const char *cmdtype, std::string *default_args, int allow_unknown, int ignore_help_classes)
static set_show_commands add_setshow_cmd_full_erased(const char *name, enum command_class theclass, var_types var_type, const literal_def *extra_literals, const setting::erased_args &args, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-decode.c:539
set_show_commands add_setshow_zinteger_cmd(const char *name, enum 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, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
Definition cli-decode.c:233
void set_cmd_completer_handle_brkchars(struct cmd_list_element *cmd, completer_handle_brkchars_ftype *func)
Definition cli-decode.c:125
void help_cmd(const char *command, struct ui_file *stream)
void complete_on_cmdlist(struct cmd_list_element *list, completion_tracker &tracker, const char *text, const char *word, int ignore_help_classes)
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)
static void print_doc_of_command(const cmd_list_element &c, bool verbose, compiled_regex &highlight, struct ui_file *stream)
struct cmd_list_element * add_abbrev_prefix_cmd(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)
Definition cli-decode.c:468
void deprecated_cmd_warning(const char *text, struct cmd_list_element *list)
bool valid_cmd_char_p(int c)
static void help_cmd_list(struct cmd_list_element *list, enum command_class theclass, bool recurse, struct ui_file *stream)
static void print_help_for_command(const cmd_list_element &c, bool recurse, struct ui_file *stream)
cmd_list_element * add_com_alias(const char *name, cmd_list_element *target, command_class theclass, int abbrev_flag)
set_show_commands add_setshow_optional_filename_cmd(const char *name, enum 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, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
const literal_def integer_unlimited_literals[]
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)
static void set_cmd_simple_func(struct cmd_list_element *cmd, cmd_simple_func_ftype *simple_func)
Definition cli-decode.c:99
static void update_prefix_field_of_prefixed_commands(struct cmd_list_element *c)
Definition cli-decode.c:328
static set_show_commands add_setshow_cmd_full(const char *name, enum command_class theclass, var_types var_type, T *var, const literal_def *extra_literals, const char *set_doc, const char *show_doc, const char *help_doc, typename setting_func_types< T >::set set_setting_func, typename setting_func_types< T >::get get_setting_func, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-decode.c:627
set_show_commands add_setshow_string_cmd(const char *name, enum 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, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-decode.c:903
void help_list(struct cmd_list_element *list, const char *cmdtype, enum command_class theclass, struct ui_file *stream)
void set_cmd_completer(struct cmd_list_element *cmd, completer_ftype *completer)
Definition cli-decode.c:117
static void fput_alias_definition_styled(const cmd_list_element &c, struct ui_file *stream)
struct cmd_list_element * add_show_prefix_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list)
Definition cli-decode.c:414
void apropos_cmd(struct ui_file *stream, struct cmd_list_element *commandlist, bool verbose, compiled_regex &regex)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc)
set_show_commands add_setshow_zuinteger_unlimited_cmd(const char *name, enum 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, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
static bool user_documented_alias(const cmd_list_element &alias)
static void do_prefix_cmd(const char *args, int from_tty, struct cmd_list_element *c)
Definition cli-decode.c:378
void cmd_func(struct cmd_list_element *cmd, const char *args, int from_tty)
set_show_commands add_setshow_uinteger_cmd(const char *name, enum 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, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
set_show_commands add_setshow_enum_cmd(const char *name, enum 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, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-decode.c:688
void not_just_help_class_command(const char *args, int from_tty)
Definition cli-decode.c:483
set_show_commands add_setshow_integer_cmd(const char *name, enum 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, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
static void do_simple_func(const char *args, int from_tty, cmd_list_element *c)
Definition cli-decode.c:93
struct cmd_list_element * deprecate_cmd(struct cmd_list_element *cmd, const char *replacement)
Definition cli-decode.c:280
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
struct cmd_list_element * add_prefix_cmd(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)
Definition cli-decode.c:357
static cmd_list_element::aliases_list_type delete_cmd(const char *name, cmd_list_element **list, cmd_list_element **prehook, cmd_list_element **prehookee, cmd_list_element **posthook, cmd_list_element **posthookee)
bool valid_user_defined_cmd_name_p(const char *name)
static void fput_command_name_styled(const cmd_list_element &c, struct ui_file *stream)
set_show_commands add_setshow_boolean_cmd(const char *name, enum 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, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-decode.c:809
int find_command_name_length(const char *text)
cmd_list_element * add_info_alias(const char *name, cmd_list_element *target, int abbrev_flag)
const literal_def uinteger_unlimited_literals[]
int cmd_simple_func_eq(struct cmd_list_element *cmd, cmd_simple_func_ftype *simple_func)
Definition cli-decode.c:110
set_show_commands add_setshow_pinteger_cmd(const char *name, enum 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, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
const char *const boolean_enums[]
Definition cli-decode.c:800
static struct cmd_list_element * lookup_cmd_with_subcommands(cmd_list_element **subcommands, cmd_list_element *list)
Definition cli-decode.c:61
static void fput_command_names_styled(const cmd_list_element &c, bool always_fput_c_name, const char *postfix, struct ui_file *stream)
set_show_commands add_setshow_string_noescape_cmd(const char *name, enum 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, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-decode.c:953
static struct cmd_list_element * find_cmd(const char *command, int len, struct cmd_list_element *clist, int ignore_help_classes, int *nfound)
static void integer_literals_completer(struct cmd_list_element *c, completion_tracker &tracker, const char *text, const char *word)
Definition cli-decode.c:589
set_show_commands add_setshow_auto_boolean_cmd(const char *name, enum command_class theclass, enum 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, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-decode.c:752
int lookup_cmd_composition(const char *text, struct cmd_list_element **alias, struct cmd_list_element **prefix_cmd, struct cmd_list_element **cmd)
static void do_show_prefix_cmd(const char *args, int from_tty, struct cmd_list_element *c)
Definition cli-decode.c:406
struct cmd_list_element * lookup_cmd_exact(const char *name, struct cmd_list_element *list, bool ignore_help_classes)
void complete_on_enum(completion_tracker &tracker, const char *const *enumlist, const char *text, const char *word)
struct cmd_list_element * add_basic_prefix_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list)
Definition cli-decode.c:391
int cli_user_command_p(struct cmd_list_element *cmd)
static struct cmd_list_element * add_set_or_show_cmd(const char *name, enum cmd_types type, enum command_class theclass, var_types var_type, const literal_def *extra_literals, const setting::erased_args &arg, const char *doc, struct cmd_list_element **list)
Definition cli-decode.c:506
const char *const auto_boolean_enums[]
Definition cli-decode.c:744
struct cmd_list_element * add_info(const char *name, cmd_simple_func_ftype *fun, const char *doc)
static void undef_cmd_error(const char *, const char *)
static struct cmd_list_element * do_add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
Definition cli-decode.c:181
void print_doc_line(struct ui_file *stream, const char *str, bool for_value_prefix)
set_show_commands add_setshow_zuinteger_cmd(const char *name, enum 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, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
cmd_types
Definition cli-decode.h:36
@ set_cmd
Definition cli-decode.h:38
@ show_cmd
Definition cli-decode.h:39
void cmd_show_list(struct cmd_list_element *list, int from_tty)
cli_style_option title_style
#define CMD_LIST_AMBIGUOUS
Definition command.h:539
void completer_ftype(struct cmd_list_element *, completion_tracker &tracker, const char *text, const char *word)
Definition command.h:511
void cmd_simple_func_ftype(const char *args, int from_tty)
Definition command.h:388
void show_value_ftype(struct ui_file *file, int from_tty, struct cmd_list_element *cmd, const char *value)
Definition command.h:660
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
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
command_class
Definition command.h:43
@ class_user
Definition command.h:67
@ all_commands
Definition command.h:50
@ class_alias
Definition command.h:62
@ class_run
Definition command.h:54
@ all_classes
Definition command.h:49
@ no_class
Definition command.h:53
@ class_info
Definition command.h:59
gdb::unique_xmalloc_ptr< char > make_completion_match_str(const char *match_name, const char *text, const char *word)
Definition completer.c:1646
void filename_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
Definition completer.c:204
auto_boolean
Definition defs.h:247
const char * alias
Definition nds32-tdep.c:114
void(* func)(remote_target *remote, char *)
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 doc_allocated
Definition cli-decode.h:145
struct cmd_list_element * hook_post
Definition cli-decode.h:206
unsigned int abbrev_flag
Definition cli-decode.h:164
union cmd_list_element::@27 function
aliases_list_type aliases
Definition cli-decode.h:265
struct cmd_list_element * hookee_post
Definition cli-decode.h:251
const char * doc
Definition cli-decode.h:193
std::vector< std::string > command_components() const
Definition cli-decode.c:151
bool * suppress_notification
Definition cli-decode.h:271
cmd_simple_func_ftype * simple_func
Definition cli-decode.h:185
cmd_func_ftype * func
Definition cli-decode.h:175
gdb::optional< setting > var
Definition cli-decode.h:236
struct cmd_list_element * hookee_pre
Definition cli-decode.h:247
struct cmd_list_element * hook_pre
Definition cli-decode.h:203
std::string prefixname() const
Definition cli-decode.c:132
std::string default_args
Definition cli-decode.h:210
struct cmd_list_element ** subcommands
Definition cli-decode.h:214
completer_handle_brkchars_ftype * completer_handle_brkchars
Definition cli-decode.h:228
unsigned int cmd_deprecated
Definition cli-decode.h:124
completer_ftype * completer
Definition cli-decode.h:220
struct cmd_list_element * prefix
Definition cli-decode.h:217
unsigned int deprecated_warn_user
Definition cli-decode.h:130
bool is_alias() const
Definition cli-decode.h:90
bool is_command_class_help() const
Definition cli-decode.h:100
intrusive_list< cmd_list_element, aliases_list_member_node_type > aliases_list_type
Definition cli-decode.h:264
void * context() const
Definition cli-decode.h:109
__extension__ enum cmd_types type
Definition cli-decode.h:168
void(* destroyer)(struct cmd_list_element *self, void *context)
Definition cli-decode.h:233
struct cmd_list_element * next
Definition cli-decode.h:113
struct cmd_list_element * alias_target
Definition cli-decode.h:255
const char * name
Definition cli-decode.h:116
const char *const * enums
Definition cli-decode.h:240
bool is_prefix() const
Definition cli-decode.h:94
show_value_ftype * show_value_func
Definition cli-decode.h:197
const char * replacement
Definition cli-decode.h:200
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
cmd_list_element * set
Definition command.h:422
cmd_list_element * show
Definition command.h:422
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 >::set set
Definition command.h:210
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
static styled_string_s * styled_string(const ui_file_style &style, const char *str, styled_string_s &&tmp={})
Definition ui-out.h:151
void fputs_highlighted(const char *str, const compiled_regex &highlight, struct ui_file *stream)
Definition utils.c:1828
void fprintf_styled(struct ui_file *stream, const ui_file_style &style, const char *format,...)
Definition utils.c:1898
void gdb_printf(struct ui_file *stream, const char *format,...)
Definition utils.c:1886
void gdb_puts(const char *linebuffer, struct ui_file *stream)
Definition utils.c:1809
#define gdb_stdout
Definition utils.h:182