- /*
- * If a non-default channel has been created in the
- * session, explicitely require that -c chan_name needs
- * to be provided.
- */
- if (usess->has_non_default_channel && channel_name[0] == '\0') {
- ret = LTTNG_ERR_NEED_CHANNEL_NAME;
- goto error;
- }
-
- /* Get channel from global UST domain */
- uchan = trace_ust_find_channel_by_name(usess->domain_global.channels,
- channel_name);
- if (uchan == NULL) {
- /* Create default channel */
- attr = channel_new_default_attr(LTTNG_DOMAIN_UST,
- usess->buffer_type);
- if (attr == NULL) {
- ret = LTTNG_ERR_FATAL;
- goto error;
- }
- strncpy(attr->name, channel_name, sizeof(attr->name));
-
- ret = cmd_enable_channel(session, domain, attr, wpipe);
- if (ret != LTTNG_OK) {
- free(attr);
- goto error;
- }
- free(attr);
-
- /* Get the newly created channel reference back */
- uchan = trace_ust_find_channel_by_name(
- usess->domain_global.channels, channel_name);
- assert(uchan);
- }
-
- /* At this point, the session and channel exist on the tracer */
- ret = event_ust_enable_tracepoint(usess, uchan, event,
- filter_expression, filter, exclusion);
- if (ret != LTTNG_OK) {
- goto error;
- }
- break;
- }
- case LTTNG_DOMAIN_JUL:
- {
- struct agent *agt;
- struct lttng_event uevent;
- struct lttng_domain tmp_dom;
- struct ltt_ust_session *usess = session->ust_session;
-
- assert(usess);
-
- agt = trace_ust_find_agent(usess, LTTNG_DOMAIN_JUL);
- if (!agt) {
- agt = agent_create(LTTNG_DOMAIN_JUL);
- if (!agt) {
- ret = -LTTNG_ERR_NOMEM;
- goto error;
- }
- agent_add(agt, usess->agents);
- }
-
- /* Create the default tracepoint. */
- memset(&uevent, 0, sizeof(uevent));
- uevent.type = LTTNG_EVENT_TRACEPOINT;
- uevent.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
- if (is_root) {
- strncpy(uevent.name, DEFAULT_SYS_JUL_EVENT_NAME,
- sizeof(uevent.name));
- } else {
- strncpy(uevent.name, DEFAULT_USER_JUL_EVENT_NAME,
- sizeof(uevent.name));
- }
- uevent.name[sizeof(uevent.name) - 1] = '\0';
-
- /*
- * The domain type is changed because we are about to enable the
- * default channel and event for the JUL domain that are hardcoded.
- * This happens in the UST domain.
- */
- memcpy(&tmp_dom, domain, sizeof(tmp_dom));
- tmp_dom.type = LTTNG_DOMAIN_UST;
-
- ret = cmd_enable_event(session, &tmp_dom, DEFAULT_JUL_CHANNEL_NAME,
- &uevent, filter_expression, filter, NULL, wpipe);
- if (ret != LTTNG_OK && ret != LTTNG_ERR_UST_EVENT_ENABLED) {
- goto error;
- }