From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id BgFUDjbgnmB1JwAAWB0awg (envelope-from ) for ; Fri, 14 May 2021 16:40:22 -0400 Received: by simark.ca (Postfix, from userid 112) id 32DA81F11C; Fri, 14 May 2021 16:40:22 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 51FEA1E783 for ; Fri, 14 May 2021 16:40:18 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 032673851C04; Fri, 14 May 2021 20:40:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 032673851C04 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1621024818; bh=aj3lKkYfl5IoX4zeiCMlXQydqkvP4AHbWzvnUh3yKFc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=T/mB3Ufr7Nt1y3vXUfLCzEAebMQ5e16K5fv0zB10jDWpe5DBkQIle7N5wkl907SxU FswlRxf9xcup8wh7HDfhYxVlXdkMArm4p/C6sJ15e/v88w8ZwdmQ7GXWqOaJobkw/a yb0RCT6uXG+fzVr7n2D1d+fLsiAakGYMc8Li05T4= Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id 1CA493851C04 for ; Fri, 14 May 2021 20:40:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1CA493851C04 Received: by mail-wr1-x433.google.com with SMTP id r12so460450wrp.1 for ; Fri, 14 May 2021 13:40:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aj3lKkYfl5IoX4zeiCMlXQydqkvP4AHbWzvnUh3yKFc=; b=N/+k+C3Y6vzrw2EkayuizD4W/sQmc2zP29/WXxbQMgB68udJgkkq0mxTLEvLsBuatt i3e8LhQpS102Iqc5N5Jy0guHRcCD6XVZiQHIaHNhd050R7n+ELJweBdHnsDTLqGjKwUb IHF0Um4E5KnRycAM8/R0ytQ4VU+Oez8DB3KoR8Wto8iKFmhoam+QVshlhjj6nfK0YTyj eBhAY0I4vrhtb3nybPn87n0Hd6pLUJBvTQ7xuvIAaMusst2wy3HZ7WkmP3qr2RXEn8Yf FI90jxOrT+4Q5jhaMhP+FL6xN1M4LxrdoRqHWDxhQoS9BAYT0hqIHmCLpNJ3IIqHH28C XZyw== X-Gm-Message-State: AOAM5303gh7m0klCvWG49hmOiPKMBvq6Svrdx+4hgLbuU2o66r65kNAZ ehvDlRH/KLnJZfawhW63sZg+XpPRi0OxLjrU7WkyeP49E4ZkMxYb4de5yDn01vSTGnc0+o/dKyF 26wEeR6VkFDBfouDJrtqdq1ZHIR7iZU0n2+wmo4/eCDF16zTaVJt7AstY1lYJWvcSruml7Z6h1A == X-Google-Smtp-Source: ABdhPJzUmvXMETl8cMiTWQdH/H8NL1fp975H4cGEaYLXfcgMZ/bj+vcqE9J7Ae7Mqcl88dghzsJXqg== X-Received: by 2002:a5d:46c7:: with SMTP id g7mr25849610wrs.394.1621024808481; Fri, 14 May 2021 13:40:08 -0700 (PDT) Received: from focaccia.undoers.io (cpc159317-cmbg20-2-0-cust151.5-4.cable.virginm.net. [81.111.29.152]) by smtp.gmail.com with ESMTPSA id h14sm9122619wrq.45.2021.05.14.13.40.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 May 2021 13:40:07 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH v3 3/5] gdb: move declarations and docs for cli-decode.c to cli-decode.h Date: Fri, 14 May 2021 21:39:55 +0100 Message-Id: <20210514203955.98069-1-mbarisione@undo.io> X-Mailer: git-send-email 2.28.0 In-Reply-To: <46adb353-2e92-ca43-2afd-beaa5b779672@polymtl.ca> References: <46adb353-2e92-ca43-2afd-beaa5b779672@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Marco Barisione via Gdb-patches Reply-To: Marco Barisione Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Declarations and the documentation should be in the header file for the corresponding .c file. This helps keeping command.h cleaner. I also updated the documentation for add_cmd which ended up being docs for the wrong function (do_add_cmd) and quite outdated. gdb/ChangeLog: * command.h (cmd_const_cfunc_ftype): Move declaration to cli/cli-decode.h. (valid_user_defined_cmd_name_p): Ditto. (valid_cmd_char_p): Ditto. (add_alias_cmd): Ditto. (add_prefix_cmd): Ditto. (add_abbrev_prefix_cmd): Ditto. (cmd_const_sfunc_ftype): Ditto. (set_cmd_sfunc): Ditto. (set_cmd_completer): Ditto. (set_cmd_completer_handle_brkchars): Ditto. (cmd_cfunc_eq): Ditto. (set_cmd_context): Ditto. (get_cmd_context): Ditto. (CMD_LIST_AMBIGUOUS): Ditto. (lookup_cmd): Ditto. (lookup_cmd_exact): Ditto. (deprecate_cmd): Ditto. (deprecated_cmd_warning): Ditto. (lookup_cmd_composition): Ditto. (add_com): Ditto. (add_com_alias): Ditto. (add_info): Ditto. (add_info_alias): Ditto. (complete_on_cmdlist): Ditto. (complete_on_enum): Ditto. (help_list): Ditto. (add_setshow_enum_cmd): Ditto. (add_setshow_auto_boolean_cmd): Ditto. (add_setshow_boolean_cmd): Ditto. (add_setshow_filename_cmd): Ditto. (add_setshow_string_cmd): Ditto. (add_setshow_optional_filename_cmd): Ditto. (add_setshow_integer_cmd): Ditto. (add_setshow_uinteger_cmd): Ditto. (add_setshow_zinteger_cmd): Ditto. (add_setshow_zuinteger_cmd): Ditto. (add_setshow_zuinteger_unlimited_cmd): Ditto. (completer_ftype): Move to completer.h. (completer_handle_brkchars_ftype): Ditto. * cli/cli-decode.h (cmd_const_sfunc_ftype): Move declaration from command.h (valid_user_defined_cmd_name_p): Ditto. (valid_cmd_char_p): Ditto. (add_alias_cmd): Ditto. (add_prefix_cmd): Ditto. (add_abbrev_prefix_cmd): Ditto. (set_cmd_sfunc): Ditto. (set_cmd_completer): Ditto. (set_cmd_completer_handle_brkchars): Ditto. (cmd_cfunc_eq): Ditto. (set_cmd_context): Ditto. (get_cmd_context): Ditto. (CMD_LIST_AMBIGUOUS): Ditto. (lookup_cmd): Ditto. (deprecate_cmd): Ditto. (deprecated_cmd_warning): Ditto. (lookup_cmd_composition): Ditto. (add_com): Ditto. (add_com_alias): Ditto. (add_info): Ditto. (add_info_alias): Ditto. (complete_on_cmdlist): Ditto. (complete_on_enum): Ditto. (help_list): Ditto. (add_setshow_enum_cmd): Ditto. (add_setshow_auto_boolean_cmd): Ditto. (add_setshow_filename_cmd): Ditto. (add_setshow_string_cmd): Ditto. (add_setshow_integer_cmd): Ditto. (add_setshow_uinteger_cmd): Ditto. (add_setshow_zinteger_cmd): Ditto. (add_setshow_zuinteger_cmd): Ditto. (add_cmd): Move declaration from command.h and fix documentation. * cli/cli-decode.c (add_cmd): Move documentation to cli/cli-decode.h (add_cmd_suppress_notification): Ditto. (update_prefix_field_of_prefixed_commands): Ditto. (do_prefix_cmd): Ditto. (do_show_prefix_cmd): Ditto. (add_show_prefix_cmd): Ditto. (add_abbrev_prefix_cmd): Ditto. (add_setshow_cmd_full): Ditto. (help_cmd): Ditto. (find_command_name_length): Ditto. (valid_cmd_char_p): Ditto. (valid_user_defined_cmd_name_p): Ditto. (undef_cmd_error): Ditto. (lookup_cmd): Ditto. (lookup_cmd_exact): Ditto. (lookup_cmd_composition_1): Ditto. (lookup_cmd_composition): Ditto. (complete_on_cmdlist): Ditto. (cmd_func_p): Ditto. * (do_add_cmd): Remove outdated documentation and refer to the documentation for add_cmd. * completer.h (completer_ftype): Moved from command.h. (completer_handle_brkchars_ftype): Ditto. * breakpoint.h: Include cli/cli-decode.h. * charset.c: Ditto. * cli/cli-logging.c: Ditto. * cli/cli-style.c: Ditto. * complaints.c: Ditto. * copying.c: Ditto. * cp-abi.c: Ditto. * filesystem.c: Ditto. * gdb-demangle.c: Ditto. * interps.c: Ditto. * macrocmd.c: Ditto. * maint-test-options.c: Ditto. * maint-test-settings.c: Ditto. * observable.c: Ditto. * osabi.c: Ditto. * reggroups.c: Ditto. * ser-unix.c: Ditto. * serial.c: Ditto. * user-regs.c: Ditto. * xml-support.c: Ditto. --- gdb/breakpoint.h | 1 + gdb/charset.c | 1 + gdb/cli/cli-decode.c | 155 +++---------- gdb/cli/cli-decode.h | 473 +++++++++++++++++++++++++++++++++++++- gdb/cli/cli-logging.c | 1 + gdb/cli/cli-style.c | 1 + gdb/command.h | 380 +----------------------------- gdb/complaints.c | 1 + gdb/completer.h | 21 ++ gdb/copying.c | 1 + gdb/cp-abi.c | 1 + gdb/filesystem.c | 1 + gdb/gdb-demangle.c | 1 + gdb/interps.c | 1 + gdb/macrocmd.c | 1 + gdb/maint-test-options.c | 1 + gdb/maint-test-settings.c | 1 + gdb/observable.c | 1 + gdb/osabi.c | 1 + gdb/reggroups.c | 1 + gdb/ser-unix.c | 1 + gdb/serial.c | 1 + gdb/user-regs.c | 1 + gdb/xml-support.c | 1 + 24 files changed, 543 insertions(+), 506 deletions(-) diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 54c5e423e10..15022892d6b 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -30,6 +30,7 @@ #include "gdbsupport/array-view.h" #include "gdbsupport/function-view.h" #include "gdbsupport/refcounted-object.h" +#include "cli/cli-decode.h" #include "cli/cli-script.h" struct block; diff --git a/gdb/charset.c b/gdb/charset.c index 9fb1a1f0b67..6fb3cdfaeb7 100644 --- a/gdb/charset.c +++ b/gdb/charset.c @@ -19,6 +19,7 @@ #include "defs.h" #include "charset.h" +#include "cli/cli-decode.h" #include "gdbcmd.h" #include "gdb_obstack.h" #include "gdbsupport/gdb_wait.h" diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 32edb526c87..f13bbbf60d9 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -160,23 +160,7 @@ set_cmd_completer_handle_brkchars (struct cmd_list_element *cmd, cmd->completer_handle_brkchars = func; } -/* Add element named NAME. - Space for NAME and DOC must be allocated by the caller. - CLASS is the top level category into which commands are broken down - for "help" purposes. - FUN should be the function to execute the command; - it will get a character string as argument, with leading - and trailing blanks already eliminated. - - DOC is a documentation string for the command. - Its first line should be a complete sentence. - It should start with ? for a command that is an abbreviation - or with * for a command that most users don't need to know about. - - Add this command to command list *LIST. - - Returns a pointer to the added command (not necessarily the head - of *LIST). */ +/* Like ADD_CMD, but the command function fields are not modified. */ static struct cmd_list_element * do_add_cmd (const char *name, enum command_class theclass, @@ -227,6 +211,8 @@ do_add_cmd (const char *name, enum command_class theclass, return c; } +/* See cli-decode.h. */ + struct cmd_list_element * add_cmd (const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list) @@ -237,6 +223,8 @@ add_cmd (const char *name, enum command_class theclass, return result; } +/* See cli-decode.h. */ + struct cmd_list_element * add_cmd (const char *name, enum command_class theclass, cmd_const_cfunc_ftype *fun, @@ -247,7 +235,7 @@ add_cmd (const char *name, enum command_class theclass, return result; } -/* Add an element with a suppress notification to the LIST of commands. */ +/* See cli-decode.h. */ struct cmd_list_element * add_cmd_suppress_notification (const char *name, enum command_class theclass, @@ -263,16 +251,7 @@ add_cmd_suppress_notification (const char *name, enum command_class theclass, return element; } - -/* Deprecates a command CMD. - REPLACEMENT is the name of the command which should be used in - place of this command, or NULL if no such command exists. - - This function does not check to see if command REPLACEMENT exists - since gdb may not have gotten around to adding REPLACEMENT when - this function is called. - - Returns a pointer to the deprecated command. */ +/* See cli-decode.h. */ struct cmd_list_element * deprecate_cmd (struct cmd_list_element *cmd, const char *replacement) @@ -372,11 +351,7 @@ update_prefix_field_of_prefixed_commands (struct cmd_list_element *c) } } - -/* Like add_cmd but adds an element for a command prefix: a name that - should be followed by a subcommand to be looked up in another - command list. PREFIXLIST should be the address of the variable - containing that list. */ +/* See cli-decode.h. */ struct cmd_list_element * add_prefix_cmd (const char *name, enum command_class theclass, @@ -410,7 +385,7 @@ do_prefix_cmd (const char *args, int from_tty, struct cmd_list_element *c) all_commands, gdb_stdout); } -/* See command.h. */ +/* See cli-decode.h. */ struct cmd_list_element * add_basic_prefix_cmd (const char *name, enum command_class theclass, @@ -433,7 +408,7 @@ do_show_prefix_cmd (const char *args, int from_tty, struct cmd_list_element *c) cmd_show_list (*c->prefixlist, from_tty); } -/* See command.h. */ +/* See cli-decode.h. */ struct cmd_list_element * add_show_prefix_cmd (const char *name, enum command_class theclass, @@ -447,8 +422,7 @@ add_show_prefix_cmd (const char *name, enum command_class theclass, return cmd; } -/* Like ADD_PREFIX_CMD but sets the suppress_notification pointer on the - new command list element. */ +/* See cli-decode.h. */ struct cmd_list_element * add_prefix_cmd_suppress_notification @@ -465,7 +439,7 @@ add_prefix_cmd_suppress_notification return element; } -/* Like add_prefix_cmd but sets the abbrev_flag on the new command. */ +/* See cli-decode.h. */ struct cmd_list_element * add_abbrev_prefix_cmd (const char *name, enum command_class theclass, @@ -481,7 +455,8 @@ add_abbrev_prefix_cmd (const char *name, enum command_class theclass, return c; } -/* This is an empty "cfunc". */ +/* See cli-decode.h. */ + void not_just_help_class_command (const char *args, int from_tty) { @@ -581,10 +556,7 @@ add_setshow_cmd_full (const char *name, *show_result = show; } -/* Add element named NAME to command list LIST (the list for set or - some sublist thereof). CLASS is as in add_cmd. ENUMLIST is a list - of strings which may follow NAME. VAR is address of the variable - which will contain the matching string (from ENUMLIST). */ +/* See cli-decode.h. */ void add_setshow_enum_cmd (const char *name, @@ -1274,18 +1246,8 @@ help_cmd (const char *command, struct ui_file *stream) 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. - */ +/* See cli-decode.h. */ + void help_list (struct cmd_list_element *list, const char *cmdtype, enum command_class theclass, struct ui_file *stream) @@ -1583,7 +1545,7 @@ find_command_name_length (const char *text) return p - text; } -/* See command.h. */ +/* See cli-decode.h. */ bool valid_cmd_char_p (int c) @@ -1594,7 +1556,7 @@ valid_cmd_char_p (int c) return isalnum (c) || c == '-' || c == '_' || c == '.'; } -/* See command.h. */ +/* See cli-decode.h. */ bool valid_user_defined_cmd_name_p (const char *name) @@ -1615,7 +1577,7 @@ valid_user_defined_cmd_name_p (const char *name) return true; } -/* See command.h. */ +/* See cli-decode.h. */ struct cmd_list_element * lookup_cmd_1 (const char **text, struct cmd_list_element *clist, @@ -1751,24 +1713,7 @@ undef_cmd_error (const char *cmdtype, const char *q) cmdtype); } -/* Look up the contents of *LINE as a command in the command list LIST. - LIST is a chain of struct cmd_list_element's. - If it is found, return the struct cmd_list_element for that command, - update *LINE to point after the command name, at the first argument - and update *DEFAULT_ARGS (if DEFAULT_ARGS is not null) to the default - args to prepend to the user provided args when running the command. - Note that if the found cmd_list_element is found via an alias, - the default args of the alias are returned. - - If not found, call error if ALLOW_UNKNOWN is zero - otherwise (or if error returns) return zero. - Call error if specified command is ambiguous, - unless ALLOW_UNKNOWN is negative. - CMDTYPE precedes the word "command" in the error message. - - If IGNORE_HELP_CLASSES is nonzero, ignore any command list - elements which are actually help classes rather than commands (i.e. - the function field of the struct cmd_list_element is 0). */ +/* See cli-decode.h. */ struct cmd_list_element * lookup_cmd (const char **line, struct cmd_list_element *list, @@ -1872,7 +1817,7 @@ lookup_cmd (const char **line, struct cmd_list_element *list, return 0; } -/* See command.h. */ +/* See cli-decode.h. */ struct cmd_list_element * lookup_cmd_exact (const char *name, @@ -1887,28 +1832,8 @@ lookup_cmd_exact (const char *name, return cmd; } -/* We are here presumably because an alias or command in TEXT is - deprecated and a warning message should be generated. This - function decodes TEXT and potentially generates a warning message - as outlined below. - - Example for 'set endian big' which has a fictitious alias 'seb'. - - If alias wasn't used in TEXT, and the command is deprecated: - "warning: 'set endian big' is deprecated." - - If alias was used, and only the alias is deprecated: - "warning: 'seb' an alias for the command 'set endian big' is deprecated." - - If alias was used and command is deprecated (regardless of whether - the alias itself is deprecated: - - "warning: 'set endian big' (seb) is deprecated." +/* See cli-decode.h. */ - After the message has been sent, clear the appropriate flags in the - command and/or the alias so the user is no longer bothered. - -*/ void deprecated_cmd_warning (const char *text, struct cmd_list_element *list) { @@ -2064,20 +1989,7 @@ lookup_cmd_composition_1 (const char *text, } } -/* Look up the contents of TEXT as a command in the command list 'cmdlist'. - Return 1 on success, 0 on failure. - - If TEXT refers to an alias, *ALIAS will point to that alias. - - If TEXT is a subcommand (i.e. one that is preceded by a prefix - command) set *PREFIX_CMD. - - Set *CMD to point to the command TEXT indicates. - - If any of *ALIAS, *PREFIX_CMD, or *CMD cannot be determined or do not - exist, they are NULL when we return. - -*/ +/* See cli-decode.h. */ int lookup_cmd_composition (const char *text, @@ -2090,13 +2002,7 @@ lookup_cmd_composition (const char *text, /* Helper function for SYMBOL_COMPLETION_FUNCTION. */ -/* Return a vector of char pointers which point to the different - possible completions in LIST of TEXT. - - WORD points in the same buffer as TEXT, and completions should be - returned relative to this position. For example, suppose TEXT is - "foo" and we want to complete to "foobar". If WORD is "oo", return - "oobar"; if WORD is "baz/foo", return "baz/foobar". */ +/* See cli-decode.h. */ void complete_on_cmdlist (struct cmd_list_element *list, @@ -2149,12 +2055,7 @@ complete_on_cmdlist (struct cmd_list_element *list, /* Helper function for SYMBOL_COMPLETION_FUNCTION. */ -/* Add the different possible completions in ENUMLIST of TEXT. - - WORD points in the same buffer as TEXT, and completions should be - returned relative to this position. For example, suppose TEXT is "foo" - and we want to complete to "foobar". If WORD is "oo", return - "oobar"; if WORD is "baz/foo", return "baz/foobar". */ +/* See cli-decode.h. */ void complete_on_enum (completion_tracker &tracker, @@ -2170,16 +2071,16 @@ complete_on_enum (completion_tracker &tracker, tracker.add_completion (make_completion_match_str (name, text, word)); } +/* See cli-decode.h. */ -/* Check function pointer. */ int cmd_func_p (struct cmd_list_element *cmd) { return (cmd->func != NULL); } +/* See cli-decode.h. */ -/* Call the command function. */ void cmd_func (struct cmd_list_element *cmd, const char *args, int from_tty) { diff --git a/gdb/cli/cli-decode.h b/gdb/cli/cli-decode.h index da6013a6cc5..54057a149be 100644 --- a/gdb/cli/cli-decode.h +++ b/gdb/cli/cli-decode.h @@ -37,9 +37,23 @@ enum cmd_types show_cmd }; +struct cmd_list_element; + +typedef void cmd_const_sfunc_ftype (const char *args, int from_tty, + cmd_list_element *c); + +/* A function implementing a command, see add_cmd and related functions. + + ARGS is a string containing the arguments to the command (with leading + and trailing blanks already eliminated). + + FROM_TTY is a flag specifying whether this command was originated from + the user invoking it interactively. */ + +typedef void cmd_const_cfunc_ftype (const char *args, int from_tty); + /* This structure records one command'd definition. */ - struct cmd_list_element { cmd_list_element (const char *name_, enum command_class theclass_, @@ -256,8 +270,349 @@ struct cmd_list_element int *suppress_notification = nullptr; }; +/* API to the manipulation of command lists. */ + +/* Return TRUE if NAME is a valid user-defined command name. + This is a stricter subset of all gdb commands, + see find_command_name_length. */ + +extern bool valid_user_defined_cmd_name_p (const char *name); + +/* Return TRUE if C is a valid command character. */ + +extern bool valid_cmd_char_p (int c); + +/* Add a command named NAME in command list *LIST. + + NAME and DOC are not duplicated. If they are not static string, they + must have been allocated with xmalloc or xstrdup and the + NAME_ALLOCATED/DOC_ALLOCATED fields must be set to 1 on the returned + command. + + THECLASS is the top level category into which commands are broken down + for "help" purposes. + + FUN is the function which implements the command. + + DOC is a documentation string for the command. + Its first line should be a complete sentence. + It should start with ? for a command that is an abbreviation + or with * for a command that most users don't need to know about. + + If NAME already existed in *LIST, all its hooks and aliases are moved + to the new command. + + Return a pointer to the added command (not necessarily the head of + *LIST). */ + +extern cmd_list_element *add_cmd (const char *name, + command_class theclass, + cmd_const_cfunc_ftype *fun, + const char *doc, + cmd_list_element **list); + +/* Like add_cmd, but no command function is specified. */ + +extern cmd_list_element *add_cmd (const char *name, + command_class theclass, + const char *doc, + cmd_list_element **list); + +/* Add an element with a suppress notification to the LIST of commands. */ + +extern cmd_list_element *add_cmd_suppress_notification + (const char *name, command_class theclass, cmd_const_cfunc_ftype *fun, + const char *doc, cmd_list_element **list, int *suppress_notification); + +extern cmd_list_element *add_alias_cmd (const char *name, + const char *oldname, + command_class theclass, + int abbrev_flag, + cmd_list_element **list); + +extern cmd_list_element *add_alias_cmd (const char *name, + cmd_list_element *old, + command_class theclass, + int abbrev_flag, + cmd_list_element **list); + +/* Like add_cmd but adds an element for a command prefix: a name that + should be followed by a subcommand to be looked up in another + command list. PREFIXLIST should be the address of the variable + containing that list. */ + +extern cmd_list_element *add_prefix_cmd (const char *name, + command_class theclass, + cmd_const_cfunc_ftype *fun, + const char *doc, + cmd_list_element **prefixlist, + int allow_unknown, + cmd_list_element **list); + +/* Like add_prefix_cmd, but sets the callback to a function that + simply calls help_list. */ + +extern cmd_list_element *add_basic_prefix_cmd + (const char *name, command_class theclass, const char *doc, + cmd_list_element **prefixlist, int allow_unknown, + cmd_list_element **list); + +/* Like add_prefix_cmd, but useful for "show" prefixes. This sets the + callback to a function that simply calls cmd_show_list. */ + +extern cmd_list_element *add_show_prefix_cmd + (const char *name, command_class theclass, const char *doc, + cmd_list_element **prefixlist, int allow_unknown, + cmd_list_element **list); + +/* Like ADD_PREFIX_CMD but sets the suppress_notification pointer on the + new command list element. */ + +extern cmd_list_element *add_prefix_cmd_suppress_notification + (const char *name, command_class theclass, cmd_const_cfunc_ftype *fun, + const char *doc, cmd_list_element **prefixlist, int allow_unknown, + cmd_list_element **list, int *suppress_notification); + +/* Like add_prefix_cmd but sets the abbrev_flag on the new command. */ + +extern cmd_list_element *add_abbrev_prefix_cmd + (const char *name, command_class theclass, cmd_const_cfunc_ftype *fun, + const char *doc, cmd_list_element **prefixlist, int allow_unknown, + cmd_list_element **list); + +extern void set_cmd_sfunc (cmd_list_element *cmd, + cmd_const_sfunc_ftype *sfunc); + +extern void set_cmd_completer (cmd_list_element *, completer_ftype *); + +/* Set the completer_handle_brkchars callback. */ + +extern void set_cmd_completer_handle_brkchars + (cmd_list_element *, completer_handle_brkchars_ftype *); + +/* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs + around in cmd objects to test the value of the commands sfunc(). */ +extern int cmd_cfunc_eq (cmd_list_element *cmd, + cmd_const_cfunc_ftype *cfun); + +/* Each command object has a local context attached to it. */ + +extern void set_cmd_context (cmd_list_element *cmd, void *context); +extern void *get_cmd_context (cmd_list_element *cmd); + +/* Flag for an ambiguous cmd_list result. */ + +#define CMD_LIST_AMBIGUOUS ((cmd_list_element *) -1) + +/* Look up the contents of *LINE as a command in the command list LIST. + LIST is a chain of struct cmd_list_element's. + If it is found, return the struct cmd_list_element for that command, + update *LINE to point after the command name, at the first argument + and update *DEFAULT_ARGS (if DEFAULT_ARGS is not null) to the default + args to prepend to the user provided args when running the command. + Note that if the found cmd_list_element is found via an alias, + the default args of the alias are returned. + + If not found, call error if ALLOW_UNKNOWN is zero + otherwise (or if error returns) return zero. + Call error if specified command is ambiguous, + unless ALLOW_UNKNOWN is negative. + CMDTYPE precedes the word "command" in the error message. + + If IGNORE_HELP_CLASSES is nonzero, ignore any command list + elements which are actually help classes rather than commands (i.e. + the function field of the struct cmd_list_element is 0). */ + +extern cmd_list_element *lookup_cmd (const char **line, + cmd_list_element *list, + const char *cmdtype, + std::string *default_args, + int allow_unknown, + int ignore_help_classes); + +/* This routine takes a line of TEXT and a CLIST in which to start the + lookup. When it returns it will have incremented the text pointer past + the section of text it matched, set *RESULT_LIST to point to the list in + which the last word was matched, and will return a pointer to the cmd + list element which the text matches. It will return NULL if no match at + all was possible. It will return -1 (cast appropriately, ick) if ambigous + matches are possible; in this case *RESULT_LIST will be set to point to + the list in which there are ambiguous choices (and *TEXT will be set to + the ambiguous text string). + + if DEFAULT_ARGS is not null, *DEFAULT_ARGS is set to the found command + default args (possibly empty). + + If the located command was an abbreviation, this routine returns the base + command of the abbreviation. Note that *DEFAULT_ARGS will contain the + default args defined for the alias. + + It does no error reporting whatsoever; control will always return + to the superior routine. + + In the case of an ambiguous return (-1), *RESULT_LIST will be set to point + at the prefix_command (ie. the best match) *or* (special case) will be NULL + if no prefix command was ever found. For example, in the case of "info a", + "info" matches without ambiguity, but "a" could be "args" or "address", so + *RESULT_LIST is set to the cmd_list_element for "info". So in this case + RESULT_LIST should not be interpreted as a pointer to the beginning of a + list; it simply points to a specific command. In the case of an ambiguous + return *TEXT is advanced past the last non-ambiguous prefix (e.g. + "info t" can be "info types" or "info target"; upon return *TEXT has been + advanced past "info "). + + If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise + affect the operation). + + This routine does *not* modify the text pointed to by TEXT. + + If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which + are actually help classes rather than commands (i.e. the function field of + the struct cmd_list_element is NULL). + + When LOOKUP_FOR_COMPLETION_P is true the completion is being requested + for the completion engine, no warnings should be printed. */ + +extern cmd_list_element *lookup_cmd_1 + (const char **text, cmd_list_element *clist, + cmd_list_element **result_list, std::string *default_args, + int ignore_help_classes, bool lookup_for_completion_p = false); + +/* Look up the command called NAME in the command list LIST. + + Unlike LOOKUP_CMD, partial matches are ignored and only exact matches + on NAME are considered. + + LIST is a chain of struct cmd_list_element's. + + If IGNORE_HELP_CLASSES is true (the default), ignore any command list + elements which are actually help classes rather than commands (i.e. + the function field of the struct cmd_list_element is null). + + If found, return the struct cmd_list_element for that command, + otherwise return NULLPTR. */ + +extern cmd_list_element *lookup_cmd_exact + (const char *name, cmd_list_element *list, + bool ignore_help_classes = true); + +/* Deprecates a command CMD. + REPLACEMENT is the name of the command which should be used in + place of this command, or NULL if no such command exists. + + This function does not check to see if command REPLACEMENT exists + since gdb may not have gotten around to adding REPLACEMENT when + this function is called. + + Returns a pointer to the deprecated command. */ + +extern cmd_list_element *deprecate_cmd (cmd_list_element *cmd, + const char *replacement); + +/* We are here presumably because an alias or command in TEXT is + deprecated and a warning message should be generated. This + function decodes TEXT and potentially generates a warning message + as outlined below. + + Example for 'set endian big' which has a fictitious alias 'seb'. + + If alias wasn't used in TEXT, and the command is deprecated: + "warning: 'set endian big' is deprecated." + + If alias was used, and only the alias is deprecated: + "warning: 'seb' an alias for the command 'set endian big' is deprecated." + + If alias was used and command is deprecated (regardless of whether + the alias itself is deprecated: + + "warning: 'set endian big' (seb) is deprecated." + + After the message has been sent, clear the appropriate flags in the + command and/or the alias so the user is no longer bothered. */ + +extern void deprecated_cmd_warning (const char *text, + cmd_list_element *list); + +/* Look up the contents of TEXT as a command in the command list 'cmdlist'. + Return 1 on success, 0 on failure. + + If TEXT refers to an alias, *ALIAS will point to that alias. + + If TEXT is a subcommand (i.e. one that is preceded by a prefix + command) set *PREFIX_CMD. + + Set *CMD to point to the command TEXT indicates. + + If any of *ALIAS, *PREFIX_CMD, or *CMD cannot be determined or do not + exist, they are NULL when we return. */ + +extern int lookup_cmd_composition (const char *text, + cmd_list_element **alias, + cmd_list_element **prefix_cmd, + cmd_list_element **cmd); + +extern cmd_list_element *add_com (const char *name, + command_class theclass, + cmd_const_cfunc_ftype *fun, + const char *doc); + +extern cmd_list_element *add_com_alias (const char *name, + const char *oldname, + command_class theclass, + int abbrev_flag); + +extern cmd_list_element *add_com_suppress_notification + (const char *name, command_class theclass, cmd_const_cfunc_ftype *fun, + const char *doc, int *supress_notification); + +extern cmd_list_element *add_info (const char *name, + cmd_const_cfunc_ftype *fun, + const char *doc); + +extern cmd_list_element *add_info_alias (const char *name, + const char *oldname, + int abbrev_flag); + +/* Return a vector of char pointers which point to the different + possible completions in LIST of TEXT. + + WORD points in the same buffer as TEXT, and completions should be + returned relative to this position. For example, suppose TEXT is + "foo" and we want to complete to "foobar". If WORD is "oo", return + "oobar"; if WORD is "baz/foo", return "baz/foobar". */ + +extern void complete_on_cmdlist (cmd_list_element *list, + completion_tracker &tracker, + const char *text, const char *word, + int ignore_help_classes); + +/* Add the different possible completions in ENUMLIST of TEXT. + + WORD points in the same buffer as TEXT, and completions should be + returned relative to this position. For example, suppose TEXT is "foo" + and we want to complete to "foobar". If WORD is "oo", return + "oobar"; if WORD is "baz/foo", return "baz/foobar". */ + +extern void complete_on_enum (completion_tracker &tracker, + const char *const *enumlist, + const char *text, const char *word); + /* Functions that implement commands about CLI commands. */ +/* 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. */ + +extern void help_list (cmd_list_element *list, const char *cmdtype, + command_class theclass, ui_file *stream); + extern void help_cmd (const char *, struct ui_file *); extern void apropos_cmd (struct ui_file *, struct cmd_list_element *, @@ -291,4 +646,120 @@ extern int cli_user_command_p (struct cmd_list_element *); extern int find_command_name_length (const char *); +/* Support for adding set and show commands. */ + +/* Add element named NAME to command list LIST (the list for set or + some sublist thereof). CLASS is as in add_cmd. ENUMLIST is a list + of strings which may follow NAME. VAR is address of the variable + which will contain the matching string (from ENUMLIST). */ + +extern void add_setshow_enum_cmd (const char *name, + command_class theclass, + const char *const *enumlist, + const char **var, const char *set_doc, + const char *show_doc, + const char *help_doc, + cmd_const_sfunc_ftype *set_func, + show_value_ftype *show_func, + cmd_list_element **set_list, + cmd_list_element **show_list, + void *context = nullptr); + +extern void add_setshow_auto_boolean_cmd (const char *name, + command_class theclass, + auto_boolean *var, + const char *set_doc, + const char *show_doc, + const char *help_doc, + cmd_const_sfunc_ftype *set_func, + show_value_ftype *show_func, + cmd_list_element **set_list, + cmd_list_element **show_list); + +extern cmd_list_element * add_setshow_boolean_cmd + (const char *name, command_class theclass, bool *var, + const char *set_doc, const char *show_doc, const char *help_doc, + cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, + cmd_list_element **set_list, cmd_list_element **show_list); + +extern void add_setshow_filename_cmd (const char *name, + command_class theclass, char **var, + const char *set_doc, + const char *show_doc, + const char *help_doc, + cmd_const_sfunc_ftype *set_func, + show_value_ftype *show_func, + cmd_list_element **set_list, + cmd_list_element **show_list); + +extern void add_setshow_string_cmd (const char *name, + command_class theclass, char **var, + const char *set_doc, + const char *show_doc, + const char *help_doc, + cmd_const_sfunc_ftype *set_func, + show_value_ftype *show_func, + cmd_list_element **set_list, + cmd_list_element **show_list); + +extern cmd_list_element *add_setshow_string_noescape_cmd + (const char *name, command_class theclass, char **var, + const char *set_doc, const char *show_doc, const char *help_doc, + cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, + cmd_list_element **set_list, cmd_list_element **show_list); + +extern void add_setshow_optional_filename_cmd + (const char *name, command_class theclass, char **var, + const char *set_doc, const char *show_doc, const char *help_doc, + cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, + cmd_list_element **set_list, cmd_list_element **show_list); + +extern void add_setshow_integer_cmd (const char *name, + command_class theclass, int *var, + const char *set_doc, + const char *show_doc, + const char *help_doc, + cmd_const_sfunc_ftype *set_func, + show_value_ftype *show_func, + cmd_list_element **set_list, + cmd_list_element **show_list); + +extern void add_setshow_uinteger_cmd (const char *name, + command_class theclass, + unsigned int *var, + const char *set_doc, + const char *show_doc, + const char *help_doc, + cmd_const_sfunc_ftype *set_func, + show_value_ftype *show_func, + cmd_list_element **set_list, + cmd_list_element **show_list); + +extern void add_setshow_zinteger_cmd (const char *name, + command_class theclass, int *var, + const char *set_doc, + const char *show_doc, + const char *help_doc, + cmd_const_sfunc_ftype *set_func, + show_value_ftype *show_func, + cmd_list_element **set_list, + cmd_list_element **show_list); + +extern void add_setshow_zuinteger_cmd (const char *name, + command_class theclass, + unsigned int *var, + const char *set_doc, + const char *show_doc, + const char *help_doc, + cmd_const_sfunc_ftype *set_func, + show_value_ftype *show_func, + cmd_list_element **set_list, + cmd_list_element **show_list); + +extern void add_setshow_zuinteger_unlimited_cmd + (const char *name, command_class theclass, int *var, + const char *set_doc, const char *show_doc, const char *help_doc, + cmd_const_sfunc_ftype *set_func, show_value_ftype *show_func, + cmd_list_element **set_list, cmd_list_element **show_list); + #endif /* CLI_CLI_DECODE_H */ diff --git a/gdb/cli/cli-logging.c b/gdb/cli/cli-logging.c index dfedd7599a2..44e6d2991af 100644 --- a/gdb/cli/cli-logging.c +++ b/gdb/cli/cli-logging.c @@ -21,6 +21,7 @@ #include "gdbcmd.h" #include "ui-out.h" #include "interps.h" +#include "cli/cli-decode.h" #include "cli/cli-style.h" static char *saved_filename; diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c index 25a1d888f86..4f95d7883d0 100644 --- a/gdb/cli/cli-style.c +++ b/gdb/cli/cli-style.c @@ -19,6 +19,7 @@ #include "defs.h" #include "cli/cli-cmds.h" +#include "cli/cli-decode.h" #include "cli/cli-setshow.h" #include "cli/cli-style.h" #include "source-cache.h" diff --git a/gdb/command.h b/gdb/command.h index 33feb19166c..3e3543927a4 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -128,8 +128,6 @@ var_types; /* This structure records one command'd definition. */ struct cmd_list_element; -typedef void cmd_const_cfunc_ftype (const char *args, int from_tty); - /* This structure specifies notifications to be suppressed by a cli command interpreter. */ @@ -141,252 +139,12 @@ struct cli_suppress_notification extern struct cli_suppress_notification cli_suppress_notification; -/* Forward-declarations of the entry-points of cli/cli-decode.c. */ - -/* API to the manipulation of command lists. */ - -/* Return TRUE if NAME is a valid user-defined command name. - This is a stricter subset of all gdb commands, - see find_command_name_length. */ - -extern bool valid_user_defined_cmd_name_p (const char *name); - -/* Return TRUE if C is a valid command character. */ - -extern bool valid_cmd_char_p (int c); - -/* Const-correct variant of the above. */ - -extern struct cmd_list_element *add_cmd (const char *, enum command_class, - cmd_const_cfunc_ftype *fun, - const char *, - struct cmd_list_element **); - -/* Like add_cmd, but no command function is specified. */ - -extern struct cmd_list_element *add_cmd (const char *, enum command_class, - const char *, - struct cmd_list_element **); - -extern struct cmd_list_element *add_cmd_suppress_notification - (const char *name, enum command_class theclass, - cmd_const_cfunc_ftype *fun, const char *doc, - struct cmd_list_element **list, - int *suppress_notification); - -extern struct cmd_list_element *add_alias_cmd (const char *, const char *, - enum command_class, int, - struct cmd_list_element **); - -extern struct cmd_list_element *add_alias_cmd (const char *, - cmd_list_element *, - enum command_class, int, - struct cmd_list_element **); - - -extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class, - cmd_const_cfunc_ftype *fun, - const char *, - struct cmd_list_element **, - int, - struct cmd_list_element **); - -/* Like add_prefix_cmd, but sets the callback to a function that - simply calls help_list. */ - -extern struct cmd_list_element *add_basic_prefix_cmd - (const char *, enum command_class, const char *, struct cmd_list_element **, - int, struct cmd_list_element **); - -/* Like add_prefix_cmd, but useful for "show" prefixes. This sets the - callback to a function that simply calls cmd_show_list. */ - -extern struct cmd_list_element *add_show_prefix_cmd - (const char *, enum command_class, const char *, struct cmd_list_element **, - int, struct cmd_list_element **); - -extern struct cmd_list_element *add_prefix_cmd_suppress_notification - (const char *name, enum command_class theclass, - cmd_const_cfunc_ftype *fun, - const char *doc, struct cmd_list_element **prefixlist, - int allow_unknown, - struct cmd_list_element **list, - int *suppress_notification); - -extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *, - enum command_class, - cmd_const_cfunc_ftype *fun, - const char *, - struct cmd_list_element - **, int, - struct cmd_list_element - **); - -typedef void cmd_const_sfunc_ftype (const char *args, int from_tty, - struct cmd_list_element *c); -extern void set_cmd_sfunc (struct cmd_list_element *cmd, - cmd_const_sfunc_ftype *sfunc); - -/* A completion routine. Add possible completions to tracker. - - TEXT is the text beyond what was matched for the command itself - (leading whitespace is skipped). It stops where we are supposed to - stop completing (rl_point) and is '\0' terminated. WORD points in - the same buffer as TEXT, and completions should be returned - relative to this position. For example, suppose TEXT is "foo" and - we want to complete to "foobar". If WORD is "oo", return "oobar"; - if WORD is "baz/foo", return "baz/foobar". */ -typedef void completer_ftype (struct cmd_list_element *, - completion_tracker &tracker, - const char *text, const char *word); - -/* Same, but for set_cmd_completer_handle_brkchars. */ -typedef void completer_handle_brkchars_ftype (struct cmd_list_element *, - completion_tracker &tracker, - const char *text, const char *word); - -extern void set_cmd_completer (struct cmd_list_element *, completer_ftype *); - -/* Set the completer_handle_brkchars callback. */ - -extern void set_cmd_completer_handle_brkchars (struct cmd_list_element *, - completer_handle_brkchars_ftype *); - -/* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs - around in cmd objects to test the value of the commands sfunc(). */ -extern int cmd_cfunc_eq (struct cmd_list_element *cmd, - cmd_const_cfunc_ftype *cfun); - -/* Each command object has a local context attached to it. */ -extern void set_cmd_context (struct cmd_list_element *cmd, - void *context); -extern void *get_cmd_context (struct cmd_list_element *cmd); - - /* Execute CMD's pre/post hook. Throw an error if the command fails. If already executing this pre/post hook, or there is no pre/post hook, the call is silently ignored. */ extern void execute_cmd_pre_hook (struct cmd_list_element *cmd); extern void execute_cmd_post_hook (struct cmd_list_element *cmd); -/* Flag for an ambiguous cmd_list result. */ -#define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1) - -extern struct cmd_list_element *lookup_cmd (const char **, - struct cmd_list_element *, - const char *, - std::string *, - int, int); - -/* This routine takes a line of TEXT and a CLIST in which to start the - lookup. When it returns it will have incremented the text pointer past - the section of text it matched, set *RESULT_LIST to point to the list in - which the last word was matched, and will return a pointer to the cmd - list element which the text matches. It will return NULL if no match at - all was possible. It will return -1 (cast appropriately, ick) if ambigous - matches are possible; in this case *RESULT_LIST will be set to point to - the list in which there are ambiguous choices (and *TEXT will be set to - the ambiguous text string). - - if DEFAULT_ARGS is not null, *DEFAULT_ARGS is set to the found command - default args (possibly empty). - - If the located command was an abbreviation, this routine returns the base - command of the abbreviation. Note that *DEFAULT_ARGS will contain the - default args defined for the alias. - - It does no error reporting whatsoever; control will always return - to the superior routine. - - In the case of an ambiguous return (-1), *RESULT_LIST will be set to point - at the prefix_command (ie. the best match) *or* (special case) will be NULL - if no prefix command was ever found. For example, in the case of "info a", - "info" matches without ambiguity, but "a" could be "args" or "address", so - *RESULT_LIST is set to the cmd_list_element for "info". So in this case - RESULT_LIST should not be interpreted as a pointer to the beginning of a - list; it simply points to a specific command. In the case of an ambiguous - return *TEXT is advanced past the last non-ambiguous prefix (e.g. - "info t" can be "info types" or "info target"; upon return *TEXT has been - advanced past "info "). - - If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise - affect the operation). - - This routine does *not* modify the text pointed to by TEXT. - - If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which - are actually help classes rather than commands (i.e. the function field of - the struct cmd_list_element is NULL). - - When LOOKUP_FOR_COMPLETION_P is true the completion is being requested - for the completion engine, no warnings should be printed. */ - -extern struct cmd_list_element *lookup_cmd_1 - (const char **text, struct cmd_list_element *clist, - struct cmd_list_element **result_list, std::string *default_args, - int ignore_help_classes, bool lookup_for_completion_p = false); - -/* Look up the command called NAME in the command list LIST. - - Unlike LOOKUP_CMD, partial matches are ignored and only exact matches - on NAME are considered. - - LIST is a chain of struct cmd_list_element's. - - If IGNORE_HELP_CLASSES is true (the default), ignore any command list - elements which are actually help classes rather than commands (i.e. - the function field of the struct cmd_list_element is null). - - If found, return the struct cmd_list_element for that command, - otherwise return NULLPTR. */ - -extern struct cmd_list_element *lookup_cmd_exact - (const char *name, - struct cmd_list_element *list, - bool ignore_help_classes = true); - -extern struct cmd_list_element *deprecate_cmd (struct cmd_list_element *, - const char * ); - -extern void deprecated_cmd_warning (const char *, struct cmd_list_element *); - -extern int lookup_cmd_composition (const char *text, - struct cmd_list_element **alias, - struct cmd_list_element **prefix_cmd, - struct cmd_list_element **cmd); - -extern struct cmd_list_element *add_com (const char *, enum command_class, - cmd_const_cfunc_ftype *fun, - const char *); - -extern struct cmd_list_element *add_com_alias (const char *, const char *, - enum command_class, int); - -extern struct cmd_list_element *add_com_suppress_notification - (const char *name, enum command_class theclass, - cmd_const_cfunc_ftype *fun, const char *doc, - int *supress_notification); - -extern struct cmd_list_element *add_info (const char *, - cmd_const_cfunc_ftype *fun, - const char *); - -extern struct cmd_list_element *add_info_alias (const char *, const char *, - int); - -extern void complete_on_cmdlist (struct cmd_list_element *, - completion_tracker &tracker, - const char *, const char *, int); - -extern void complete_on_enum (completion_tracker &tracker, - const char *const *enumlist, - const char *, const char *); - -/* Functions that implement commands about CLI commands. */ - -extern void help_list (struct cmd_list_element *, const char *, - enum command_class, struct ui_file *); - /* Method for show a set/show variable's VALUE on FILE. If this method isn't supplied deprecated_show_value_hack() is called (which is not good). */ @@ -398,142 +156,6 @@ typedef void (show_value_ftype) (struct ui_file *file, instead print the value out directly. */ extern show_value_ftype deprecated_show_value_hack; -extern void add_setshow_enum_cmd (const char *name, - enum command_class theclass, - const char *const *enumlist, - const char **var, - const char *set_doc, - const char *show_doc, - const char *help_doc, - cmd_const_sfunc_ftype *set_func, - show_value_ftype *show_func, - struct cmd_list_element **set_list, - struct cmd_list_element **show_list, - void *context = nullptr); - -extern void add_setshow_auto_boolean_cmd (const char *name, - enum command_class theclass, - enum auto_boolean *var, - const char *set_doc, - const char *show_doc, - const char *help_doc, - cmd_const_sfunc_ftype *set_func, - show_value_ftype *show_func, - struct cmd_list_element **set_list, - struct cmd_list_element **show_list); - -extern cmd_list_element * - add_setshow_boolean_cmd (const char *name, - enum command_class theclass, - bool *var, - const char *set_doc, const char *show_doc, - const char *help_doc, - cmd_const_sfunc_ftype *set_func, - show_value_ftype *show_func, - struct cmd_list_element **set_list, - struct cmd_list_element **show_list); - -extern void add_setshow_filename_cmd (const char *name, - enum command_class theclass, - char **var, - const char *set_doc, - const char *show_doc, - const char *help_doc, - cmd_const_sfunc_ftype *set_func, - show_value_ftype *show_func, - struct cmd_list_element **set_list, - struct cmd_list_element **show_list); - -extern void add_setshow_string_cmd (const char *name, - enum command_class theclass, - char **var, - const char *set_doc, - const char *show_doc, - const char *help_doc, - cmd_const_sfunc_ftype *set_func, - show_value_ftype *show_func, - struct cmd_list_element **set_list, - struct cmd_list_element **show_list); - -extern struct cmd_list_element *add_setshow_string_noescape_cmd - (const char *name, - enum command_class theclass, - char **var, - const char *set_doc, - const char *show_doc, - const char *help_doc, - cmd_const_sfunc_ftype *set_func, - show_value_ftype *show_func, - struct cmd_list_element **set_list, - struct cmd_list_element **show_list); - -extern void add_setshow_optional_filename_cmd (const char *name, - enum command_class theclass, - char **var, - const char *set_doc, - const char *show_doc, - const char *help_doc, - cmd_const_sfunc_ftype *set_func, - show_value_ftype *show_func, - struct cmd_list_element **set_list, - struct cmd_list_element **show_list); - -extern void add_setshow_integer_cmd (const char *name, - enum command_class theclass, - int *var, - const char *set_doc, - const char *show_doc, - const char *help_doc, - cmd_const_sfunc_ftype *set_func, - show_value_ftype *show_func, - struct cmd_list_element **set_list, - struct cmd_list_element **show_list); - -extern void add_setshow_uinteger_cmd (const char *name, - enum command_class theclass, - unsigned int *var, - const char *set_doc, - const char *show_doc, - const char *help_doc, - cmd_const_sfunc_ftype *set_func, - show_value_ftype *show_func, - struct cmd_list_element **set_list, - struct cmd_list_element **show_list); - -extern void add_setshow_zinteger_cmd (const char *name, - enum command_class theclass, - int *var, - const char *set_doc, - const char *show_doc, - const char *help_doc, - cmd_const_sfunc_ftype *set_func, - show_value_ftype *show_func, - struct cmd_list_element **set_list, - struct cmd_list_element **show_list); - -extern void add_setshow_zuinteger_cmd (const char *name, - enum command_class theclass, - unsigned int *var, - const char *set_doc, - const char *show_doc, - const char *help_doc, - cmd_const_sfunc_ftype *set_func, - show_value_ftype *show_func, - struct cmd_list_element **set_list, - struct cmd_list_element **show_list); - -extern void - add_setshow_zuinteger_unlimited_cmd (const char *name, - enum command_class theclass, - int *var, - const char *set_doc, - const char *show_doc, - const char *help_doc, - cmd_const_sfunc_ftype *set_func, - show_value_ftype *show_func, - struct cmd_list_element **set_list, - struct cmd_list_element **show_list); - /* Do a "show" command for each thing on a command list. */ extern void cmd_show_list (struct cmd_list_element *, int); @@ -596,9 +218,11 @@ extern void save_command_line (const char *cmd); extern void not_just_help_class_command (const char *, int); /* Check function pointer. */ + extern int cmd_func_p (struct cmd_list_element *cmd); /* Call the command function. */ + extern void cmd_func (struct cmd_list_element *cmd, const char *args, int from_tty); diff --git a/gdb/complaints.c b/gdb/complaints.c index fecbcd74ce5..b36c201ca75 100644 --- a/gdb/complaints.c +++ b/gdb/complaints.c @@ -18,6 +18,7 @@ along with this program. If not, see . */ #include "defs.h" +#include "cli/cli-decode.h" #include "complaints.h" #include "command.h" #include "gdbcmd.h" diff --git a/gdb/completer.h b/gdb/completer.h index 240490f0c05..9aa05bcd26a 100644 --- a/gdb/completer.h +++ b/gdb/completer.h @@ -601,6 +601,27 @@ extern char *gdb_completion_word_break_characters (void); not "const char *". */ extern void set_rl_completer_word_break_characters (const char *break_chars); +/* A completion routine. Add possible completions to tracker. + + TEXT is the text beyond what was matched for the command itself + (leading whitespace is skipped). It stops where we are supposed to + stop completing (rl_point) and is '\0' terminated. WORD points in + the same buffer as TEXT, and completions should be returned + relative to this position. For example, suppose TEXT is "foo" and + we want to complete to "foobar". If WORD is "oo", return "oobar"; + if WORD is "baz/foo", return "baz/foobar". */ + +typedef void completer_ftype (cmd_list_element *, + completion_tracker &tracker, + const char *text, const char *word); + +/* Same, but for set_cmd_completer_handle_brkchars. */ + +typedef void completer_handle_brkchars_ftype (cmd_list_element *, + completion_tracker &tracker, + const char *text, + const char *word); + /* Get the matching completer_handle_brkchars_ftype function for FN. FN is one of the core completer functions above (filename, location, symbol, etc.). This function is useful for cases when diff --git a/gdb/copying.c b/gdb/copying.c index 63183450a0e..2cedc9e410a 100644 --- a/gdb/copying.c +++ b/gdb/copying.c @@ -3,6 +3,7 @@ Modify copying.awk instead. <== */ #include "defs.h" +#include "cli/cli-decode.h" #include "command.h" #include "gdbcmd.h" diff --git a/gdb/cp-abi.c b/gdb/cp-abi.c index f831b2b34b3..2284ea6ca70 100644 --- a/gdb/cp-abi.c +++ b/gdb/cp-abi.c @@ -20,6 +20,7 @@ #include "defs.h" #include "value.h" #include "cp-abi.h" +#include "cli/cli-decode.h" #include "command.h" #include "gdbcmd.h" #include "ui-out.h" diff --git a/gdb/filesystem.c b/gdb/filesystem.c index f28d24fa1b9..ff8a09690d5 100644 --- a/gdb/filesystem.c +++ b/gdb/filesystem.c @@ -19,6 +19,7 @@ #include "defs.h" #include "filesystem.h" +#include "cli/cli-decode.h" #include "gdbarch.h" #include "gdbcmd.h" diff --git a/gdb/gdb-demangle.c b/gdb/gdb-demangle.c index 24e92009d73..9000b2d02c4 100644 --- a/gdb/gdb-demangle.c +++ b/gdb/gdb-demangle.c @@ -24,6 +24,7 @@ to a styles of demangling, and GDB specific. */ #include "defs.h" +#include "cli/cli-decode.h" #include "cli/cli-utils.h" /* for skip_to_space */ #include "command.h" #include "gdbcmd.h" diff --git a/gdb/interps.c b/gdb/interps.c index ec19822b571..918ad28d244 100644 --- a/gdb/interps.c +++ b/gdb/interps.c @@ -30,6 +30,7 @@ them take over the input in their resume proc. */ #include "defs.h" +#include "cli/cli-decode.h" #include "gdbcmd.h" #include "ui-out.h" #include "gdbsupport/event-loop.h" diff --git a/gdb/macrocmd.c b/gdb/macrocmd.c index 4e4a68d5c1d..015df3f5101 100644 --- a/gdb/macrocmd.c +++ b/gdb/macrocmd.c @@ -22,6 +22,7 @@ #include "macrotab.h" #include "macroexp.h" #include "macroscope.h" +#include "cli/cli-decode.h" #include "cli/cli-style.h" #include "cli/cli-utils.h" #include "command.h" diff --git a/gdb/maint-test-options.c b/gdb/maint-test-options.c index b773e759bb7..a16fbe55ddc 100644 --- a/gdb/maint-test-options.c +++ b/gdb/maint-test-options.c @@ -19,6 +19,7 @@ #include "defs.h" #include "gdbcmd.h" +#include "cli/cli-decode.h" #include "cli/cli-option.h" /* This file defines three "maintenance test-options" subcommands to diff --git a/gdb/maint-test-settings.c b/gdb/maint-test-settings.c index 0ce88905518..e4d2889538c 100644 --- a/gdb/maint-test-settings.c +++ b/gdb/maint-test-settings.c @@ -19,6 +19,7 @@ #include "defs.h" +#include "cli/cli-decode.h" #include "gdbcmd.h" /* Command list for "maint set test-settings". */ diff --git a/gdb/observable.c b/gdb/observable.c index 51f5edb0a1f..9d340f23d83 100644 --- a/gdb/observable.c +++ b/gdb/observable.c @@ -19,6 +19,7 @@ #include "defs.h" #include "observable.h" +#include "cli/cli-decode.h" #include "command.h" #include "gdbcmd.h" diff --git a/gdb/osabi.c b/gdb/osabi.c index b1603c09c85..165ae61929f 100644 --- a/gdb/osabi.c +++ b/gdb/osabi.c @@ -21,6 +21,7 @@ #include "osabi.h" #include "arch-utils.h" +#include "cli/cli-decode.h" #include "gdbcmd.h" #include "command.h" #include "gdb_bfd.h" diff --git a/gdb/reggroups.c b/gdb/reggroups.c index 96ff1d3d97d..3a2119aaf47 100644 --- a/gdb/reggroups.c +++ b/gdb/reggroups.c @@ -21,6 +21,7 @@ #include "defs.h" #include "arch-utils.h" +#include "cli/cli-decode.h" #include "reggroups.h" #include "gdbtypes.h" #include "regcache.h" diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c index e97dc2f925d..9abdb70e1d6 100644 --- a/gdb/ser-unix.c +++ b/gdb/ser-unix.c @@ -33,6 +33,7 @@ #include "gdbsupport/filestuff.h" #include #include "inflow.h" +#include "cli/cli-decode.h" struct hardwire_ttystate { diff --git a/gdb/serial.c b/gdb/serial.c index 719cd66c08c..71033a9a35e 100644 --- a/gdb/serial.c +++ b/gdb/serial.c @@ -21,6 +21,7 @@ #include #include "serial.h" #include "gdbcmd.h" +#include "cli/cli-decode.h" #include "cli/cli-utils.h" /* Is serial being debugged? */ diff --git a/gdb/user-regs.c b/gdb/user-regs.c index 5845eb13a5a..1e4b5e95a65 100644 --- a/gdb/user-regs.c +++ b/gdb/user-regs.c @@ -26,6 +26,7 @@ #include "arch-utils.h" #include "command.h" #include "cli/cli-cmds.h" +#include "cli/cli-decode.h" /* A table of user registers. diff --git a/gdb/xml-support.c b/gdb/xml-support.c index 5ba1e53bf92..26c7e5de2eb 100644 --- a/gdb/xml-support.c +++ b/gdb/xml-support.c @@ -21,6 +21,7 @@ #include "gdbcmd.h" #include "xml-builtin.h" #include "xml-support.h" +#include "cli/cli-decode.h" #include "gdbsupport/filestuff.h" #include "safe-ctype.h" #include -- 2.28.0