cli-decode.c
来自「这个是LINUX下的GDB调度工具的源码」· C语言 代码 · 共 1,605 行 · 第 1/4 页
C
1,605 行
}/* Add an auto-boolean command named NAME to both the set and show command list lists. CLASS is as in add_cmd. VAR is address of the variable which will contain the value. DOC is the documentation string. FUNC is the corresponding callback. */voidadd_setshow_auto_boolean_cmd (char *name, enum command_class class, enum auto_boolean *var, const char *set_doc, const char *show_doc, const char *help_doc, const char *print, cmd_sfunc_ftype *set_func, cmd_sfunc_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list){ static const char *auto_boolean_enums[] = { "on", "off", "auto", NULL }; struct cmd_list_element *c; add_setshow_cmd_full (name, class, var_auto_boolean, var, set_doc, show_doc, help_doc, print, set_func, show_func, set_list, show_list, &c, NULL); c->enums = auto_boolean_enums;}/* Add element named NAME to both the set and show command LISTs (the list for set/show or some sublist thereof). CLASS is as in add_cmd. VAR is address of the variable which will contain the value. SET_DOC and SHOW_DOC are the documentation strings. */voidadd_setshow_boolean_cmd (char *name, enum command_class class, int *var, const char *set_doc, const char *show_doc, const char *help_doc, const char *print, cmd_sfunc_ftype *set_func, cmd_sfunc_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list){ static const char *boolean_enums[] = { "on", "off", NULL }; struct cmd_list_element *c; add_setshow_cmd_full (name, class, var_boolean, var, set_doc, show_doc, help_doc, print, set_func, show_func, set_list, show_list, &c, NULL); c->enums = boolean_enums;}/* Add element named NAME to both the set and show command LISTs (the list for set/show or some sublist thereof). */voidadd_setshow_filename_cmd (char *name, enum command_class class, char **var, const char *set_doc, const char *show_doc, const char *help_doc, const char *print, cmd_sfunc_ftype *set_func, cmd_sfunc_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list){ add_setshow_cmd_full (name, class, var_filename, var, set_doc, show_doc, help_doc, print, set_func, show_func, set_list, show_list, NULL, NULL);}/* Add element named NAME to both the set and show command LISTs (the list for set/show or some sublist thereof). */voidadd_setshow_string_cmd (char *name, enum command_class class, char **var, const char *set_doc, const char *show_doc, const char *help_doc, const char *print, cmd_sfunc_ftype *set_func, cmd_sfunc_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list){ add_setshow_cmd_full (name, class, var_string, var, set_doc, show_doc, help_doc, print, set_func, show_func, set_list, show_list, NULL, NULL);}/* Add element named NAME to both the set and show command LISTs (the list for set/show or some sublist thereof). CLASS is as in add_cmd. VAR is address of the variable which will contain the value. SET_DOC and SHOW_DOC are the documentation strings. */voidadd_setshow_uinteger_cmd (char *name, enum command_class class, unsigned int *var, const char *set_doc, const char *show_doc, const char *help_doc, const char *print, cmd_sfunc_ftype *set_func, cmd_sfunc_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list){ add_setshow_cmd_full (name, class, var_uinteger, var, set_doc, show_doc, help_doc, print, set_func, show_func, set_list, show_list, NULL, NULL);}/* Add element named NAME to both the set and show command LISTs (the list for set/show or some sublist thereof). CLASS is as in add_cmd. VAR is address of the variable which will contain the value. SET_DOC and SHOW_DOC are the documentation strings. */voidadd_setshow_zinteger_cmd (char *name, enum command_class class, int *var, const char *set_doc, const char *show_doc, const char *help_doc, const char *print, cmd_sfunc_ftype *set_func, cmd_sfunc_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list){ add_setshow_cmd_full (name, class, var_zinteger, var, set_doc, show_doc, help_doc, print, set_func, show_func, set_list, show_list, NULL, NULL);}/* Where SETCMD has already been added, add the corresponding show command to LIST and return a pointer to the added command (not necessarily the head of LIST). *//* NOTE: cagney/2002-03-17: The original version of deprecated_add_show_from_set used memcpy() to clone `set' into `show'. This meant that in addition to all the needed fields (var, name, et.al.) some unnecessary fields were copied (namely the callback function). The function explictly copies relevant fields. For a `set' and `show' command to share the same callback, the caller must set both explicitly. */struct cmd_list_element *deprecated_add_show_from_set (struct cmd_list_element *setcmd, struct cmd_list_element **list){ char *doc; const static char setstring[] = "Set "; /* Create a doc string by replacing "Set " at the start of the `set'' command's doco with "Show ". */ gdb_assert (strncmp (setcmd->doc, setstring, sizeof (setstring) - 1) == 0); doc = concat ("Show ", setcmd->doc + sizeof (setstring) - 1, NULL); /* Insert the basic command. */ return add_set_or_show_cmd (setcmd->name, show_cmd, setcmd->class, setcmd->var_type, setcmd->var, doc, list);}/* Remove the command named NAME from the command list. */voiddelete_cmd (char *name, struct cmd_list_element **list){ struct cmd_list_element *c; struct cmd_list_element *p; while (*list && strcmp ((*list)->name, name) == 0) { if ((*list)->hookee_pre) (*list)->hookee_pre->hook_pre = 0; /* Hook slips out of its mouth */ if ((*list)->hookee_post) (*list)->hookee_post->hook_post = 0; /* Hook slips out of its bottom */ p = (*list)->next; xfree (* list); *list = p; } if (*list) for (c = *list; c->next;) { if (strcmp (c->next->name, name) == 0) { if (c->next->hookee_pre) c->next->hookee_pre->hook_pre = 0; /* hooked cmd gets away. */ if (c->next->hookee_post) c->next->hookee_post->hook_post = 0; /* remove post hook */ /* :( no fishing metaphore */ p = c->next->next; xfree (c->next); c->next = p; } else c = c->next; }}/* Shorthands to the commands above. *//* Add an element to the list of info subcommands. */struct cmd_list_element *add_info (char *name, void (*fun) (char *, int), char *doc){ return add_cmd (name, no_class, fun, doc, &infolist);}/* Add an alias to the list of info subcommands. */struct cmd_list_element *add_info_alias (char *name, char *oldname, int abbrev_flag){ return add_alias_cmd (name, oldname, 0, abbrev_flag, &infolist);}/* Add an element to the list of commands. */struct cmd_list_element *add_com (char *name, enum command_class class, void (*fun) (char *, int), char *doc){ return add_cmd (name, class, fun, doc, &cmdlist);}/* Add an alias or abbreviation command to the list of commands. */struct cmd_list_element *add_com_alias (char *name, char *oldname, enum command_class class, int abbrev_flag){ return add_alias_cmd (name, oldname, class, abbrev_flag, &cmdlist);}/* Recursively walk the commandlist structures, and print out the documentation of commands that match our regex in either their name, or their documentation.*/void apropos_cmd (struct ui_file *stream, struct cmd_list_element *commandlist, struct re_pattern_buffer *regex, char *prefix){ struct cmd_list_element *c; int returnvalue=1; /*Needed to avoid double printing*/ /* Walk through the commands */ for (c=commandlist;c;c=c->next) { if (c->name != NULL) { /* Try to match against the name*/ returnvalue=re_search(regex,c->name,strlen(c->name),0,strlen(c->name),NULL); if (returnvalue >= 0) { /* Stolen from help_cmd_list. We don't directly use * help_cmd_list because it doesn't let us print out * single commands */ fprintf_filtered (stream, "%s%s -- ", prefix, c->name); print_doc_line (stream, c->doc); fputs_filtered ("\n", stream); returnvalue=0; /*Set this so we don't print it again.*/ } } if (c->doc != NULL && returnvalue != 0) { /* Try to match against documentation */ if (re_search(regex,c->doc,strlen(c->doc),0,strlen(c->doc),NULL) >=0) { /* Stolen from help_cmd_list. We don't directly use * help_cmd_list because it doesn't let us print out * single commands */ fprintf_filtered (stream, "%s%s -- ", prefix, c->name); print_doc_line (stream, c->doc); fputs_filtered ("\n", stream); } } /* Check if this command has subcommands */ if (c->prefixlist != NULL) { /* Recursively call ourselves on the subcommand list, passing the right prefix in. */ apropos_cmd (stream,*c->prefixlist,regex,c->prefixname); } }}/* This command really has to deal with two things: * 1) I want documentation on *this string* (usually called by * "help commandname"). * 2) I want documentation on *this list* (usually called by * giving a command that requires subcommands. Also called by saying * just "help".) * * I am going to split this into two seperate comamnds, help_cmd and * help_list. */voidhelp_cmd (char *command, struct ui_file *stream){ struct cmd_list_element *c; extern struct cmd_list_element *cmdlist; if (!command) { help_list (cmdlist, "", all_classes, stream); return; } if (strcmp (command, "all") == 0) { help_all (stream); return; } c = lookup_cmd (&command, cmdlist, "", 0, 0); if (c == 0) return; /* There are three cases here. If c->prefixlist is nonzero, we have a prefix command. Print its documentation, then list its subcommands. If c->func is non NULL, we really have a command. Print its documentation and return. If c->func is NULL, we have a class name. Print its documentation (as if it were a command) and then set class to the number of this class so that the commands in the class will be listed. */ fputs_filtered (c->doc, stream); fputs_filtered ("\n", stream); if (c->prefixlist == 0 && c->func != NULL) return; fprintf_filtered (stream, "\n"); /* If this is a prefix command, print it's subcommands */ if (c->prefixlist) help_list (*c->prefixlist, c->prefixname, all_commands, stream); /* If this is a class name, print all of the commands in the class */ if (c->func == NULL) help_list (cmdlist, "", c->class, stream); if (c->hook_pre || c->hook_post) fprintf_filtered (stream, "\nThis command has a hook (or hooks) defined:\n"); if (c->hook_pre) fprintf_filtered (stream, "\tThis command is run after : %s (pre hook)\n", c->hook_pre->name); if (c->hook_post) fprintf_filtered (stream, "\tThis command is run before : %s (post hook)\n", c->hook_post->name);}/* * Get a specific kind of help on a command list. * * LIST is the list. * CMDTYPE is the prefix to use in the title string. * CLASS is the class with which to list the nodes of this list (see * documentation for help_cmd_list below), As usual, ALL_COMMANDS for * everything, ALL_CLASSES for just classes, and non-negative for only things * in a specific class. * and STREAM is the output stream on which to print things. * If you call this routine with a class >= 0, it recurses. */voidhelp_list (struct cmd_list_element *list, char *cmdtype, enum command_class class, struct ui_file *stream){ int len; char *cmdtype1, *cmdtype2; /* If CMDTYPE is "foo ", CMDTYPE1 gets " foo" and CMDTYPE2 gets "foo sub" */ len = strlen (cmdtype); cmdtype1 = (char *) alloca (len + 1); cmdtype1[0] = 0; cmdtype2 = (char *) alloca (len + 4); cmdtype2[0] = 0; if (len) { cmdtype1[0] = ' '; strncpy (cmdtype1 + 1, cmdtype, len - 1); cmdtype1[len] = 0; strncpy (cmdtype2, cmdtype, len - 1); strcpy (cmdtype2 + len - 1, " sub"); } if (class == all_classes) fprintf_filtered (stream, "List of classes of %scommands:\n\n", cmdtype2); else fprintf_filtered (stream, "List of %scommands:\n\n", cmdtype2); help_cmd_list (list, class, cmdtype, (int) class >= 0, stream); if (class == all_classes)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?