Fix context mapping for UST and kernel
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 27 Jan 2012 21:38:17 +0000 (16:38 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 27 Jan 2012 21:38:17 +0000 (16:38 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/lttng.h
src/bin/lttng-sessiond/context.c
src/bin/lttng-sessiond/trace-ust.c
src/bin/lttng/commands/add_context.c
src/common/lttng-kernel.h

index 71e754018cc096c354e2506d001aa12a97d0bd09..0fd323c8bf3e158edd0b3a77781ac85ecfb67a7f 100644 (file)
@@ -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 {
index 0e7acefdb178e662e6588d2628be894830818301..b5345728a6a954b5bbe78c76f1ea9d4b7796c923 100644 (file)
@@ -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,
index 80644ac8330b438da015b7f149ff10cee002bb5b..0858f47d53b29ea598f94471b4271d029ba1a2bd 100644 (file)
@@ -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;
index a7ab4268ac5401805d83d675639962d834f0fb50..6c374d17da93ffbd16174d88883f7dec7a35f908 100644 (file)
@@ -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 },
index e8bc626262a674fc76c5f18332a257bb1b4a76ab..6451c9638db4c007bc5fc5b5b11ac48496e1b3a8 100644 (file)
@@ -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,
This page took 0.032031 seconds and 4 git commands to generate.