aboutsummaryrefslogtreecommitdiff
path: root/gdb/mi/mi-cmd-var.c
diff options
context:
space:
mode:
authorVladimir Prus <vladimir@codesourcery.com>2008-05-28 12:06:36 +0000
committerVladimir Prus <vladimir@codesourcery.com>2008-05-28 12:06:36 +0000
commitf7f9ae2c16fc3c4b620beee844aec2562ea71ab4 (patch)
treee12364fd9b579f8b690de636d929945ce638f407 /gdb/mi/mi-cmd-var.c
parent124b52c6d8bb2e44bd22fd1da6e18bb9ad7e30a6 (diff)
downloadgdb-f7f9ae2c16fc3c4b620beee844aec2562ea71ab4.zip
gdb-f7f9ae2c16fc3c4b620beee844aec2562ea71ab4.tar.gz
gdb-f7f9ae2c16fc3c4b620beee844aec2562ea71ab4.tar.bz2
Refactor varobj_update interface.
* varobj.c (varobj_update): Report changes as vector. Also return not just a list of varobj, but a list of special structures that tell what exactly has changed. * varobj.h (enum varobj_update_error): Rename to varobj_scope_status. (struct varobj_update_result_t): New. (varobj_update): Adjust prototype. * mi/mi-cmd-var.c: Adjust for changes.
Diffstat (limited to 'gdb/mi/mi-cmd-var.c')
-rw-r--r--gdb/mi/mi-cmd-var.c78
1 files changed, 34 insertions, 44 deletions
diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c
index 2f009fa..50f7add 100644
--- a/gdb/mi/mi-cmd-var.c
+++ b/gdb/mi/mi-cmd-var.c
@@ -654,62 +654,52 @@ static void
varobj_update_one (struct varobj *var, enum print_values print_values,
int explicit)
{
- struct varobj **changelist;
struct varobj **cc;
struct cleanup *cleanup = NULL;
- int nc;
-
- nc = varobj_update (&var, &changelist, explicit);
-
- /* nc >= 0 represents the number of changes reported into changelist.
- nc < 0 means that an error occured or the the variable has
- changed type (TYPE_CHANGED). */
+ VEC (varobj_update_result) *changes;
+ varobj_update_result *r;
+ int i;
+
+ changes = varobj_update (&var, explicit);
- if (nc == 0)
- return;
- else if (nc < 0)
+ for (i = 0; VEC_iterate (varobj_update_result, changes, i, r); ++i)
{
if (mi_version (uiout) > 1)
cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
- ui_out_field_string (uiout, "name", varobj_get_objname(var));
+ ui_out_field_string (uiout, "name", varobj_get_objname (r->varobj));
- switch (nc)
- {
- case NOT_IN_SCOPE:
+ switch (r->status)
+ {
+ case VAROBJ_IN_SCOPE:
+ if (mi_print_value_p (varobj_get_gdb_type (r->varobj), print_values))
+ ui_out_field_string (uiout, "value", varobj_get_value (r->varobj));
+ ui_out_field_string (uiout, "in_scope", "true");
+ break;
+ case VAROBJ_NOT_IN_SCOPE:
ui_out_field_string (uiout, "in_scope", "false");
break;
- case INVALID:
+ case VAROBJ_INVALID:
ui_out_field_string (uiout, "in_scope", "invalid");
break;
- case TYPE_CHANGED:
- ui_out_field_string (uiout, "in_scope", "true");
- ui_out_field_string (uiout, "type_changed", "true");
- ui_out_field_string (uiout, "new_type", varobj_get_type(var));
- ui_out_field_int (uiout, "new_num_children",
- varobj_get_num_children(var));
- if (mi_print_value_p (varobj_get_gdb_type (var), print_values))
- ui_out_field_string (uiout, "value", varobj_get_value (var));
- break;
- }
- if (mi_version (uiout) > 1)
- do_cleanups (cleanup);
- }
- else
- {
- cc = changelist;
- while (*cc != NULL)
+ }
+
+ if (r->status != VAROBJ_INVALID)
{
- if (mi_version (uiout) > 1)
- cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
- ui_out_field_string (uiout, "name", varobj_get_objname (*cc));
- if (mi_print_value_p (varobj_get_gdb_type (*cc), print_values))
- ui_out_field_string (uiout, "value", varobj_get_value (*cc));
- ui_out_field_string (uiout, "in_scope", "true");
- ui_out_field_string (uiout, "type_changed", "false");
- if (mi_version (uiout) > 1)
- do_cleanups (cleanup);
- cc++;
+ if (r->type_changed)
+ ui_out_field_string (uiout, "type_changed", "true");
+ else
+ ui_out_field_string (uiout, "type_changed", "false");
}
- xfree (changelist);
+
+ if (r->type_changed)
+ {
+ ui_out_field_string (uiout, "new_type", varobj_get_type (r->varobj));
+ ui_out_field_int (uiout, "new_num_children",
+ varobj_get_num_children (r->varobj));
+ }
+
+ if (mi_version (uiout) > 1)
+ do_cleanups (cleanup);
}
+ VEC_free (varobj_update_result, changes);
}