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

@ -124,10 +124,10 @@ struct varobj
int num_children = -1;
/* If this object is a child, this points to its immediate parent. */
const struct varobj *parent = NULL;
struct varobj *parent = NULL;
/* Children of this object. */
VEC (varobj_p) *children = NULL;
std::vector<varobj *> children;
/* Description of the root variable. Points to root variable for
children. */
@ -280,8 +280,8 @@ extern int varobj_get_num_children (struct varobj *var);
that was returned. The resulting VEC will contain at least the
children from *FROM to just before *TO; it might contain more
children, depending on whether any more were available. */
extern VEC (varobj_p)* varobj_list_children (struct varobj *var,
int *from, int *to);
extern const std::vector<varobj *> &
varobj_list_children (struct varobj *var, int *from, int *to);
extern std::string varobj_get_type (struct varobj *var);
@ -341,8 +341,8 @@ extern std::string
extern void varobj_formatted_print_options (struct value_print_options *opts,
enum varobj_display_formats format);
extern void varobj_restrict_range (VEC (varobj_p) *children, int *from,
int *to);
extern void varobj_restrict_range (const std::vector<varobj *> &children,
int *from, int *to);
extern int varobj_default_is_path_expr_parent (const struct varobj *var);