- /* Check if event name is given */
- if (strlen(cmd_ctx->lsm->u.context.event_name) == 0) {
- no_event = 1;
- }
-
- /* Create Kernel context */
- ctx.ctx = cmd_ctx->lsm->u.context.ctx.ctx;
- ctx.u.perf_counter.type = cmd_ctx->lsm->u.context.ctx.u.perf_counter.type;
- ctx.u.perf_counter.config = cmd_ctx->lsm->u.context.ctx.u.perf_counter.config;
- strncpy(ctx.u.perf_counter.name,
- cmd_ctx->lsm->u.context.ctx.u.perf_counter.name,
- sizeof(ctx.u.perf_counter.name));
-
- if (strlen(cmd_ctx->lsm->u.context.channel_name) == 0) {
- /* Go over all channels */
- DBG("Adding context to all channels");
- cds_list_for_each_entry(chan,
- &cmd_ctx->session->kernel_session->channel_list.head, list) {
- if (no_event) {
- ret = kernel_add_channel_context(chan, &ctx);
- if (ret < 0) {
- ret = LTTCOMM_KERN_CONTEXT_FAIL;
- goto error;
- }
- } else {
- event = get_kernel_event_by_name(cmd_ctx->lsm->u.context.event_name, chan);
- if (event != NULL) {
- ret = kernel_add_event_context(event, &ctx);
- if (ret < 0) {
- ret = LTTCOMM_KERN_CONTEXT_FAIL;
- goto error;
- }
- found = 1;
- break;
- }
- }
- }
- } else {
- chan = get_kernel_channel_by_name(cmd_ctx->lsm->u.context.channel_name,
- cmd_ctx->session->kernel_session);
- if (chan == NULL) {
- ret = LTTCOMM_KERN_CHAN_NOT_FOUND;
+ switch (cmd_ctx->lsm->domain.type) {
+ case LTTNG_DOMAIN_KERNEL:
+ /* Create Kernel context */
+ kctx.ctx = cmd_ctx->lsm->u.context.ctx.ctx;
+ kctx.u.perf_counter.type = cmd_ctx->lsm->u.context.ctx.u.perf_counter.type;
+ kctx.u.perf_counter.config = cmd_ctx->lsm->u.context.ctx.u.perf_counter.config;
+ strncpy(kctx.u.perf_counter.name,
+ cmd_ctx->lsm->u.context.ctx.u.perf_counter.name,
+ LTTNG_SYMBOL_NAME_LEN);
+ kctx.u.perf_counter.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0';
+
+ /* Add kernel context to kernel tracer. See context.c */
+ ret = add_kernel_context(cmd_ctx->session->kernel_session, &kctx,
+ cmd_ctx->lsm->u.context.event_name,
+ cmd_ctx->lsm->u.context.channel_name);
+ if (ret != LTTCOMM_OK) {