void info_osdata (const char *type) { struct ui_out *uiout = current_uiout; struct osdata_item *last = NULL; int ncols = 0; int col_to_skip = -1; if (type == NULL) type = ""; std::unique_ptr<osdata> osdata = get_osdata (type); int nrows = osdata->items.size (); if (*type == '\0' && nrows == 0) error (_("Available types of OS data not reported.")); if (!osdata->items.empty ()) { last = &osdata->items.back (); ncols = last->columns.size (); /* As a special case, scan the listing of available data types for a column named "Title", and only include it with MI output; this column's normal use is for titles for interface elements like menus, and it clutters up CLI output. */ if (*type == '\0' && !uiout->is_mi_like_p ()) { for (int ix = 0; ix < last->columns.size (); ix++) { if (last->columns[ix].name == "Title") col_to_skip = ix; } /* Be sure to reduce the total column count, otherwise internal errors ensue. */ if (col_to_skip >= 0) --ncols; } } 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. */ if (ncols == 0) return; if (last != NULL && !last->columns.empty ()) { for (int ix = 0; ix < last->columns.size (); ix++) { char col_name[32]; if (ix == col_to_skip) continue; snprintf (col_name, 32, "col%d", ix); uiout->table_header (10, ui_left, col_name, last->columns[ix].name.c_str ()); } } uiout->table_body (); if (nrows != 0) { for (const osdata_item &item : osdata->items) { { ui_out_emit_tuple tuple_emitter (uiout, "item"); for (int ix_cols = 0; ix_cols < item.columns.size (); ix_cols++) { char col_name[32]; if (ix_cols == col_to_skip) continue; snprintf (col_name, 32, "col%d", ix_cols); uiout->field_string (col_name, item.columns[ix_cols].value.c_str ()); } } uiout->text ("\n"); } } }
static void darwin_debug_regions_recurse (task_t task) { mach_vm_address_t r_addr; mach_vm_address_t r_start; mach_vm_size_t r_size; natural_t r_depth; mach_msg_type_number_t r_info_size; vm_region_submap_short_info_data_64_t r_info; kern_return_t kret; int ret; struct ui_out *uiout = current_uiout; ui_out_emit_table table_emitter (uiout, 9, -1, "regions"); if (gdbarch_addr_bit (target_gdbarch ()) <= 32) { uiout->table_header (10, ui_left, "start", "Start"); uiout->table_header (10, ui_left, "end", "End"); } else { uiout->table_header (18, ui_left, "start", "Start"); uiout->table_header (18, ui_left, "end", "End"); } uiout->table_header (3, ui_left, "min-prot", "Min"); uiout->table_header (3, ui_left, "max-prot", "Max"); uiout->table_header (5, ui_left, "inheritence", "Inh"); uiout->table_header (9, ui_left, "share-mode", "Shr"); uiout->table_header (1, ui_left, "depth", "D"); uiout->table_header (3, ui_left, "submap", "Sm"); uiout->table_header (0, ui_noalign, "tag", "Tag"); uiout->table_body (); r_start = 0; r_depth = 0; while (1) { const char *tag; r_info_size = VM_REGION_SUBMAP_SHORT_INFO_COUNT_64; r_size = -1; kret = mach_vm_region_recurse (task, &r_start, &r_size, &r_depth, (vm_region_recurse_info_t) &r_info, &r_info_size); if (kret != KERN_SUCCESS) break; { 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"); if (r_info.is_submap) r_depth++; else r_start += r_size; } }