From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7871 invoked by alias); 25 Feb 2011 20:17:23 -0000 Received: (qmail 7836 invoked by uid 22791); 25 Feb 2011 20:17:16 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-outbound-2.vmware.com (HELO smtp-outbound-2.vmware.com) (65.115.85.73) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 25 Feb 2011 20:17:11 +0000 Received: from mailhost4.vmware.com (mailhost4.vmware.com [10.16.67.124]) by smtp-outbound-2.vmware.com (Postfix) with ESMTP id B1E7954005; Fri, 25 Feb 2011 12:17:09 -0800 (PST) Received: from msnyder-server.eng.vmware.com (promd-2s-dhcp138.eng.vmware.com [10.20.124.138]) by mailhost4.vmware.com (Postfix) with ESMTP id A647BC9FF4; Fri, 25 Feb 2011 12:17:09 -0800 (PST) Message-ID: <4D680E45.50607@vmware.com> Date: Fri, 25 Feb 2011 20:52:00 -0000 From: Michael Snyder User-Agent: Thunderbird 2.0.0.24 (X11/20101201) MIME-Version: 1.0 To: "gdb-patches@sourceware.org" , Pedro Alves Subject: [rfa] Use get_number_or_range for kill inferior etc. Content-Type: multipart/mixed; boundary="------------020600040702000304020505" X-IsSubscribed: yes 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 X-SW-Source: 2011-02/txt/msg00779.txt.bz2 This is a multi-part message in MIME format. --------------020600040702000304020505 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 36 With an additional testsuite test. --------------020600040702000304020505 Content-Type: text/plain; name="remove.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="remove.txt" Content-length: 5855 2011-02-25 Michael Snyder * inferior.c (detach_inferior_command): Use get_number_or_range. (kill_inferior_command): Ditto. (remove_inferior_command): Ditto. (initialize_inferiors): Make command names plural. Update help strings. 2011-02-25 Michael Snyder * gdb.multi/base.exp: Add test for remove-inferiors. Index: inferior.c =================================================================== RCS file: /cvs/src/src/gdb/inferior.c,v retrieving revision 1.24 diff -u -p -u -p -r1.24 inferior.c --- inferior.c 25 Feb 2011 19:19:25 -0000 1.24 +++ inferior.c 25 Feb 2011 20:15:42 -0000 @@ -626,20 +626,23 @@ detach_inferior_command (char *args, int if (!args || !*args) error (_("Requires argument (inferior id to detach)")); - num = parse_and_eval_long (args); + while (*args != '\0') + { + num = get_number_or_range (&args); - if (!valid_gdb_inferior_id (num)) - error (_("Inferior ID %d not known."), num); + if (!valid_gdb_inferior_id (num)) + error (_("Inferior ID %d not known."), num); - pid = gdb_inferior_id_to_pid (num); + pid = gdb_inferior_id_to_pid (num); - tp = any_thread_of_process (pid); - if (!tp) - error (_("Inferior has no threads.")); + tp = any_thread_of_process (pid); + if (!tp) + error (_("Inferior has no threads.")); - switch_to_thread (tp->ptid); + switch_to_thread (tp->ptid); - detach_command (NULL, from_tty); + detach_command (NULL, from_tty); + } } static void @@ -651,20 +654,23 @@ kill_inferior_command (char *args, int f if (!args || !*args) error (_("Requires argument (inferior id to kill)")); - num = parse_and_eval_long (args); + while (*args != '\0') + { + num = get_number_or_range (&args); - if (!valid_gdb_inferior_id (num)) - error (_("Inferior ID %d not known."), num); + if (!valid_gdb_inferior_id (num)) + error (_("Inferior ID %d not known."), num); - pid = gdb_inferior_id_to_pid (num); + pid = gdb_inferior_id_to_pid (num); - tp = any_thread_of_process (pid); - if (!tp) - error (_("Inferior has no threads.")); + tp = any_thread_of_process (pid); + if (!tp) + error (_("Inferior has no threads.")); - switch_to_thread (tp->ptid); + switch_to_thread (tp->ptid); - target_kill (); + target_kill (); + } bfd_cache_close_all (); } @@ -740,19 +746,25 @@ remove_inferior_command (char *args, int int num; struct inferior *inf; - num = parse_and_eval_long (args); - inf = find_inferior_id (num); + if (args == NULL || *args == '\0') + error (_("Requires an argument (inferior id to remove)")); - if (inf == NULL) - error (_("Inferior ID %d not known."), num); + while (*args != '\0') + { + num = get_number_or_range (&args); + inf = find_inferior_id (num); + + if (inf == NULL) + error (_("Inferior ID %d not known."), num); - if (inf == current_inferior ()) - error (_("Can not remove current symbol inferior.")); + if (inf == current_inferior ()) + error (_("Can not remove current symbol inferior.")); - if (inf->pid != 0) - error (_("Can not remove an active inferior.")); + if (inf->pid != 0) + error (_("Can not remove an active inferior.")); - delete_inferior_1 (inf, 1); + delete_inferior_1 (inf, 1); + } } struct inferior * @@ -1048,13 +1060,13 @@ initialize_inferiors (void) add_com ("add-inferior", no_class, add_inferior_command, _("\ Add a new inferior.\n\ Usage: add-inferior [-copies ] [-exec ]\n\ -N is the optional number of inferior to add, default is 1.\n\ +N is the optional number of inferiors to add, default is 1.\n\ FILENAME is the file name of the executable to use\n\ as main program.")); - add_com ("remove-inferior", no_class, remove_inferior_command, _("\ -Remove inferior ID.\n\ -Usage: remove-inferior ID")); + add_com ("remove-inferiors", no_class, remove_inferior_command, _("\ +Remove inferior ID (or list of IDs).\n\ +Usage: remove-inferiors ID...")); add_com ("clone-inferior", no_class, clone_inferior_command, _("\ Clone inferior ID.\n\ @@ -1064,12 +1076,12 @@ executable loaded as the copied inferior adds 1 copy. If ID is not specified, it is the current inferior\n\ that is cloned.")); - add_cmd ("inferior", class_run, detach_inferior_command, _("\ -Detach from inferior ID."), + add_cmd ("inferiors", class_run, detach_inferior_command, _("\ +Detach from inferior ID (or list of IDS)."), &detachlist); - add_cmd ("inferior", class_run, kill_inferior_command, _("\ -Kill inferior ID."), + add_cmd ("inferiors", class_run, kill_inferior_command, _("\ +Kill inferior ID (or list of IDs)."), &killlist); add_cmd ("inferior", class_run, inferior_command, _("\ Index: testsuite/gdb.multi/base.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.multi/base.exp,v retrieving revision 1.8 diff -u -p -u -p -r1.8 base.exp --- testsuite/gdb.multi/base.exp 25 Feb 2011 19:19:26 -0000 1.8 +++ testsuite/gdb.multi/base.exp 25 Feb 2011 20:15:42 -0000 @@ -156,3 +156,34 @@ if { ![runto_main] } then { gdb_test "break hello" ".*" gdb_test "continue" "Breakpoint \[0-9\].*, hello.*" + +# Now let's remove the other two + +gdb_test_no_output "remove-inferior 2-3" "remove-inferior 2-3" + +set see1 0 +set see2 0 +set see3 0 + +gdb_test_multiple "info inferiors" "check remove-inferiors" { + -re ". 3 \[^\r\n\]*${exec3}" { + set see3 1 + exp_continue + } + -re ". 2 \[^\r\n\]*${exec2}" { + set see2 1 + exp_continue + } + -re ". 1 \[^\r\n\]*${exec1}" { + set see1 1 + exp_continue + } + -re "$gdb_prompt $" { + if { $see1 && !$see2 && !$see3 } then { + pass "check remove-inferiors" + } else { + fail "check remove-inferiors" + } + } +} + --------------020600040702000304020505--