From: Marco Barisione <mbarisione@undo.io>
To: gdb-patches@sourceware.org
Subject: [PATCH 3/4] gdb: update the docs for add_cmd and do_add_cmd to match reality
Date: Fri, 8 Jan 2021 10:07:05 +0000 [thread overview]
Message-ID: <20210108100706.96190-4-mbarisione@undo.io> (raw)
In-Reply-To: <20210108100706.96190-1-mbarisione@undo.io>
It looks like the docs for add_cmd ended up being the docs for
do_add_cmd. Moreover, they were outdated.
gdb/ChangeLog:
* cli/cli-decode.c (do_add_cmd): Remove outdated documentation
and refer to the documentation for add_cmd.
(add_cmd): Add comment referring to the docs in command.h.
* command.h (add_cmd): Add updated documentation.
---
gdb/cli/cli-decode.c | 22 +++++-----------------
gdb/command.h | 40 +++++++++++++++++++++++++++++++++-------
2 files changed, 38 insertions(+), 24 deletions(-)
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 87785107e3d..a25e3f420b3 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 command.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 command.h. */
+
struct cmd_list_element *
add_cmd (const char *name, enum command_class theclass,
cmd_const_cfunc_ftype *fun,
diff --git a/gdb/command.h b/gdb/command.h
index 827a19637a2..df40cbf7119 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -155,18 +155,44 @@ extern bool valid_user_defined_cmd_name_p (const char *name);
extern bool valid_cmd_char_p (int c);
-/* Const-correct variant of the above. */
+/* Add a command named NAME in command list *LIST.
-extern struct cmd_list_element *add_cmd (const char *, enum command_class,
+ 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 should be the function to execute the command; it will get two
+ arguments, a character string (with leading and trailing blanks already
+ eliminated) containing the command arguments, and an integer indicating
+ whether input comes from a TTY or not.
+
+ 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 struct cmd_list_element *add_cmd (const char *name,
+ enum command_class theclass,
cmd_const_cfunc_ftype *fun,
- const char *,
- struct cmd_list_element **);
+ const char *doc,
+ struct cmd_list_element **list);
/* 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 (const char *name,
+ enum command_class theclass,
+ const char *doc,
+ struct cmd_list_element **list);
extern struct cmd_list_element *add_cmd_suppress_notification
(const char *name, enum command_class theclass,
--
2.28.0
next prev parent reply other threads:[~2021-01-08 10:07 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-08 10:07 [PATCH 0/4] Add support for command renaming Marco Barisione
2021-01-08 10:07 ` [PATCH 1/4] gdb: add lookup_cmd_exact to simplify a common pattern Marco Barisione
2021-01-10 0:06 ` Lancelot SIX
2021-01-17 10:47 ` Marco Barisione
2021-01-17 19:02 ` Lancelot SIX
2021-01-25 11:33 ` Luis Machado
2021-01-08 10:07 ` [PATCH 2/4] gdb: prevent prefix commands from being hooks Marco Barisione
2021-01-08 10:07 ` Marco Barisione [this message]
2021-01-08 10:07 ` [PATCH 4/4] gdb: Add support for renaming commands Marco Barisione
2021-01-08 10:30 ` Eli Zaretskii
2021-01-25 11:26 ` [PATCH v2 0/5] Add support for command renaming Marco Barisione
2021-01-25 11:26 ` [PATCH v2 1/5] gdb: add lookup_cmd_exact to simplify a common pattern Marco Barisione
2021-03-08 18:58 ` Simon Marchi
2021-05-07 14:47 ` Marco Barisione
2021-01-25 11:26 ` [PATCH v2 2/5] gdb: prevent prefix commands from being hooks Marco Barisione
2021-03-08 21:32 ` Simon Marchi
2021-03-09 9:42 ` Marco Barisione
2021-03-16 3:17 ` Simon Marchi
2021-05-07 14:59 ` Marco Barisione
2021-05-07 19:30 ` Simon Marchi
2021-05-07 20:11 ` Marco Barisione
2021-05-14 20:38 ` [PATCH v3 " Marco Barisione
2021-01-25 11:26 ` [PATCH v2 3/5] gdb: update the docs for add_cmd and do_add_cmd to match reality Marco Barisione
2021-03-08 22:52 ` Simon Marchi
2021-03-08 23:10 ` Simon Marchi
2021-05-14 20:39 ` [PATCH v3 3/5] gdb: move declarations and docs for cli-decode.c to cli-decode.h Marco Barisione
2021-01-25 11:26 ` [PATCH v2 4/5] gdb: generate the prefix name for prefix commands on demand Marco Barisione
2021-03-08 23:25 ` Simon Marchi
2021-03-16 17:00 ` Simon Marchi
2021-05-12 11:10 ` Marco Barisione
2021-01-25 11:26 ` [PATCH v2 5/5] gdb: Add support for renaming commands Marco Barisione
2021-03-23 18:45 ` Simon Marchi
2021-05-14 20:41 ` [PATCH v3 5/5] gdb: add " Marco Barisione
2021-02-08 17:53 ` [PING] [PATCH v2 0/5] Add support for command renaming Marco Barisione
2021-02-15 8:27 ` [PING2] " Marco Barisione
2021-02-22 8:28 ` [PING 3] " Marco Barisione
2021-03-01 8:32 ` [PING 4] " Marco Barisione
2021-03-08 9:23 ` [PING 5] " Marco Barisione
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210108100706.96190-4-mbarisione@undo.io \
--to=mbarisione@undo.io \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).