From: Mathieu Desnoyers Date: Fri, 27 Jan 2012 21:38:17 +0000 (-0500) Subject: Fix context mapping for UST and kernel X-Git-Tag: v2.0-pre19~44 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9197c5c48e2d1db4c2f9318bbf0af0af9918fdc8;p=lttng-tools.git Fix context mapping for UST and kernel Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng/lttng.h b/include/lttng/lttng.h index 71e754018..0fd323c8b 100644 --- a/include/lttng/lttng.h +++ b/include/lttng/lttng.h @@ -81,7 +81,7 @@ enum lttng_event_output { enum lttng_event_context_type { LTTNG_EVENT_CONTEXT_PID = 0, LTTNG_EVENT_CONTEXT_PERF_COUNTER = 1, - LTTNG_EVENT_CONTEXT_COMM = 2, + LTTNG_EVENT_CONTEXT_PROCNAME = 2, LTTNG_EVENT_CONTEXT_PRIO = 3, LTTNG_EVENT_CONTEXT_NICE = 4, LTTNG_EVENT_CONTEXT_VPID = 5, @@ -89,6 +89,7 @@ enum lttng_event_context_type { LTTNG_EVENT_CONTEXT_VTID = 7, LTTNG_EVENT_CONTEXT_PPID = 8, LTTNG_EVENT_CONTEXT_VPPID = 9, + LTTNG_EVENT_CONTEXT_PTHREAD_ID = 10, }; enum lttng_calibrate_type { diff --git a/src/bin/lttng-sessiond/context.c b/src/bin/lttng-sessiond/context.c index 0e7acefdb..b5345728a 100644 --- a/src/bin/lttng-sessiond/context.c +++ b/src/bin/lttng-sessiond/context.c @@ -239,7 +239,41 @@ int context_kernel_add(struct ltt_kernel_session *ksession, struct lttng_kernel_context kctx; /* Setup kernel context structure */ - kctx.ctx = ctx->ctx; + switch (ctx->ctx) { + case LTTNG_EVENT_CONTEXT_PID: + kctx.ctx = LTTNG_KERNEL_CONTEXT_PID; + break; + case LTTNG_EVENT_CONTEXT_PERF_COUNTER: + kctx.ctx = LTTNG_KERNEL_CONTEXT_PERF_COUNTER; + break; + case LTTNG_EVENT_CONTEXT_PROCNAME: + kctx.ctx = LTTNG_KERNEL_CONTEXT_PROCNAME; + break; + case LTTNG_EVENT_CONTEXT_PRIO: + kctx.ctx = LTTNG_KERNEL_CONTEXT_PRIO; + break; + case LTTNG_EVENT_CONTEXT_NICE: + kctx.ctx = LTTNG_KERNEL_CONTEXT_NICE; + break; + case LTTNG_EVENT_CONTEXT_VPID: + kctx.ctx = LTTNG_KERNEL_CONTEXT_VPID; + break; + case LTTNG_EVENT_CONTEXT_TID: + kctx.ctx = LTTNG_KERNEL_CONTEXT_TID; + break; + case LTTNG_EVENT_CONTEXT_VTID: + kctx.ctx = LTTNG_KERNEL_CONTEXT_VTID; + break; + case LTTNG_EVENT_CONTEXT_PPID: + kctx.ctx = LTTNG_KERNEL_CONTEXT_PPID; + break; + case LTTNG_EVENT_CONTEXT_VPPID: + kctx.ctx = LTTNG_KERNEL_CONTEXT_VPPID; + break; + default: + return LTTCOMM_KERN_CONTEXT_FAIL; + } + kctx.u.perf_counter.type = ctx->u.perf_counter.type; kctx.u.perf_counter.config = ctx->u.perf_counter.config; strncpy(kctx.u.perf_counter.name, ctx->u.perf_counter.name, diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 80644ac83..0858f47d5 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -289,6 +289,25 @@ struct ltt_ust_context *trace_ust_create_context( struct lttng_event_context *ctx) { struct ltt_ust_context *uctx; + enum lttng_ust_context_type utype; + + switch (ctx->ctx) { + case LTTNG_EVENT_CONTEXT_VTID: + utype = LTTNG_UST_CONTEXT_VTID; + break; + case LTTNG_EVENT_CONTEXT_VPID: + utype = LTTNG_UST_CONTEXT_VPID; + break; + case LTTNG_EVENT_CONTEXT_PTHREAD_ID: + utype = LTTNG_UST_CONTEXT_PTHREAD_ID; + break; + case LTTNG_EVENT_CONTEXT_PROCNAME: + utype = LTTNG_UST_CONTEXT_PROCNAME; + break; + default: + ERR("Invalid UST context"); + return NULL; + } uctx = zmalloc(sizeof(struct ltt_ust_context)); if (uctx == NULL) { @@ -296,7 +315,7 @@ struct ltt_ust_context *trace_ust_create_context( goto error; } - uctx->ctx.ctx = ctx->ctx; + uctx->ctx.ctx = utype; lttng_ht_node_init_ulong(&uctx->node, (unsigned long) uctx->ctx.ctx); return uctx; diff --git a/src/bin/lttng/commands/add_context.c b/src/bin/lttng/commands/add_context.c index a7ab4268a..6c374d17d 100644 --- a/src/bin/lttng/commands/add_context.c +++ b/src/bin/lttng/commands/add_context.c @@ -67,6 +67,7 @@ enum context_type { CONTEXT_VTID = 7, CONTEXT_PPID = 8, CONTEXT_VPPID = 9, + CONTEXT_PTHREAD_ID = 10, }; /* @@ -205,6 +206,7 @@ const struct ctx_opts { { "nice", CONTEXT_NICE }, { "vpid", CONTEXT_VPID }, { "tid", CONTEXT_TID }, + { "pthread_id", CONTEXT_PTHREAD_ID }, { "vtid", CONTEXT_VTID }, { "ppid", CONTEXT_PPID }, { "vppid", CONTEXT_VPPID }, diff --git a/src/common/lttng-kernel.h b/src/common/lttng-kernel.h index e8bc62626..6451c9638 100644 --- a/src/common/lttng-kernel.h +++ b/src/common/lttng-kernel.h @@ -44,7 +44,7 @@ enum lttng_kernel_instrumentation { enum lttng_kernel_context_type { LTTNG_KERNEL_CONTEXT_PID = 0, LTTNG_KERNEL_CONTEXT_PERF_COUNTER = 1, - LTTNG_KERNEL_CONTEXT_COMM = 2, + LTTNG_KERNEL_CONTEXT_PROCNAME = 2, LTTNG_KERNEL_CONTEXT_PRIO = 3, LTTNG_KERNEL_CONTEXT_NICE = 4, LTTNG_KERNEL_CONTEXT_VPID = 5,