gdb/cli/cli-decode.h - gdb

Data types defined

Macros defined

Source code

  1. /* Header file for GDB command decoding library.

  2.    Copyright (C) 2000-2015 Free Software Foundation, Inc.

  3.    This program is free software; you can redistribute it and/or modify
  4.    it under the terms of the GNU General Public License as published by
  5.    the Free Software Foundation; either version 3 of the License, or
  6.    (at your option) any later version.

  7.    This program is distributed in the hope that it will be useful,
  8.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.    GNU General Public License for more details.

  11.    You should have received a copy of the GNU General Public License
  12.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  13. #if !defined (CLI_DECODE_H)
  14. #define CLI_DECODE_H 1

  15. /* This file defines the private interfaces for any code implementing
  16.    command internals.  */

  17. /* Include the public interfaces.  */
  18. #include "command.h"

  19. struct re_pattern_buffer;

  20. #if 0
  21. /* FIXME: cagney/2002-03-17: Once cmd_type() has been removed, ``enum
  22.    cmd_types'' can be moved from "command.h" to "cli-decode.h".  */
  23. /* Not a set/show command.  Note that some commands which begin with
  24.    "set" or "show" might be in this category, if their syntax does
  25.    not fall into one of the following categories.  */
  26. typedef enum cmd_types
  27.   {
  28.     not_set_cmd,
  29.     set_cmd,
  30.     show_cmd
  31.   }
  32. cmd_types;
  33. #endif

  34. /* This structure records one command'd definition.  */


  35. struct cmd_list_element
  36.   {
  37.     /* Points to next command in this list.  */
  38.     struct cmd_list_element *next;

  39.     /* Name of this command.  */
  40.     const char *name;

  41.     /* Command class; class values are chosen by application program.  */
  42.     enum command_class class;

  43.     /* When 1 indicated that this command is deprecated.  It may be
  44.        removed from gdb's command set in the future.  */

  45.     unsigned int cmd_deprecated : 1;

  46.     /* The user needs to be warned that this is a deprecated command.
  47.        The user should only be warned the first time a command is
  48.        used.  */

  49.     unsigned int deprecated_warn_user : 1;

  50.     /* When functions are deprecated at compile time (this is the way
  51.        it should, in general, be done) the memory containing the
  52.        replacement string is statically allocated.  In some cases it
  53.        makes sense to deprecate commands at runtime (the testsuite is
  54.        one example).  In this case the memory for replacement is
  55.        malloc'ed.  When a command is undeprecated or re-deprecated at
  56.        runtime we don't want to risk calling free on statically
  57.        allocated memory, so we check this flag.  */

  58.     unsigned int malloced_replacement : 1;

  59.     /* Set if the doc field should be xfree'd.  */

  60.     unsigned int doc_allocated : 1;

  61.     /* Flag that specifies if this command is already running its hook.  */
  62.     /* Prevents the possibility of hook recursion.  */
  63.     unsigned int hook_in : 1;

  64.     /* For prefix commands only:
  65.        nonzero means do not get an error if subcommand is not
  66.        recognized; call the prefix's own function in that case.  */
  67.     unsigned int allow_unknown : 1;

  68.     /* Nonzero says this is an abbreviation, and should not
  69.        be mentioned in lists of commands.
  70.        This allows "br<tab>" to complete to "break", which it
  71.        otherwise wouldn't.  */
  72.     unsigned int abbrev_flag : 1;

  73.     /* Type of "set" or "show" command (or SET_NOT_SET if not "set"
  74.        or "show").  */
  75.     ENUM_BITFIELD (cmd_types) type : 2;

  76.     /* What kind of variable is *VAR?  */
  77.     ENUM_BITFIELD (var_types) var_type : 4;

  78.     /* Function definition of this command.  NULL for command class
  79.        names and for help topics that are not really commands.  NOTE:
  80.        cagney/2002-02-02: This function signature is evolving.  For
  81.        the moment suggest sticking with either set_cmd_cfunc() or
  82.        set_cmd_sfunc().  */
  83.     void (*func) (struct cmd_list_element *c, char *args, int from_tty);
  84.     /* The command's real callback.  At present func() bounces through
  85.        to one of the below.  */
  86.     union
  87.       {
  88.         /* If type is not_set_cmd, call it like this: */
  89.         cmd_cfunc_ftype *cfunc;
  90.         /* If type is set_cmd or show_cmd, first set the variables,
  91.            and then call this: */
  92.         cmd_sfunc_ftype *sfunc;
  93.       }
  94.     function;

  95.     /* Local state (context) for this command.  This can be anything.  */
  96.     void *context;

  97.     /* Documentation of this command (or help topic).
  98.        First line is brief documentation; remaining lines form, with it,
  99.        the full documentation.  First line should end with a period.
  100.        Entire string should also end with a period, not a newline.  */
  101.     const char *doc;

  102.     /* For set/show commands.  A method for printing the output to the
  103.        specified stream.  */
  104.     show_value_ftype *show_value_func;

  105.     /* If this command is deprecated, this is the replacement name.  */
  106.     const char *replacement;

  107.     /* If this command represents a show command, then this function
  108.        is called before the variable's value is examined.  */
  109.     void (*pre_show_hook) (struct cmd_list_element *c);

  110.     /* Hook for another command to be executed before this command.  */
  111.     struct cmd_list_element *hook_pre;

  112.     /* Hook for another command to be executed after this command.  */
  113.     struct cmd_list_element *hook_post;

  114.     /* Nonzero identifies a prefix command.  For them, the address
  115.        of the variable containing the list of subcommands.  */
  116.     struct cmd_list_element **prefixlist;

  117.     /* For prefix commands only:
  118.        String containing prefix commands to get here: this one
  119.        plus any others needed to get to it.  Should end in a space.
  120.        It is used before the word "command" in describing the
  121.        commands reached through this prefix.  */
  122.     const char *prefixname;

  123.     /* The prefix command of this command.  */
  124.     struct cmd_list_element *prefix;

  125.     /* Completion routine for this command.  TEXT is the text beyond
  126.        what was matched for the command itself (leading whitespace is
  127.        skipped).  It stops where we are supposed to stop completing
  128.        (rl_point) and is '\0' terminated.

  129.        Return value is a malloc'd vector of pointers to possible
  130.        completions terminated with NULL.  If there are no completions,
  131.        returning a pointer to a NULL would work but returning NULL
  132.        itself is also valid.  WORD points in the same buffer as TEXT,
  133.        and completions should be returned relative to this position.
  134.        For example, suppose TEXT is "foo" and we want to complete to
  135.        "foobar".  If WORD is "oo", return "oobar"; if WORD is
  136.        "baz/foo", return "baz/foobar".  */
  137.     completer_ftype *completer;

  138.     /* Handle the word break characters for this completer.  Usually
  139.        this function need not be defined, but for some types of
  140.        completers (e.g., Python completers declared as methods inside
  141.        a class) the word break chars may need to be redefined
  142.        depending on the completer type (e.g., for filename
  143.        completers).  */

  144.     completer_ftype_void *completer_handle_brkchars;

  145.     /* Destruction routine for this command.  If non-NULL, this is
  146.        called when this command instance is destroyed.  This may be
  147.        used to finalize the CONTEXT field, if needed.  */
  148.     void (*destroyer) (struct cmd_list_element *self, void *context);

  149.     /* Pointer to variable affected by "set" and "show".  Doesn't
  150.        matter if type is not_set.  */
  151.     void *var;

  152.     /* Pointer to NULL terminated list of enumerated values (like
  153.        argv).  */
  154.     const char *const *enums;

  155.     /* Pointer to command strings of user-defined commands */
  156.     struct command_line *user_commands;

  157.     /* Pointer to command that is hooked by this one, (by hook_pre)
  158.        so the hook can be removed when this one is deleted.  */
  159.     struct cmd_list_element *hookee_pre;

  160.     /* Pointer to command that is hooked by this one, (by hook_post)
  161.        so the hook can be removed when this one is deleted.  */
  162.     struct cmd_list_element *hookee_post;

  163.     /* Pointer to command that is aliased by this one, so the
  164.        aliased command can be located in case it has been hooked.  */
  165.     struct cmd_list_element *cmd_pointer;

  166.     /* Start of a linked list of all aliases of this command.  */
  167.     struct cmd_list_element *aliases;

  168.     /* Link pointer for aliases on an alias list.  */
  169.     struct cmd_list_element *alias_chain;
  170.   };

  171. extern void help_cmd_list (struct cmd_list_element *, enum command_class,
  172.                            const char *, int, struct ui_file *);

  173. /* Functions that implement commands about CLI commands.  */

  174. extern void help_cmd (const char *, struct ui_file *);

  175. extern void apropos_cmd (struct ui_file *, struct cmd_list_element *,
  176.                          struct re_pattern_buffer *, const char *);

  177. /* Used to mark commands that don't do anything.  If we just leave the
  178.    function field NULL, the command is interpreted as a help topic, or
  179.    as a class of commands.  */

  180. extern void not_just_help_class_command (char *arg, int from_tty);

  181. /* Exported to cli/cli-setshow.c */

  182. extern void print_doc_line (struct ui_file *, const char *);

  183. extern const char * const auto_boolean_enums[];

  184. /* Verify whether a given cmd_list_element is a user-defined command.
  185.    Return 1 if it is user-defined.  Return 0 otherwise.  */

  186. extern int cli_user_command_p (struct cmd_list_element *);

  187. #endif /* !defined (CLI_DECODE_H) */