From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19425 invoked by alias); 10 Dec 2010 21:38:08 -0000 Received: (qmail 19416 invoked by uid 22791); 10 Dec 2010 21:38:08 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from imr3.ericy.com (HELO imr3.ericy.com) (198.24.6.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 10 Dec 2010 21:38:02 +0000 Received: from eusaamw0706.eamcs.ericsson.se ([147.117.20.31]) by imr3.ericy.com (8.13.8/8.13.8) with ESMTP id oBALbor2005984 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Fri, 10 Dec 2010 15:37:51 -0600 Received: from EUSAACMS0703.eamcs.ericsson.se ([169.254.1.63]) by eusaamw0706.eamcs.ericsson.se ([147.117.20.31]) with mapi; Fri, 10 Dec 2010 16:37:50 -0500 From: Marc Khouzam To: Marc Khouzam , Tom Tromey CC: "gdb-patches@sourceware.org" Date: Fri, 10 Dec 2010 21: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/msg00149.txt.bz2 > Below is a more complete solution, copying the code from: > mi_cmd_execute(). It basically sets a thread, after setting the inferior. > Sorry about missing it before. >=20 > Doing this lead me to another segfault. I confirmed that it is part > of 7.2 and not introduced by my patch. So, I'm posting this patch now, > but I will email and investigate about the new segfault. There is > not much point to this current patch until the segfault is fixed, but > they are still two different issues, which is why I'm still posting this > patch. The segfault is caused by the fact that I removed the inferior while it was still running. I posted a question about that, but I think it is not a normal use case, and therefore, does not prevent the below patch from adding value. What do you think of the below for 7_2? Thanks =20 Marc 2010-12-10 Marc Khouzam * mi/mi-main.c (mi_cmd_remove_inferior): Don't delete current 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.4 diff -u -r1.178.2.4 mi-main.c --- gdb/mi/mi-main.c 9 Dec 2010 19:22:59 -0000 1.178.2.4 +++ gdb/mi/mi-main.c 10 Dec 2010 20:45:44 -0000 @@ -1623,6 +1623,18 @@ ui_out_field_fmt (uiout, "inferior", "i%d", inf->num); } +/* Callback used to find the first inferior other than the + current one. */ + +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,22 @@ if (!inf) error ("the specified thread group does not exist"); + if (inf =3D=3D current_inferior ()) + { + struct thread_info *tp =3D 0; + struct inferior *new_inferior + =3D iterate_over_inferiors (get_other_inferior, NULL); + + if (new_inferior =3D=3D NULL) + error (_("Cannot remove last inferior")); + + set_current_inferior (new_inferior); + if (new_inferior->pid !=3D 0) + tp =3D any_thread_of_process (new_inferior->pid); + switch_to_thread (tp ? tp->ptid : null_ptid); + set_current_program_space (new_inferior->pspace); + } + delete_inferior_1 (inf, 1 /* silent */); }