channels[i].attr.read_timer_interval =
uchan->attr.read_timer_interval;
channels[i].attr.output = uchan->attr.output;
+ channels[i].enabled = uchan->enabled;
i++;
}
break;
int i = 0, ret = 0;
unsigned int nb_event = 0;
struct cds_lfht_iter iter;
+ struct cds_lfht_node *node;
struct ltt_ust_channel *uchan;
struct ltt_ust_event *uevent;
struct lttng_event *tmp;
rcu_read_lock();
- /* Count events in all channels */
- cds_lfht_for_each_entry(ust_global->channels, &iter, uchan, node) {
- nb_event += hashtable_get_count(uchan->events);
+ node = hashtable_lookup(ust_global->channels, (void *) channel_name,
+ strlen(channel_name), &iter);
+ if (node == NULL) {
+ ret = -LTTCOMM_UST_CHAN_NOT_FOUND;
+ goto error;
}
+ uchan = caa_container_of(node, struct ltt_ust_channel, node);
+
+ nb_event += hashtable_get_count(uchan->events);
+
if (nb_event == 0) {
ret = nb_event;
goto error;
goto error;
}
- cds_lfht_for_each_entry(ust_global->channels, &iter, uchan, node) {
- cds_lfht_for_each_entry(uchan->events, &iter, uevent, node) {
- strncpy(tmp[i].name, uevent->attr.name, LTTNG_SYMBOL_NAME_LEN);
- tmp[i].name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
- tmp[i].enabled = uevent->enabled;
- switch (uevent->attr.instrumentation) {
- case LTTNG_UST_TRACEPOINT:
- tmp[i].type = LTTNG_EVENT_TRACEPOINT;
- break;
- case LTTNG_UST_PROBE:
- tmp[i].type = LTTNG_EVENT_PROBE;
- break;
- case LTTNG_UST_FUNCTION:
- tmp[i].type = LTTNG_EVENT_FUNCTION;
- break;
- }
- i++;
+ cds_lfht_for_each_entry(uchan->events, &iter, uevent, node) {
+ strncpy(tmp[i].name, uevent->attr.name, LTTNG_SYMBOL_NAME_LEN);
+ tmp[i].name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
+ tmp[i].enabled = uevent->enabled;
+ switch (uevent->attr.instrumentation) {
+ case LTTNG_UST_TRACEPOINT:
+ tmp[i].type = LTTNG_EVENT_TRACEPOINT;
+ break;
+ case LTTNG_UST_PROBE:
+ tmp[i].type = LTTNG_EVENT_PROBE;
+ break;
+ case LTTNG_UST_FUNCTION:
+ tmp[i].type = LTTNG_EVENT_FUNCTION;
+ break;
}
+ i++;
}
ret = nb_event;
int domain, char *channel_name)
{
int ret;
+ struct ltt_ust_session *usess;
+
+ usess = session->ust_session;
switch (domain) {
- case LTTNG_DOMAIN_KERNEL:
- ret = channel_kernel_disable(session->kernel_session,
- channel_name);
- if (ret != LTTCOMM_OK) {
- goto error;
- }
+ case LTTNG_DOMAIN_KERNEL:
+ {
+ ret = channel_kernel_disable(session->kernel_session,
+ channel_name);
+ if (ret != LTTCOMM_OK) {
+ goto error;
+ }
- kernel_wait_quiescent(kernel_tracer_fd);
- break;
- case LTTNG_DOMAIN_UST_PID:
- break;
- default:
- ret = LTTCOMM_UNKNOWN_DOMAIN;
+ kernel_wait_quiescent(kernel_tracer_fd);
+ break;
+ }
+ case LTTNG_DOMAIN_UST:
+ {
+ struct ltt_ust_channel *uchan;
+
+ /* Get channel in global UST domain HT */
+ 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_channel_all(usess, uchan);
+ if (ret < 0) {
+ ret = LTTCOMM_UST_DISABLE_FAIL;
+ goto error;
+ }
+
+ uchan->enabled = 0;
+
+ break;
+ }
+ case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
+ case LTTNG_DOMAIN_UST_EXEC_NAME:
+ case LTTNG_DOMAIN_UST_PID:
+ ret = LTTCOMM_NOT_IMPLEMENTED;
+ goto error;
+ default:
+ ret = LTTCOMM_UNKNOWN_DOMAIN;
+ goto error;
}
ret = LTTCOMM_OK;
* Command LTTNG_ENABLE_CHANNEL processed by the client thread.
*/
static int cmd_enable_channel(struct ltt_session *session,
- struct lttng_domain *domain, struct lttng_channel *attr)
+ int domain, struct lttng_channel *attr)
{
int ret;
struct ltt_ust_session *usess = session->ust_session;
DBG("Enabling channel %s for session %s", attr->name, session->name);
- switch (domain->type) {
+ switch (domain) {
case LTTNG_DOMAIN_KERNEL:
{
struct ltt_kernel_channel *kchan;
hashtable_add_unique(usess->domain_global.channels, &uchan->node);
rcu_read_unlock();
DBG2("UST channel %s added to global domain HT", attr->name);
+
+ /* Add channel to all registered applications */
+ ret = ust_app_create_channel_all(usess, uchan);
+ if (ret != 0) {
+ ret = LTTCOMM_UST_CHAN_FAIL;
+ goto error;
+ }
} else {
- ret = LTTCOMM_UST_CHAN_EXIST;
- goto error;
- }
+ /* If already enabled, everything is OK */
+ if (uchan->enabled) {
+ ret = LTTCOMM_OK;
+ goto error;
+ }
- /* Add channel to all registered applications */
- ret = ust_app_create_channel_all(usess, uchan);
- if (ret != 0) {
- goto error;
+ ret = ust_app_enable_channel_all(usess, uchan);
+ if (ret < 0) {
+ ret = LTTCOMM_UST_ENABLE_FAIL;
+ goto error;
+ }
}
uchan->enabled = 1;
break;
}
+ case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
+ case LTTNG_DOMAIN_UST_EXEC_NAME:
case LTTNG_DOMAIN_UST_PID:
- {
- /*
- int sock;
- struct ltt_ust_channel *uchan;
- struct ltt_ust_session *usess;
- struct ust_app *app;
-
- usess = trace_ust_get_session_by_pid(&session->ust_session_list,
- domain->attr.pid);
- if (usess == NULL) {
- ret = LTTCOMM_UST_CHAN_NOT_FOUND;
- goto error;
- }
-
- app = ust_app_get_by_pid(domain->attr.pid);
- if (app == NULL) {
- ret = LTTCOMM_APP_NOT_FOUND;
- goto error;
- }
- sock = app->sock;
-
- uchan = trace_ust_get_channel_by_name(attr->name, usess);
- if (uchan == NULL) {
- ret = channel_ust_create(usess, attr, sock);
- } else {
- ret = channel_ust_enable(usess, uchan, sock);
- }
-
- if (ret != LTTCOMM_OK) {
- goto error;
- }
-
- ret = copy_ust_channel_to_app(usess, attr, app);
- if (ret != LTTCOMM_OK) {
- goto error;
- }
-
- DBG("UST channel %s created for app sock %d with pid %d",
- attr->name, app->sock, domain->attr.pid);
- */
ret = LTTCOMM_NOT_IMPLEMENTED;
goto error;
- }
default:
ret = LTTCOMM_UNKNOWN_DOMAIN;
goto error;
{
struct ltt_ust_channel *uchan;
struct ltt_ust_event *uevent;
+ struct lttng_channel *attr;
uchan = trace_ust_find_channel_by_name(usess->domain_global.channels,
channel_name);
if (uchan == NULL) {
- /* TODO: Create default channel */
- ret = LTTCOMM_UST_CHAN_NOT_FOUND;
- goto error;
+ /* Create default channel */
+ attr = channel_new_default_attr(domain);
+ if (attr == NULL) {
+ ret = LTTCOMM_FATAL;
+ goto error;
+ }
+ snprintf(attr->name, NAME_MAX, "%s", channel_name);
+
+ /* Use the internal command enable channel */
+ ret = cmd_enable_channel(session, domain, attr);
+ if (ret < 0) {
+ goto error;
+ }
+
+ free(attr);
+
+ /* Get the newly created channel reference back */
+ uchan = trace_ust_find_channel_by_name(
+ usess->domain_global.channels, channel_name);
+ if (uchan == NULL) {
+ /* Something is really wrong */
+ ret = LTTCOMM_FATAL;
+ goto error;
+ }
}
uevent = trace_ust_find_event_by_name(uchan->events, event->name);
kernel_wait_quiescent(kernel_tracer_fd);
}
- /* Flag session that trace should start automatically */
if (usess) {
usess->start_trace = 0;
}
case LTTNG_ENABLE_CHANNEL:
{
- ret = cmd_enable_channel(cmd_ctx->session, &cmd_ctx->lsm->domain,
+ ret = cmd_enable_channel(cmd_ctx->session, cmd_ctx->lsm->domain.type,
&cmd_ctx->lsm->u.channel.chan);
break;
}