- /* 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);
+ {
+ ui_out_emit_table table_emitter (current_uiout,
+ 5 + ui_out_extra_fields,
+ probes.size (), "StaticProbes");
+
+ std::sort (probes.begin (), probes.end (), 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 (const bound_probe &probe : probes)
+ {
+ const char *probe_type = probe.prob->get_static_ops ()->type_name ();
+
+ size_type = std::max (strlen (probe_type), size_type);
+ size_name = std::max (probe.prob->get_name ().size (), size_name);
+ size_provider = std::max (probe.prob->get_provider ().size (),
+ 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 (spops == &any_static_probe_ops)
+ {
+ /* 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 (const static_probe_ops *po : all_static_probe_ops)
+ if (exists_probe_with_spops (probes, po))
+ gen_ui_out_table_header_info (probes, po);
+ }
+ else
+ gen_ui_out_table_header_info (probes, spops);
+
+ current_uiout->table_header (size_objname, ui_left, "object", _("Object"));
+ current_uiout->table_body ();
+
+ for (const bound_probe &probe : probes)
+ {
+ const char *probe_type = probe.prob->get_static_ops ()->type_name ();
+
+ ui_out_emit_tuple tuple_emitter (current_uiout, "probe");
+
+ current_uiout->field_string ("type", probe_type);
+ current_uiout->field_string ("provider",
+ probe.prob->get_provider ().c_str ());
+ current_uiout->field_string ("name", probe.prob->get_name ().c_str ());
+ current_uiout->field_core_addr ("addr", probe.prob->get_gdbarch (),
+ probe.prob->get_relocated_address
+ (probe.objfile));
+
+ if (spops == &any_static_probe_ops)
+ {
+ for (const static_probe_ops *po : all_static_probe_ops)
+ {
+ if (probe.prob->get_static_ops () == po)
+ print_ui_out_info (probe.prob);
+ else if (exists_probe_with_spops (probes, po))
+ print_ui_out_not_applicables (po);
+ }
+ }
+ else
+ print_ui_out_info (probe.prob);
+
+ current_uiout->field_string ("object",
+ objfile_name (probe.objfile));
+ current_uiout->text ("\n");
+ }
+
+ any_found = !probes.empty ();
+ }