+/* Implementation of the `enable probes' command. */
+
+static void
+enable_probes_command (const char *arg, int from_tty)
+{
+ std::string provider, probe_name, objname;
+ struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
+
+ parse_probe_linespec ((const char *) arg, &provider, &probe_name, &objname);
+
+ std::vector<bound_probe> probes
+ = collect_probes (objname, provider, probe_name, NULL);
+ if (probes.empty ())
+ {
+ current_uiout->message (_("No probes matched.\n"));
+ do_cleanups (cleanup);
+ return;
+ }
+
+ /* Enable the selected probes, provided their backends support the
+ notion of enabling a probe. */
+ for (const bound_probe &probe: probes)
+ {
+ const struct probe_ops *pops = probe.probe->pops;
+
+ if (pops->enable_probe != NULL)
+ {
+ pops->enable_probe (probe.probe);
+ current_uiout->message (_("Probe %s:%s enabled.\n"),
+ probe.probe->provider, probe.probe->name);
+ }
+ else
+ current_uiout->message (_("Probe %s:%s cannot be enabled.\n"),
+ probe.probe->provider, probe.probe->name);
+ }
+
+ do_cleanups (cleanup);
+}
+
+/* Implementation of the `disable probes' command. */
+
+static void
+disable_probes_command (const char *arg, int from_tty)
+{
+ std::string provider, probe_name, objname;
+ struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
+
+ parse_probe_linespec ((const char *) arg, &provider, &probe_name, &objname);
+
+ std::vector<bound_probe> probes
+ = collect_probes (objname, provider, probe_name, NULL /* pops */);
+ if (probes.empty ())
+ {
+ current_uiout->message (_("No probes matched.\n"));
+ do_cleanups (cleanup);
+ return;
+ }
+
+ /* Disable the selected probes, provided their backends support the
+ notion of enabling a probe. */
+ for (const bound_probe &probe : probes)
+ {
+ const struct probe_ops *pops = probe.probe->pops;
+
+ if (pops->disable_probe != NULL)
+ {
+ pops->disable_probe (probe.probe);
+ current_uiout->message (_("Probe %s:%s disabled.\n"),
+ probe.probe->provider, probe.probe->name);
+ }
+ else
+ current_uiout->message (_("Probe %s:%s cannot be disabled.\n"),
+ probe.probe->provider, probe.probe->name);
+ }
+
+ do_cleanups (cleanup);
+}
+