aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi
diff options
context:
space:
mode:
authorVladimir Prus <vladimir@codesourcery.com>2008-01-30 07:17:31 +0000
committerVladimir Prus <vladimir@codesourcery.com>2008-01-30 07:17:31 +0000
commitd56d46f5c7560a45f3a1c6101893ca84969c98a9 (patch)
treef5e7fd5adec6eef7edea4c5d72c36acaab4fa2e2 /gdb/mi
parent44288b4427d328fe143009a158dcf3f8c4051aae (diff)
downloadgdb-d56d46f5c7560a45f3a1c6101893ca84969c98a9.zip
gdb-d56d46f5c7560a45f3a1c6101893ca84969c98a9.tar.gz
gdb-d56d46f5c7560a45f3a1c6101893ca84969c98a9.tar.bz2
Use vector for varobj_list_children interface.
* gdb/varobj.c (varobj_list_children): Return vector of varobjs. * gdb/varobj.h (varobj_list_children): Adjust prototype. (varobj_p): Declare. Declare vector thereof. * mi/mi-cmd-var.c (mi_cmd_var_list_children): Adjust for varobj_list_children change. * Makefile.in (varobj_h): Update dependencies.
Diffstat (limited to 'gdb/mi')
-rw-r--r--gdb/mi/mi-cmd-var.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index 96d01f5..7dfa1f0 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -354,12 +354,13 @@ mi_print_value_p (struct type *type, enum print_values print_values)
enum mi_cmd_result
mi_cmd_var_list_children (char *command, char **argv, int argc)
{
- struct varobj *var;
- struct varobj **childlist;
- struct varobj **cc;
+ struct varobj *var;
+ VEC(varobj_p) *children;
+ struct varobj *child;
struct cleanup *cleanup_children;
int numchild;
enum print_values print_values;
+ int ix;
if (argc != 1 && argc != 2)
error (_("mi_cmd_var_list_children: Usage: [PRINT_VALUES] NAME"));
@@ -372,34 +373,28 @@ mi_cmd_var_list_children (char *command, char **argv, int argc)
if (var == NULL)
error (_("Variable object not found"));
- numchild = varobj_list_children (var, &childlist);
- ui_out_field_int (uiout, "numchild", numchild);
+ children = varobj_list_children (var);
+ ui_out_field_int (uiout, "numchild", VEC_length (varobj_p, children));
if (argc == 2)
print_values = mi_parse_values_option (argv[0]);
else
print_values = PRINT_NO_VALUES;
- if (numchild <= 0)
- {
- xfree (childlist);
- return MI_CMD_DONE;
- }
+ if (VEC_length (varobj_p, children) == 0)
+ return MI_CMD_DONE;
if (mi_version (uiout) == 1)
cleanup_children = make_cleanup_ui_out_tuple_begin_end (uiout, "children");
else
cleanup_children = make_cleanup_ui_out_list_begin_end (uiout, "children");
- cc = childlist;
- while (*cc != NULL)
+ for (ix = 0; VEC_iterate (varobj_p, children, ix, child); ++ix)
{
struct cleanup *cleanup_child;
cleanup_child = make_cleanup_ui_out_tuple_begin_end (uiout, "child");
- print_varobj (*cc, print_values, 1 /* print expression */);
- cc++;
+ print_varobj (child, print_values, 1 /* print expression */);
do_cleanups (cleanup_child);
}
do_cleanups (cleanup_children);
- xfree (childlist);
return MI_CMD_DONE;
}