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  <tom@tromey.com>

	* 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.
This commit is contained in:
Tom Tromey 2017-04-12 16:16:10 -06:00
parent a14a62ddff
commit 0092b74da6
4 changed files with 14 additions and 15 deletions

View File

@ -1,3 +1,9 @@
2017-04-22 Tom Tromey <tom@tromey.com>
* 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 <tom@tromey.com>
* tracepoint.c (tvariables_info_1)

View File

@ -34,6 +34,7 @@
#include "extension.h"
#include <ctype.h>
#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<ui_out_emit_tuple> 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 reading variable: %s>"), 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,

View File

@ -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<ui_out_emit_tuple> 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);
}

View File

@ -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<ui_out_emit_tuple> 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. */