X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Ftrace-ust.c;h=55ca4fb3c9bfe5fc6b142cc9a5aa51dda4e117c3;hp=4d39e213326b6ce903e459b6bb243d807051696a;hb=e9404c27e7cc9d841785e6c4292c1add19fbc1cc;hpb=1cf992b8ff3eb5bf79e0c209f5e50f16b8d220d9 diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 4d39e2133..55ca4fb3c 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2011 - David Goulet + * Copyright (C) 2016 - Jérémie Galarneau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2 only, @@ -355,6 +356,8 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan, luc->attr.switch_timer_interval = chan->attr.switch_timer_interval; luc->attr.read_timer_interval = chan->attr.read_timer_interval; luc->attr.output = (enum lttng_ust_output) chan->attr.output; + luc->monitor_timer_interval = + ((struct lttng_channel_extended *) chan->attr.extended.ptr)->monitor_timer_interval; /* Translate to UST output enum */ switch (luc->attr.output) { @@ -518,7 +521,8 @@ error: } static -int trace_ust_context_type_event_to_ust(enum lttng_event_context_type type) +int trace_ust_context_type_event_to_ust( + enum lttng_event_context_type type) { int utype; @@ -546,6 +550,9 @@ int trace_ust_context_type_event_to_ust(enum lttng_event_context_type type) utype = LTTNG_UST_CONTEXT_PERF_THREAD_COUNTER; } break; + case LTTNG_EVENT_CONTEXT_APP_CONTEXT: + utype = LTTNG_UST_CONTEXT_APP_CONTEXT; + break; default: utype = -1; break; @@ -584,6 +591,15 @@ int trace_ust_match_context(struct ltt_ust_context *uctx, return 0; } break; + case LTTNG_UST_CONTEXT_APP_CONTEXT: + assert(uctx->ctx.u.app_ctx.provider_name); + assert(uctx->ctx.u.app_ctx.ctx_name); + if (strcmp(uctx->ctx.u.app_ctx.provider_name, + ctx->u.app_ctx.provider_name) || + strcmp(uctx->ctx.u.app_ctx.ctx_name, + ctx->u.app_ctx.ctx_name)) { + return 0; + } default: break; @@ -599,7 +615,7 @@ int trace_ust_match_context(struct ltt_ust_context *uctx, struct ltt_ust_context *trace_ust_create_context( struct lttng_event_context *ctx) { - struct ltt_ust_context *uctx; + struct ltt_ust_context *uctx = NULL; int utype; assert(ctx); @@ -607,13 +623,13 @@ struct ltt_ust_context *trace_ust_create_context( utype = trace_ust_context_type_event_to_ust(ctx->ctx); if (utype < 0) { ERR("Invalid UST context"); - return NULL; + goto end; } uctx = zmalloc(sizeof(struct ltt_ust_context)); - if (uctx == NULL) { + if (!uctx) { PERROR("zmalloc ltt_ust_context"); - goto error; + goto end; } uctx->ctx.ctx = (enum lttng_ust_context_type) utype; @@ -625,14 +641,31 @@ struct ltt_ust_context *trace_ust_create_context( LTTNG_UST_SYM_NAME_LEN); uctx->ctx.u.perf_counter.name[LTTNG_UST_SYM_NAME_LEN - 1] = '\0'; break; + case LTTNG_UST_CONTEXT_APP_CONTEXT: + { + char *provider_name = NULL, *ctx_name = NULL; + + provider_name = strdup(ctx->u.app_ctx.provider_name); + if (!provider_name) { + goto error; + } + uctx->ctx.u.app_ctx.provider_name = provider_name; + + ctx_name = strdup(ctx->u.app_ctx.ctx_name); + if (!ctx_name) { + goto error; + } + uctx->ctx.u.app_ctx.ctx_name = ctx_name; + break; + } default: break; } lttng_ht_node_init_ulong(&uctx->node, (unsigned long) uctx->ctx.ctx); - +end: return uctx; - error: + trace_ust_destroy_context(uctx); return NULL; } @@ -931,7 +964,7 @@ static void destroy_context_rcu(struct rcu_head *head) struct ltt_ust_context *ctx = caa_container_of(node, struct ltt_ust_context, node); - free(ctx); + trace_ust_destroy_context(ctx); } /* @@ -976,6 +1009,20 @@ void trace_ust_destroy_event(struct ltt_ust_event *event) free(event); } +/* + * Cleanup ust context structure. + */ +void trace_ust_destroy_context(struct ltt_ust_context *ctx) +{ + assert(ctx); + + if (ctx->ctx.ctx == LTTNG_UST_CONTEXT_APP_CONTEXT) { + free(ctx->ctx.u.app_ctx.provider_name); + free(ctx->ctx.u.app_ctx.ctx_name); + } + free(ctx); +} + /* * URCU intermediate call to complete destroy event. */