From: Tom Tromey Date: Wed, 12 Apr 2017 22:30:21 +0000 (-0600) Subject: Use ui_out_emit_list X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=10f489e57677e670bf980e93896762594e9ad908;p=binutils-gdb.git Use ui_out_emit_list This changes some spots to use ui_out_emit_list. This only touches "easy" cases, where the cleanup was used in a block-structured way. There's also one more use of ui_out_emit_tuple in here. ChangeLog 2017-04-22 Tom Tromey * mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries): Use ui_out_emit_list. * stack.c (print_frame): Use ui_out_emit_list. * mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Use ui_out_emit_list. * mi/mi-main.c (print_one_inferior) (mi_cmd_data_list_register_names) (mi_cmd_data_list_register_values, mi_cmd_list_features) (mi_cmd_list_target_features, mi_cmd_trace_frame_collected): Use ui_out_emit_list. * mi/mi-interp.c (mi_on_normal_stop_1): Use ui_out_emit_list. (mi_output_solib_attribs): Use ui_out_emit_list, ui_out_emit_tuple. * mi/mi-cmd-var.c (varobj_update_one): Use ui_out_emit_list. * mi/mi-cmd-stack.c (mi_cmd_stack_list_frames) (mi_cmd_stack_list_args, list_args_or_locals): Use ui_out_emit_list. * disasm.c (do_assembly_only): Use ui_out_emit_list. * breakpoint.c (print_solib_event, output_thread_groups): Use ui_out_emit_list. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index fb066d04c78..28ae0a7717c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,26 @@ +2017-04-22 Tom Tromey + + * mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries): Use + ui_out_emit_list. + * stack.c (print_frame): Use ui_out_emit_list. + * mi/mi-symbol-cmds.c (mi_cmd_symbol_list_lines): Use + ui_out_emit_list. + * mi/mi-main.c (print_one_inferior) + (mi_cmd_data_list_register_names) + (mi_cmd_data_list_register_values, mi_cmd_list_features) + (mi_cmd_list_target_features, mi_cmd_trace_frame_collected): Use + ui_out_emit_list. + * mi/mi-interp.c (mi_on_normal_stop_1): Use ui_out_emit_list. + (mi_output_solib_attribs): Use ui_out_emit_list, + ui_out_emit_tuple. + * mi/mi-cmd-var.c (varobj_update_one): Use ui_out_emit_list. + * mi/mi-cmd-stack.c (mi_cmd_stack_list_frames) + (mi_cmd_stack_list_args, list_args_or_locals): Use + ui_out_emit_list. + * disasm.c (do_assembly_only): Use ui_out_emit_list. + * breakpoint.c (print_solib_event, output_thread_groups): Use + ui_out_emit_list. + 2017-04-22 Tom Tromey * mi/mi-main.c (print_variable_or_computed): Use ui_out_emit_tuple. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 269cddd251b..b0f7cb5af96 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -4885,13 +4885,11 @@ print_solib_event (int is_catchpoint) if (any_deleted) { - struct cleanup *cleanup; char *name; int ix; current_uiout->text (_(" Inferior unloaded ")); - cleanup = make_cleanup_ui_out_list_begin_end (current_uiout, - "removed"); + ui_out_emit_list list_emitter (current_uiout, "removed"); for (ix = 0; VEC_iterate (char_ptr, current_program_space->deleted_solibs, ix, name); @@ -4902,19 +4900,15 @@ print_solib_event (int is_catchpoint) current_uiout->field_string ("library", name); current_uiout->text ("\n"); } - - do_cleanups (cleanup); } if (any_added) { struct so_list *iter; int ix; - struct cleanup *cleanup; current_uiout->text (_(" Inferior loaded ")); - cleanup = make_cleanup_ui_out_list_begin_end (current_uiout, - "added"); + ui_out_emit_list list_emitter (current_uiout, "added"); for (ix = 0; VEC_iterate (so_list_ptr, current_program_space->added_solibs, ix, iter); @@ -4925,8 +4919,6 @@ print_solib_event (int is_catchpoint) current_uiout->field_string ("library", iter->so_name); current_uiout->text ("\n"); } - - do_cleanups (cleanup); } } @@ -6271,7 +6263,6 @@ output_thread_groups (struct ui_out *uiout, VEC(int) *inf_num, int mi_only) { - struct cleanup *back_to; int is_mi = uiout->is_mi_like_p (); int inf; int i; @@ -6281,7 +6272,7 @@ output_thread_groups (struct ui_out *uiout, if (!is_mi && mi_only) return; - back_to = make_cleanup_ui_out_list_begin_end (uiout, field_name); + ui_out_emit_list list_emitter (uiout, field_name); for (i = 0; VEC_iterate (int, inf_num, i, inf); ++i) { @@ -6302,8 +6293,6 @@ output_thread_groups (struct ui_out *uiout, uiout->text (plongest (inf)); } } - - do_cleanups (back_to); } /* Print B to gdb_stdout. */ diff --git a/gdb/disasm.c b/gdb/disasm.c index fde52c392b2..83f9871628e 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -732,13 +732,9 @@ do_assembly_only (struct gdbarch *gdbarch, struct ui_out *uiout, CORE_ADDR low, CORE_ADDR high, int how_many, int flags) { - struct cleanup *ui_out_chain; - - ui_out_chain = make_cleanup_ui_out_list_begin_end (uiout, "asm_insns"); + ui_out_emit_list list_emitter (uiout, "asm_insns"); dump_insns (gdbarch, uiout, low, high, how_many, flags, NULL); - - do_cleanups (ui_out_chain); } /* Initialize the disassemble info struct ready for the specified diff --git a/gdb/mi/mi-cmd-file.c b/gdb/mi/mi-cmd-file.c index d166ff6ee3c..2b3522b7b16 100644 --- a/gdb/mi/mi-cmd-file.c +++ b/gdb/mi/mi-cmd-file.c @@ -144,8 +144,7 @@ mi_cmd_file_list_shared_libraries (const char *command, char **argv, int argc) update_solib_list (1); /* Print the table header. */ - struct cleanup *cleanup - = make_cleanup_ui_out_list_begin_end (uiout, "shared-libraries"); + ui_out_emit_list list_emitter (uiout, "shared-libraries"); ALL_SO_LIBS (so) { @@ -160,6 +159,4 @@ mi_cmd_file_list_shared_libraries (const char *command, char **argv, int argc) do_cleanups (tuple_clean_up); } - - do_cleanups (cleanup); } diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index bd24e5b1588..6250b75cae1 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -82,7 +82,6 @@ mi_cmd_stack_list_frames (const char *command, char **argv, int argc) int frame_low; int frame_high; int i; - struct cleanup *cleanup_stack; struct frame_info *fi; enum ext_lang_bt_status result = EXT_LANG_BT_ERROR; int raw_arg = 0; @@ -143,7 +142,7 @@ mi_cmd_stack_list_frames (const char *command, char **argv, int argc) if (fi == NULL) error (_("-stack-list-frames: Not enough frames in stack.")); - cleanup_stack = make_cleanup_ui_out_list_begin_end (current_uiout, "stack"); + ui_out_emit_list list_emitter (current_uiout, "stack"); if (! raw_arg && frame_filters) { @@ -177,8 +176,6 @@ mi_cmd_stack_list_frames (const char *command, char **argv, int argc) print_frame_info (fi, 1, LOC_AND_ADDRESS, 0 /* args */, 0); } } - - do_cleanups (cleanup_stack); } void @@ -291,7 +288,6 @@ mi_cmd_stack_list_args (const char *command, char **argv, int argc) int frame_high; int i; struct frame_info *fi; - struct cleanup *cleanup_stack_args; enum print_values print_values; struct ui_out *uiout = current_uiout; int raw_arg = 0; @@ -359,8 +355,7 @@ mi_cmd_stack_list_args (const char *command, char **argv, int argc) if (fi == NULL) error (_("-stack-list-arguments: Not enough frames in stack.")); - cleanup_stack_args - = make_cleanup_ui_out_list_begin_end (uiout, "stack-args"); + ui_out_emit_list list_emitter (uiout, "stack-args"); if (! raw_arg && frame_filters) { @@ -394,7 +389,6 @@ mi_cmd_stack_list_args (const char *command, char **argv, int argc) list_args_or_locals (arguments, print_values, fi, skip_unavailable); } } - do_cleanups (cleanup_stack_args); } /* Print a list of the local variables (including arguments) for the @@ -570,7 +564,6 @@ list_args_or_locals (enum what_to_list what, enum print_values values, const struct block *block; struct symbol *sym; struct block_iterator iter; - struct cleanup *cleanup_list; struct type *type; const char *name_of_result; struct ui_out *uiout = current_uiout; @@ -593,7 +586,7 @@ list_args_or_locals (enum what_to_list what, enum print_values values, "unexpected what_to_list: %d", (int) what); } - cleanup_list = make_cleanup_ui_out_list_begin_end (uiout, name_of_result); + ui_out_emit_list list_emitter (uiout, name_of_result); while (block != 0) { @@ -681,7 +674,6 @@ list_args_or_locals (enum what_to_list what, enum print_values values, else block = BLOCK_SUPERBLOCK (block); } - do_cleanups (cleanup_list); } void diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c index 1a7e322c7c4..191e7703feb 100644 --- a/gdb/mi/mi-cmd-var.c +++ b/gdb/mi/mi-cmd-var.c @@ -772,16 +772,14 @@ varobj_update_one (struct varobj *var, enum print_values print_values, { int j; varobj_p child; - struct cleanup *cleanup; - cleanup = make_cleanup_ui_out_list_begin_end (uiout, "new_children"); + ui_out_emit_list list_emitter (uiout, "new_children"); for (j = 0; VEC_iterate (varobj_p, r->newobj, j, child); ++j) { ui_out_emit_tuple tuple_emitter (uiout, NULL); print_varobj (child, print_values, 1 /* print_expression */); } - do_cleanups (cleanup); VEC_free (varobj_p, r->newobj); r->newobj = NULL; /* Paranoia. */ } diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c index a769fe9f5cf..959ae37376b 100644 --- a/gdb/mi/mi-interp.c +++ b/gdb/mi/mi-interp.c @@ -680,11 +680,9 @@ mi_on_normal_stop_1 (struct bpstats *bs, int print_frame) mi_uiout->field_int ("thread-id", tp->global_num); if (non_stop) { - struct cleanup *back_to = make_cleanup_ui_out_list_begin_end - (mi_uiout, "stopped-threads"); + ui_out_emit_list list_emitter (mi_uiout, "stopped-threads"); mi_uiout->field_int (NULL, tp->global_num); - do_cleanups (back_to); } else mi_uiout->field_string ("stopped-threads", "all"); @@ -1128,17 +1126,13 @@ mi_output_solib_attribs (ui_out *uiout, struct so_list *solib) if (!gdbarch_has_global_solist (target_gdbarch ())) uiout->field_fmt ("thread-group", "i%d", current_inferior ()->num); - struct cleanup *cleanup - = make_cleanup_ui_out_list_begin_end (uiout, "ranges"); - struct cleanup *tuple_clean_up - = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + ui_out_emit_list list_emitter (uiout, "ranges"); + ui_out_emit_tuple tuple_emitter (uiout, NULL); if (solib->addr_high != 0) { uiout->field_core_addr ("from", gdbarch, solib->addr_low); uiout->field_core_addr ("to", gdbarch, solib->addr_high); } - do_cleanups (tuple_clean_up); - do_cleanups (cleanup); } static void diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 7e225db82e4..cb68fd61133 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -686,8 +686,7 @@ print_one_inferior (struct inferior *inferior, void *xdata) if (!VEC_empty (int, data.cores)) { int *b, *e; - struct cleanup *back_to_2 = - make_cleanup_ui_out_list_begin_end (uiout, "cores"); + ui_out_emit_list list_emitter (uiout, "cores"); qsort (VEC_address (int, data.cores), VEC_length (int, data.cores), sizeof (int), @@ -699,8 +698,6 @@ print_one_inferior (struct inferior *inferior, void *xdata) for (; b != e; ++b) uiout->field_int (NULL, *b); - - do_cleanups (back_to_2); } if (top_data->recurse) @@ -994,7 +991,6 @@ mi_cmd_data_list_register_names (const char *command, char **argv, int argc) struct ui_out *uiout = current_uiout; int regnum, numregs; int i; - struct cleanup *cleanup; /* Note that the test for a valid register must include checking the gdbarch_register_name because gdbarch_num_regs may be allocated @@ -1006,7 +1002,7 @@ mi_cmd_data_list_register_names (const char *command, char **argv, int argc) gdbarch = get_current_arch (); numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch); - cleanup = make_cleanup_ui_out_list_begin_end (uiout, "register-names"); + ui_out_emit_list list_emitter (uiout, "register-names"); if (argc == 0) /* No args, just do all the regs. */ { @@ -1035,7 +1031,6 @@ mi_cmd_data_list_register_names (const char *command, char **argv, int argc) else uiout->field_string (NULL, gdbarch_register_name (gdbarch, regnum)); } - do_cleanups (cleanup); } void @@ -1157,7 +1152,6 @@ mi_cmd_data_list_register_values (const char *command, char **argv, int argc) struct gdbarch *gdbarch; int regnum, numregs, format; int i; - struct cleanup *list_cleanup; int skip_unavailable = 0; int oind = 0; enum opt @@ -1204,7 +1198,7 @@ mi_cmd_data_list_register_values (const char *command, char **argv, int argc) gdbarch = get_frame_arch (frame); numregs = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch); - list_cleanup = make_cleanup_ui_out_list_begin_end (uiout, "register-values"); + ui_out_emit_list list_emitter (uiout, "register-values"); if (argc - oind == 1) { @@ -1234,7 +1228,6 @@ mi_cmd_data_list_register_values (const char *command, char **argv, int argc) else error (_("bad register number")); } - do_cleanups (list_cleanup); } /* Output one register REGNUM's contents in the desired FORMAT. If @@ -1830,10 +1823,9 @@ mi_cmd_list_features (const char *command, char **argv, int argc) { if (argc == 0) { - struct cleanup *cleanup = NULL; struct ui_out *uiout = current_uiout; - cleanup = make_cleanup_ui_out_list_begin_end (uiout, "features"); + ui_out_emit_list list_emitter (uiout, "features"); uiout->field_string (NULL, "frozen-varobjs"); uiout->field_string (NULL, "pending-breakpoints"); uiout->field_string (NULL, "thread-info"); @@ -1848,7 +1840,6 @@ mi_cmd_list_features (const char *command, char **argv, int argc) if (ext_lang_initialized_p (get_ext_lang_defn (EXT_LANG_PYTHON))) uiout->field_string (NULL, "python"); - do_cleanups (cleanup); return; } @@ -1860,15 +1851,13 @@ mi_cmd_list_target_features (const char *command, char **argv, int argc) { if (argc == 0) { - struct cleanup *cleanup = NULL; struct ui_out *uiout = current_uiout; - cleanup = make_cleanup_ui_out_list_begin_end (uiout, "features"); + ui_out_emit_list list_emitter (uiout, "features"); if (mi_async_p ()) uiout->field_string (NULL, "async"); if (target_can_execute_reverse) uiout->field_string (NULL, "reverse"); - do_cleanups (cleanup); return; } @@ -2787,12 +2776,9 @@ mi_cmd_trace_frame_collected (const char *command, char **argv, int argc) /* Explicitly wholly collected variables. */ { - struct cleanup *list_cleanup; int i; - list_cleanup = make_cleanup_ui_out_list_begin_end (uiout, - "explicit-variables"); - + ui_out_emit_list list_emitter (uiout, "explicit-variables"); const std::vector &wholly_collected = clist->wholly_collected (); for (size_t i = 0; i < wholly_collected.size (); i++) @@ -2800,19 +2786,14 @@ mi_cmd_trace_frame_collected (const char *command, char **argv, int argc) const std::string &str = wholly_collected[i]; print_variable_or_computed (str.c_str (), var_print_values); } - - do_cleanups (list_cleanup); } /* Computed expressions. */ { - struct cleanup *list_cleanup; char *p; int i; - list_cleanup - = make_cleanup_ui_out_list_begin_end (uiout, - "computed-expressions"); + ui_out_emit_list list_emitter (uiout, "computed-expressions"); const std::vector &computed = clist->computed (); for (size_t i = 0; i < computed.size (); i++) @@ -2820,8 +2801,6 @@ mi_cmd_trace_frame_collected (const char *command, char **argv, int argc) const std::string &str = computed[i]; print_variable_or_computed (str.c_str (), comp_print_values); } - - do_cleanups (list_cleanup); } /* Registers. Given pseudo-registers, and that some architectures @@ -2829,13 +2808,12 @@ mi_cmd_trace_frame_collected (const char *command, char **argv, int argc) the trace frame info, but instead consult the register cache for register availability. */ { - struct cleanup *list_cleanup; struct frame_info *frame; struct gdbarch *gdbarch; int regnum; int numregs; - list_cleanup = make_cleanup_ui_out_list_begin_end (uiout, "registers"); + ui_out_emit_list list_emitter (uiout, "registers"); frame = get_selected_frame (NULL); gdbarch = get_frame_arch (frame); @@ -2849,8 +2827,6 @@ mi_cmd_trace_frame_collected (const char *command, char **argv, int argc) output_register (frame, regnum, registers_format, 1); } - - do_cleanups (list_cleanup); } /* Trace state variables. */ diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c index f9e464dfcb6..ea17af77a4a 100644 --- a/gdb/mi/mi-symbol-cmds.c +++ b/gdb/mi/mi-symbol-cmds.c @@ -33,7 +33,6 @@ mi_cmd_symbol_list_lines (const char *command, char **argv, int argc) char *filename; struct symtab *s; int i; - struct cleanup *cleanup_stack; struct ui_out *uiout = current_uiout; if (argc != 1) @@ -50,8 +49,8 @@ mi_cmd_symbol_list_lines (const char *command, char **argv, int argc) need to perform any other sorting. */ gdbarch = get_objfile_arch (SYMTAB_OBJFILE (s)); - cleanup_stack = make_cleanup_ui_out_list_begin_end (uiout, "lines"); + ui_out_emit_list list_emitter (uiout, "lines"); if (SYMTAB_LINETABLE (s) != NULL && SYMTAB_LINETABLE (s)->nitems > 0) for (i = 0; i < SYMTAB_LINETABLE (s)->nitems; i++) { @@ -59,6 +58,4 @@ mi_cmd_symbol_list_lines (const char *command, char **argv, int argc) uiout->field_core_addr ("pc", gdbarch, SYMTAB_LINETABLE (s)->item[i].pc); uiout->field_int ("line", SYMTAB_LINETABLE (s)->item[i].line); } - - do_cleanups (cleanup_stack); } diff --git a/gdb/stack.c b/gdb/stack.c index fa4726448ac..7f8a51caa56 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1196,7 +1196,6 @@ print_frame (struct frame_info *frame, int print_level, { struct gdbarch *gdbarch = get_frame_arch (frame); int numargs; - struct cleanup *args_list_chain; if (gdbarch_frame_num_args_p (gdbarch)) { @@ -1206,20 +1205,20 @@ print_frame (struct frame_info *frame, int print_level, else numargs = -1; - args_list_chain = make_cleanup_ui_out_list_begin_end (uiout, "args"); - TRY - { - print_frame_args (func, frame, numargs, gdb_stdout); - } - CATCH (e, RETURN_MASK_ERROR) - { - } - END_CATCH + { + ui_out_emit_list list_emitter (uiout, "args"); + TRY + { + print_frame_args (func, frame, numargs, gdb_stdout); + } + CATCH (e, RETURN_MASK_ERROR) + { + } + END_CATCH - /* FIXME: ARGS must be a list. If one argument is a string it - will have " that will not be properly escaped. */ - /* Invoke ui_out_tuple_end. */ - do_cleanups (args_list_chain); + /* FIXME: ARGS must be a list. If one argument is a string it + will have " that will not be properly escaped. */ + } QUIT; } uiout->text (")");