aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2017-11-22 15:08:06 -0500
committerSimon Marchi <simon.marchi@ericsson.com>2017-11-22 15:08:06 -0500
commitddf0ea085b626ddcbb14f88f495bcb677b7ab6e9 (patch)
tree23357c4c7097c35cc21f9baba5c13f3d3ed57cee /gdb/mi
parent9e5b9d2b295d1771647a9e4bc942e398142ccf9b (diff)
downloadgdb-ddf0ea085b626ddcbb14f88f495bcb677b7ab6e9.zip
gdb-ddf0ea085b626ddcbb14f88f495bcb677b7ab6e9.tar.gz
gdb-ddf0ea085b626ddcbb14f88f495bcb677b7ab6e9.tar.bz2
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.
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/mi-cmd-var.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index 0215b1a..084cc38 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -352,10 +352,7 @@ mi_cmd_var_list_children (const char *command, char **argv, int argc)
{
struct ui_out *uiout = current_uiout;
struct varobj *var;
- VEC(varobj_p) *children;
- struct varobj *child;
enum print_values print_values;
- int ix;
int from, to;
if (argc < 1 || argc > 4)
@@ -379,7 +376,9 @@ mi_cmd_var_list_children (const char *command, char **argv, int argc)
to = -1;
}
- children = varobj_list_children (var, &from, &to);
+ const std::vector<varobj *> &children
+ = varobj_list_children (var, &from, &to);
+
uiout->field_int ("numchild", to - from);
if (argc == 2 || argc == 4)
print_values = mi_parse_print_values (argv[0]);
@@ -401,13 +400,11 @@ mi_cmd_var_list_children (const char *command, char **argv, int argc)
tuple_emitter.emplace (uiout, "children");
else
list_emitter.emplace (uiout, "children");
- for (ix = from;
- ix < to && VEC_iterate (varobj_p, children, ix, child);
- ++ix)
+ for (int ix = from; ix < to && ix < children.size (); ix++)
{
ui_out_emit_tuple child_emitter (uiout, "child");
- print_varobj (child, print_values, 1 /* print expression */);
+ print_varobj (children[ix], print_values, 1 /* print expression */);
}
}