From 4a2b031d5452226cf7894f313b3aac603f7ec5fb Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sun, 23 Apr 2017 10:21:50 -0600 Subject: Introduce and use ui_out_emit_table This introduces ui_out_emit_table, similar to the other existing ui_out RAII classes, and then uses it in a number of places. This replaces some cleanups. ChangeLog 2017-08-03 Tom Tromey * tracepoint.c (tvariables_info_1): Use ui_out_emit_table. (info_static_tracepoint_markers_command): Likewise. * solib.c (info_sharedlibrary_command): Use ui_out_emit_table. * skip.c (skip_info): Use ui_out_emit_table. * progspace.c (print_program_space): Use ui_out_emit_table. * osdata.c (info_osdata): Use ui_out_emit_table. * mi/mi-cmd-info.c (mi_cmd_info_ada_exceptions): Use ui_out_emit_table. * linux-thread-db.c (info_auto_load_libthread_db): Use ui_out_emit_table. * inferior.c (print_inferior): Use ui_out_emit_table. * gdb_bfd.c (maintenance_info_bfds): Use ui_out_emit_table. * breakpoint.c (breakpoint_1): Use ui_out_emit_table. * auto-load.c (auto_load_info_scripts): Use ui_out_emit_table. * ada-tasks.c (print_ada_task_info): Use ui_out_emit_table. * ui-out.h (class ui_out_emit_table): New. --- gdb/solib.c | 93 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 45 insertions(+), 48 deletions(-) (limited to 'gdb/solib.c') diff --git a/gdb/solib.c b/gdb/solib.c index 788cf15..5b538eb 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -1045,7 +1045,6 @@ info_sharedlibrary_command (char *pattern, int from_tty) int so_missing_debug_info = 0; int addr_width; int nr_libs; - struct cleanup *table_cleanup; struct gdbarch *gdbarch = target_gdbarch (); struct ui_out *uiout = current_uiout; @@ -1062,8 +1061,8 @@ info_sharedlibrary_command (char *pattern, int from_tty) update_solib_list (from_tty); - /* make_cleanup_ui_out_table_begin_end needs to know the number of - rows, so we need to make two passes over the libs. */ + /* ui_out_emit_table table_emitter needs to know the number of rows, + so we need to make two passes over the libs. */ for (nr_libs = 0, so = so_list_head; so; so = so->next) { @@ -1075,54 +1074,52 @@ info_sharedlibrary_command (char *pattern, int from_tty) } } - table_cleanup = - make_cleanup_ui_out_table_begin_end (uiout, 4, nr_libs, - "SharedLibraryTable"); - - /* The "- 1" is because ui_out adds one space between columns. */ - uiout->table_header (addr_width - 1, ui_left, "from", "From"); - uiout->table_header (addr_width - 1, ui_left, "to", "To"); - uiout->table_header (12 - 1, ui_left, "syms-read", "Syms Read"); - uiout->table_header (0, ui_noalign, "name", "Shared Object Library"); - - uiout->table_body (); - - ALL_SO_LIBS (so) - { - if (! so->so_name[0]) - continue; - if (pattern && ! re_exec (so->so_name)) - continue; - - ui_out_emit_tuple tuple_emitter (uiout, "lib"); - - if (so->addr_high != 0) - { - uiout->field_core_addr ("from", gdbarch, so->addr_low); - uiout->field_core_addr ("to", gdbarch, so->addr_high); - } - else - { - uiout->field_skip ("from"); - uiout->field_skip ("to"); - } - - if (! interp_ui_out (top_level_interpreter ())->is_mi_like_p () - && so->symbols_loaded - && !objfile_has_symbols (so->objfile)) - { - so_missing_debug_info = 1; - uiout->field_string ("syms-read", "Yes (*)"); - } - else - uiout->field_string ("syms-read", so->symbols_loaded ? "Yes" : "No"); + { + ui_out_emit_table table_emitter (uiout, 4, nr_libs, "SharedLibraryTable"); - uiout->field_string ("name", so->so_name); + /* The "- 1" is because ui_out adds one space between columns. */ + uiout->table_header (addr_width - 1, ui_left, "from", "From"); + uiout->table_header (addr_width - 1, ui_left, "to", "To"); + uiout->table_header (12 - 1, ui_left, "syms-read", "Syms Read"); + uiout->table_header (0, ui_noalign, "name", "Shared Object Library"); - uiout->text ("\n"); - } + uiout->table_body (); - do_cleanups (table_cleanup); + ALL_SO_LIBS (so) + { + if (! so->so_name[0]) + continue; + if (pattern && ! re_exec (so->so_name)) + continue; + + ui_out_emit_tuple tuple_emitter (uiout, "lib"); + + if (so->addr_high != 0) + { + uiout->field_core_addr ("from", gdbarch, so->addr_low); + uiout->field_core_addr ("to", gdbarch, so->addr_high); + } + else + { + uiout->field_skip ("from"); + uiout->field_skip ("to"); + } + + if (! interp_ui_out (top_level_interpreter ())->is_mi_like_p () + && so->symbols_loaded + && !objfile_has_symbols (so->objfile)) + { + so_missing_debug_info = 1; + uiout->field_string ("syms-read", "Yes (*)"); + } + else + uiout->field_string ("syms-read", so->symbols_loaded ? "Yes" : "No"); + + uiout->field_string ("name", so->so_name); + + uiout->text ("\n"); + } + } if (nr_libs == 0) { -- cgit v1.1