Fix crash in -var-delete
Vladimir Prus
ghost@cs.msu.su
Thu Nov 8 07:08:00 GMT 2007
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
More information about the Gdb-patches
mailing list