Home | History | Annotate | Line # | Download | only in gdb
command.h revision 1.3
      1  1.1  christos /* Header file for command creation.
      2  1.1  christos 
      3  1.3  christos    Copyright (C) 1986-2015 Free Software Foundation, Inc.
      4  1.1  christos 
      5  1.1  christos    This program is free software; you can redistribute it and/or modify
      6  1.1  christos    it under the terms of the GNU General Public License as published by
      7  1.1  christos    the Free Software Foundation; either version 3 of the License, or
      8  1.1  christos    (at your option) any later version.
      9  1.1  christos 
     10  1.1  christos    This program is distributed in the hope that it will be useful,
     11  1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     12  1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13  1.1  christos    GNU General Public License for more details.
     14  1.1  christos 
     15  1.1  christos    You should have received a copy of the GNU General Public License
     16  1.1  christos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
     17  1.1  christos 
     18  1.1  christos #if !defined (COMMAND_H)
     19  1.1  christos #define COMMAND_H 1
     20  1.1  christos 
     21  1.1  christos #include "gdb_vecs.h"
     22  1.1  christos 
     23  1.1  christos /* This file defines the public interface for any code wanting to
     24  1.1  christos    create commands.  */
     25  1.1  christos 
     26  1.1  christos /* Command classes are top-level categories into which commands are
     27  1.1  christos    broken down for "help" purposes.
     28  1.1  christos 
     29  1.1  christos    Notes on classes: class_alias is for alias commands which are not
     30  1.1  christos    abbreviations of the original command.  class-pseudo is for
     31  1.1  christos    commands which are not really commands nor help topics ("stop").  */
     32  1.1  christos 
     33  1.1  christos enum command_class
     34  1.1  christos {
     35  1.1  christos   /* Special args to help_list */
     36  1.1  christos   class_deprecated = -3, all_classes = -2, all_commands = -1,
     37  1.1  christos   /* Classes of commands */
     38  1.1  christos   no_class = -1, class_run = 0, class_vars, class_stack, class_files,
     39  1.1  christos   class_support, class_info, class_breakpoint, class_trace,
     40  1.1  christos   class_alias, class_bookmark, class_obscure, class_maintenance,
     41  1.1  christos   class_pseudo, class_tui, class_user, class_xdb,
     42  1.1  christos   no_set_class	/* Used for "show" commands that have no corresponding
     43  1.1  christos 		   "set" command.  */
     44  1.1  christos };
     45  1.1  christos 
     46  1.1  christos /* FIXME: cagney/2002-03-17: Once cmd_type() has been removed, ``enum
     47  1.1  christos    cmd_types'' can be moved from "command.h" to "cli-decode.h".  */
     48  1.1  christos /* Not a set/show command.  Note that some commands which begin with
     49  1.1  christos    "set" or "show" might be in this category, if their syntax does
     50  1.1  christos    not fall into one of the following categories.  */
     51  1.1  christos typedef enum cmd_types
     52  1.1  christos   {
     53  1.1  christos     not_set_cmd,
     54  1.1  christos     set_cmd,
     55  1.1  christos     show_cmd
     56  1.1  christos   }
     57  1.1  christos cmd_types;
     58  1.1  christos 
     59  1.1  christos /* Types of "set" or "show" command.  */
     60  1.1  christos typedef enum var_types
     61  1.1  christos   {
     62  1.1  christos     /* "on" or "off".  *VAR is an integer which is nonzero for on,
     63  1.1  christos        zero for off.  */
     64  1.1  christos     var_boolean,
     65  1.1  christos 
     66  1.1  christos     /* "on" / "true" / "enable" or "off" / "false" / "disable" or
     67  1.1  christos        "auto.  *VAR is an ``enum auto_boolean''.  NOTE: In general a
     68  1.1  christos        custom show command will need to be implemented - one that for
     69  1.1  christos        "auto" prints both the "auto" and the current auto-selected
     70  1.1  christos        value.  */
     71  1.1  christos     var_auto_boolean,
     72  1.1  christos 
     73  1.1  christos     /* Unsigned Integer.  *VAR is an unsigned int.  The user can type
     74  1.1  christos        0 to mean "unlimited", which is stored in *VAR as UINT_MAX.  */
     75  1.1  christos     var_uinteger,
     76  1.1  christos 
     77  1.1  christos     /* Like var_uinteger but signed.  *VAR is an int.  The user can
     78  1.1  christos        type 0 to mean "unlimited", which is stored in *VAR as
     79  1.1  christos        INT_MAX.  The only remaining use of it is the Python API.
     80  1.1  christos        Don't use it elsewhere.  */
     81  1.1  christos     var_integer,
     82  1.1  christos 
     83  1.1  christos     /* String which the user enters with escapes (e.g. the user types
     84  1.1  christos        \n and it is a real newline in the stored string).
     85  1.1  christos        *VAR is a malloc'd string, or NULL if the string is empty.  */
     86  1.1  christos     var_string,
     87  1.1  christos     /* String which stores what the user types verbatim.
     88  1.1  christos        *VAR is a malloc'd string, or NULL if the string is empty.  */
     89  1.1  christos     var_string_noescape,
     90  1.1  christos     /* String which stores a filename.  (*VAR) is a malloc'd string,
     91  1.1  christos        or "" if the string was empty.  */
     92  1.1  christos     var_optional_filename,
     93  1.1  christos     /* String which stores a filename.  (*VAR) is a malloc'd
     94  1.1  christos        string.  */
     95  1.1  christos     var_filename,
     96  1.1  christos     /* ZeroableInteger.  *VAR is an int.  Like var_integer except
     97  1.1  christos        that zero really means zero.  */
     98  1.1  christos     var_zinteger,
     99  1.1  christos     /* ZeroableUnsignedInteger.  *VAR is an unsigned int.  Zero really
    100  1.1  christos        means zero.  */
    101  1.1  christos     var_zuinteger,
    102  1.1  christos     /* ZeroableUnsignedInteger with unlimited value.  *VAR is an int,
    103  1.1  christos        but its range is [0, INT_MAX].  -1 stands for unlimited and
    104  1.1  christos        other negative numbers are not allowed.  */
    105  1.1  christos     var_zuinteger_unlimited,
    106  1.1  christos     /* Enumerated type.  Can only have one of the specified values.
    107  1.1  christos        *VAR is a char pointer to the name of the element that we
    108  1.1  christos        find.  */
    109  1.1  christos     var_enum
    110  1.1  christos   }
    111  1.1  christos var_types;
    112  1.1  christos 
    113  1.1  christos /* This structure records one command'd definition.  */
    114  1.1  christos struct cmd_list_element;
    115  1.1  christos 
    116  1.3  christos typedef void cmd_cfunc_ftype (char *args, int from_tty);
    117  1.3  christos 
    118  1.1  christos /* Forward-declarations of the entry-points of cli/cli-decode.c.  */
    119  1.1  christos 
    120  1.1  christos /* API to the manipulation of command lists.  */
    121  1.1  christos 
    122  1.1  christos extern int valid_user_defined_cmd_name_p (const char *name);
    123  1.1  christos 
    124  1.1  christos extern struct cmd_list_element *add_cmd (const char *, enum command_class,
    125  1.3  christos 					 cmd_cfunc_ftype *fun,
    126  1.3  christos 					 const char *,
    127  1.1  christos 					 struct cmd_list_element **);
    128  1.1  christos 
    129  1.1  christos extern struct cmd_list_element *add_alias_cmd (const char *, const char *,
    130  1.1  christos 					       enum command_class, int,
    131  1.1  christos 					       struct cmd_list_element **);
    132  1.1  christos 
    133  1.1  christos extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class,
    134  1.3  christos 						cmd_cfunc_ftype *fun,
    135  1.3  christos 						const char *,
    136  1.1  christos 						struct cmd_list_element **,
    137  1.3  christos 						const char *, int,
    138  1.1  christos 						struct cmd_list_element **);
    139  1.1  christos 
    140  1.1  christos extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
    141  1.1  christos 						       enum command_class,
    142  1.3  christos 						       cmd_cfunc_ftype *fun,
    143  1.3  christos 						       const char *,
    144  1.1  christos 						       struct cmd_list_element
    145  1.3  christos 						       **, const char *, int,
    146  1.1  christos 						       struct cmd_list_element
    147  1.1  christos 						       **);
    148  1.1  christos 
    149  1.1  christos /* Set the commands corresponding callback.  */
    150  1.1  christos 
    151  1.1  christos extern void set_cmd_cfunc (struct cmd_list_element *cmd,
    152  1.1  christos 			   cmd_cfunc_ftype *cfunc);
    153  1.1  christos 
    154  1.1  christos typedef void cmd_sfunc_ftype (char *args, int from_tty,
    155  1.1  christos 			      struct cmd_list_element *c);
    156  1.1  christos extern void set_cmd_sfunc (struct cmd_list_element *cmd,
    157  1.1  christos 			   cmd_sfunc_ftype *sfunc);
    158  1.1  christos 
    159  1.1  christos typedef VEC (char_ptr) *completer_ftype (struct cmd_list_element *,
    160  1.1  christos 					 const char *, const char *);
    161  1.1  christos 
    162  1.3  christos typedef void completer_ftype_void (struct cmd_list_element *,
    163  1.3  christos 				   const char *, const char *);
    164  1.3  christos 
    165  1.1  christos extern void set_cmd_completer (struct cmd_list_element *, completer_ftype *);
    166  1.1  christos 
    167  1.3  christos /* Set the completer_handle_brkchars callback.  */
    168  1.3  christos 
    169  1.3  christos extern void set_cmd_completer_handle_brkchars (struct cmd_list_element *,
    170  1.3  christos 					       completer_ftype_void *);
    171  1.3  christos 
    172  1.1  christos /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
    173  1.1  christos    around in cmd objects to test the value of the commands sfunc().  */
    174  1.1  christos extern int cmd_cfunc_eq (struct cmd_list_element *cmd,
    175  1.3  christos 			 cmd_cfunc_ftype *cfun);
    176  1.1  christos 
    177  1.1  christos /* Each command object has a local context attached to it.  */
    178  1.1  christos extern void set_cmd_context (struct cmd_list_element *cmd,
    179  1.1  christos 			     void *context);
    180  1.1  christos extern void *get_cmd_context (struct cmd_list_element *cmd);
    181  1.1  christos 
    182  1.1  christos 
    183  1.1  christos /* Execute CMD's pre/post hook.  Throw an error if the command fails.
    184  1.1  christos    If already executing this pre/post hook, or there is no pre/post
    185  1.1  christos    hook, the call is silently ignored.  */
    186  1.1  christos extern void execute_cmd_pre_hook (struct cmd_list_element *cmd);
    187  1.1  christos extern void execute_cmd_post_hook (struct cmd_list_element *cmd);
    188  1.1  christos 
    189  1.1  christos /* Return the type of the command.  */
    190  1.1  christos extern enum cmd_types cmd_type (struct cmd_list_element *cmd);
    191  1.1  christos 
    192  1.1  christos /* Flag for an ambiguous cmd_list result.  */
    193  1.1  christos #define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1)
    194  1.1  christos 
    195  1.1  christos extern struct cmd_list_element *lookup_cmd (const char **,
    196  1.1  christos 					    struct cmd_list_element *, char *,
    197  1.1  christos 					    int, int);
    198  1.1  christos 
    199  1.1  christos extern struct cmd_list_element *lookup_cmd_1 (const char **,
    200  1.1  christos 					      struct cmd_list_element *,
    201  1.1  christos 					      struct cmd_list_element **,
    202  1.1  christos 					      int);
    203  1.1  christos 
    204  1.1  christos extern struct cmd_list_element *deprecate_cmd (struct cmd_list_element *,
    205  1.3  christos 					       const char * );
    206  1.1  christos 
    207  1.1  christos extern void deprecated_cmd_warning (const char *);
    208  1.1  christos 
    209  1.1  christos extern int lookup_cmd_composition (const char *text,
    210  1.1  christos 				   struct cmd_list_element **alias,
    211  1.1  christos 				   struct cmd_list_element **prefix_cmd,
    212  1.1  christos 				   struct cmd_list_element **cmd);
    213  1.1  christos 
    214  1.1  christos extern struct cmd_list_element *add_com (const char *, enum command_class,
    215  1.3  christos 					 cmd_cfunc_ftype *fun,
    216  1.3  christos 					 const char *);
    217  1.1  christos 
    218  1.1  christos extern struct cmd_list_element *add_com_alias (const char *, const char *,
    219  1.1  christos 					       enum command_class, int);
    220  1.1  christos 
    221  1.1  christos extern struct cmd_list_element *add_info (const char *,
    222  1.3  christos 					  cmd_cfunc_ftype *fun,
    223  1.3  christos 					  const char *);
    224  1.1  christos 
    225  1.3  christos extern struct cmd_list_element *add_info_alias (const char *, const char *,
    226  1.3  christos 						int);
    227  1.1  christos 
    228  1.1  christos extern VEC (char_ptr) *complete_on_cmdlist (struct cmd_list_element *,
    229  1.1  christos 					    const char *, const char *, int);
    230  1.1  christos 
    231  1.1  christos extern VEC (char_ptr) *complete_on_enum (const char *const *enumlist,
    232  1.1  christos 					 const char *, const char *);
    233  1.1  christos 
    234  1.1  christos /* Functions that implement commands about CLI commands.  */
    235  1.1  christos 
    236  1.3  christos extern void help_list (struct cmd_list_element *, const char *,
    237  1.1  christos 		       enum command_class, struct ui_file *);
    238  1.1  christos 
    239  1.1  christos /* Method for show a set/show variable's VALUE on FILE.  If this
    240  1.1  christos    method isn't supplied deprecated_show_value_hack() is called (which
    241  1.1  christos    is not good).  */
    242  1.1  christos typedef void (show_value_ftype) (struct ui_file *file,
    243  1.1  christos 				 int from_tty,
    244  1.1  christos 				 struct cmd_list_element *cmd,
    245  1.1  christos 				 const char *value);
    246  1.1  christos /* NOTE: i18n: This function is not i18n friendly.  Callers should
    247  1.1  christos    instead print the value out directly.  */
    248  1.1  christos extern show_value_ftype deprecated_show_value_hack;
    249  1.1  christos 
    250  1.1  christos extern void add_setshow_enum_cmd (const char *name,
    251  1.1  christos 				  enum command_class class,
    252  1.1  christos 				  const char *const *enumlist,
    253  1.1  christos 				  const char **var,
    254  1.1  christos 				  const char *set_doc,
    255  1.1  christos 				  const char *show_doc,
    256  1.1  christos 				  const char *help_doc,
    257  1.1  christos 				  cmd_sfunc_ftype *set_func,
    258  1.1  christos 				  show_value_ftype *show_func,
    259  1.1  christos 				  struct cmd_list_element **set_list,
    260  1.1  christos 				  struct cmd_list_element **show_list);
    261  1.1  christos 
    262  1.1  christos extern void add_setshow_auto_boolean_cmd (const char *name,
    263  1.1  christos 					  enum command_class class,
    264  1.1  christos 					  enum auto_boolean *var,
    265  1.1  christos 					  const char *set_doc,
    266  1.1  christos 					  const char *show_doc,
    267  1.1  christos 					  const char *help_doc,
    268  1.1  christos 					  cmd_sfunc_ftype *set_func,
    269  1.1  christos 					  show_value_ftype *show_func,
    270  1.1  christos 					  struct cmd_list_element **set_list,
    271  1.1  christos 					  struct cmd_list_element **show_list);
    272  1.1  christos 
    273  1.1  christos extern void add_setshow_boolean_cmd (const char *name,
    274  1.1  christos 				     enum command_class class,
    275  1.1  christos 				     int *var,
    276  1.1  christos 				     const char *set_doc, const char *show_doc,
    277  1.1  christos 				     const char *help_doc,
    278  1.1  christos 				     cmd_sfunc_ftype *set_func,
    279  1.1  christos 				     show_value_ftype *show_func,
    280  1.1  christos 				     struct cmd_list_element **set_list,
    281  1.1  christos 				     struct cmd_list_element **show_list);
    282  1.1  christos 
    283  1.1  christos extern void add_setshow_filename_cmd (const char *name,
    284  1.1  christos 				      enum command_class class,
    285  1.1  christos 				      char **var,
    286  1.1  christos 				      const char *set_doc,
    287  1.1  christos 				      const char *show_doc,
    288  1.1  christos 				      const char *help_doc,
    289  1.1  christos 				      cmd_sfunc_ftype *set_func,
    290  1.1  christos 				      show_value_ftype *show_func,
    291  1.1  christos 				      struct cmd_list_element **set_list,
    292  1.1  christos 				      struct cmd_list_element **show_list);
    293  1.1  christos 
    294  1.1  christos extern void add_setshow_string_cmd (const char *name,
    295  1.1  christos 				    enum command_class class,
    296  1.1  christos 				    char **var,
    297  1.1  christos 				    const char *set_doc,
    298  1.1  christos 				    const char *show_doc,
    299  1.1  christos 				    const char *help_doc,
    300  1.1  christos 				    cmd_sfunc_ftype *set_func,
    301  1.1  christos 				    show_value_ftype *show_func,
    302  1.1  christos 				    struct cmd_list_element **set_list,
    303  1.1  christos 				    struct cmd_list_element **show_list);
    304  1.1  christos 
    305  1.1  christos extern struct cmd_list_element *add_setshow_string_noescape_cmd
    306  1.1  christos 		      (const char *name,
    307  1.1  christos 		       enum command_class class,
    308  1.1  christos 		       char **var,
    309  1.1  christos 		       const char *set_doc,
    310  1.1  christos 		       const char *show_doc,
    311  1.1  christos 		       const char *help_doc,
    312  1.1  christos 		       cmd_sfunc_ftype *set_func,
    313  1.1  christos 		       show_value_ftype *show_func,
    314  1.1  christos 		       struct cmd_list_element **set_list,
    315  1.1  christos 		       struct cmd_list_element **show_list);
    316  1.1  christos 
    317  1.1  christos extern void add_setshow_optional_filename_cmd (const char *name,
    318  1.1  christos 					       enum command_class class,
    319  1.1  christos 					       char **var,
    320  1.1  christos 					       const char *set_doc,
    321  1.1  christos 					       const char *show_doc,
    322  1.1  christos 					       const char *help_doc,
    323  1.1  christos 					       cmd_sfunc_ftype *set_func,
    324  1.1  christos 					       show_value_ftype *show_func,
    325  1.1  christos 					       struct cmd_list_element **set_list,
    326  1.1  christos 					       struct cmd_list_element **show_list);
    327  1.1  christos 
    328  1.1  christos extern void add_setshow_integer_cmd (const char *name,
    329  1.1  christos 				     enum command_class class,
    330  1.1  christos 				     int *var,
    331  1.1  christos 				     const char *set_doc,
    332  1.1  christos 				     const char *show_doc,
    333  1.1  christos 				     const char *help_doc,
    334  1.1  christos 				     cmd_sfunc_ftype *set_func,
    335  1.1  christos 				     show_value_ftype *show_func,
    336  1.1  christos 				     struct cmd_list_element **set_list,
    337  1.1  christos 				     struct cmd_list_element **show_list);
    338  1.1  christos 
    339  1.1  christos extern void add_setshow_uinteger_cmd (const char *name,
    340  1.1  christos 				      enum command_class class,
    341  1.1  christos 				      unsigned int *var,
    342  1.1  christos 				      const char *set_doc,
    343  1.1  christos 				      const char *show_doc,
    344  1.1  christos 				      const char *help_doc,
    345  1.1  christos 				      cmd_sfunc_ftype *set_func,
    346  1.1  christos 				      show_value_ftype *show_func,
    347  1.1  christos 				      struct cmd_list_element **set_list,
    348  1.1  christos 				      struct cmd_list_element **show_list);
    349  1.1  christos 
    350  1.1  christos extern void add_setshow_zinteger_cmd (const char *name,
    351  1.1  christos 				      enum command_class class,
    352  1.1  christos 				      int *var,
    353  1.1  christos 				      const char *set_doc,
    354  1.1  christos 				      const char *show_doc,
    355  1.1  christos 				      const char *help_doc,
    356  1.1  christos 				      cmd_sfunc_ftype *set_func,
    357  1.1  christos 				      show_value_ftype *show_func,
    358  1.1  christos 				      struct cmd_list_element **set_list,
    359  1.1  christos 				      struct cmd_list_element **show_list);
    360  1.1  christos 
    361  1.1  christos extern void add_setshow_zuinteger_cmd (const char *name,
    362  1.1  christos 				       enum command_class class,
    363  1.1  christos 				       unsigned int *var,
    364  1.1  christos 				       const char *set_doc,
    365  1.1  christos 				       const char *show_doc,
    366  1.1  christos 				       const char *help_doc,
    367  1.1  christos 				       cmd_sfunc_ftype *set_func,
    368  1.1  christos 				       show_value_ftype *show_func,
    369  1.1  christos 				       struct cmd_list_element **set_list,
    370  1.1  christos 				       struct cmd_list_element **show_list);
    371  1.1  christos 
    372  1.1  christos extern void
    373  1.1  christos   add_setshow_zuinteger_unlimited_cmd (const char *name,
    374  1.1  christos 				       enum command_class class,
    375  1.1  christos 				       int *var,
    376  1.1  christos 				       const char *set_doc,
    377  1.1  christos 				       const char *show_doc,
    378  1.1  christos 				       const char *help_doc,
    379  1.1  christos 				       cmd_sfunc_ftype *set_func,
    380  1.1  christos 				       show_value_ftype *show_func,
    381  1.1  christos 				       struct cmd_list_element **set_list,
    382  1.1  christos 				       struct cmd_list_element **show_list);
    383  1.1  christos 
    384  1.1  christos /* Do a "show" command for each thing on a command list.  */
    385  1.1  christos 
    386  1.3  christos extern void cmd_show_list (struct cmd_list_element *, int, const char *);
    387  1.1  christos 
    388  1.1  christos /* Used everywhere whenever at least one parameter is required and
    389  1.1  christos    none is specified.  */
    390  1.1  christos 
    391  1.3  christos extern void error_no_arg (const char *) ATTRIBUTE_NORETURN;
    392  1.1  christos 
    393  1.1  christos extern void dont_repeat (void);
    394  1.1  christos 
    395  1.1  christos extern struct cleanup *prevent_dont_repeat (void);
    396  1.1  christos 
    397  1.1  christos /* Used to mark commands that don't do anything.  If we just leave the
    398  1.1  christos    function field NULL, the command is interpreted as a help topic, or
    399  1.1  christos    as a class of commands.  */
    400  1.1  christos 
    401  1.1  christos extern void not_just_help_class_command (char *, int);
    402  1.1  christos 
    403  1.1  christos /* Check function pointer.  */
    404  1.1  christos extern int cmd_func_p (struct cmd_list_element *cmd);
    405  1.1  christos 
    406  1.1  christos /* Call the command function.  */
    407  1.1  christos extern void cmd_func (struct cmd_list_element *cmd,
    408  1.1  christos 		      char *args, int from_tty);
    409  1.1  christos 
    410  1.1  christos #endif /* !defined (COMMAND_H) */
    411