char *channel_name)
{
int ret;
- struct ltt_kernel_channel *kchan;
switch (domain) {
case LTTNG_DOMAIN_KERNEL:
- kchan = trace_kernel_get_channel_by_name(channel_name,
- session->kernel_session);
+ {
+ struct ltt_kernel_session *ksess;
+ struct ltt_kernel_channel *kchan;
+
+ ksess = session->kernel_session;
+
+ kchan = trace_kernel_get_channel_by_name(channel_name, ksess);
if (kchan == NULL) {
ret = LTTCOMM_KERN_CHAN_NOT_FOUND;
goto error;
}
- ret = event_kernel_disable_all(session->kernel_session, kchan);
+ ret = event_kernel_disable_all(ksess, kchan);
if (ret != LTTCOMM_OK) {
goto error;
}
kernel_wait_quiescent(kernel_tracer_fd);
break;
+ }
+ case LTTNG_DOMAIN_UST:
+ {
+ struct ltt_ust_session *usess;
+ struct ltt_ust_channel *uchan;
+
+ usess = session->ust_session;
+
+ uchan = trace_ust_find_channel_by_name(usess->domain_global.channels,
+ channel_name);
+ if (uchan == NULL) {
+ ret = LTTCOMM_UST_CHAN_NOT_FOUND;
+ goto error;
+ }
+
+ ret = ust_app_disable_event_all(usess, uchan);
+ if (ret < 0) {
+ ret = LTTCOMM_UST_DISABLE_FAIL;
+ goto error;
+ }
+
+ DBG2("Disable all UST event in channel %s completed", channel_name);
+
+ break;
+ }
+ case LTTNG_DOMAIN_UST_EXEC_NAME:
+ case LTTNG_DOMAIN_UST_PID:
+ case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
default:
- /* TODO: Userspace tracing */
ret = LTTCOMM_NOT_IMPLEMENTED;
goto error;
}
return NULL;
}
+/*
+ * Disable the specified event on to UST tracer for the UST session.
+ */
+static int disable_ust_event(struct ust_app *app,
+ struct ust_app_session *ua_sess, struct ust_app_event *ua_event)
+{
+ int ret;
+
+ ret = ustctl_disable(app->key.sock, ua_event->obj);
+ if (ret < 0) {
+ ERR("UST app event %s disable failed for app (pid: %d) "
+ "and session handle %d with ret %d",
+ ua_event->attr.name, app->key.pid, ua_sess->handle, ret);
+ goto error;
+ }
+
+ DBG2("UST app event %s disabled successfully for app (pid: %d)",
+ ua_event->attr.name, app->key.pid);
+
+error:
+ return ret;
+}
+
/*
* Disable the specified channel on to UST tracer for the UST session.
*/
return NULL;
}
+/*
+ * Disable on the tracer side a ust app event for the session and channel.
+ */
+static int disable_ust_app_event(struct ust_app_session *ua_sess,
+ struct ust_app_channel *ua_chan, struct ust_app_event *ua_event,
+ struct ust_app *app)
+{
+ int ret;
+
+ ret = disable_ust_event(app, ua_sess, ua_event);
+ if (ret < 0) {
+ goto error;
+ }
+
+ ua_event->enabled = 0;
+
+error:
+ return ret;
+}
+
/*
* Lookup ust app channel for session and disable it on the tracer side.
*/
return ret;
}
+/*
+ * For a specific UST session and UST channel, create the event for all
+ * registered apps.
+ */
+int ust_app_disable_event_all(struct ltt_ust_session *usess,
+ struct ltt_ust_channel *uchan)
+{
+ int ret = 0;
+ struct cds_lfht_iter iter, uiter;
+ struct cds_lfht_node *ua_chan_node;
+ struct ust_app *app;
+ struct ust_app_session *ua_sess;
+ struct ust_app_channel *ua_chan;
+ struct ust_app_event *ua_event;
+
+ DBG("UST app disabling all event for all apps in channel "
+ "%s for session uid %d", uchan->name, usess->uid);
+
+ rcu_read_lock();
+
+ /* For all registered applications */
+ cds_lfht_for_each_entry(ust_app_ht, &iter, app, node) {
+ ua_sess = lookup_session_by_app(usess, app);
+ if (ua_sess == NULL) {
+ /* Next app */
+ continue;
+ }
+
+ /* Lookup channel in the ust app session */
+ ua_chan_node = hashtable_lookup(ua_sess->channels,
+ (void *)uchan->name, strlen(uchan->name),
+ &uiter);
+ if (ua_chan_node == NULL) {
+ DBG2("Channel %s not found in session uid %d for app pid %d."
+ "Skipping", uchan->name, app->key.pid, usess->uid);
+ continue;
+ }
+ ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
+
+ /* Disable each events of channel */
+ cds_lfht_for_each_entry(ua_chan->events, &uiter, ua_event, node) {
+ ret = disable_ust_app_event(ua_sess, ua_chan, ua_event, app);
+ if (ret < 0) {
+ /* XXX: Report error someday... */
+ continue;
+ }
+ }
+ }
+
+ rcu_read_unlock();
+
+ return ret;
+}
+
/*
* For a specific UST session, create the channel for all registered apps.
*/
struct ltt_ust_channel *uchan);
int ust_app_enable_channel_all(struct ltt_ust_session *usess,
struct ltt_ust_channel *uchan);
+int ust_app_disable_event_all(struct ltt_ust_session *usess,
+ struct ltt_ust_channel *uchan);
void ust_app_global_update(struct ltt_ust_session *usess, int sock);
void ust_app_clean_list(void);
#include "../utils.h"
static char *opt_event_list;
-static char *opt_kernel;
+static int opt_kernel;
static char *opt_channel_name;
static char *opt_session_name;
static int opt_pid_all;
fprintf(ofp, " -h, --help Show this help\n");
fprintf(ofp, " -s, --session Apply on session name\n");
fprintf(ofp, " -c, --channel Apply on this channel\n");
- fprintf(ofp, " -a, --all-events Enable all tracepoints\n");
+ fprintf(ofp, " -a, --all-events Disable all tracepoints\n");
fprintf(ofp, " -k, --kernel Apply for the kernel tracer\n");
fprintf(ofp, " -u, --userspace [CMD] Apply for the user-space tracer\n");
fprintf(ofp, " --all If -u, apply on all traceable apps\n");
if (opt_kernel) {
dom.type = LTTNG_DOMAIN_KERNEL;
+ } else if (opt_pid != 0) {
+ dom.type = LTTNG_DOMAIN_UST_PID;
+ dom.attr.pid = opt_pid;
+ DBG("PID %d set to lttng handle", opt_pid);
+ } else if (opt_userspace && opt_cmd_name == NULL) {
+ dom.type = LTTNG_DOMAIN_UST;
+ DBG("UST global domain selected");
+ } else if (opt_userspace && opt_cmd_name != NULL) {
+ dom.type = LTTNG_DOMAIN_UST_EXEC_NAME;
+ strncpy(dom.attr.exec_name, opt_cmd_name, NAME_MAX);
+ } else {
+ ERR("Please specify a tracer (--kernel or --userspace)");
+ ret = CMD_NOT_IMPLEMENTED;
+ goto error;
}
handle = lttng_create_handle(session_name, &dom);
}
if (opt_disable_all) {
- if (opt_kernel) {
- ret = lttng_disable_event(handle, NULL, channel_name);
+ ret = lttng_disable_event(handle, NULL, channel_name);
+ if (ret < 0) {
goto error;
}
- /* TODO: User-space tracer */
+ MSG("All %s events are disabled in channel %s",
+ opt_kernel ? "kernel" : "UST", channel_name);
+ goto end;
}
/* Strip event list */
while (event_name != NULL) {
/* Kernel tracer action */
if (opt_kernel) {
- DBG("Disabling kernel event %s for channel %s",
+ DBG("Disabling kernel event %s in channel %s",
event_name, channel_name);
-
- ret = lttng_disable_event(handle, event_name, channel_name);
- if (ret < 0) {
- MSG("Unable to disable event %s for channel %s",
- event_name, channel_name);
- } else {
- MSG("Kernel event %s disabled for channel %s",
- event_name, channel_name);
- }
} else if (opt_userspace) { /* User-space tracer action */
- /*
- * TODO: Waiting on lttng UST 2.0
- */
- if (opt_pid_all) {
- } else if (opt_pid != 0) {
+ if (!opt_pid_all) {
+ MSG("Only supporting tracing all UST processes (-u --all) for now.");
+ ret = CMD_NOT_IMPLEMENTED;
+ goto error;
}
- ret = CMD_NOT_IMPLEMENTED;
- goto error;
+ DBG("Disabling UST event %s in channel %s",
+ event_name, channel_name);
} else {
ERR("Please specify a tracer (--kernel or --userspace)");
goto error;
}
+ ret = lttng_disable_event(handle, event_name, channel_name);
+ if (ret < 0) {
+ MSG("Unable to disable %s event %s in channel %s",
+ opt_kernel ? "kernel" : "UST", event_name,
+ channel_name);
+ } else {
+ MSG("%s event %s disabled in channel %s",
+ opt_kernel ? "kernel" : "UST", event_name,
+ channel_name);
+ }
+
/* Next event */
event_name = strtok(NULL, ",");
}
+end:
error:
if (opt_channel_name == NULL) {
free(channel_name);