Fix crash when a variable object being deleted

has any of its children deleted previously.

	* varobj.c (delete_variable_1): Don't recurse
	into deleted children.
This commit is contained in:
Vladimir Prus 2007-11-07 20:06:29 +00:00
parent 91ea499d4a
commit 214270abf3
5 changed files with 41 additions and 0 deletions

View File

@ -1,3 +1,11 @@
2007-11-07 Vladimir Prus <vladimir@codesourcery.com>
Fix crash when a variable object being deleted
has any of its children deleted previously.
* varobj.c (delete_variable_1): Don't recurse
into deleted children.
2007-11-07 Markus Deuling <deuling@de.ibm.com>
* gdbarch.sh (legacy_virtual_frame_pointer): Add gdbarch parameter.

View File

@ -1,3 +1,8 @@
2007-11-07 Vladimir Prus <vladimir@codesourcery.com>
* gdb.mi/mi-var-child.c (do_child_deletion): New.
* gdb.mi/mi-var-child.exp: Run child_deletion tests.
2007-11-05 Luis Machado <luisgpm@br.ibm.com>
* gdb.base/printcmds.exp: New function

View File

@ -306,6 +306,29 @@ do_special_tests (void)
incr_a(2);
}
struct very_simple_struct
{
int a;
int b;
};
int
do_child_deletion (void)
{
/*: BEGIN: child_deletion :*/
struct very_simple_struct s = {1, 2};
/*:
mi_create_varobj S s "create varobj for s"
mi_list_varobj_children S {{S.a a 0 int} {S.b b 0 int}} \
"list children of S"
mi_delete_varobj S.a "delete S.a"
mi_delete_varobj S.b "delete S.b"
mi_delete_varobj S "delete S"
:*/
return 99;
/*: END: child_deletion :*/
}
int
main (int argc, char *argv [])
{
@ -313,6 +336,7 @@ main (int argc, char *argv [])
do_block_tests ();
do_children_tests ();
do_special_tests ();
do_child_deletion ();
exit (0);
}

View File

@ -1227,7 +1227,9 @@ mi_gdb_test "-var-update *" \
"\\^done,changelist=\\\[\{name=\"psnp->ptrs.0.next.next.long_ptr\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
"update all vars psnp->next->next->long_ptr (and 2.long_ptr) changed"
mi_prepare_inline_tests $srcfile
mi_run_inline_test child_deletion
mi_gdb_exit

View File

@ -1292,6 +1292,8 @@ delete_variable_1 (struct cpstack **resultp, int *delcountp,
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;
delete_variable_1 (resultp, delcountp, child, 0, only_children_p);