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

	* 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.
This commit is contained in:
Tom Tromey 2017-04-23 10:21:50 -06:00
parent fd9770d81f
commit 4a2b031d54
14 changed files with 204 additions and 188 deletions

View file

@ -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");
{
ui_out_emit_table table_emitter (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");
/* 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 ();
uiout->table_body ();
ALL_SO_LIBS (so)
{
if (! so->so_name[0])
continue;
if (pattern && ! re_exec (so->so_name))
continue;
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");
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 (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");
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->field_string ("name", so->so_name);
uiout->text ("\n");
}
do_cleanups (table_cleanup);
uiout->text ("\n");
}
}
if (nr_libs == 0)
{