+2017-09-09 Tom Tromey <tom@tromey.com>
+
+ * ui-out.h (make_cleanup_ui_out_table_begin_end): Remove.
+ (class ui_out_emit_table): Update comment.
+ * ui-out.c (do_cleanup_table_end)
+ (make_cleanup_ui_out_table_begin_end): Remove.
+ * spu-tdep.c (info_spu_mailbox_list): Use ui_out_emit_table.
+ (info_spu_dma_cmdlist): Likewise.
+ * probe.c (info_probes_for_ops): Use ui_out_emit_table.
+ * darwin-nat-info.c (darwin_debug_regions_recurse): Use
+ ui_out_emit_table.
+
2017-09-09 Tom Tromey <tom@tromey.com>
* thread.c (print_thread_info_1): Use ui_out_emit_table,
vm_region_submap_short_info_data_64_t r_info;
kern_return_t kret;
int ret;
- struct cleanup *table_chain;
struct ui_out *uiout = current_uiout;
- table_chain = make_cleanup_ui_out_table_begin_end (uiout, 9, -1, "regions");
+ ui_out_emit_table table_emitter (uiout, 9, -1, "regions");
if (gdbarch_addr_bit (target_gdbarch ()) <= 32)
{
while (1)
{
const char *tag;
- struct cleanup *row_chain;
r_info_size = VM_REGION_SUBMAP_SHORT_INFO_COUNT_64;
r_size = -1;
&r_info_size);
if (kret != KERN_SUCCESS)
break;
- row_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "regions-row");
-
- uiout->field_core_addr ("start", target_gdbarch (), r_start);
- uiout->field_core_addr ("end", target_gdbarch (), r_start + r_size);
- uiout->field_string ("min-prot",
- unparse_protection (r_info.protection));
- uiout->field_string ("max-prot",
- unparse_protection (r_info.max_protection));
- uiout->field_string ("inheritence",
- unparse_inheritance (r_info.inheritance));
- uiout->field_string ("share-mode",
- unparse_share_mode (r_info.share_mode));
- uiout->field_int ("depth", r_depth);
- uiout->field_string ("submap",
- r_info.is_submap ? _("sm ") : _("obj"));
- tag = unparse_user_tag (r_info.user_tag);
- if (tag)
- uiout->field_string ("tag", tag);
- else
- uiout->field_int ("tag", r_info.user_tag);
- do_cleanups (row_chain);
+ {
+ ui_out_emit_tuple tuple_emitter (uiout, "regions-row");
+
+ uiout->field_core_addr ("start", target_gdbarch (), r_start);
+ uiout->field_core_addr ("end", target_gdbarch (), r_start + r_size);
+ uiout->field_string ("min-prot",
+ unparse_protection (r_info.protection));
+ uiout->field_string ("max-prot",
+ unparse_protection (r_info.max_protection));
+ uiout->field_string ("inheritence",
+ unparse_inheritance (r_info.inheritance));
+ uiout->field_string ("share-mode",
+ unparse_share_mode (r_info.share_mode));
+ uiout->field_int ("depth", r_depth);
+ uiout->field_string ("submap",
+ r_info.is_submap ? _("sm ") : _("obj"));
+ tag = unparse_user_tag (r_info.user_tag);
+ if (tag)
+ uiout->field_string ("tag", tag);
+ else
+ uiout->field_int ("tag", r_info.user_tag);
+ }
if (!uiout->is_mi_like_p ())
uiout->text ("\n");
else
r_start += r_size;
}
- do_cleanups (table_chain);
-
}
else
ui_out_extra_fields = get_number_extra_fields (pops);
- make_cleanup_ui_out_table_begin_end (current_uiout,
- 5 + ui_out_extra_fields,
- VEC_length (bound_probe_s, probes),
- "StaticProbes");
-
- if (!VEC_empty (bound_probe_s, probes))
- qsort (VEC_address (bound_probe_s, probes),
- VEC_length (bound_probe_s, probes),
- sizeof (bound_probe_s), compare_probes);
-
- /* What's the size of an address in our architecture? */
- size_addr = gdbarch_addr_bit (gdbarch) == 64 ? 18 : 10;
-
- /* Determining the maximum size of each field (`type', `provider',
- `name' and `objname'). */
- for (i = 0; VEC_iterate (bound_probe_s, probes, i, probe); ++i)
- {
- const char *probe_type = probe->probe->pops->type_name (probe->probe);
-
- size_type = std::max (strlen (probe_type), size_type);
- size_name = std::max (strlen (probe->probe->name), size_name);
- size_provider = std::max (strlen (probe->probe->provider), size_provider);
- size_objname = std::max (strlen (objfile_name (probe->objfile)),
- size_objname);
- }
-
- current_uiout->table_header (size_type, ui_left, "type", _("Type"));
- current_uiout->table_header (size_provider, ui_left, "provider",
- _("Provider"));
- current_uiout->table_header (size_name, ui_left, "name", _("Name"));
- current_uiout->table_header (size_addr, ui_left, "addr", _("Where"));
-
- if (pops == NULL)
- {
- const struct probe_ops *po;
- int ix;
-
- /* We have to generate the table header for each new probe type
- that we will print. Note that this excludes probe types not
- having any defined probe with the search criteria. */
- for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, po); ++ix)
- if (exists_probe_with_pops (probes, po))
- gen_ui_out_table_header_info (probes, po);
- }
- else
- gen_ui_out_table_header_info (probes, pops);
-
- current_uiout->table_header (size_objname, ui_left, "object", _("Object"));
- current_uiout->table_body ();
-
- for (i = 0; VEC_iterate (bound_probe_s, probes, i, probe); ++i)
- {
- const char *probe_type = probe->probe->pops->type_name (probe->probe);
-
- ui_out_emit_tuple tuple_emitter (current_uiout, "probe");
-
- current_uiout->field_string ("type",probe_type);
- current_uiout->field_string ("provider", probe->probe->provider);
- current_uiout->field_string ("name", probe->probe->name);
- current_uiout->field_core_addr (
- "addr", probe->probe->arch,
- get_probe_address (probe->probe, probe->objfile));
-
- if (pops == NULL)
- {
- const struct probe_ops *po;
- int ix;
-
- for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, po);
- ++ix)
- if (probe->probe->pops == po)
- print_ui_out_info (probe->probe);
- else if (exists_probe_with_pops (probes, po))
- print_ui_out_not_applicables (po);
- }
- else
- print_ui_out_info (probe->probe);
-
- current_uiout->field_string ("object",
- objfile_name (probe->objfile));
- current_uiout->text ("\n");
- }
-
- any_found = !VEC_empty (bound_probe_s, probes);
+ {
+ ui_out_emit_table table_emitter (current_uiout,
+ 5 + ui_out_extra_fields,
+ VEC_length (bound_probe_s, probes),
+ "StaticProbes");
+
+ if (!VEC_empty (bound_probe_s, probes))
+ qsort (VEC_address (bound_probe_s, probes),
+ VEC_length (bound_probe_s, probes),
+ sizeof (bound_probe_s), compare_probes);
+
+ /* What's the size of an address in our architecture? */
+ size_addr = gdbarch_addr_bit (gdbarch) == 64 ? 18 : 10;
+
+ /* Determining the maximum size of each field (`type', `provider',
+ `name' and `objname'). */
+ for (i = 0; VEC_iterate (bound_probe_s, probes, i, probe); ++i)
+ {
+ const char *probe_type = probe->probe->pops->type_name (probe->probe);
+
+ size_type = std::max (strlen (probe_type), size_type);
+ size_name = std::max (strlen (probe->probe->name), size_name);
+ size_provider = std::max (strlen (probe->probe->provider), size_provider);
+ size_objname = std::max (strlen (objfile_name (probe->objfile)),
+ size_objname);
+ }
+
+ current_uiout->table_header (size_type, ui_left, "type", _("Type"));
+ current_uiout->table_header (size_provider, ui_left, "provider",
+ _("Provider"));
+ current_uiout->table_header (size_name, ui_left, "name", _("Name"));
+ current_uiout->table_header (size_addr, ui_left, "addr", _("Where"));
+
+ if (pops == NULL)
+ {
+ const struct probe_ops *po;
+ int ix;
+
+ /* We have to generate the table header for each new probe type
+ that we will print. Note that this excludes probe types not
+ having any defined probe with the search criteria. */
+ for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, po); ++ix)
+ if (exists_probe_with_pops (probes, po))
+ gen_ui_out_table_header_info (probes, po);
+ }
+ else
+ gen_ui_out_table_header_info (probes, pops);
+
+ current_uiout->table_header (size_objname, ui_left, "object", _("Object"));
+ current_uiout->table_body ();
+
+ for (i = 0; VEC_iterate (bound_probe_s, probes, i, probe); ++i)
+ {
+ const char *probe_type = probe->probe->pops->type_name (probe->probe);
+
+ ui_out_emit_tuple tuple_emitter (current_uiout, "probe");
+
+ current_uiout->field_string ("type",probe_type);
+ current_uiout->field_string ("provider", probe->probe->provider);
+ current_uiout->field_string ("name", probe->probe->name);
+ current_uiout->field_core_addr (
+ "addr", probe->probe->arch,
+ get_probe_address (probe->probe, probe->objfile));
+
+ if (pops == NULL)
+ {
+ const struct probe_ops *po;
+ int ix;
+
+ for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, po);
+ ++ix)
+ if (probe->probe->pops == po)
+ print_ui_out_info (probe->probe);
+ else if (exists_probe_with_pops (probes, po))
+ print_ui_out_not_applicables (po);
+ }
+ else
+ print_ui_out_info (probe->probe);
+
+ current_uiout->field_string ("object",
+ objfile_name (probe->objfile));
+ current_uiout->text ("\n");
+ }
+
+ any_found = !VEC_empty (bound_probe_s, probes);
+ }
do_cleanups (cleanup);
if (!any_found)
info_spu_mailbox_list (gdb_byte *buf, int nr, enum bfd_endian byte_order,
const char *field, const char *msg)
{
- struct cleanup *chain;
int i;
if (nr <= 0)
return;
- chain = make_cleanup_ui_out_table_begin_end (current_uiout, 1, nr, "mbox");
+ ui_out_emit_table table_emitter (current_uiout, 1, nr, "mbox");
current_uiout->table_header (32, ui_left, field, msg);
current_uiout->table_body ();
for (i = 0; i < nr; i++)
{
- struct cleanup *val_chain;
- ULONGEST val;
- val_chain = make_cleanup_ui_out_tuple_begin_end (current_uiout, "mbox");
- val = extract_unsigned_integer (buf + 4*i, 4, byte_order);
- current_uiout->field_fmt (field, "0x%s", phex (val, 4));
- do_cleanups (val_chain);
+ {
+ ULONGEST val;
+ ui_out_emit_tuple tuple_emitter (current_uiout, "mbox");
+ val = extract_unsigned_integer (buf + 4*i, 4, byte_order);
+ current_uiout->field_fmt (field, "0x%s", phex (val, 4));
+ }
if (!current_uiout->is_mi_like_p ())
printf_filtered ("\n");
}
-
- do_cleanups (chain);
}
static void
int *seq = XALLOCAVEC (int, nr);
int done = 0;
- struct cleanup *chain;
int i, j;
nr = i;
- chain = make_cleanup_ui_out_table_begin_end (current_uiout, 10, nr,
- "dma_cmd");
+ ui_out_emit_table table_emitter (current_uiout, 10, nr, "dma_cmd");
current_uiout->table_header (7, ui_left, "opcode", "Opcode");
current_uiout->table_header (3, ui_left, "tag", "Tag");
for (i = 0; i < nr; i++)
{
- struct cleanup *cmd_chain;
ULONGEST mfc_cq_dw0;
ULONGEST mfc_cq_dw1;
ULONGEST mfc_cq_dw2;
ea_valid_p = spu_mfc_get_bitfield (mfc_cq_dw2, 39, 39);
cmd_error_p = spu_mfc_get_bitfield (mfc_cq_dw2, 40, 40);
- cmd_chain = make_cleanup_ui_out_tuple_begin_end (current_uiout, "cmd");
-
- if (spu_mfc_opcode[mfc_cmd_opcode])
- current_uiout->field_string ("opcode", spu_mfc_opcode[mfc_cmd_opcode]);
- else
- current_uiout->field_int ("opcode", mfc_cmd_opcode);
+ {
+ ui_out_emit_tuple tuple_emitter (current_uiout, "cmd");
- current_uiout->field_int ("tag", mfc_cmd_tag);
- current_uiout->field_int ("tid", tclass_id);
- current_uiout->field_int ("rid", rclass_id);
+ if (spu_mfc_opcode[mfc_cmd_opcode])
+ current_uiout->field_string ("opcode", spu_mfc_opcode[mfc_cmd_opcode]);
+ else
+ current_uiout->field_int ("opcode", mfc_cmd_opcode);
- if (ea_valid_p)
- current_uiout->field_fmt ("ea", "0x%s", phex (mfc_ea, 8));
- else
- current_uiout->field_skip ("ea");
+ current_uiout->field_int ("tag", mfc_cmd_tag);
+ current_uiout->field_int ("tid", tclass_id);
+ current_uiout->field_int ("rid", rclass_id);
- current_uiout->field_fmt ("lsa", "0x%05x", mfc_lsa << 4);
- if (qw_valid_p)
- current_uiout->field_fmt ("size", "0x%05x", mfc_size << 4);
- else
- current_uiout->field_fmt ("size", "0x%05x", mfc_size);
+ if (ea_valid_p)
+ current_uiout->field_fmt ("ea", "0x%s", phex (mfc_ea, 8));
+ else
+ current_uiout->field_skip ("ea");
- if (list_valid_p)
- {
- current_uiout->field_fmt ("lstaddr", "0x%05x", list_lsa << 3);
- current_uiout->field_fmt ("lstsize", "0x%05x", list_size << 3);
- }
- else
- {
- current_uiout->field_skip ("lstaddr");
- current_uiout->field_skip ("lstsize");
- }
+ current_uiout->field_fmt ("lsa", "0x%05x", mfc_lsa << 4);
+ if (qw_valid_p)
+ current_uiout->field_fmt ("size", "0x%05x", mfc_size << 4);
+ else
+ current_uiout->field_fmt ("size", "0x%05x", mfc_size);
- if (cmd_error_p)
- current_uiout->field_string ("error_p", "*");
- else
- current_uiout->field_skip ("error_p");
+ if (list_valid_p)
+ {
+ current_uiout->field_fmt ("lstaddr", "0x%05x", list_lsa << 3);
+ current_uiout->field_fmt ("lstsize", "0x%05x", list_size << 3);
+ }
+ else
+ {
+ current_uiout->field_skip ("lstaddr");
+ current_uiout->field_skip ("lstsize");
+ }
- do_cleanups (cmd_chain);
+ if (cmd_error_p)
+ current_uiout->field_string ("error_p", "*");
+ else
+ current_uiout->field_skip ("error_p");
+ }
if (!current_uiout->is_mi_like_p ())
printf_filtered ("\n");
}
-
- do_cleanups (chain);
}
static void
m_table_up = nullptr;
}
-static void
-do_cleanup_table_end (void *data)
-{
- ui_out *uiout = (ui_out *) data;
-
- uiout->table_end ();
-}
-
-struct cleanup *
-make_cleanup_ui_out_table_begin_end (ui_out *uiout, int nr_cols, int nr_rows,
- const char *tblid)
-{
- uiout->table_begin (nr_cols, nr_rows, tblid);
- return make_cleanup (do_cleanup_table_end, uiout);
-}
-
void
ui_out::begin (ui_out_type type, const char *id)
{
ui_out_type_list
};
-extern struct cleanup *make_cleanup_ui_out_table_begin_end (struct ui_out *ui_out,
- int nr_cols,
- int nr_rows,
- const char *tblid);
/* Compatibility wrappers. */
extern struct cleanup *make_cleanup_ui_out_list_begin_end (struct ui_out *uiout,
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. */
+/* Start a new table on construction, and end the table on
+ destruction. */
class ui_out_emit_table
{
public: