+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.
+
2017-08-02 Maciej W. Rozycki <macro@imgtec.com>
* mips-tdep.c (mips_fpu_type_str): New function.
struct ada_tasks_inferior_data *data;
int taskno, nb_tasks;
int taskno_arg = 0;
- struct cleanup *old_chain;
int nb_columns;
if (ada_build_task_list () == 0)
nb_tasks = VEC_length (ada_task_info_s, data->task_list);
nb_columns = uiout->is_mi_like_p () ? 8 : 7;
- old_chain = make_cleanup_ui_out_table_begin_end (uiout, nb_columns,
- nb_tasks, "tasks");
+ ui_out_emit_table table_emitter (uiout, nb_columns, nb_tasks, "tasks");
uiout->table_header (1, ui_left, "current", "");
uiout->table_header (3, ui_right, "id", "ID");
uiout->table_header (9, ui_right, "task-id", "TID");
uiout->text ("\n");
}
-
- do_cleanups (old_chain);
}
/* Print a detailed description of the Ada task whose ID is TASKNO_STR
if (nr_scripts > 0 && pattern == auto_load_info_scripts_pattern_nl)
uiout->text ("\n");
- /* Note: This creates a cleanup to output the table end marker. */
- make_cleanup_ui_out_table_begin_end (uiout, 2, nr_scripts,
- "AutoLoadedScriptsTable");
+ {
+ ui_out_emit_table table_emitter (uiout, 2, nr_scripts,
+ "AutoLoadedScriptsTable");
- uiout->table_header (7, ui_left, "loaded", "Loaded");
- uiout->table_header (70, ui_left, "script", "Script");
- uiout->table_body ();
+ uiout->table_header (7, ui_left, "loaded", "Loaded");
+ uiout->table_header (70, ui_left, "script", "Script");
+ uiout->table_body ();
- print_scripts (script_files);
- print_scripts (script_texts);
+ print_scripts (script_files);
+ print_scripts (script_texts);
+ }
- /* Finish up the table before checking for no matching scripts. */
do_cleanups (script_chain);
if (nr_scripts == 0)
struct breakpoint *b;
struct bp_location *last_loc = NULL;
int nr_printable_breakpoints;
- struct cleanup *bkpttbl_chain;
struct value_print_options opts;
int print_address_bits = 0;
int print_type_col_width = 14;
}
}
- if (opts.addressprint)
- bkpttbl_chain
- = make_cleanup_ui_out_table_begin_end (uiout, 6,
- nr_printable_breakpoints,
- "BreakpointTable");
- else
- bkpttbl_chain
- = make_cleanup_ui_out_table_begin_end (uiout, 5,
- nr_printable_breakpoints,
- "BreakpointTable");
-
- if (nr_printable_breakpoints > 0)
- annotate_breakpoints_headers ();
- if (nr_printable_breakpoints > 0)
- annotate_field (0);
- uiout->table_header (7, ui_left, "number", "Num"); /* 1 */
- if (nr_printable_breakpoints > 0)
- annotate_field (1);
- uiout->table_header (print_type_col_width, ui_left, "type", "Type"); /* 2 */
- if (nr_printable_breakpoints > 0)
- annotate_field (2);
- uiout->table_header (4, ui_left, "disp", "Disp"); /* 3 */
- if (nr_printable_breakpoints > 0)
- annotate_field (3);
- uiout->table_header (3, ui_left, "enabled", "Enb"); /* 4 */
- if (opts.addressprint)
- {
- if (nr_printable_breakpoints > 0)
- annotate_field (4);
- if (print_address_bits <= 32)
- uiout->table_header (10, ui_left, "addr", "Address"); /* 5 */
- else
- uiout->table_header (18, ui_left, "addr", "Address"); /* 5 */
- }
- if (nr_printable_breakpoints > 0)
- annotate_field (5);
- uiout->table_header (40, ui_noalign, "what", "What"); /* 6 */
- uiout->table_body ();
- if (nr_printable_breakpoints > 0)
- annotate_breakpoints_table ();
-
- ALL_BREAKPOINTS (b)
- {
- QUIT;
- /* If we have a filter, only list the breakpoints it accepts. */
- if (filter && !filter (b))
- continue;
+ {
+ ui_out_emit_table table_emitter (uiout,
+ opts.addressprint ? 6 : 5,
+ nr_printable_breakpoints,
+ "BreakpointTable");
+
+ if (nr_printable_breakpoints > 0)
+ annotate_breakpoints_headers ();
+ if (nr_printable_breakpoints > 0)
+ annotate_field (0);
+ uiout->table_header (7, ui_left, "number", "Num"); /* 1 */
+ if (nr_printable_breakpoints > 0)
+ annotate_field (1);
+ uiout->table_header (print_type_col_width, ui_left, "type", "Type"); /* 2 */
+ if (nr_printable_breakpoints > 0)
+ annotate_field (2);
+ uiout->table_header (4, ui_left, "disp", "Disp"); /* 3 */
+ if (nr_printable_breakpoints > 0)
+ annotate_field (3);
+ uiout->table_header (3, ui_left, "enabled", "Enb"); /* 4 */
+ if (opts.addressprint)
+ {
+ if (nr_printable_breakpoints > 0)
+ annotate_field (4);
+ if (print_address_bits <= 32)
+ uiout->table_header (10, ui_left, "addr", "Address"); /* 5 */
+ else
+ uiout->table_header (18, ui_left, "addr", "Address"); /* 5 */
+ }
+ if (nr_printable_breakpoints > 0)
+ annotate_field (5);
+ uiout->table_header (40, ui_noalign, "what", "What"); /* 6 */
+ uiout->table_body ();
+ if (nr_printable_breakpoints > 0)
+ annotate_breakpoints_table ();
+
+ ALL_BREAKPOINTS (b)
+ {
+ QUIT;
+ /* If we have a filter, only list the breakpoints it accepts. */
+ if (filter && !filter (b))
+ continue;
- /* If we have an "args" string, it is a list of breakpoints to
- accept. Skip the others. */
+ /* If we have an "args" string, it is a list of breakpoints to
+ accept. Skip the others. */
- if (args != NULL && *args != '\0')
- {
- if (allflag) /* maintenance info breakpoint */
- {
- if (parse_and_eval_long (args) != b->number)
- continue;
- }
- else /* all others */
- {
- if (!number_is_in_list (args, b->number))
- continue;
- }
- }
- /* We only print out user settable breakpoints unless the
- allflag is set. */
- if (allflag || user_breakpoint_p (b))
- print_one_breakpoint (b, &last_loc, allflag);
- }
-
- do_cleanups (bkpttbl_chain);
+ if (args != NULL && *args != '\0')
+ {
+ if (allflag) /* maintenance info breakpoint */
+ {
+ if (parse_and_eval_long (args) != b->number)
+ continue;
+ }
+ else /* all others */
+ {
+ if (!number_is_in_list (args, b->number))
+ continue;
+ }
+ }
+ /* We only print out user settable breakpoints unless the
+ allflag is set. */
+ if (allflag || user_breakpoint_p (b))
+ print_one_breakpoint (b, &last_loc, allflag);
+ }
+ }
if (nr_printable_breakpoints == 0)
{
static void
maintenance_info_bfds (char *arg, int from_tty)
{
- struct cleanup *cleanup;
struct ui_out *uiout = current_uiout;
- cleanup = make_cleanup_ui_out_table_begin_end (uiout, 3, -1, "bfds");
+ ui_out_emit_table table_emitter (uiout, 3, -1, "bfds");
uiout->table_header (10, ui_left, "refcount", "Refcount");
uiout->table_header (18, ui_left, "addr", "Address");
uiout->table_header (40, ui_left, "filename", "Filename");
uiout->table_body ();
htab_traverse (all_bfds, print_one_bfd, uiout);
-
- do_cleanups (cleanup);
}
/* -Wmissing-prototypes */
print_inferior (struct ui_out *uiout, char *requested_inferiors)
{
struct inferior *inf;
- struct cleanup *old_chain;
int inf_count = 0;
/* Compute number of inferiors we will print. */
return;
}
- old_chain = make_cleanup_ui_out_table_begin_end (uiout, 4, inf_count,
- "inferiors");
+ ui_out_emit_table table_emitter (uiout, 4, inf_count, "inferiors");
uiout->table_header (1, ui_left, "current", "");
uiout->table_header (4, ui_left, "number", "Num");
uiout->table_header (17, ui_left, "target-id", "Description");
uiout->text ("\n");
}
-
- do_cleanups (old_chain);
}
static void
if (info_count > 0 && args == auto_load_info_scripts_pattern_nl)
uiout->text ("\n");
- make_cleanup_ui_out_table_begin_end (uiout, 2, unique_filenames,
- "LinuxThreadDbTable");
+ {
+ ui_out_emit_table table_emitter (uiout, 2, unique_filenames,
+ "LinuxThreadDbTable");
- uiout->table_header (max_filename_len, ui_left, "filename", "Filename");
- uiout->table_header (pids_len, ui_left, "PIDs", "Pids");
- uiout->table_body ();
+ uiout->table_header (max_filename_len, ui_left, "filename", "Filename");
+ uiout->table_header (pids_len, ui_left, "PIDs", "Pids");
+ uiout->table_body ();
- pids = (char *) xmalloc (max_pids_len + 1);
- make_cleanup (xfree, pids);
+ pids = (char *) xmalloc (max_pids_len + 1);
+ make_cleanup (xfree, pids);
- /* Note I is incremented inside the cycle, not at its end. */
- for (i = 0; i < info_count;)
- {
- ui_out_emit_tuple tuple_emitter (uiout, NULL);
- char *pids_end;
-
- info = array[i];
- uiout->field_string ("filename", info->filename);
- pids_end = pids;
+ /* Note I is incremented inside the cycle, not at its end. */
+ for (i = 0; i < info_count;)
+ {
+ ui_out_emit_tuple tuple_emitter (uiout, NULL);
+ char *pids_end;
- while (i < info_count && strcmp (info->filename, array[i]->filename) == 0)
- {
- if (pids_end != pids)
- {
- *pids_end++ = ',';
- *pids_end++ = ' ';
- }
- pids_end += xsnprintf (pids_end, &pids[max_pids_len + 1] - pids_end,
- "%u", array[i]->pid);
- gdb_assert (pids_end < &pids[max_pids_len + 1]);
+ info = array[i];
+ uiout->field_string ("filename", info->filename);
+ pids_end = pids;
- i++;
- }
- *pids_end = '\0';
+ while (i < info_count && strcmp (info->filename,
+ array[i]->filename) == 0)
+ {
+ if (pids_end != pids)
+ {
+ *pids_end++ = ',';
+ *pids_end++ = ' ';
+ }
+ pids_end += xsnprintf (pids_end,
+ &pids[max_pids_len + 1] - pids_end,
+ "%u", array[i]->pid);
+ gdb_assert (pids_end < &pids[max_pids_len + 1]);
+
+ i++;
+ }
+ *pids_end = '\0';
- uiout->field_string ("pids", pids);
+ uiout->field_string ("pids", pids);
- uiout->text ("\n");
- }
+ uiout->text ("\n");
+ }
+ }
do_cleanups (back_to);
exceptions = ada_exceptions_list (regexp);
old_chain = make_cleanup (VEC_cleanup (ada_exc_info), &exceptions);
- make_cleanup_ui_out_table_begin_end
- (uiout, 2, VEC_length (ada_exc_info, exceptions), "ada-exceptions");
+ ui_out_emit_table table_emitter (uiout, 2,
+ VEC_length (ada_exc_info, exceptions),
+ "ada-exceptions");
uiout->table_header (1, ui_left, "name", "Name");
uiout->table_header (1, ui_left, "address", "Address");
uiout->table_body ();
}
}
- make_cleanup_ui_out_table_begin_end (uiout, ncols, nrows,
- "OSDataTable");
+ ui_out_emit_table table_emitter (uiout, ncols, nrows, "OSDataTable");
/* With no columns/items, we just output an empty table, but we
still output the table. This matters for MI. */
{
struct program_space *pspace;
int count = 0;
- struct cleanup *old_chain;
/* Compute number of pspaces we will print. */
ALL_PSPACES (pspace)
/* There should always be at least one. */
gdb_assert (count > 0);
- old_chain = make_cleanup_ui_out_table_begin_end (uiout, 3, count, "pspaces");
+ ui_out_emit_table table_emitter (uiout, 3, count, "pspaces");
uiout->table_header (1, ui_left, "current", "");
uiout->table_header (4, ui_left, "id", "Id");
uiout->table_header (17, ui_left, "exec", "Executable");
uiout->text ("\n");
}
-
- do_cleanups (old_chain);
}
/* Boolean test for an already-known program space id. */
struct skiplist_entry *e;
int num_printable_entries = 0;
struct value_print_options opts;
- struct cleanup *tbl_chain;
get_user_print_options (&opts);
return;
}
- tbl_chain = make_cleanup_ui_out_table_begin_end (current_uiout, 6,
- num_printable_entries,
- "SkiplistTable");
+ ui_out_emit_table table_emitter (current_uiout, 6, num_printable_entries,
+ "SkiplistTable");
current_uiout->table_header (5, ui_left, "number", "Num"); /* 1 */
current_uiout->table_header (3, ui_left, "enabled", "Enb"); /* 2 */
current_uiout->text ("\n");
}
-
- do_cleanups (tbl_chain);
}
static void
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;
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)
{
}
}
- 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)
{
struct trace_state_variable *tsv;
int ix;
int count = 0;
- struct cleanup *back_to;
struct ui_out *uiout = current_uiout;
if (VEC_length (tsv_s, tvariables) == 0 && !uiout->is_mi_like_p ())
tsv->value_known = target_get_trace_state_variable_value (tsv->number,
&(tsv->value));
- back_to = make_cleanup_ui_out_table_begin_end (uiout, 3,
- count, "trace-variables");
+ ui_out_emit_table table_emitter (uiout, 3, count, "trace-variables");
uiout->table_header (15, ui_left, "name", "Name");
uiout->table_header (11, ui_left, "initial", "Initial");
uiout->table_header (11, ui_left, "current", "Current");
uiout->field_string ("current", c);
uiout->text ("\n");
}
-
- do_cleanups (back_to);
}
/* List all the trace state variables. */
don't work without in-process agent, so we don't bother users to type
`set agent on' when to use static tracepoint. */
- old_chain
- = make_cleanup_ui_out_table_begin_end (uiout, 5, -1,
- "StaticTracepointMarkersTable");
+ ui_out_emit_table table_emitter (uiout, 5, -1,
+ "StaticTracepointMarkersTable");
uiout->table_header (7, ui_left, "counter", "Cnt");
uiout->table_body ();
markers = target_static_tracepoint_markers_by_strid (NULL);
- make_cleanup (VEC_cleanup (static_tracepoint_marker_p), &markers);
+ old_chain = make_cleanup (VEC_cleanup (static_tracepoint_marker_p), &markers);
for (i = 0;
VEC_iterate (static_tracepoint_marker_p,
typedef ui_out_emit_type<ui_out_type_tuple> ui_out_emit_tuple;
typedef ui_out_emit_type<ui_out_type_list> ui_out_emit_list;
+/* This is similar to make_cleanup_ui_out_table_begin_end, but written
+ as an RAII class. */
+class ui_out_emit_table
+{
+public:
+
+ ui_out_emit_table (struct ui_out *uiout, int nr_cols, int nr_rows,
+ const char *tblid)
+ : m_uiout (uiout)
+ {
+ m_uiout->table_begin (nr_cols, nr_rows, tblid);
+ }
+
+ ~ui_out_emit_table ()
+ {
+ m_uiout->table_end ();
+ }
+
+ ui_out_emit_table (const ui_out_emit_table &) = delete;
+ ui_out_emit_table &operator= (const ui_out_emit_table &) = delete;
+
+private:
+
+ struct ui_out *m_uiout;
+};
+
#endif /* UI_OUT_H */