}
int lttng_attach_context(struct lttng_ust_context *context_param,
+ union ust_args *uargs,
struct lttng_ctx **ctx, struct lttng_session *session)
{
/*
return lttng_add_ip_to_ctx(ctx);
case LTTNG_UST_CONTEXT_CPU_ID:
return lttng_add_cpu_id_to_ctx(ctx);
+ case LTTNG_UST_CONTEXT_APP_CONTEXT:
+ return lttng_ust_add_app_context_to_ctx_rcu(uargs->app_context.ctxname,
+ ctx);
default:
return -EINVAL;
}
static
long lttng_abi_add_context(int objd,
struct lttng_ust_context *context_param,
+ union ust_args *uargs,
struct lttng_ctx **ctx, struct lttng_session *session)
{
- return lttng_attach_context(context_param, ctx, session);
+ return lttng_attach_context(context_param, uargs, ctx, session);
}
/**
}
case LTTNG_UST_CONTEXT:
return lttng_abi_add_context(objd,
- (struct lttng_ust_context *) arg,
+ (struct lttng_ust_context *) arg, uargs,
&channel->ctx, channel->session);
case LTTNG_UST_ENABLE:
return lttng_channel_enable(channel);
const struct lttng_ust_objd_ops *ops;
struct ustcomm_ust_reply lur;
union ust_args args;
+ char ctxstr[LTTNG_UST_SYM_NAME_LEN]; /* App context string. */
ssize_t len;
memset(&lur, 0, sizeof(lur));
ret = -ENOSYS;
break;
}
+ case LTTNG_UST_CONTEXT:
+ switch (lum->u.context.ctx) {
+ case LTTNG_UST_CONTEXT_APP_CONTEXT:
+ {
+ char *p;
+ size_t ctxlen, recvlen;
+
+ ctxlen = strlen("$app.") + lum->u.context.u.app_ctx.provider_name_len - 1
+ + strlen(":") + lum->u.context.u.app_ctx.ctx_name_len;
+ if (ctxlen >= LTTNG_UST_SYM_NAME_LEN) {
+ ERR("Application context string length size is too large: %zu bytes",
+ ctxlen);
+ ret = -EINVAL;
+ goto error;
+ }
+ strcpy(ctxstr, "$app.");
+ p = &ctxstr[strlen("$app.")];
+ recvlen = ctxlen - strlen("$app.");
+ len = ustcomm_recv_unix_sock(sock, p, recvlen);
+ switch (len) {
+ case 0: /* orderly shutdown */
+ ret = 0;
+ goto error;
+ default:
+ if (len == recvlen) {
+ DBG("app context data received");
+ break;
+ } else if (len < 0) {
+ DBG("Receive failed from lttng-sessiond with errno %d", (int) -len);
+ if (len == -ECONNRESET) {
+ ERR("%s remote end closed connection", sock_info->name);
+ ret = len;
+ goto error;
+ }
+ ret = len;
+ goto error;
+ } else {
+ DBG("incorrect app context data message size: %zd", len);
+ ret = -EINVAL;
+ goto error;
+ }
+ }
+ /* Put : between provider and ctxname. */
+ p[lum->u.context.u.app_ctx.provider_name_len - 1] = ':';
+ args.app_context.ctxname = ctxstr;
+ break;
+ }
+ default:
+ break;
+ }
+ if (ops->cmd) {
+ ret = ops->cmd(lum->handle, lum->cmd,
+ (unsigned long) &lum->u,
+ &args, sock_info);
+ } else {
+ ret = -ENOSYS;
+ }
+ break;
default:
if (ops->cmd)
ret = ops->cmd(lum->handle, lum->cmd,