From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21233 invoked by alias); 29 Dec 2016 18:13:38 -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 21217 invoked by uid 89); 29 Dec 2016 18:13:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.5 required=5.0 tests=AWL,BAYES_50,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=sk:number_, Hx-languages-length:2190, anew, 77513 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 29 Dec 2016 18:13:27 +0000 Received: from svr-orw-mbx-03.mgc.mentorg.com ([147.34.90.203]) by relay1.mentorg.com with esmtp id 1cMfCf-0005k7-S9 from Luis_Gustavo@mentor.com ; Thu, 29 Dec 2016 10:13:25 -0800 Received: from [172.30.9.233] (147.34.91.1) by svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Thu, 29 Dec 2016 10:13:22 -0800 Subject: Re: [PATCH] gdb: add -a option for remove-inferior References: <87a8bebqug.fsf@catern.com> To: , Reply-To: Luis Machado From: Luis Machado Message-ID: <6f026574-b416-61ba-759a-4c3503d23224@codesourcery.com> Date: Thu, 29 Dec 2016 18:13:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <87a8bebqug.fsf@catern.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) To svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) X-IsSubscribed: yes X-SW-Source: 2016-12/txt/msg00440.txt.bz2 On 12/29/2016 11:13 AM, sbaugh@catern.com wrote: > > I find myself frequently wanting to wipe out the current set of > inferiors: detaching from all of them, or killing them all, and then > starting anew. A -a flag to the various inferior commands which currently > just take ranges of ids would make this a lot easier. Does that sound > like a reasonable enhancement? > > If this patch is acceptable I'll go ahead and add -a flags like this to > all the inferior commands where it makes sense, and add docs, and > resubmit. > > > This adds a -a option for remove-inferior; when passed, all inferiors > will be removed. > > --- > gdb/inferior.c | 18 +++++++++++++++--- > 1 file changed, 15 insertions(+), 3 deletions(-) > > diff --git a/gdb/inferior.c b/gdb/inferior.c > index 32b6db2..f4cd062 100644 > --- a/gdb/inferior.c > +++ b/gdb/inferior.c > @@ -775,13 +775,25 @@ info_inferiors_command (char *args, int from_tty) > print_inferior (current_uiout, args); > } > > -/* remove-inferior ID */ > +/* remove-inferior [-a] ID */ > > static void > remove_inferior_command (char *args, int from_tty) > { > if (args == NULL || *args == '\0') > - error (_("Requires an argument (inferior id(s) to remove)")); > + error (_("Requires an argument (inferior id(s) to remove or -a)")); > + > + if (startswith (args, "-a")) > + { > + struct inferior *inf, *cur; > + cur = current_inferior(); > + ALL_INFERIORS(inf) > + { > + if (inf != cur) > + delete_inferior (inf); > + } > + return; > + } > > number_or_range_parser parser (args); > while (!parser.finished ()) > @@ -1056,7 +1068,7 @@ as main program.")); > > add_com ("remove-inferiors", no_class, remove_inferior_command, _("\ > Remove inferior ID (or list of IDs).\n\ > -Usage: remove-inferiors ID...")); > +Usage: remove-inferiors [-a] ID...")); > > add_com ("clone-inferior", no_class, clone_inferior_command, _("\ > Clone inferior ID.\n\ > It sounds like a reasonable option to me. I wonder if a regular expression would be better than -a? So, it would be easier to say "remove-inferior *". It may be a bit more complicated to address though. In any case, -a seems to be a good addition.