xref: /dragonfly/contrib/gdb-7/gdb/cli/cli-decode.h (revision ef5ccd6c)
15796c8dcSSimon Schubert /* Header file for GDB command decoding library.
25796c8dcSSimon Schubert 
3*ef5ccd6cSJohn Marino    Copyright (C) 2000-2013 Free Software Foundation, Inc.
45796c8dcSSimon Schubert 
55796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
65796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
75796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
85796c8dcSSimon Schubert    (at your option) any later version.
95796c8dcSSimon Schubert 
105796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
115796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
125796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
135796c8dcSSimon Schubert    GNU General Public License for more details.
145796c8dcSSimon Schubert 
155796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
165796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
175796c8dcSSimon Schubert 
185796c8dcSSimon Schubert #if !defined (CLI_DECODE_H)
195796c8dcSSimon Schubert #define CLI_DECODE_H 1
205796c8dcSSimon Schubert 
21*ef5ccd6cSJohn Marino /* This file defines the private interfaces for any code implementing
22*ef5ccd6cSJohn Marino    command internals.  */
23*ef5ccd6cSJohn Marino 
24*ef5ccd6cSJohn Marino /* Include the public interfaces.  */
255796c8dcSSimon Schubert #include "command.h"
265796c8dcSSimon Schubert 
275796c8dcSSimon Schubert struct re_pattern_buffer;
285796c8dcSSimon Schubert 
295796c8dcSSimon Schubert #if 0
305796c8dcSSimon Schubert /* FIXME: cagney/2002-03-17: Once cmd_type() has been removed, ``enum
315796c8dcSSimon Schubert    cmd_types'' can be moved from "command.h" to "cli-decode.h".  */
325796c8dcSSimon Schubert /* Not a set/show command.  Note that some commands which begin with
335796c8dcSSimon Schubert    "set" or "show" might be in this category, if their syntax does
345796c8dcSSimon Schubert    not fall into one of the following categories.  */
355796c8dcSSimon Schubert typedef enum cmd_types
365796c8dcSSimon Schubert   {
375796c8dcSSimon Schubert     not_set_cmd,
385796c8dcSSimon Schubert     set_cmd,
395796c8dcSSimon Schubert     show_cmd
405796c8dcSSimon Schubert   }
415796c8dcSSimon Schubert cmd_types;
425796c8dcSSimon Schubert #endif
435796c8dcSSimon Schubert 
445796c8dcSSimon Schubert /* This structure records one command'd definition.  */
455796c8dcSSimon Schubert 
465796c8dcSSimon Schubert 
475796c8dcSSimon Schubert /* This flag is used by the code executing commands to warn the user
48c50c785cSJohn Marino    the first time a deprecated command is used, see the 'flags' field
49c50c785cSJohn Marino    in the following struct.
505796c8dcSSimon Schubert */
515796c8dcSSimon Schubert #define CMD_DEPRECATED            0x1
525796c8dcSSimon Schubert #define DEPRECATED_WARN_USER      0x2
535796c8dcSSimon Schubert #define MALLOCED_REPLACEMENT      0x4
54*ef5ccd6cSJohn Marino #define DOC_ALLOCATED             0x8
555796c8dcSSimon Schubert 
565796c8dcSSimon Schubert struct cmd_list_element
575796c8dcSSimon Schubert   {
585796c8dcSSimon Schubert     /* Points to next command in this list.  */
595796c8dcSSimon Schubert     struct cmd_list_element *next;
605796c8dcSSimon Schubert 
615796c8dcSSimon Schubert     /* Name of this command.  */
625796c8dcSSimon Schubert     char *name;
635796c8dcSSimon Schubert 
645796c8dcSSimon Schubert     /* Command class; class values are chosen by application program.  */
655796c8dcSSimon Schubert     enum command_class class;
665796c8dcSSimon Schubert 
675796c8dcSSimon Schubert     /* Function definition of this command.  NULL for command class
685796c8dcSSimon Schubert        names and for help topics that are not really commands.  NOTE:
695796c8dcSSimon Schubert        cagney/2002-02-02: This function signature is evolving.  For
705796c8dcSSimon Schubert        the moment suggest sticking with either set_cmd_cfunc() or
715796c8dcSSimon Schubert        set_cmd_sfunc().  */
725796c8dcSSimon Schubert     void (*func) (struct cmd_list_element *c, char *args, int from_tty);
735796c8dcSSimon Schubert     /* The command's real callback.  At present func() bounces through
745796c8dcSSimon Schubert        to one of the below.  */
755796c8dcSSimon Schubert     union
765796c8dcSSimon Schubert       {
775796c8dcSSimon Schubert 	/* If type is not_set_cmd, call it like this: */
785796c8dcSSimon Schubert 	cmd_cfunc_ftype *cfunc;
795796c8dcSSimon Schubert 	/* If type is set_cmd or show_cmd, first set the variables,
805796c8dcSSimon Schubert 	   and then call this: */
815796c8dcSSimon Schubert 	cmd_sfunc_ftype *sfunc;
825796c8dcSSimon Schubert       }
835796c8dcSSimon Schubert     function;
845796c8dcSSimon Schubert 
855796c8dcSSimon Schubert     /* Local state (context) for this command.  This can be anything.  */
865796c8dcSSimon Schubert     void *context;
875796c8dcSSimon Schubert 
885796c8dcSSimon Schubert     /* Documentation of this command (or help topic).
895796c8dcSSimon Schubert        First line is brief documentation; remaining lines form, with it,
905796c8dcSSimon Schubert        the full documentation.  First line should end with a period.
915796c8dcSSimon Schubert        Entire string should also end with a period, not a newline.  */
925796c8dcSSimon Schubert     char *doc;
935796c8dcSSimon Schubert 
945796c8dcSSimon Schubert     /* For set/show commands.  A method for printing the output to the
955796c8dcSSimon Schubert        specified stream.  */
965796c8dcSSimon Schubert     show_value_ftype *show_value_func;
975796c8dcSSimon Schubert 
985796c8dcSSimon Schubert     /* flags : a bitfield
995796c8dcSSimon Schubert 
1005796c8dcSSimon Schubert        bit 0: (LSB) CMD_DEPRECATED, when 1 indicated that this command
1015796c8dcSSimon Schubert        is deprecated.  It may be removed from gdb's command set in the
1025796c8dcSSimon Schubert        future.
1035796c8dcSSimon Schubert 
1045796c8dcSSimon Schubert        bit 1: DEPRECATED_WARN_USER, the user needs to be warned that
1055796c8dcSSimon Schubert        this is a deprecated command.  The user should only be warned
1065796c8dcSSimon Schubert        the first time a command is used.
1075796c8dcSSimon Schubert 
1085796c8dcSSimon Schubert        bit 2: MALLOCED_REPLACEMENT, when functions are deprecated at
1095796c8dcSSimon Schubert        compile time (this is the way it should, in general, be done)
1105796c8dcSSimon Schubert        the memory containing the replacement string is statically
1115796c8dcSSimon Schubert        allocated.  In some cases it makes sense to deprecate commands
1125796c8dcSSimon Schubert        at runtime (the testsuite is one example).  In this case the
1135796c8dcSSimon Schubert        memory for replacement is malloc'ed.  When a command is
1145796c8dcSSimon Schubert        undeprecated or re-deprecated at runtime we don't want to risk
1155796c8dcSSimon Schubert        calling free on statically allocated memory, so we check this
116*ef5ccd6cSJohn Marino        flag.
117*ef5ccd6cSJohn Marino 
118*ef5ccd6cSJohn Marino        bit 3: DOC_ALLOCATED, set if the doc field should be xfree'd.  */
119c50c785cSJohn Marino 
1205796c8dcSSimon Schubert     int flags;
1215796c8dcSSimon Schubert 
1225796c8dcSSimon Schubert     /* If this command is deprecated, this is the replacement name.  */
1235796c8dcSSimon Schubert     char *replacement;
1245796c8dcSSimon Schubert 
1255796c8dcSSimon Schubert     /* If this command represents a show command, then this function
1265796c8dcSSimon Schubert        is called before the variable's value is examined.  */
1275796c8dcSSimon Schubert     void (*pre_show_hook) (struct cmd_list_element *c);
1285796c8dcSSimon Schubert 
1295796c8dcSSimon Schubert     /* Hook for another command to be executed before this command.  */
1305796c8dcSSimon Schubert     struct cmd_list_element *hook_pre;
1315796c8dcSSimon Schubert 
1325796c8dcSSimon Schubert     /* Hook for another command to be executed after this command.  */
1335796c8dcSSimon Schubert     struct cmd_list_element *hook_post;
1345796c8dcSSimon Schubert 
1355796c8dcSSimon Schubert     /* Flag that specifies if this command is already running its hook.  */
1365796c8dcSSimon Schubert     /* Prevents the possibility of hook recursion.  */
1375796c8dcSSimon Schubert     int hook_in;
1385796c8dcSSimon Schubert 
1395796c8dcSSimon Schubert     /* Nonzero identifies a prefix command.  For them, the address
1405796c8dcSSimon Schubert        of the variable containing the list of subcommands.  */
1415796c8dcSSimon Schubert     struct cmd_list_element **prefixlist;
1425796c8dcSSimon Schubert 
1435796c8dcSSimon Schubert     /* For prefix commands only:
1445796c8dcSSimon Schubert        String containing prefix commands to get here: this one
1455796c8dcSSimon Schubert        plus any others needed to get to it.  Should end in a space.
1465796c8dcSSimon Schubert        It is used before the word "command" in describing the
1475796c8dcSSimon Schubert        commands reached through this prefix.  */
1485796c8dcSSimon Schubert     char *prefixname;
1495796c8dcSSimon Schubert 
1505796c8dcSSimon Schubert     /* For prefix commands only:
1515796c8dcSSimon Schubert        nonzero means do not get an error if subcommand is not
1525796c8dcSSimon Schubert        recognized; call the prefix's own function in that case.  */
1535796c8dcSSimon Schubert     char allow_unknown;
1545796c8dcSSimon Schubert 
155*ef5ccd6cSJohn Marino     /* The prefix command of this command.  */
156*ef5ccd6cSJohn Marino     struct cmd_list_element *prefix;
157*ef5ccd6cSJohn Marino 
1585796c8dcSSimon Schubert     /* Nonzero says this is an abbreviation, and should not
1595796c8dcSSimon Schubert        be mentioned in lists of commands.
1605796c8dcSSimon Schubert        This allows "br<tab>" to complete to "break", which it
1615796c8dcSSimon Schubert        otherwise wouldn't.  */
1625796c8dcSSimon Schubert     char abbrev_flag;
1635796c8dcSSimon Schubert 
1645796c8dcSSimon Schubert     /* Completion routine for this command.  TEXT is the text beyond
1655796c8dcSSimon Schubert        what was matched for the command itself (leading whitespace is
1665796c8dcSSimon Schubert        skipped).  It stops where we are supposed to stop completing
1675796c8dcSSimon Schubert        (rl_point) and is '\0' terminated.
1685796c8dcSSimon Schubert 
169c50c785cSJohn Marino        Return value is a malloc'd vector of pointers to possible
170c50c785cSJohn Marino        completions terminated with NULL.  If there are no completions,
171c50c785cSJohn Marino        returning a pointer to a NULL would work but returning NULL
172c50c785cSJohn Marino        itself is also valid.  WORD points in the same buffer as TEXT,
173c50c785cSJohn Marino        and completions should be returned relative to this position.
174c50c785cSJohn Marino        For example, suppose TEXT is "foo" and we want to complete to
175c50c785cSJohn Marino        "foobar".  If WORD is "oo", return "oobar"; if WORD is
176c50c785cSJohn Marino        "baz/foo", return "baz/foobar".  */
177*ef5ccd6cSJohn Marino     completer_ftype *completer;
1785796c8dcSSimon Schubert 
1795796c8dcSSimon Schubert     /* Destruction routine for this command.  If non-NULL, this is
1805796c8dcSSimon Schubert        called when this command instance is destroyed.  This may be
1815796c8dcSSimon Schubert        used to finalize the CONTEXT field, if needed.  */
1825796c8dcSSimon Schubert     void (*destroyer) (struct cmd_list_element *self, void *context);
1835796c8dcSSimon Schubert 
1845796c8dcSSimon Schubert     /* Type of "set" or "show" command (or SET_NOT_SET if not "set"
1855796c8dcSSimon Schubert        or "show").  */
1865796c8dcSSimon Schubert     cmd_types type;
1875796c8dcSSimon Schubert 
188c50c785cSJohn Marino     /* Pointer to variable affected by "set" and "show".  Doesn't
189c50c785cSJohn Marino        matter if type is not_set.  */
1905796c8dcSSimon Schubert     void *var;
1915796c8dcSSimon Schubert 
1925796c8dcSSimon Schubert     /* What kind of variable is *VAR?  */
1935796c8dcSSimon Schubert     var_types var_type;
1945796c8dcSSimon Schubert 
195c50c785cSJohn Marino     /* Pointer to NULL terminated list of enumerated values (like
196c50c785cSJohn Marino        argv).  */
197*ef5ccd6cSJohn Marino     const char *const *enums;
1985796c8dcSSimon Schubert 
1995796c8dcSSimon Schubert     /* Pointer to command strings of user-defined commands */
2005796c8dcSSimon Schubert     struct command_line *user_commands;
2015796c8dcSSimon Schubert 
2025796c8dcSSimon Schubert     /* Pointer to command that is hooked by this one, (by hook_pre)
2035796c8dcSSimon Schubert        so the hook can be removed when this one is deleted.  */
2045796c8dcSSimon Schubert     struct cmd_list_element *hookee_pre;
2055796c8dcSSimon Schubert 
2065796c8dcSSimon Schubert     /* Pointer to command that is hooked by this one, (by hook_post)
2075796c8dcSSimon Schubert        so the hook can be removed when this one is deleted.  */
2085796c8dcSSimon Schubert     struct cmd_list_element *hookee_post;
2095796c8dcSSimon Schubert 
2105796c8dcSSimon Schubert     /* Pointer to command that is aliased by this one, so the
2115796c8dcSSimon Schubert        aliased command can be located in case it has been hooked.  */
2125796c8dcSSimon Schubert     struct cmd_list_element *cmd_pointer;
2135796c8dcSSimon Schubert 
2145796c8dcSSimon Schubert     /* Start of a linked list of all aliases of this command.  */
2155796c8dcSSimon Schubert     struct cmd_list_element *aliases;
2165796c8dcSSimon Schubert 
2175796c8dcSSimon Schubert     /* Link pointer for aliases on an alias list.  */
2185796c8dcSSimon Schubert     struct cmd_list_element *alias_chain;
2195796c8dcSSimon Schubert   };
2205796c8dcSSimon Schubert 
2215796c8dcSSimon Schubert extern void help_cmd_list (struct cmd_list_element *, enum command_class,
2225796c8dcSSimon Schubert 			   char *, int, struct ui_file *);
2235796c8dcSSimon Schubert 
2245796c8dcSSimon Schubert /* Functions that implement commands about CLI commands.  */
2255796c8dcSSimon Schubert 
2265796c8dcSSimon Schubert extern void help_cmd (char *, struct ui_file *);
2275796c8dcSSimon Schubert 
2285796c8dcSSimon Schubert extern void apropos_cmd (struct ui_file *, struct cmd_list_element *,
2295796c8dcSSimon Schubert                          struct re_pattern_buffer *, char *);
2305796c8dcSSimon Schubert 
2315796c8dcSSimon Schubert /* Used to mark commands that don't do anything.  If we just leave the
2325796c8dcSSimon Schubert    function field NULL, the command is interpreted as a help topic, or
2335796c8dcSSimon Schubert    as a class of commands.  */
2345796c8dcSSimon Schubert 
2355796c8dcSSimon Schubert extern void not_just_help_class_command (char *arg, int from_tty);
2365796c8dcSSimon Schubert 
2375796c8dcSSimon Schubert /* Exported to cli/cli-setshow.c */
2385796c8dcSSimon Schubert 
2395796c8dcSSimon Schubert extern void print_doc_line (struct ui_file *, char *);
2405796c8dcSSimon Schubert 
241*ef5ccd6cSJohn Marino extern const char * const auto_boolean_enums[];
2425796c8dcSSimon Schubert 
2435796c8dcSSimon Schubert #endif /* !defined (CLI_DECODE_H) */
244