Make varobj::children an std::vector

This patch makes the children field of varobj an std::vector, and
updates the fallout.

One note is that varobj::parent must be made non-const.  The reason is
that when a child deletes itself, it modifies its writes NULL to its
slot in its parent's children vector.  With the VEC, the const didn't
made the parent's children vector content const, only the pointer to it,
but with std::vector, even the content is.

gdb/ChangeLog:

	* varobj.h (struct varobj) <parent>: Remove const.
	<children>: Change type to std::vector.
	(varobj_list_children): Return std::vector const reference.
	(varobj_restrict_range): Change parameter type to std::vector
	const reference.
	* varobj.c (varobj_has_more): Adjust.
	(varobj_restrict_range): Change parameter type to std::vector
	const reference and adjust.
	(install_dynamic_child): Adjust.
	(update_dynamic_varobj_children): Adjust.
	(varobj_list_children): Return std::vector const reference and
	adjust.
	(varobj_add_child): Adjust.
	(update_type_if_necessary): Adjust.
	(varobj_update): Adjust.
	(delete_variable_1): Adjust.
	* ada-varobj.c (ada_value_has_mutated): Adjust.
	* mi/mi-cmd-var.c (mi_cmd_var_list_children): Adjust.
This commit is contained in:
Simon Marchi 2017-11-22 15:08:06 -05:00 committed by Simon Marchi
parent 9e5b9d2b29
commit ddf0ea085b
5 changed files with 74 additions and 62 deletions

View file

@ -959,7 +959,6 @@ static int
ada_value_has_mutated (const struct varobj *var, struct value *new_val,
struct type *new_type)
{
int i;
int from = -1;
int to = -1;
@ -983,10 +982,10 @@ ada_value_has_mutated (const struct varobj *var, struct value *new_val,
has mutated or not. So just assume it hasn't. */
varobj_restrict_range (var->children, &from, &to);
for (i = from; i < to; i++)
for (int i = from; i < to; i++)
if (ada_varobj_get_name_of_child (new_val, new_type,
var->name.c_str (), i)
!= VEC_index (varobj_p, var->children, i)->name)
!= var->children[i]->name)
return 1;
return 0;