GDB (API)
|
00001 /* Header file for command creation. 00002 00003 Copyright (C) 1986-2013 Free Software Foundation, Inc. 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 3 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00017 00018 #if !defined (COMMAND_H) 00019 #define COMMAND_H 1 00020 00021 #include "gdb_vecs.h" 00022 00023 /* This file defines the public interface for any code wanting to 00024 create commands. */ 00025 00026 /* Command classes are top-level categories into which commands are 00027 broken down for "help" purposes. 00028 00029 Notes on classes: class_alias is for alias commands which are not 00030 abbreviations of the original command. class-pseudo is for 00031 commands which are not really commands nor help topics ("stop"). */ 00032 00033 enum command_class 00034 { 00035 /* Special args to help_list */ 00036 class_deprecated = -3, all_classes = -2, all_commands = -1, 00037 /* Classes of commands */ 00038 no_class = -1, class_run = 0, class_vars, class_stack, class_files, 00039 class_support, class_info, class_breakpoint, class_trace, 00040 class_alias, class_bookmark, class_obscure, class_maintenance, 00041 class_pseudo, class_tui, class_user, class_xdb, 00042 no_set_class /* Used for "show" commands that have no corresponding 00043 "set" command. */ 00044 }; 00045 00046 /* FIXME: cagney/2002-03-17: Once cmd_type() has been removed, ``enum 00047 cmd_types'' can be moved from "command.h" to "cli-decode.h". */ 00048 /* Not a set/show command. Note that some commands which begin with 00049 "set" or "show" might be in this category, if their syntax does 00050 not fall into one of the following categories. */ 00051 typedef enum cmd_types 00052 { 00053 not_set_cmd, 00054 set_cmd, 00055 show_cmd 00056 } 00057 cmd_types; 00058 00059 /* Types of "set" or "show" command. */ 00060 typedef enum var_types 00061 { 00062 /* "on" or "off". *VAR is an integer which is nonzero for on, 00063 zero for off. */ 00064 var_boolean, 00065 00066 /* "on" / "true" / "enable" or "off" / "false" / "disable" or 00067 "auto. *VAR is an ``enum auto_boolean''. NOTE: In general a 00068 custom show command will need to be implemented - one that for 00069 "auto" prints both the "auto" and the current auto-selected 00070 value. */ 00071 var_auto_boolean, 00072 00073 /* Unsigned Integer. *VAR is an unsigned int. The user can type 00074 0 to mean "unlimited", which is stored in *VAR as UINT_MAX. */ 00075 var_uinteger, 00076 00077 /* Like var_uinteger but signed. *VAR is an int. The user can 00078 type 0 to mean "unlimited", which is stored in *VAR as 00079 INT_MAX. The only remaining use of it is the Python API. 00080 Don't use it elsewhere. */ 00081 var_integer, 00082 00083 /* String which the user enters with escapes (e.g. the user types 00084 \n and it is a real newline in the stored string). 00085 *VAR is a malloc'd string, or NULL if the string is empty. */ 00086 var_string, 00087 /* String which stores what the user types verbatim. 00088 *VAR is a malloc'd string, or NULL if the string is empty. */ 00089 var_string_noescape, 00090 /* String which stores a filename. (*VAR) is a malloc'd string, 00091 or "" if the string was empty. */ 00092 var_optional_filename, 00093 /* String which stores a filename. (*VAR) is a malloc'd 00094 string. */ 00095 var_filename, 00096 /* ZeroableInteger. *VAR is an int. Like var_integer except 00097 that zero really means zero. */ 00098 var_zinteger, 00099 /* ZeroableUnsignedInteger. *VAR is an unsigned int. Zero really 00100 means zero. */ 00101 var_zuinteger, 00102 /* ZeroableUnsignedInteger with unlimited value. *VAR is an int, 00103 but its range is [0, INT_MAX]. -1 stands for unlimited and 00104 other negative numbers are not allowed. */ 00105 var_zuinteger_unlimited, 00106 /* Enumerated type. Can only have one of the specified values. 00107 *VAR is a char pointer to the name of the element that we 00108 find. */ 00109 var_enum 00110 } 00111 var_types; 00112 00113 /* This structure records one command'd definition. */ 00114 struct cmd_list_element; 00115 00116 /* Forward-declarations of the entry-points of cli/cli-decode.c. */ 00117 00118 /* API to the manipulation of command lists. */ 00119 00120 extern int valid_user_defined_cmd_name_p (const char *name); 00121 00122 extern struct cmd_list_element *add_cmd (const char *, enum command_class, 00123 void (*fun) (char *, int), char *, 00124 struct cmd_list_element **); 00125 00126 extern struct cmd_list_element *add_alias_cmd (const char *, const char *, 00127 enum command_class, int, 00128 struct cmd_list_element **); 00129 00130 extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class, 00131 void (*fun) (char *, int), 00132 char *, 00133 struct cmd_list_element **, 00134 char *, int, 00135 struct cmd_list_element **); 00136 00137 extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *, 00138 enum command_class, 00139 void (*fun) (char *, 00140 int), 00141 char *, 00142 struct cmd_list_element 00143 **, char *, int, 00144 struct cmd_list_element 00145 **); 00146 00147 /* Set the commands corresponding callback. */ 00148 00149 typedef void cmd_cfunc_ftype (char *args, int from_tty); 00150 extern void set_cmd_cfunc (struct cmd_list_element *cmd, 00151 cmd_cfunc_ftype *cfunc); 00152 00153 typedef void cmd_sfunc_ftype (char *args, int from_tty, 00154 struct cmd_list_element *c); 00155 extern void set_cmd_sfunc (struct cmd_list_element *cmd, 00156 cmd_sfunc_ftype *sfunc); 00157 00158 typedef VEC (char_ptr) *completer_ftype (struct cmd_list_element *, 00159 const char *, const char *); 00160 00161 extern void set_cmd_completer (struct cmd_list_element *, completer_ftype *); 00162 00163 /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs 00164 around in cmd objects to test the value of the commands sfunc(). */ 00165 extern int cmd_cfunc_eq (struct cmd_list_element *cmd, 00166 void (*cfunc) (char *args, int from_tty)); 00167 00168 /* Each command object has a local context attached to it. */ 00169 extern void set_cmd_context (struct cmd_list_element *cmd, 00170 void *context); 00171 extern void *get_cmd_context (struct cmd_list_element *cmd); 00172 00173 00174 /* Execute CMD's pre/post hook. Throw an error if the command fails. 00175 If already executing this pre/post hook, or there is no pre/post 00176 hook, the call is silently ignored. */ 00177 extern void execute_cmd_pre_hook (struct cmd_list_element *cmd); 00178 extern void execute_cmd_post_hook (struct cmd_list_element *cmd); 00179 00180 /* Return the type of the command. */ 00181 extern enum cmd_types cmd_type (struct cmd_list_element *cmd); 00182 00183 /* Flag for an ambiguous cmd_list result. */ 00184 #define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1) 00185 00186 extern struct cmd_list_element *lookup_cmd (const char **, 00187 struct cmd_list_element *, char *, 00188 int, int); 00189 00190 extern struct cmd_list_element *lookup_cmd_1 (const char **, 00191 struct cmd_list_element *, 00192 struct cmd_list_element **, 00193 int); 00194 00195 extern struct cmd_list_element *deprecate_cmd (struct cmd_list_element *, 00196 char * ); 00197 00198 extern void deprecated_cmd_warning (const char *); 00199 00200 extern int lookup_cmd_composition (const char *text, 00201 struct cmd_list_element **alias, 00202 struct cmd_list_element **prefix_cmd, 00203 struct cmd_list_element **cmd); 00204 00205 extern struct cmd_list_element *add_com (const char *, enum command_class, 00206 void (*fun) (char *, int), 00207 char *); 00208 00209 extern struct cmd_list_element *add_com_alias (const char *, const char *, 00210 enum command_class, int); 00211 00212 extern struct cmd_list_element *add_info (const char *, 00213 void (*fun) (char *, int), 00214 char *); 00215 00216 extern struct cmd_list_element *add_info_alias (const char *, char *, int); 00217 00218 extern VEC (char_ptr) *complete_on_cmdlist (struct cmd_list_element *, 00219 const char *, const char *, int); 00220 00221 extern VEC (char_ptr) *complete_on_enum (const char *const *enumlist, 00222 const char *, const char *); 00223 00224 /* Functions that implement commands about CLI commands. */ 00225 00226 extern void help_list (struct cmd_list_element *, char *, 00227 enum command_class, struct ui_file *); 00228 00229 /* Method for show a set/show variable's VALUE on FILE. If this 00230 method isn't supplied deprecated_show_value_hack() is called (which 00231 is not good). */ 00232 typedef void (show_value_ftype) (struct ui_file *file, 00233 int from_tty, 00234 struct cmd_list_element *cmd, 00235 const char *value); 00236 /* NOTE: i18n: This function is not i18n friendly. Callers should 00237 instead print the value out directly. */ 00238 extern show_value_ftype deprecated_show_value_hack; 00239 00240 extern void add_setshow_enum_cmd (const char *name, 00241 enum command_class class, 00242 const char *const *enumlist, 00243 const char **var, 00244 const char *set_doc, 00245 const char *show_doc, 00246 const char *help_doc, 00247 cmd_sfunc_ftype *set_func, 00248 show_value_ftype *show_func, 00249 struct cmd_list_element **set_list, 00250 struct cmd_list_element **show_list); 00251 00252 extern void add_setshow_auto_boolean_cmd (const char *name, 00253 enum command_class class, 00254 enum auto_boolean *var, 00255 const char *set_doc, 00256 const char *show_doc, 00257 const char *help_doc, 00258 cmd_sfunc_ftype *set_func, 00259 show_value_ftype *show_func, 00260 struct cmd_list_element **set_list, 00261 struct cmd_list_element **show_list); 00262 00263 extern void add_setshow_boolean_cmd (const char *name, 00264 enum command_class class, 00265 int *var, 00266 const char *set_doc, const char *show_doc, 00267 const char *help_doc, 00268 cmd_sfunc_ftype *set_func, 00269 show_value_ftype *show_func, 00270 struct cmd_list_element **set_list, 00271 struct cmd_list_element **show_list); 00272 00273 extern void add_setshow_filename_cmd (const char *name, 00274 enum command_class class, 00275 char **var, 00276 const char *set_doc, 00277 const char *show_doc, 00278 const char *help_doc, 00279 cmd_sfunc_ftype *set_func, 00280 show_value_ftype *show_func, 00281 struct cmd_list_element **set_list, 00282 struct cmd_list_element **show_list); 00283 00284 extern void add_setshow_string_cmd (const char *name, 00285 enum command_class class, 00286 char **var, 00287 const char *set_doc, 00288 const char *show_doc, 00289 const char *help_doc, 00290 cmd_sfunc_ftype *set_func, 00291 show_value_ftype *show_func, 00292 struct cmd_list_element **set_list, 00293 struct cmd_list_element **show_list); 00294 00295 extern struct cmd_list_element *add_setshow_string_noescape_cmd 00296 (const char *name, 00297 enum command_class class, 00298 char **var, 00299 const char *set_doc, 00300 const char *show_doc, 00301 const char *help_doc, 00302 cmd_sfunc_ftype *set_func, 00303 show_value_ftype *show_func, 00304 struct cmd_list_element **set_list, 00305 struct cmd_list_element **show_list); 00306 00307 extern void add_setshow_optional_filename_cmd (const char *name, 00308 enum command_class class, 00309 char **var, 00310 const char *set_doc, 00311 const char *show_doc, 00312 const char *help_doc, 00313 cmd_sfunc_ftype *set_func, 00314 show_value_ftype *show_func, 00315 struct cmd_list_element **set_list, 00316 struct cmd_list_element **show_list); 00317 00318 extern void add_setshow_integer_cmd (const char *name, 00319 enum command_class class, 00320 int *var, 00321 const char *set_doc, 00322 const char *show_doc, 00323 const char *help_doc, 00324 cmd_sfunc_ftype *set_func, 00325 show_value_ftype *show_func, 00326 struct cmd_list_element **set_list, 00327 struct cmd_list_element **show_list); 00328 00329 extern void add_setshow_uinteger_cmd (const char *name, 00330 enum command_class class, 00331 unsigned int *var, 00332 const char *set_doc, 00333 const char *show_doc, 00334 const char *help_doc, 00335 cmd_sfunc_ftype *set_func, 00336 show_value_ftype *show_func, 00337 struct cmd_list_element **set_list, 00338 struct cmd_list_element **show_list); 00339 00340 extern void add_setshow_zinteger_cmd (const char *name, 00341 enum command_class class, 00342 int *var, 00343 const char *set_doc, 00344 const char *show_doc, 00345 const char *help_doc, 00346 cmd_sfunc_ftype *set_func, 00347 show_value_ftype *show_func, 00348 struct cmd_list_element **set_list, 00349 struct cmd_list_element **show_list); 00350 00351 extern void add_setshow_zuinteger_cmd (const char *name, 00352 enum command_class class, 00353 unsigned int *var, 00354 const char *set_doc, 00355 const char *show_doc, 00356 const char *help_doc, 00357 cmd_sfunc_ftype *set_func, 00358 show_value_ftype *show_func, 00359 struct cmd_list_element **set_list, 00360 struct cmd_list_element **show_list); 00361 00362 extern void 00363 add_setshow_zuinteger_unlimited_cmd (const char *name, 00364 enum command_class class, 00365 int *var, 00366 const char *set_doc, 00367 const char *show_doc, 00368 const char *help_doc, 00369 cmd_sfunc_ftype *set_func, 00370 show_value_ftype *show_func, 00371 struct cmd_list_element **set_list, 00372 struct cmd_list_element **show_list); 00373 00374 /* Do a "show" command for each thing on a command list. */ 00375 00376 extern void cmd_show_list (struct cmd_list_element *, int, char *); 00377 00378 /* Used everywhere whenever at least one parameter is required and 00379 none is specified. */ 00380 00381 extern void error_no_arg (char *) ATTRIBUTE_NORETURN; 00382 00383 extern void dont_repeat (void); 00384 00385 extern struct cleanup *prevent_dont_repeat (void); 00386 00387 /* Used to mark commands that don't do anything. If we just leave the 00388 function field NULL, the command is interpreted as a help topic, or 00389 as a class of commands. */ 00390 00391 extern void not_just_help_class_command (char *, int); 00392 00393 /* Check function pointer. */ 00394 extern int cmd_func_p (struct cmd_list_element *cmd); 00395 00396 /* Call the command function. */ 00397 extern void cmd_func (struct cmd_list_element *cmd, 00398 char *args, int from_tty); 00399 00400 #endif /* !defined (COMMAND_H) */