42 int ignore_help_classes,
56 for (p = list; p != NULL; p = p->
next)
79 for (p = *list; p != NULL; p = p->
next)
96 int recurse,
struct ui_file *stream);
214 if (*list == NULL || strcmp ((*list)->name,
name) >= 0)
314 &prehook, &prehookee,
315 &posthook, &posthookee);
319 && !posthook && ! posthookee);
328 c->
doc = xstrdup (old->
doc);
465 const char *set_doc,
const char *show_doc,
466 const char *help_doc,
479 if (help_doc != NULL)
481 full_set_doc =
xstrprintf (
"%s\n%s", set_doc, help_doc);
482 full_show_doc =
xstrprintf (
"%s\n%s", show_doc, help_doc);
486 full_set_doc = xstrdup (set_doc);
487 full_show_doc = xstrdup (show_doc);
490 full_set_doc, set_list);
491 set->doc_allocated = 1;
493 if (set_func != NULL)
499 full_show_doc, show_list);
503 if (set_result != NULL)
505 if (show_result != NULL)
517 const char *
const *enumlist,
520 const char *show_doc,
521 const char *help_doc,
530 set_doc, show_doc, help_doc,
547 const char *set_doc,
const char *show_doc,
548 const char *help_doc,
557 set_doc, show_doc, help_doc,
570 const char *set_doc,
const char *show_doc,
571 const char *help_doc,
577 static const char *boolean_enums[] = {
"on",
"off", NULL };
581 set_doc, show_doc, help_doc,
585 c->
enums = boolean_enums;
593 const char *set_doc,
const char *show_doc,
594 const char *help_doc,
603 set_doc, show_doc, help_doc,
615 const char *set_doc,
const char *show_doc,
616 const char *help_doc,
623 set_doc, show_doc, help_doc,
634 const char *set_doc,
const char *show_doc,
635 const char *help_doc,
644 set_doc, show_doc, help_doc,
656 const char *set_doc,
const char *show_doc,
657 const char *help_doc,
666 set_doc, show_doc, help_doc,
681 const char *text,
const char *word)
683 static const char *
const keywords[] =
700 const char *set_doc,
const char *show_doc,
701 const char *help_doc,
710 set_doc, show_doc, help_doc,
725 const char *set_doc,
const char *show_doc,
726 const char *help_doc,
735 set_doc, show_doc, help_doc,
750 const char *set_doc,
const char *show_doc,
751 const char *help_doc,
758 set_doc, show_doc, help_doc,
769 const char *show_doc,
770 const char *help_doc,
779 set_doc, show_doc, help_doc,
794 const char *set_doc,
const char *show_doc,
795 const char *help_doc,
802 set_doc, show_doc, help_doc,
830 previous_chain_ptr = list;
832 for (iter = *previous_chain_ptr; iter; iter = *previous_chain_ptr)
850 *previous_chain_ptr = iter->
next;
875 previous_chain_ptr = &iter->
next;
946 for (c=commandlist;c;c=c->
next)
951 size_t name_len = strlen (c->
name);
954 returnvalue = regex.
search (c->
name, name_len, 0, name_len, NULL);
955 if (returnvalue >= 0)
961 if (c->
doc != NULL && returnvalue < 0)
963 size_t doc_len = strlen (c->
doc);
966 if (regex.
search (c->
doc, doc_len, 0, doc_len, NULL) >= 0)
1006 if (strcmp (command,
"all") == 0)
1041 if (c->
func == NULL)
1046 "\nThis command has a hook (or hooks) defined:\n");
1050 "\tThis command is run after : %s (pre hook)\n",
1054 "\tThis command is run before : %s (post hook)\n",
1075 char *cmdtype1, *cmdtype2;
1079 len = strlen (cmdtype);
1080 cmdtype1 = (
char *) alloca (len + 1);
1082 cmdtype2 = (
char *) alloca (len + 4);
1087 memcpy (cmdtype1 + 1, cmdtype, len - 1);
1089 memcpy (cmdtype2, cmdtype, len - 1);
1090 strcpy (cmdtype2 + len - 1,
" sub");
1103 Type \"help%s\" followed by a class name for a list of commands in ",
1109 Type \"help all\" for the list of all commands.");
1113 cmdtype1, cmdtype2);
1121 "for commands related to \"word\".\n", stream);
1122 fputs_filtered (
"Command name abbreviations are allowed if unambiguous.\n",
1130 int seen_unclassified = 0;
1139 if (c->
func == NULL)
1157 if (!seen_unclassified)
1160 seen_unclassified = 1;
1172 static char *line_buffer = 0;
1173 static int line_size;
1179 line_buffer = (
char *)
xmalloc (line_size);
1185 while (*p && *p !=
'\n' 1186 && ((*p !=
'.' && *p !=
',') || (p[1] && !isspace (p[1]))))
1188 if (p - str > line_size - 1)
1190 line_size = p - str + 1;
1191 xfree (line_buffer);
1192 line_buffer = (
char *)
xmalloc (line_size);
1194 strncpy (line_buffer, str, p - str);
1195 line_buffer[p - str] =
'\0';
1196 if (islower (line_buffer[0]))
1197 line_buffer[0] = toupper (line_buffer[0]);
1206 int recurse,
struct ui_file *stream)
1243 for (c = list; c; c = c->
next)
1270 int ignore_help_classes,
int *nfound)
1276 for (c = clist; c; c = c->
next)
1277 if (!strncmp (command, c->
name, len)
1278 && (!ignore_help_classes || c->
func))
1282 if (c->
name[len] ==
'\0')
1296 const char *p = text;
1312 while (isalnum (*p) || *p ==
'-' || *p ==
'_' 1314 || *p ==
'+' || *p ==
'<' || *p ==
'>' || *p ==
'$')
1335 for (p =
name; *p !=
'\0'; ++p)
1391 const char *line = *text;
1393 while (**text ==
' ' || **text ==
'\t')
1407 command = (
char *) alloca (len + 1);
1408 memcpy (command, *text, len);
1409 command[len] =
'\0';
1414 found =
find_cmd (command, len, clist, ignore_help_classes, &nfound);
1422 if (result_list != NULL)
1451 ignore_help_classes);
1455 if (result_list != NULL)
1456 *result_list = clist;
1464 if (result_list != NULL)
1470 *result_list = found;
1481 if (result_list != NULL)
1482 *result_list = clist;
1492 error (
_(
"Undefined %scommand: \"%s\". Try \"help%s%.*s\"."),
1495 *cmdtype ?
" " :
"",
1496 (
int) strlen (cmdtype) - 1,
1516 const char *cmdtype,
1526 error (
_(
"Lack of needed %scommand"), cmdtype);
1528 c =
lookup_cmd_1 (line, list, &last_list, ignore_help_classes);
1537 q = (
char *) alloca (len + 1);
1538 strncpy (q, *line, len);
1549 int local_allow_unknown = (last_list ? last_list->
allow_unknown :
1551 const char *local_cmdtype = last_list ? last_list->
prefixname : cmdtype;
1553 (last_list ? *(last_list->
prefixlist) : list);
1555 if (local_allow_unknown < 0)
1569 ((*line)[amb_len] && (*line)[amb_len] !=
' ' 1570 && (*line)[amb_len] !=
'\t');
1575 for (c = local_list; c; c = c->
next)
1576 if (!strncmp (*line, c->
name, amb_len))
1578 if (strlen (ambbuf) + strlen (c->
name) + 6
1579 < (int)
sizeof ambbuf)
1581 if (strlen (ambbuf))
1582 strcat (ambbuf,
", ");
1583 strcat (ambbuf, c->
name);
1587 strcat (ambbuf,
"..");
1591 error (
_(
"Ambiguous %scommand \"%s\": %s."), local_cmdtype,
1598 if (c->
type ==
set_cmd && **line !=
'\0' && !isspace (**line))
1599 error (
_(
"Argument must be preceded by space."));
1603 while (**line ==
' ' || **line ==
'\t')
1648 if (!((
alias ?
alias->deprecated_warn_user : 0)
1676 if (
alias->replacement)
1691 alias->deprecated_warn_user = 0;
1735 while (*text ==
' ' || *text ==
'\t')
1748 command = (
char *) alloca (len + 1);
1749 memcpy (command, text, len);
1750 command[len] =
'\0';
1755 *cmd =
find_cmd (command, len, cur_list, 1, &nfound);
1766 if ((*cmd)->cmd_pointer)
1773 *prefix_cmd = prev_cmd;
1775 if ((*cmd)->prefixlist)
1797 const char *text,
const char *word,
1798 int ignore_help_classes)
1801 int textlen = strlen (text);
1803 int saw_deprecated_match = 0;
1809 for (pass = 0; pass < 2; ++pass)
1811 bool got_matches =
false;
1813 for (ptr = list; ptr; ptr = ptr->
next)
1814 if (!strncmp (ptr->
name, text, textlen)
1816 && (!ignore_help_classes || ptr->
func 1823 saw_deprecated_match = 1;
1838 if (!saw_deprecated_match)
1854 const char *
const *enumlist,
1855 const char *text,
const char *word)
1857 int textlen = strlen (text);
1861 for (i = 0; (
name = enumlist[i]) != NULL; i++)
1862 if (strncmp (
name, text, textlen) == 0)
1871 return (cmd->
func != NULL);
1886 (*cmd->
func) (cmd, args, from_tty);
1889 error (
_(
"Invalid command"));
unsigned int doc_allocated
void add_setshow_filename_cmd(const char *name, enum command_class theclass, char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void set_cmd_context(struct cmd_list_element *cmd, void *context)
static void empty_sfunc(const char *args, int from_tty, struct cmd_list_element *c)
unsigned int deprecated_warn_user
union cmd_list_element::@20 function
struct cmd_list_element * next
void * get_cmd_context(struct cmd_list_element *cmd)
unsigned int cmd_deprecated
completer_handle_brkchars_ftype * completer_handle_brkchars
void add_setshow_integer_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
static void do_sfunc(struct cmd_list_element *c, const char *args, int from_tty)
static void print_help_for_command(struct cmd_list_element *c, const char *prefix, int recurse, struct ui_file *stream)
static struct cmd_list_element * lookup_cmd_for_prefixlist(struct cmd_list_element **key, struct cmd_list_element *list)
__extension__ enum cmd_types type
void 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_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void cmd_const_sfunc_ftype(const char *args, int from_tty, struct cmd_list_element *c)
struct cmd_list_element * deprecate_cmd(struct cmd_list_element *cmd, const char *replacement)
int cmd_cfunc_eq(struct cmd_list_element *cmd, cmd_const_cfunc_ftype *cfunc)
struct cmd_list_element * hook_post
void complete_on_cmdlist(struct cmd_list_element *list, completion_tracker &tracker, const char *text, const char *word, int ignore_help_classes)
void print_doc_line(struct ui_file *stream, const char *str)
const char *const * enums
void help_cmd_list(struct cmd_list_element *list, enum command_class theclass, const char *prefix, int recurse, struct ui_file *stream)
unsigned int allow_unknown
struct cmd_list_element * add_info(const char *name, cmd_const_cfunc_ftype *fun, const char *doc)
void complete_on_enum(completion_tracker &tracker, const char *const *enumlist, const char *text, const char *word)
struct cmd_list_element * lookup_cmd(const char **line, struct cmd_list_element *list, const char *cmdtype, int allow_unknown, int ignore_help_classes)
struct cmd_list_element * aliases
void 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_const_sfunc_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)
struct cmd_list_element * hookee_post
struct cmd_list_element * lookup_cmd_1(const char **text, struct cmd_list_element *clist, struct cmd_list_element **result_list, int ignore_help_classes)
void filename_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
struct cmd_list_element * cmdlist
void deprecated_cmd_warning(const char *text)
void set_cmd_sfunc(struct cmd_list_element *cmd, cmd_const_sfunc_ftype *sfunc)
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, void *var, const char *doc, struct cmd_list_element **list)
struct cmd_list_element * prefix
int lookup_cmd_composition(const char *text, struct cmd_list_element **alias, struct cmd_list_element **prefix_cmd, struct cmd_list_element **cmd)
void printf_filtered(const char *format,...)
struct command_line * user_commands
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
void 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_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct cmd_list_element * cmd_pointer
int search(const char *string, int size, int startpos, int range, struct re_registers *regs)
static void do_const_cfunc(struct cmd_list_element *c, const char *args, int from_tty)
struct cmd_list_element * infolist
struct cmd_list_element * setlist
void add_setshow_uinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_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_com_suppress_notification(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc, int *suppress_notification)
struct cmd_list_element * hook_pre
void cmd_func(struct cmd_list_element *cmd, const char *args, int from_tty)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
void set_cmd_completer(struct cmd_list_element *cmd, completer_ftype *completer)
void 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_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void(* destroyer)(struct cmd_list_element *self, void *context)
struct cmd_list_element * add_com_alias(const char *name, const char *oldname, enum command_class theclass, int abbrev_flag)
void fputs_filtered(const char *linebuffer, struct ui_file *stream)
struct cmd_list_element * add_setshow_string_noescape_cmd(const char *name, enum command_class theclass, char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void set_cmd_completer_handle_brkchars(struct cmd_list_element *cmd, completer_handle_brkchars_ftype *func)
static void integer_unlimited_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
__extension__ enum var_types var_type
void add_setshow_string_cmd(const char *name, enum command_class theclass, char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void symbol_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
void not_just_help_class_command(const char *args, int from_tty)
static void set_cmd_prefix(struct cmd_list_element *c, struct cmd_list_element **list)
static struct cmd_list_element * delete_cmd(const char *name, struct cmd_list_element **list, struct cmd_list_element **prehook, struct cmd_list_element **prehookee, struct cmd_list_element **posthook, struct cmd_list_element **posthookee)
#define CMD_LIST_AMBIGUOUS
cmd_const_sfunc_ftype * sfunc
char * xstrprintf(const char *format,...)
void completer_ftype(struct cmd_list_element *, completion_tracker &tracker, const char *text, const char *word)
struct cmd_list_element * add_abbrev_prefix_cmd(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
void(* pre_show_hook)(struct cmd_list_element *c)
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *old, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
static void undef_cmd_error(const char *, const char *)
static struct cmd_list_element * find_cmd(const char *command, int len, struct cmd_list_element *clist, int ignore_help_classes, int *nfound)
int * suppress_notification
void wrap_here(const char *indent)
void apropos_cmd(struct ui_file *stream, struct cmd_list_element *commandlist, compiled_regex ®ex, const char *prefix)
void help_list(struct cmd_list_element *list, const char *cmdtype, enum command_class theclass, struct ui_file *stream)
T & emplace(Args &&... args)
static void add_setshow_cmd_full(const char *name, enum command_class theclass, var_types var_type, void *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list, struct cmd_list_element **set_result, struct cmd_list_element **show_result)
int find_command_name_length(const char *text)
int valid_user_defined_cmd_name_p(const char *name)
gdb::unique_xmalloc_ptr< char > make_completion_match_str(const char *match_name, const char *text, const char *word)
void cmd_const_cfunc_ftype(const char *args, int from_tty)
void add_setshow_boolean_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
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)
enum command_class theclass
void(* func)(struct cmd_list_element *c, const char *args, int from_tty)
struct cmd_list_element * add_info_alias(const char *name, const char *oldname, int abbrev_flag)
struct cmd_list_element * alias_chain
static int ignore(struct target_ops *ops, struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
show_value_ftype * show_value_func
void completer_handle_brkchars_ftype(struct cmd_list_element *, completion_tracker &tracker, const char *text, const char *word)
void add_setshow_optional_filename_cmd(const char *name, enum command_class theclass, char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
cmd_const_cfunc_ftype * const_cfunc
struct cmd_list_element ** prefixlist
static void set_cmd_cfunc(struct cmd_list_element *cmd, cmd_const_cfunc_ftype *cfunc)
static void help_all(struct ui_file *stream)
struct cmd_list_element * hookee_pre
static struct cmd_list_element * do_add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
void help_cmd(const char *command, struct ui_file *stream)
unsigned int malloced_replacement
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, const char *doc)
completer_ftype * completer
int cli_user_command_p(struct cmd_list_element *cmd)
const char *const auto_boolean_enums[]
void 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_const_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void error(const char *fmt,...)
int cmd_func_p(struct cmd_list_element *cmd)
enum cmd_types cmd_type(struct cmd_list_element *cmd)
void() show_value_ftype(struct ui_file *file, int from_tty, struct cmd_list_element *cmd, const char *value)