+ switch (ctx->ctx) {
+ case LTTNG_EVENT_CONTEXT_PID:
+ kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_PID;
+ break;
+ case LTTNG_EVENT_CONTEXT_PROCNAME:
+ kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_PROCNAME;
+ break;
+ case LTTNG_EVENT_CONTEXT_PRIO:
+ kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_PRIO;
+ break;
+ case LTTNG_EVENT_CONTEXT_NICE:
+ kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_NICE;
+ break;
+ case LTTNG_EVENT_CONTEXT_VPID:
+ kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_VPID;
+ break;
+ case LTTNG_EVENT_CONTEXT_TID:
+ kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_TID;
+ break;
+ case LTTNG_EVENT_CONTEXT_VTID:
+ kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_VTID;
+ break;
+ case LTTNG_EVENT_CONTEXT_PPID:
+ kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_PPID;
+ break;
+ case LTTNG_EVENT_CONTEXT_VPPID:
+ kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_VPPID;
+ break;
+ case LTTNG_EVENT_CONTEXT_HOSTNAME:
+ kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_HOSTNAME;
+ break;
+ case LTTNG_EVENT_CONTEXT_PERF_CPU_COUNTER:
+ case LTTNG_EVENT_CONTEXT_PERF_COUNTER:
+ kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_PERF_CPU_COUNTER;
+ break;
+ case LTTNG_EVENT_CONTEXT_INTERRUPTIBLE:
+ kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_INTERRUPTIBLE;
+ break;
+ case LTTNG_EVENT_CONTEXT_PREEMPTIBLE:
+ kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_PREEMPTIBLE;
+ break;
+ case LTTNG_EVENT_CONTEXT_NEED_RESCHEDULE:
+ kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_NEED_RESCHEDULE;
+ break;
+ case LTTNG_EVENT_CONTEXT_MIGRATABLE:
+ kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_MIGRATABLE;
+ break;
+ case LTTNG_EVENT_CONTEXT_CALLSTACK_KERNEL:
+ kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL;
+ break;
+ case LTTNG_EVENT_CONTEXT_CALLSTACK_USER:
+ kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_CALLSTACK_USER;
+ break;
+ default:
+ ret = LTTNG_ERR_KERN_CONTEXT_FAIL;
+ goto error;
+ }
+
+ kctx->ctx.u.perf_counter.type = ctx->u.perf_counter.type;
+ kctx->ctx.u.perf_counter.config = ctx->u.perf_counter.config;
+ strncpy(kctx->ctx.u.perf_counter.name, ctx->u.perf_counter.name,