From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 73563 invoked by alias); 17 May 2017 12:16:33 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 73462 invoked by uid 89); 17 May 2017 12:16:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=HX-PHP-Originating-Script:rcube.php, H*u:1.2.5, H*UA:1.2.5, Hx-languages-length:3158 X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 17 May 2017 12:16:27 +0000 Received: by simark.ca (Postfix, from userid 33) id D3FAA1E4A4; Wed, 17 May 2017 08:16:28 -0400 (EDT) To: Yao Qi Subject: Re: [PATCH master/8.0] Add alias command to cmd_list_element X-PHP-Originating-Script: 33:rcube.php MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 17 May 2017 12:16:00 -0000 From: Simon Marchi Cc: gdb-patches@sourceware.org, simon.marchi@ericsson.com In-Reply-To: <1495020697-13892-1-git-send-email-yao.qi@linaro.org> References: <20170516214007.ql53i6n5mz4nbpxp@localhost> <1495020697-13892-1-git-send-email-yao.qi@linaro.org> Message-ID: <0d03dc5b2bba05ef0a4e50b087b22f92@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.2.5 X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg00382.txt.bz2 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 > > * 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 > > * 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