From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31632 invoked by alias); 8 Nov 2007 07:08:34 -0000 Received: (qmail 31618 invoked by uid 22791); 8 Nov 2007 07:08:33 -0000 X-Spam-Check-By: sourceware.org Received: from zigzag.lvk.cs.msu.su (HELO zigzag.lvk.cs.msu.su) (158.250.17.23) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 08 Nov 2007 07:08:29 +0000 Received: from Debian-exim by zigzag.lvk.cs.msu.su with spam-scanned (Exim 4.50) id 1Iq1Uz-0005ha-If for gdb-patches@sources.redhat.com; Thu, 08 Nov 2007 10:08:26 +0300 Received: from localhost ([127.0.0.1] helo=ip6-localhost) by zigzag.lvk.cs.msu.su with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.50) id 1Iq1Uk-0005gu-EV; Thu, 08 Nov 2007 10:08:06 +0300 From: Vladimir Prus To: Nick Roberts Subject: Re: Fix crash in -var-delete Date: Thu, 08 Nov 2007 07:08:00 -0000 User-Agent: KMail/1.9.6 Cc: gdb-patches@sources.redhat.com References: <200711072257.59372.ghost@cs.msu.su> <18226.40498.13190.723249@kahikatea.snap.net.nz> In-Reply-To: <18226.40498.13190.723249@kahikatea.snap.net.nz> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200711081008.03657.ghost@cs.msu.su> 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: 2007-11/txt/msg00155.txt.bz2 On Thursday 08 November 2007 08:27:14 Nick Roberts wrote: > > @@ -1292,6 +1292,8 @@ delete_variable_1 (struct cpstack **resu > > for (i = 0; i < VEC_length (varobj_p, var->children); ++i) > > { > > varobj_p child = VEC_index (varobj_p, var->children, i); > > + if (!child) > > + continue; > > if (!remove_from_parent_p) > > child->parent = NULL; > > Should child not get removed from the list of its parents' children when > deleted first time round? Then checking for child shouldn't be necessary. This would have worked previously, when children of varobj were in a linked list, and search was done by field name. However, that approach did not work when a field of structure had no name, which is quite possible in C and C++. So how, children of a varobj are stored as a vector. Each child knows its index in parent, and when a child is removed the corresponding entry in parent's vector is set to NULL. I presume it's possible to store list of children as vector of (index,child) pair, which would allow removing a child completely, but the complexity involved in that will outweight the complexity of checking for NULL child here. - Volodya