From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 62109 invoked by alias); 16 May 2017 21:22:23 -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 62090 invoked by uid 89); 16 May 2017 21:22:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_SOFTFAIL autolearn=no version=3.3.2 spammy=HX-PHP-Originating-Script:rcube.php, H*u:1.2.5, H*UA:1.2.5, Hx-languages-length:2550 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; Tue, 16 May 2017 21:22:20 +0000 Received: by simark.ca (Postfix, from userid 33) id 674C41E4B9; Tue, 16 May 2017 17:22:21 -0400 (EDT) To: Yao Qi Subject: Re: GDB 7.99.91 available for testing 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: Tue, 16 May 2017 21:22:00 -0000 From: Simon Marchi Cc: Joel Brobecker , gdb-patches@sourceware.org In-Reply-To: <20170516204954.zbv35vjzsqa3qenf@localhost> References: <20170504194442.63AAF60B72@joel.gnat.com> <1f06c802305c02d92e0806b6174d7963@polymtl.ca> <20170516204954.zbv35vjzsqa3qenf@localhost> Message-ID: X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.2.5 X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg00358.txt.bz2 On 2017-05-16 16:49, Yao Qi wrote: > On 17-05-16 09:51:42, Simon Marchi wrote: >> >> So indeed, the problem is due to the ordering of the _initialize >> functions >> that changed, _initialize_printcmd used to be called before >> _initialize_infcmd, now it's the reverse. >> >> When it works, the timeline of events to be able to get the tty alias >> working is the following: >> >> 1. The "set" command is registered as a prefix command in printcmd.c, >> which >> adds it to the global command list (cmdlist). setlist is the list of >> its >> subcommands. >> 2. The "set inferior-tty" command is added as a child of "set" (i.e. >> it's >> inserted into setlist) in infcmd.c. >> 3. The "tty" alias is created for "set inferior-tty" in infcmd.c. >> This >> looks up "set" in cmdlist, then "inferior-tty" in the subcommands of >> "set". >> It's found and everyone is happy. >> >> With the _initialize functions called in a different order, steps are >> executed in the order 2-3-1. When we try to create the alias, the >> "set" >> command has not been created and is therefore not part of cmdlist. We >> can't >> find the "set inferior-tty" command, so the alias is not created. > > When we try to create the alias (in step 3), setlist is already created > in step 2, but it is not linked with cmdlist. The command "set > inferior-tty" is created in step 2 too. Since step 2 and step 3 are > close to each other (in _initialize_infcmd), we can pass the "set > inferior-tty" cmd_list_element to the place we create alias, like this, > > cmd_name = "inferior-tty"; > c = lookup_cmd (&cmd_name, setlist, "", -1, 1); > gdb_assert (c != NULL); > add_alias_cmd ("tty", c, class_alias, 0, &cmdlist); > > this makes sure we add alias "tty" under cmdlist, and it is alias to > "set inferior-tty". Step 1 just links setlist and cmdlist together. > >> >> I think the core issue is that it's currently possible to create >> subcommands >> for prefixes that have not been created yet. We need some way of >> ensuring >> some kind of ordering. Here are some ideas: >> > > How is the patch below? I run regress tests yet, and it still needs > some comments. It's very clean, I like it. I think it's good for master and 8.0. Do you want to finish it or do you want me to pick it up? I have enhanced gdb.base/set-inferior-tty.exp to exercise the alias, it could be added to your patch: https://github.com/simark/binutils-gdb/commit/1a8bcb5dbc0dde3d8a4d3f73d0a057b3831902dd#diff-2f94d545bf202185ae6a6022ebfa93bc Thanks, Simon