From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13798 invoked by alias); 8 Dec 2010 01:38:38 -0000 Received: (qmail 13790 invoked by uid 22791); 8 Dec 2010 01:38:38 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from imr4.ericy.com (HELO imr4.ericy.com) (198.24.6.8) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 08 Dec 2010 01:38:24 +0000 Received: from eusaamw0707.eamcs.ericsson.se ([147.117.20.32]) by imr4.ericy.com (8.14.3/8.14.3/Debian-9.1ubuntu1) with ESMTP id oB827kAH002684; Tue, 7 Dec 2010 20:07:47 -0600 Received: from EUSAACMS0703.eamcs.ericsson.se ([169.254.1.63]) by eusaamw0707.eamcs.ericsson.se ([147.117.20.32]) with mapi; Tue, 7 Dec 2010 20:38:06 -0500 From: Marc Khouzam To: Tom Tromey CC: "gdb-patches@sourceware.org" Date: Wed, 08 Dec 2010 01:38:00 -0000 Subject: RE: Assertion failure because of missing inferior Message-ID: References: , In-Reply-To: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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: 2010-12/txt/msg00085.txt.bz2 From: Tom Tromey [tromey@redhat.com] >>>>> "Marc" =3D=3D Marc Khouzam writes: Marc> So, I was thinking that since a frontend shouldn't care which Marc> inferior is the current one, then '-remove-inferior' could change Marc> the current inferior to another inferior, before doing the Marc> removal. This is pretty much what the frontend would have to do Marc> anyway. Removing the very last inferior would not be allowed. Marc> The patch below does this. What do you think of this approach? > This makes sense to me. Marc> +/* Callback used to find the first inferior other than the Marc> + current one. */ Marc> +static int > Blank line between comment and function start. Marc> + if (inf =3D=3D current_inferior ()) Marc> + { Marc> + struct inferior *new_inferior =3D iterate_over_inferiors (get_= other_inferior, NULL); > This line should be broken somewhere, probably before the '=3D'. Marc> + if (new_inferior =3D=3D NULL) Marc> + error ("Cannot remove last inferior"); > Need _() around the text. Thanks for the review. Here is the updated patch. 2010-12-07 Marc Khouzam * mi/mi-main.c (mi_cmd_remove_inferior): Don't delete last inferior. (get_other_inferior): New. ### Eclipse Workspace Patch 1.0 #P src Index: gdb/mi/mi-main.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/mi/mi-main.c,v retrieving revision 1.178.2.3 diff -u -r1.178.2.3 mi-main.c --- gdb/mi/mi-main.c 12 Nov 2010 19:04:45 -0000 1.178.2.3 +++ gdb/mi/mi-main.c 8 Dec 2010 01:35:48 -0000 @@ -1623,6 +1623,18 @@ ui_out_field_fmt (uiout, "inferior", "i%d", inf->num); } =20 +/* Callback used to find the first inferior other than the + current one. */ +=20=20=20 +static int +get_other_inferior (struct inferior *inf, void *arg) +{ + if (inf =3D=3D current_inferior ()) + return 0; + + return 1; +} + void mi_cmd_remove_inferior (char *command, char **argv, int argc) { @@ -1639,6 +1651,16 @@ if (!inf) error ("the specified thread group does not exist"); =20 + if (inf =3D=3D current_inferior ()) + { + struct inferior *new_inferior=20 + =3D iterate_over_inferiors (get_other_inferior, NULL); + if (new_inferior =3D=3D NULL) + error (_("Cannot remove last inferior")); + + set_current_inferior (new_inferior); + } + delete_inferior_1 (inf, 1 /* silent */); }