From 0092b74da6d86185c4d0c0fa0f540b97647bf44a Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 12 Apr 2017 16:16:10 -0600 Subject: [PATCH] Use ui_out_emit_tuple in more places in MI This patch changes a few more spots in MI to use ui_out_emit_tuple. These changes required the use of gdb::optional. ChangeLog 2017-04-22 Tom Tromey * mi/mi-main.c (print_variable_or_computed): Use ui_out_emit_tuple. * mi/mi-cmd-var.c (varobj_update_one): Use ui_out_emit_tuple. * mi/mi-cmd-stack.c (list_arg_or_local): Use ui_out_emit_tuple. --- gdb/ChangeLog | 6 ++++++ gdb/mi/mi-cmd-stack.c | 9 +++------ gdb/mi/mi-cmd-var.c | 7 +++---- gdb/mi/mi-main.c | 7 ++----- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 37ca98858b7..fb066d04c78 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2017-04-22 Tom Tromey + + * mi/mi-main.c (print_variable_or_computed): Use ui_out_emit_tuple. + * mi/mi-cmd-var.c (varobj_update_one): Use ui_out_emit_tuple. + * mi/mi-cmd-stack.c (list_arg_or_local): Use ui_out_emit_tuple. + 2017-04-22 Tom Tromey * tracepoint.c (tvariables_info_1) diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index f288817b5c7..bd24e5b1588 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -34,6 +34,7 @@ #include "extension.h" #include #include "mi-parse.h" +#include "common/gdb_optional.h" enum what_to_list { locals, arguments, all }; @@ -483,7 +484,6 @@ static void list_arg_or_local (const struct frame_arg *arg, enum what_to_list what, enum print_values values, int skip_unavailable) { - struct cleanup *old_chain; struct ui_out *uiout = current_uiout; gdb_assert (!arg->val || !arg->error); @@ -507,10 +507,9 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what, TYPE_LENGTH (value_type (arg->val)))))) return; - old_chain = make_cleanup (null_cleanup, NULL); - + gdb::optional tuple_emitter; if (values != PRINT_NO_VALUES || what == all) - make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + tuple_emitter.emplace (uiout, nullptr); string_file stb; @@ -556,8 +555,6 @@ list_arg_or_local (const struct frame_arg *arg, enum what_to_list what, stb.printf (_(""), error_message); uiout->field_stream ("value", stb); } - - do_cleanups (old_chain); } /* Print a list of the objects for the frame FI in a certain form, diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c index 0a4ed62f89d..1a7e322c7c4 100644 --- a/gdb/mi/mi-cmd-var.c +++ b/gdb/mi/mi-cmd-var.c @@ -30,6 +30,7 @@ #include "mi-getopt.h" #include "gdbthread.h" #include "mi-parse.h" +#include "common/gdb_optional.h" extern unsigned int varobjdebug; /* defined in varobj.c. */ @@ -712,10 +713,10 @@ varobj_update_one (struct varobj *var, enum print_values print_values, for (i = 0; VEC_iterate (varobj_update_result, changes, i, r); ++i) { int from, to; - struct cleanup *cleanup = make_cleanup (null_cleanup, NULL); + gdb::optional tuple_emitter; if (mi_version (uiout) > 1) - make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + tuple_emitter.emplace (uiout, nullptr); uiout->field_string ("name", varobj_get_objname (r->varobj)); switch (r->status) @@ -784,8 +785,6 @@ varobj_update_one (struct varobj *var, enum print_values print_values, VEC_free (varobj_p, r->newobj); r->newobj = NULL; /* Paranoia. */ } - - do_cleanups (cleanup); } VEC_free (varobj_update_result, changes); } diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index d309ba3fbfd..7e225db82e4 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -2656,7 +2656,6 @@ mi_cmd_ada_task_info (const char *command, char **argv, int argc) static void print_variable_or_computed (const char *expression, enum print_values values) { - struct cleanup *old_chain; struct value *val; struct type *type; struct ui_out *uiout = current_uiout; @@ -2670,9 +2669,9 @@ print_variable_or_computed (const char *expression, enum print_values values) else val = evaluate_expression (expr.get ()); - old_chain = make_cleanup (null_cleanup, NULL); + gdb::optional tuple_emitter; if (values != PRINT_NO_VALUES) - make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + tuple_emitter.emplace (uiout, nullptr); uiout->field_string ("name", expression); switch (values) @@ -2704,8 +2703,6 @@ print_variable_or_computed (const char *expression, enum print_values values) } break; } - - do_cleanups (old_chain); } /* Implement the "-trace-frame-collected" command. */ -- 2.30.2