From: Simon Marchi <simon.marchi@polymtl.ca>
To: Yao Qi <qiyaoltc@gmail.com>
Cc: gdb-patches@sourceware.org, simon.marchi@ericsson.com
Subject: Re: [PATCH master/8.0] Add alias command to cmd_list_element
Date: Wed, 17 May 2017 12:16:00 -0000 [thread overview]
Message-ID: <0d03dc5b2bba05ef0a4e50b087b22f92@polymtl.ca> (raw)
In-Reply-To: <1495020697-13892-1-git-send-email-yao.qi@linaro.org>
On 2017-05-17 07:31, Yao Qi wrote:
> When we add alias command, we call add_alias_cmd and pass the alias
> name
> and command name. This implicitly requires the command and its prefix
> commands are already added to cmdlist. This may not be true, for
> example,
>
> add_com_alias ("tty", "set inferior-tty", class_alias, 0);
>
> "inferior-tty" command is added to setlist, but setlist may not be
> added
> to cmdlist (It depends on the order of related _initialize_XXX
> functions
> called) so that we can't find "set inferior-tty" from cmdlist.
>
> This patch fixes this problem by pass cmd_list_element of
> "inferior-tty"
"by passing"
> to add_alias_cmd, so that cmd_list_element of "inferior-tty" doesn't
> have
> to be reachable from cmdlist at that moment.
>
> Regression tested on x86_64-linux.
>
> gdb:
>
> 2017-05-17 Yao Qi <yao.qi@linaro.org>
>
> * cli/cli-decode.c (add_alias_cmd): New function.
> * command.h (add_alias_cmd): Declare.
> * infcmd.c (_initialize_infcmd): Don't call add_com_alias,
> instead call add_alias_cmd.
>
> gdb/testsuite:
>
> 2017-05-17 Simon Marchi <simon.marchi@ericsson.com>
>
> * gdb.base/set-inferior-tty.exp (test_set_inferior_tty): Add
> argument command.
> (top-level): Invoke test_set_inferior_tty.
> ---
> gdb/cli/cli-decode.c | 30
> +++++++++++++++++++----------
> gdb/command.h | 6 ++++++
> gdb/infcmd.c | 5 ++++-
> gdb/testsuite/gdb.base/set-inferior-tty.exp | 10 ++++++----
> 4 files changed, 36 insertions(+), 15 deletions(-)
>
> diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
> index d45733e..e1d257a 100644
> --- a/gdb/cli/cli-decode.c
> +++ b/gdb/cli/cli-decode.c
> @@ -284,16 +284,10 @@ deprecate_cmd (struct cmd_list_element *cmd,
> const char *replacement)
> }
>
> struct cmd_list_element *
> -add_alias_cmd (const char *name, const char *oldname, enum
> command_class theclass,
> - int abbrev_flag, struct cmd_list_element **list)
> +add_alias_cmd (const char *name, cmd_list_element *old,
> + enum command_class theclass, int abbrev_flag,
> + struct cmd_list_element **list)
> {
> - const char *tmp;
> - struct cmd_list_element *old;
> - struct cmd_list_element *c;
> -
> - tmp = oldname;
> - old = lookup_cmd (&tmp, *list, "", 1, 1);
> -
> if (old == 0)
> {
> struct cmd_list_element *prehook, *prehookee, *posthook,
> *posthookee;
> @@ -307,7 +301,7 @@ add_alias_cmd (const char *name, const char
> *oldname, enum command_class theclas
> return 0;
> }
>
> - c = add_cmd (name, theclass, NULL, old->doc, list);
> + struct cmd_list_element *c = add_cmd (name, theclass, NULL,
> old->doc, list);
>
> /* If OLD->DOC can be freed, we should make another copy. */
> if (old->doc_allocated)
> @@ -330,6 +324,22 @@ add_alias_cmd (const char *name, const char
> *oldname, enum command_class theclas
> return c;
> }
>
> +struct cmd_list_element *
> +add_alias_cmd (const char *name, const char *oldname,
> + enum command_class theclass, int abbrev_flag,
> + struct cmd_list_element **list)
> +{
> + const char *tmp;
> + struct cmd_list_element *old;
> + struct cmd_list_element *c;
c is now unused.
Otherwise, LGTM. Thanks!
Simon
next prev parent reply other threads:[~2017-05-17 12:16 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-04 19:44 GDB 7.99.91 available for testing Joel Brobecker
2017-05-08 14:53 ` Eli Zaretskii
2017-05-17 11:36 ` Yao Qi
2017-05-17 14:39 ` Eli Zaretskii
2017-05-08 15:00 ` GDB 7.99.91 MinGW compilation error in cli-script.c Eli Zaretskii
2017-05-14 3:19 ` Simon Marchi
2017-05-14 14:13 ` Eli Zaretskii
2017-05-17 14:31 ` Joel Brobecker
2017-05-17 16:01 ` Eli Zaretskii
2017-05-19 9:10 ` Eli Zaretskii
2017-05-19 9:49 ` Pedro Alves
2017-05-19 11:17 ` Eli Zaretskii
2017-05-19 11:23 ` Pedro Alves
2017-05-21 15:33 ` Eli Zaretskii
2017-05-22 15:26 ` Pedro Alves
2017-05-22 18:43 ` Eli Zaretskii
2017-05-23 9:53 ` Pedro Alves
2017-05-24 2:44 ` Eli Zaretskii
2017-05-25 10:05 ` Pedro Alves
2017-05-26 7:57 ` Eli Zaretskii
2017-05-26 11:52 ` Pedro Alves
2017-05-26 12:57 ` Eli Zaretskii
2017-05-26 13:58 ` Pedro Alves
2017-05-24 18:28 ` Eli Zaretskii
2017-05-24 19:37 ` Joel Brobecker
2017-05-25 10:12 ` Pedro Alves
2017-05-26 7:47 ` Eli Zaretskii
2017-05-26 10:54 ` Pedro Alves
2017-05-26 13:03 ` Eli Zaretskii
2017-05-26 14:10 ` Pedro Alves
2017-05-26 14:35 ` Eli Zaretskii
2017-05-26 14:45 ` Pedro Alves
2017-05-08 15:02 ` GDB 7.99.91 MinGW compilation warning in tui.c Eli Zaretskii
2017-05-09 10:17 ` Yao Qi
2017-05-13 8:12 ` Eli Zaretskii
2017-05-17 16:26 ` Yao Qi
2017-05-17 16:45 ` Eli Zaretskii
2017-05-17 18:21 ` Joel Brobecker
2017-05-19 8:02 ` Eli Zaretskii
2017-05-19 9:54 ` Pedro Alves
2017-05-19 11:14 ` Eli Zaretskii
2017-05-19 11:25 ` Pedro Alves
2017-05-19 12:51 ` Eli Zaretskii
2017-05-19 13:58 ` Pedro Alves
2017-05-19 14:40 ` Eli Zaretskii
2017-05-19 17:50 ` DJ Delorie
2017-05-19 17:55 ` Eli Zaretskii
2017-05-15 21:11 ` GDB 7.99.91 available for testing Simon Marchi
2017-05-16 13:51 ` Simon Marchi
2017-05-16 20:50 ` Yao Qi
2017-05-16 21:22 ` Simon Marchi
2017-05-16 21:40 ` Yao Qi
2017-05-17 11:31 ` [PATCH master/8.0] Add alias command to cmd_list_element Yao Qi
2017-05-17 12:16 ` Simon Marchi [this message]
2017-05-17 13:36 ` Yao Qi
2017-05-16 14:28 ` GDB 7.99.91 available for testing Joel Brobecker
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=0d03dc5b2bba05ef0a4e50b087b22f92@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=qiyaoltc@gmail.com \
--cc=simon.marchi@ericsson.com \
/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