From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10071 invoked by alias); 10 Dec 2010 21:01:17 -0000 Received: (qmail 10061 invoked by uid 22791); 10 Dec 2010 21:01:16 -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; Fri, 10 Dec 2010 21:01:10 +0000 Received: from eusaamw0706.eamcs.ericsson.se ([147.117.20.31]) by imr4.ericy.com (8.14.3/8.14.3/Debian-9.1ubuntu1) with ESMTP id oBALVA7t028170; Fri, 10 Dec 2010 15:31:11 -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:00:53 -0500 From: Marc Khouzam To: Marc Khouzam , Tom Tromey CC: "gdb-patches@sourceware.org" Date: Fri, 10 Dec 2010 21:01: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/msg00148.txt.bz2 2010-12-07 Marc Khouzam * mi/mi-main.c (mi_cmd_remove_inferior): Don't delete last inferior. (get_other_inferior): New. > I've been doing more testing and I found a problem with the patch. > It seems setting the inferior is not enough, I must also set a thread. > I will better mimic what the 'inferior' command does and submit a new > version. 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. 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=20 patch. Thanks 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); } =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,22 @@ if (!inf) error ("the specified thread group does not exist"); =20 + if (inf =3D=3D current_inferior ()) + { + struct thread_info *tp =3D 0; + 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); + 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 */); }