Use ui_out_emit_list and ui_out_emit_tuple with gdb::optional
This changes a few spots to use ui_out_emit_list and/or ui_out_emit_tuple with gdb::optional, to preserve existing behavior. This allows for the removal of a few more cleanups. ChangeLog 2017-09-09 Tom Tromey <tom@tromey.com> * mi/mi-cmd-var.c (mi_cmd_var_list_children): Use gdb::optional, ui_out_emit_list, ui_out_emit_tuple. (mi_cmd_var_update): Likewise.
This commit is contained in:
parent
ca5909c7de
commit
c0470d489b
@ -1,3 +1,9 @@
|
|||||||
|
2017-09-09 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* mi/mi-cmd-var.c (mi_cmd_var_list_children): Use gdb::optional,
|
||||||
|
ui_out_emit_list, ui_out_emit_tuple.
|
||||||
|
(mi_cmd_var_update): Likewise.
|
||||||
|
|
||||||
2017-09-09 Tom Tromey <tom@tromey.com>
|
2017-09-09 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* mi/mi-interp.c (mi_user_selected_context_changed): Use
|
* mi/mi-interp.c (mi_user_selected_context_changed): Use
|
||||||
|
@ -410,14 +410,15 @@ mi_cmd_var_list_children (const char *command, char **argv, int argc)
|
|||||||
|
|
||||||
if (from < to)
|
if (from < to)
|
||||||
{
|
{
|
||||||
struct cleanup *cleanup_children;
|
/* For historical reasons this might emit a list or a tuple, so
|
||||||
|
we construct one or the other. */
|
||||||
|
gdb::optional<ui_out_emit_tuple> tuple_emitter;
|
||||||
|
gdb::optional<ui_out_emit_list> list_emitter;
|
||||||
|
|
||||||
if (mi_version (uiout) == 1)
|
if (mi_version (uiout) == 1)
|
||||||
cleanup_children
|
tuple_emitter.emplace (uiout, "children");
|
||||||
= make_cleanup_ui_out_tuple_begin_end (uiout, "children");
|
|
||||||
else
|
else
|
||||||
cleanup_children
|
list_emitter.emplace (uiout, "children");
|
||||||
= make_cleanup_ui_out_list_begin_end (uiout, "children");
|
|
||||||
for (ix = from;
|
for (ix = from;
|
||||||
ix < to && VEC_iterate (varobj_p, children, ix, child);
|
ix < to && VEC_iterate (varobj_p, children, ix, child);
|
||||||
++ix)
|
++ix)
|
||||||
@ -426,7 +427,6 @@ mi_cmd_var_list_children (const char *command, char **argv, int argc)
|
|||||||
|
|
||||||
print_varobj (child, print_values, 1 /* print expression */);
|
print_varobj (child, print_values, 1 /* print expression */);
|
||||||
}
|
}
|
||||||
do_cleanups (cleanup_children);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uiout->field_int ("has_more", varobj_has_more (var, to));
|
uiout->field_int ("has_more", varobj_has_more (var, to));
|
||||||
@ -648,7 +648,6 @@ void
|
|||||||
mi_cmd_var_update (const char *command, char **argv, int argc)
|
mi_cmd_var_update (const char *command, char **argv, int argc)
|
||||||
{
|
{
|
||||||
struct ui_out *uiout = current_uiout;
|
struct ui_out *uiout = current_uiout;
|
||||||
struct cleanup *cleanup;
|
|
||||||
char *name;
|
char *name;
|
||||||
enum print_values print_values;
|
enum print_values print_values;
|
||||||
|
|
||||||
@ -665,10 +664,15 @@ mi_cmd_var_update (const char *command, char **argv, int argc)
|
|||||||
else
|
else
|
||||||
print_values = PRINT_NO_VALUES;
|
print_values = PRINT_NO_VALUES;
|
||||||
|
|
||||||
|
/* For historical reasons this might emit a list or a tuple, so we
|
||||||
|
construct one or the other. */
|
||||||
|
gdb::optional<ui_out_emit_tuple> tuple_emitter;
|
||||||
|
gdb::optional<ui_out_emit_list> list_emitter;
|
||||||
|
|
||||||
if (mi_version (uiout) <= 1)
|
if (mi_version (uiout) <= 1)
|
||||||
cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "changelist");
|
tuple_emitter.emplace (uiout, "changelist");
|
||||||
else
|
else
|
||||||
cleanup = make_cleanup_ui_out_list_begin_end (uiout, "changelist");
|
list_emitter.emplace (uiout, "changelist");
|
||||||
|
|
||||||
/* Check if the parameter is a "*", which means that we want to
|
/* Check if the parameter is a "*", which means that we want to
|
||||||
update all variables. */
|
update all variables. */
|
||||||
@ -693,8 +697,6 @@ mi_cmd_var_update (const char *command, char **argv, int argc)
|
|||||||
|
|
||||||
varobj_update_one (var, print_values, 1 /* explicit */);
|
varobj_update_one (var, print_values, 1 /* explicit */);
|
||||||
}
|
}
|
||||||
|
|
||||||
do_cleanups (cleanup);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Helper for mi_cmd_var_update(). */
|
/* Helper for mi_cmd_var_update(). */
|
||||||
|
Loading…
Reference in New Issue
Block a user