From 601d5acf42ebdb05ff8aa19f12fd9bdad3602781 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Tue, 20 Nov 2012 13:33:23 -0500 Subject: [PATCH] Adding context to an event is no longer possible The UST tracer does not allow to add context to an event so we've removed that. It is completely removed from the lttng UI so it's not possible either to add one to the kernel. The "event_name" of lttng_add_context is now ignored. Acked-by: Mathieu Desnoyers Signed-off-by: David Goulet --- src/bin/lttng-sessiond/cmd.c | 9 +- src/bin/lttng-sessiond/cmd.h | 3 +- src/bin/lttng-sessiond/context.c | 205 +++-------------------- src/bin/lttng-sessiond/context.h | 5 +- src/bin/lttng-sessiond/kernel.c | 29 ---- src/bin/lttng-sessiond/kernel.h | 2 - src/bin/lttng-sessiond/main.c | 1 - src/bin/lttng-sessiond/trace-kernel.c | 2 - src/bin/lttng-sessiond/trace-kernel.h | 5 - src/bin/lttng-sessiond/trace-ust.c | 7 - src/bin/lttng-sessiond/trace-ust.h | 1 - src/bin/lttng-sessiond/ust-app.c | 161 ------------------ src/bin/lttng-sessiond/ust-app.h | 11 -- src/bin/lttng/commands/add_context.c | 25 +-- src/common/sessiond-comm/sessiond-comm.h | 1 - src/lib/lttng-ctl/lttng-ctl.c | 11 +- tests/tools/test_kernel_data_trace.c | 1 - tests/tools/test_ust_data_trace.c | 1 - 18 files changed, 38 insertions(+), 442 deletions(-) diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 041b3e1bd..d58c53b66 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -1035,8 +1035,7 @@ error: * Command LTTNG_ADD_CONTEXT processed by the client thread. */ int cmd_add_context(struct ltt_session *session, int domain, - char *channel_name, char *event_name, struct lttng_event_context *ctx, - int kwpipe) + char *channel_name, struct lttng_event_context *ctx, int kwpipe) { int ret; @@ -1053,8 +1052,7 @@ int cmd_add_context(struct ltt_session *session, int domain, } /* Add kernel context to kernel tracer */ - ret = context_kernel_add(session->kernel_session, ctx, - event_name, channel_name); + ret = context_kernel_add(session->kernel_session, ctx, channel_name); if (ret != LTTNG_OK) { goto error; } @@ -1083,8 +1081,7 @@ int cmd_add_context(struct ltt_session *session, int domain, free(attr); } - - ret = context_ust_add(usess, domain, ctx, event_name, channel_name); + ret = context_ust_add(usess, domain, ctx, channel_name); if (ret != LTTNG_OK) { goto error; } diff --git a/src/bin/lttng-sessiond/cmd.h b/src/bin/lttng-sessiond/cmd.h index 20fc84a93..061cb1aef 100644 --- a/src/bin/lttng-sessiond/cmd.h +++ b/src/bin/lttng-sessiond/cmd.h @@ -45,8 +45,7 @@ int cmd_disable_event(struct ltt_session *session, int domain, int cmd_disable_event_all(struct ltt_session *session, int domain, char *channel_name); int cmd_add_context(struct ltt_session *session, int domain, - char *channel_name, char *event_name, struct lttng_event_context *ctx, - int kwpipe); + char *channel_name, struct lttng_event_context *ctx, int kwpipe); int cmd_set_filter(struct ltt_session *session, int domain, char *channel_name, char *event_name, struct lttng_filter_bytecode *bytecode); diff --git a/src/bin/lttng-sessiond/context.c b/src/bin/lttng-sessiond/context.c index 1bf3c6768..74afd4e0c 100644 --- a/src/bin/lttng-sessiond/context.c +++ b/src/bin/lttng-sessiond/context.c @@ -30,75 +30,26 @@ #include "ust-app.h" #include "trace-ust.h" -/* - * Add kernel context to an event of a specific channel. - */ -static int add_kctx_to_event(struct lttng_kernel_context *kctx, - struct ltt_kernel_channel *kchan, char *event_name) -{ - int ret, found = 0; - struct ltt_kernel_event *kevent; - - DBG("Add kernel context to event %s", event_name); - - kevent = trace_kernel_get_event_by_name(event_name, kchan); - if (kevent != NULL) { - ret = kernel_add_event_context(kevent, kctx); - if (ret < 0) { - goto error; - } - found = 1; - } - - ret = found; - -error: - return ret; -} - /* * Add kernel context to all channel. - * - * If event_name is specified, add context to event instead. */ static int add_kctx_all_channels(struct ltt_kernel_session *ksession, - struct lttng_kernel_context *kctx, char *event_name) + struct lttng_kernel_context *kctx) { - int ret, no_event = 0, found = 0; + int ret; struct ltt_kernel_channel *kchan; - if (strlen(event_name) == 0) { - no_event = 1; - } - - DBG("Adding kernel context to all channels (event: %s)", event_name); + DBG("Adding kernel context to all channels"); /* Go over all channels */ cds_list_for_each_entry(kchan, &ksession->channel_list.head, list) { - if (no_event) { - ret = kernel_add_channel_context(kchan, kctx); - if (ret < 0) { - ret = LTTNG_ERR_KERN_CONTEXT_FAIL; - goto error; - } - } else { - ret = add_kctx_to_event(kctx, kchan, event_name); - if (ret < 0) { - ret = LTTNG_ERR_KERN_CONTEXT_FAIL; - goto error; - } else if (ret == 1) { - /* Event found and context added */ - found = 1; - break; - } + ret = kernel_add_channel_context(kchan, kctx); + if (ret < 0) { + ret = LTTNG_ERR_KERN_CONTEXT_FAIL; + goto error; } } - if (!found && !no_event) { - ret = LTTNG_ERR_NO_EVENT; - goto error; - } - ret = LTTNG_OK; error: @@ -107,40 +58,17 @@ error: /* * Add kernel context to a specific channel. - * - * If event_name is specified, add context to that event. */ static int add_kctx_to_channel(struct lttng_kernel_context *kctx, - struct ltt_kernel_channel *kchan, char *event_name) + struct ltt_kernel_channel *kchan) { - int ret, no_event = 0, found = 0; - - if (strlen(event_name) == 0) { - no_event = 1; - } + int ret; - DBG("Add kernel context to channel '%s', event '%s'", - kchan->channel->name, event_name); + DBG("Add kernel context to channel '%s'", kchan->channel->name); - if (no_event) { - ret = kernel_add_channel_context(kchan, kctx); - if (ret < 0) { - ret = LTTNG_ERR_KERN_CONTEXT_FAIL; - goto error; - } - } else { - ret = add_kctx_to_event(kctx, kchan, event_name); - if (ret < 0) { - ret = LTTNG_ERR_KERN_CONTEXT_FAIL; - goto error; - } else if (ret == 1) { - /* Event found and context added */ - found = 1; - } - } - - if (!found && !no_event) { - ret = LTTNG_ERR_NO_EVENT; + ret = kernel_add_channel_context(kchan, kctx); + if (ret < 0) { + ret = LTTNG_ERR_KERN_CONTEXT_FAIL; goto error; } @@ -200,64 +128,11 @@ error: return ret; } -/* - * Add UST context to event. - */ -static int add_uctx_to_event(struct ltt_ust_session *usess, int domain, - struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, - struct lttng_event_context *ctx) -{ - int ret; - struct ltt_ust_context *uctx; - struct lttng_ht_iter iter; - struct lttng_ht_node_ulong *uctx_node; - - /* Create ltt UST context */ - uctx = trace_ust_create_context(ctx); - if (uctx == NULL) { - /* Context values are invalid. */ - ret = -EINVAL; - goto error; - } - - switch (domain) { - case LTTNG_DOMAIN_UST: - ret = ust_app_add_ctx_event_glb(usess, uchan, uevent, uctx); - if (ret < 0) { - goto error; - } - break; - default: - ret = -ENOSYS; - goto error; - } - - /* Lookup context before adding it */ - lttng_ht_lookup(uevent->ctx, (void *)((unsigned long)uctx->ctx.ctx), &iter); - uctx_node = lttng_ht_iter_get_node_ulong(&iter); - if (uctx_node != NULL) { - ret = -EEXIST; - goto error; - } - - /* Add ltt UST context node to ltt UST event */ - lttng_ht_add_unique_ulong(uevent->ctx, &uctx->node); - - DBG("Context UST %d added to event %s", uctx->ctx.ctx, uevent->attr.name); - - return 0; - -error: - free(uctx); - return ret; -} - /* * Add kernel context to tracer. */ int context_kernel_add(struct ltt_kernel_session *ksession, - struct lttng_event_context *ctx, char *event_name, - char *channel_name) + struct lttng_event_context *ctx, char *channel_name) { int ret; struct ltt_kernel_channel *kchan; @@ -309,7 +184,7 @@ int context_kernel_add(struct ltt_kernel_session *ksession, kctx.u.perf_counter.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; if (strlen(channel_name) == 0) { - ret = add_kctx_all_channels(ksession, &kctx, event_name); + ret = add_kctx_all_channels(ksession, &kctx); if (ret != LTTNG_OK) { goto error; } @@ -321,7 +196,7 @@ int context_kernel_add(struct ltt_kernel_session *ksession, goto error; } - ret = add_kctx_to_channel(&kctx, kchan, event_name); + ret = add_kctx_to_channel(&kctx, kchan); if (ret != LTTNG_OK) { goto error; } @@ -337,14 +212,12 @@ error: * Add UST context to tracer. */ int context_ust_add(struct ltt_ust_session *usess, int domain, - struct lttng_event_context *ctx, char *event_name, - char *channel_name) + struct lttng_event_context *ctx, char *channel_name) { - int ret = LTTNG_OK, have_event = 0; + int ret = LTTNG_OK; struct lttng_ht_iter iter; struct lttng_ht *chan_ht; struct ltt_ust_channel *uchan = NULL; - struct ltt_ust_event *uevent = NULL; /* * Define which channel's hashtable to use from the domain or quit if @@ -364,11 +237,6 @@ int context_ust_add(struct ltt_ust_session *usess, int domain, goto error; } - /* Do we have an event name */ - if (strlen(event_name) != 0) { - have_event = 1; - } - /* Get UST channel if defined */ if (strlen(channel_name) != 0) { uchan = trace_ust_find_channel_by_name(chan_ht, channel_name); @@ -378,39 +246,11 @@ int context_ust_add(struct ltt_ust_session *usess, int domain, } } - /* If UST channel specified and event name, get UST event ref */ - if (uchan && have_event) { - uevent = trace_ust_find_event_by_name(uchan->events, event_name); - if (uevent == NULL) { - ret = LTTNG_ERR_UST_EVENT_NOT_FOUND; - goto error; - } - } - - /* At this point, we have 4 possibilities */ - - if (uchan && uevent) { /* Add ctx to event in channel */ - ret = add_uctx_to_event(usess, domain, uchan, uevent, ctx); - } else if (uchan && !have_event) { /* Add ctx to channel */ + if (uchan) { + /* Add ctx to channel */ ret = add_uctx_to_channel(usess, domain, uchan, ctx); - } else if (!uchan && have_event) { /* Add ctx to event */ - /* Add context to event without having the channel name */ - cds_lfht_for_each_entry(chan_ht->ht, &iter.iter, uchan, node.node) { - uevent = trace_ust_find_event_by_name(uchan->events, event_name); - if (uevent != NULL) { - ret = add_uctx_to_event(usess, domain, uchan, uevent, ctx); - /* - * LTTng UST does not allowed the same event to be registered - * multiple time in different or the same channel. So, if we - * found our event, we stop. - */ - goto end; - } - } - ret = LTTNG_ERR_UST_EVENT_NOT_FOUND; - goto error; - } else if (!uchan && !have_event) { /* Add ctx all events, all channels */ - /* For all channels */ + } else { + /* Add ctx all events, all channels */ cds_lfht_for_each_entry(chan_ht->ht, &iter.iter, uchan, node.node) { ret = add_uctx_to_channel(usess, domain, uchan, ctx); if (ret < 0) { @@ -420,7 +260,6 @@ int context_ust_add(struct ltt_ust_session *usess, int domain, } } -end: switch (ret) { case -EEXIST: ret = LTTNG_ERR_UST_CONTEXT_EXIST; diff --git a/src/bin/lttng-sessiond/context.h b/src/bin/lttng-sessiond/context.h index 83c3c8310..e3047761b 100644 --- a/src/bin/lttng-sessiond/context.h +++ b/src/bin/lttng-sessiond/context.h @@ -25,9 +25,8 @@ #include "ust-ctl.h" int context_kernel_add(struct ltt_kernel_session *ksession, - struct lttng_event_context *ctx, char *event_name, char *channel_name); + struct lttng_event_context *ctx, char *channel_name); int context_ust_add(struct ltt_ust_session *usess, int domain, - struct lttng_event_context *ctx, char *event_name, - char *channel_name); + struct lttng_event_context *ctx, char *channel_name); #endif /* _LTT_CONTEXT_H */ diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index bf03dbad9..00172e801 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -66,35 +66,6 @@ error: return ret; } -/* - * Add context on a kernel event. - */ -int kernel_add_event_context(struct ltt_kernel_event *event, - struct lttng_kernel_context *ctx) -{ - int ret; - - DBG("Adding context to event %s", event->event->name); - ret = kernctl_add_context(event->fd, ctx); - if (ret < 0) { - PERROR("add context ioctl"); - goto error; - } - - event->ctx = zmalloc(sizeof(struct lttng_kernel_context)); - if (event->ctx == NULL) { - PERROR("zmalloc event context"); - goto error; - } - - memcpy(event->ctx, ctx, sizeof(struct lttng_kernel_context)); - - return 0; - -error: - return ret; -} - /* * Create a new kernel session, register it to the kernel tracer and add it to * the session daemon session. diff --git a/src/bin/lttng-sessiond/kernel.h b/src/bin/lttng-sessiond/kernel.h index 35f7368d1..86ae00371 100644 --- a/src/bin/lttng-sessiond/kernel.h +++ b/src/bin/lttng-sessiond/kernel.h @@ -32,8 +32,6 @@ int kernel_add_channel_context(struct ltt_kernel_channel *chan, struct lttng_kernel_context *ctx); -int kernel_add_event_context(struct ltt_kernel_event *event, - struct lttng_kernel_context *ctx); int kernel_create_session(struct ltt_session *session, int tracer_fd); int kernel_create_channel(struct ltt_kernel_session *session, struct lttng_channel *chan, char *path); diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 19eaa47d8..7dd652abc 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -2462,7 +2462,6 @@ skip_domain: { ret = cmd_add_context(cmd_ctx->session, cmd_ctx->lsm->domain.type, cmd_ctx->lsm->u.context.channel_name, - cmd_ctx->lsm->u.context.event_name, &cmd_ctx->lsm->u.context.ctx, kernel_poll_pipe[1]); break; } diff --git a/src/bin/lttng-sessiond/trace-kernel.c b/src/bin/lttng-sessiond/trace-kernel.c index 4d2870add..e8c381aa8 100644 --- a/src/bin/lttng-sessiond/trace-kernel.c +++ b/src/bin/lttng-sessiond/trace-kernel.c @@ -243,7 +243,6 @@ struct ltt_kernel_event *trace_kernel_create_event(struct lttng_event *ev) lke->fd = -1; lke->event = attr; lke->enabled = 1; - lke->ctx = NULL; return lke; @@ -369,7 +368,6 @@ void trace_kernel_destroy_event(struct ltt_kernel_event *event) cds_list_del(&event->list); free(event->event); - free(event->ctx); free(event); } diff --git a/src/bin/lttng-sessiond/trace-kernel.h b/src/bin/lttng-sessiond/trace-kernel.h index ed5b33189..27baa6d39 100644 --- a/src/bin/lttng-sessiond/trace-kernel.h +++ b/src/bin/lttng-sessiond/trace-kernel.h @@ -46,11 +46,6 @@ struct ltt_kernel_channel_list { struct ltt_kernel_event { int fd; int enabled; - /* - * TODO: need internal representation to support more than a - * single context. - */ - struct lttng_kernel_context *ctx; struct lttng_kernel_event *event; struct cds_list_head list; }; diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 2dcc7c25d..4c7dac8b7 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -274,12 +274,6 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev) /* Init node */ lttng_ht_node_init_str(&lue->node, lue->attr.name); - /* Alloc context hash tables */ - lue->ctx = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG); - if (lue->ctx == NULL) { - ERR("Unable to create context hash table for event %s", ev->name); - goto error_free_event; - } DBG2("Trace UST event %s, loglevel (%d,%d) created", lue->attr.name, lue->attr.loglevel_type, @@ -415,7 +409,6 @@ static void destroy_contexts(struct lttng_ht *ht) void trace_ust_destroy_event(struct ltt_ust_event *event) { DBG2("Trace destroy UST event %s", event->attr.name); - destroy_contexts(event->ctx); free(event->filter); free(event); } diff --git a/src/bin/lttng-sessiond/trace-ust.h b/src/bin/lttng-sessiond/trace-ust.h index b0a65cf19..297037b20 100644 --- a/src/bin/lttng-sessiond/trace-ust.h +++ b/src/bin/lttng-sessiond/trace-ust.h @@ -45,7 +45,6 @@ struct ltt_ust_context { struct ltt_ust_event { unsigned int enabled; struct lttng_ust_event attr; - struct lttng_ht *ctx; struct lttng_ht_node_str node; struct lttng_ust_filter_bytecode *filter; }; diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 2c42eb536..8dd7a9d1c 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -57,19 +57,7 @@ void delete_ust_app_ctx(int sock, struct ust_app_ctx *ua_ctx) static void delete_ust_app_event(int sock, struct ust_app_event *ua_event) { - int ret; - struct lttng_ht_iter iter; - struct ust_app_ctx *ua_ctx; - - /* Destroy each context of event */ - cds_lfht_for_each_entry(ua_event->ctx->ht, &iter.iter, ua_ctx, - node.node) { - ret = lttng_ht_del(ua_event->ctx, &iter); - assert(!ret); - delete_ust_app_ctx(sock, ua_ctx); - } free(ua_event->filter); - lttng_ht_destroy(ua_event->ctx); if (ua_event->obj != NULL) { ustctl_release_object(sock, ua_event->obj); @@ -326,7 +314,6 @@ struct ust_app_event *alloc_ust_app_event(char *name, ua_event->enabled = 1; strncpy(ua_event->name, name, sizeof(ua_event->name)); ua_event->name[sizeof(ua_event->name) - 1] = '\0'; - ua_event->ctx = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG); lttng_ht_node_init_str(&ua_event->node, ua_event->name); /* Copy attributes */ @@ -414,32 +401,6 @@ error: return ret; } -/* - * Create the event context on the tracer. - */ -static -int create_ust_event_context(struct ust_app_event *ua_event, - struct ust_app_ctx *ua_ctx, struct ust_app *app) -{ - int ret; - - health_code_update(&health_thread_cmd); - - ret = ustctl_add_context(app->sock, &ua_ctx->ctx, - ua_event->obj, &ua_ctx->obj); - if (ret < 0) { - goto error; - } - - ua_ctx->handle = ua_ctx->obj->handle; - - DBG2("UST app context created successfully for event %s", ua_event->name); - -error: - health_code_update(&health_thread_cmd); - return ret; -} - /* * Set the filter on the tracer. */ @@ -759,10 +720,6 @@ error: static void shadow_copy_event(struct ust_app_event *ua_event, struct ltt_ust_event *uevent) { - struct lttng_ht_iter iter; - struct ltt_ust_context *uctx; - struct ust_app_ctx *ua_ctx; - strncpy(ua_event->name, uevent->attr.name, sizeof(ua_event->name)); ua_event->name[sizeof(ua_event->name) - 1] = '\0'; @@ -781,17 +738,6 @@ static void shadow_copy_event(struct ust_app_event *ua_event, memcpy(ua_event->filter, uevent->filter, sizeof(*ua_event->filter) + uevent->filter->len); } - cds_lfht_for_each_entry(uevent->ctx->ht, &iter.iter, uctx, node.node) { - ua_ctx = alloc_ust_app_ctx(&uctx->ctx); - if (ua_ctx == NULL) { - /* malloc() failed. We should simply stop */ - return; - } - - lttng_ht_node_init_ulong(&ua_ctx->node, - (unsigned long) ua_ctx->ctx.ctx); - lttng_ht_add_unique_ulong(ua_event->ctx, &ua_ctx->node); - } } /* @@ -1034,47 +980,6 @@ error: return ret; } -/* - * Create an UST context and enable it for the event on the tracer. - */ -static -int create_ust_app_event_context(struct ust_app_session *ua_sess, - struct ust_app_event *ua_event, struct lttng_ust_context *uctx, - struct ust_app *app) -{ - int ret = 0; - struct lttng_ht_iter iter; - struct lttng_ht_node_ulong *node; - struct ust_app_ctx *ua_ctx; - - DBG2("UST app adding context to event %s", ua_event->name); - - lttng_ht_lookup(ua_event->ctx, (void *)((unsigned long)uctx->ctx), &iter); - node = lttng_ht_iter_get_node_ulong(&iter); - if (node != NULL) { - ret = -EEXIST; - goto error; - } - - ua_ctx = alloc_ust_app_ctx(uctx); - if (ua_ctx == NULL) { - /* malloc failed */ - ret = -1; - goto error; - } - - lttng_ht_node_init_ulong(&ua_ctx->node, (unsigned long) ua_ctx->ctx.ctx); - lttng_ht_add_unique_ulong(ua_event->ctx, &ua_ctx->node); - - ret = create_ust_event_context(ua_event, ua_ctx, app); - if (ret < 0) { - goto error; - } - -error: - return ret; -} - /* * Set UST filter for the event on the tracer. */ @@ -2599,15 +2504,6 @@ void ust_app_global_update(struct ltt_ust_session *usess, int sock) continue; } - /* Add context on events. */ - cds_lfht_for_each_entry(ua_event->ctx->ht, &iter_ctx.iter, - ua_ctx, node.node) { - ret = create_ust_event_context(ua_event, ua_ctx, app); - if (ret < 0) { - /* FIXME: Should we quit here or continue... */ - continue; - } - } ret = set_ust_event_filter(ua_event, app); if (ret < 0) { /* FIXME: Should we quit here or continue... */ @@ -2677,63 +2573,6 @@ int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess, return ret; } -/* - * Add context to a specific event in a channel for global UST domain. - */ -int ust_app_add_ctx_event_glb(struct ltt_ust_session *usess, - struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, - struct ltt_ust_context *uctx) -{ - int ret = 0; - struct lttng_ht_node_str *ua_chan_node, *ua_event_node; - struct lttng_ht_iter iter, uiter; - struct ust_app_session *ua_sess; - struct ust_app_event *ua_event; - struct ust_app_channel *ua_chan = NULL; - struct ust_app *app; - - rcu_read_lock(); - - cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) { - if (!app->compatible) { - /* - * TODO: In time, we should notice the caller of this error by - * telling him that this is a version error. - */ - continue; - } - ua_sess = lookup_session_by_app(usess, app); - if (ua_sess == NULL) { - continue; - } - - /* Lookup channel in the ust app session */ - lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &uiter); - ua_chan_node = lttng_ht_iter_get_node_str(&uiter); - if (ua_chan_node == NULL) { - continue; - } - ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, - node); - - lttng_ht_lookup(ua_chan->events, (void *)uevent->attr.name, &uiter); - ua_event_node = lttng_ht_iter_get_node_str(&uiter); - if (ua_event_node == NULL) { - continue; - } - ua_event = caa_container_of(ua_event_node, struct ust_app_event, - node); - - ret = create_ust_app_event_context(ua_sess, ua_event, &uctx->ctx, app); - if (ret < 0) { - continue; - } - } - - rcu_read_unlock(); - return ret; -} - /* * Add context to a specific event in a channel for global UST domain. */ diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h index ada517e10..605b4a69b 100644 --- a/src/bin/lttng-sessiond/ust-app.h +++ b/src/bin/lttng-sessiond/ust-app.h @@ -72,7 +72,6 @@ struct ust_app_event { struct lttng_ust_object_data *obj; struct lttng_ust_event attr; char name[LTTNG_UST_SYM_NAME_LEN]; - struct lttng_ht *ctx; struct lttng_ht_node_str node; struct lttng_ust_filter_bytecode *filter; }; @@ -167,9 +166,6 @@ int ust_app_enable_all_event_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan); int ust_app_disable_event_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent); -int ust_app_add_ctx_event_glb(struct ltt_ust_session *usess, - struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, - struct ltt_ust_context *uctx); int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx); int ust_app_set_filter_event_glb(struct ltt_ust_session *usess, @@ -317,13 +313,6 @@ int ust_app_enable_event_glb(struct ltt_ust_session *usess, return 0; } static inline -int ust_app_add_ctx_event_glb(struct ltt_ust_session *usess, - struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, - struct ltt_ust_context *uctx) -{ - return 0; -} -static inline int ust_app_add_ctx_channel_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan, struct ltt_ust_context *uctx) { diff --git a/src/bin/lttng/commands/add_context.c b/src/bin/lttng/commands/add_context.c index aec2d4df7..453575983 100644 --- a/src/bin/lttng/commands/add_context.c +++ b/src/bin/lttng/commands/add_context.c @@ -31,7 +31,6 @@ #define PRINT_LINE_LEN 80 -static char *opt_event_name; static char *opt_channel_name; static char *opt_session_name; static int opt_kernel; @@ -141,7 +140,6 @@ static struct poptOption long_options[] = { {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0}, {"session", 's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0}, {"channel", 'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0}, - {"event", 'e', POPT_ARG_STRING, &opt_event_name, 0, 0, 0}, {"kernel", 'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0}, {"userspace", 'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0}, {"type", 't', POPT_ARG_STRING, &opt_type, OPT_TYPE, 0, 0}, @@ -300,11 +298,10 @@ static void usage(FILE *ofp) { fprintf(ofp, "usage: lttng add-context -t TYPE [-k|-u] [OPTIONS]\n"); fprintf(ofp, "\n"); - fprintf(ofp, "If no channel and no event is given (-c/-e), the context\n"); - fprintf(ofp, "is added to all events and all channels.\n"); + fprintf(ofp, "If no channel is given (-c), the context is added to\n"); + fprintf(ofp, "all channels.\n"); fprintf(ofp, "\n"); - fprintf(ofp, "Otherwise the context is added only to the channel (-c)\n"); - fprintf(ofp, "and/or event (-e) indicated.\n"); + fprintf(ofp, "Otherwise the context is added only to the channel (-c).\n"); fprintf(ofp, "\n"); fprintf(ofp, "Exactly one domain (-k or -u) must be specified.\n"); fprintf(ofp, "\n"); @@ -313,7 +310,6 @@ static void usage(FILE *ofp) fprintf(ofp, " --list-options Simple listing of options\n"); fprintf(ofp, " -s, --session NAME Apply to session name\n"); fprintf(ofp, " -c, --channel NAME Apply to channel\n"); - fprintf(ofp, " -e, --event NAME Apply to event\n"); fprintf(ofp, " -k, --kernel Apply to the kernel tracer\n"); fprintf(ofp, " -u, --userspace Apply to the user-space tracer\n"); fprintf(ofp, "\n"); @@ -326,7 +322,7 @@ static void usage(FILE *ofp) fprintf(ofp, "\n"); fprintf(ofp, "Example:\n"); fprintf(ofp, "This command will add the context information 'prio' and two perf\n" - "counters (hardware branch misses and cache misses), to all events\n" + "counters (hardware branch misses and cache misses), to all channels\n" "in the trace data output:\n"); fprintf(ofp, "# lttng add-context -k -t prio -t perf:branch-misses -t perf:cache-misses\n"); fprintf(ofp, "\n"); @@ -398,25 +394,16 @@ static int add_context(char *session_name) } DBG("Adding context..."); - ret = lttng_add_context(handle, &context, opt_event_name, - opt_channel_name); + ret = lttng_add_context(handle, &context, NULL, opt_channel_name); if (ret < 0) { ERR("%s: %s", type->opt->symbol, lttng_strerror(ret)); warn = 1; continue; } else { - if (opt_channel_name && opt_event_name) { - MSG("%s context %s added to event %s channel %s", - opt_kernel ? "kernel" : "UST", type->opt->symbol, - opt_channel_name, opt_event_name); - } else if (opt_channel_name && !opt_event_name) { + if (opt_channel_name) { MSG("%s context %s added to channel %s", opt_kernel ? "kernel" : "UST", type->opt->symbol, opt_channel_name); - } else if (!opt_channel_name && opt_event_name) { - MSG("%s context %s added to event %s", - opt_kernel ? "kernel" : "UST", type->opt->symbol, - opt_event_name); } else { MSG("%s context %s added to all channels", opt_kernel ? "kernel" : "UST", type->opt->symbol) diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index 5c030a97e..88ba54449 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -186,7 +186,6 @@ struct lttcomm_session_msg { /* Context */ struct { char channel_name[LTTNG_SYMBOL_NAME_LEN]; - char event_name[LTTNG_SYMBOL_NAME_LEN]; struct lttng_event_context ctx; } context; /* Use by register_consumer */ diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 20bb8c6fa..4884b0294 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -749,10 +749,10 @@ int lttng_stop_tracing_no_wait(const char *session_name) } /* - * Add context to event and/or channel. - * If event_name is NULL, the context is applied to all events of the channel. - * If channel_name is NULL, a lookup of the event's channel is done. - * If both are NULL, the context is applied to all events of all channels. + * Add context to a channel. + * + * If the given channel is NULL, add the contexts to all channels. + * The event_name param is ignored. * * Returns the size of the returned payload data or a negative error code. */ @@ -774,9 +774,6 @@ int lttng_add_context(struct lttng_handle *handle, /* Copy channel name */ copy_string(lsm.u.context.channel_name, channel_name, sizeof(lsm.u.context.channel_name)); - /* Copy event name */ - copy_string(lsm.u.context.event_name, event_name, - sizeof(lsm.u.context.event_name)); copy_lttng_domain(&lsm.domain, &handle->domain); diff --git a/tests/tools/test_kernel_data_trace.c b/tests/tools/test_kernel_data_trace.c index 1edd20d6e..ed70f0ffb 100644 --- a/tests/tools/test_kernel_data_trace.c +++ b/tests/tools/test_kernel_data_trace.c @@ -156,7 +156,6 @@ static void create_kernel_event(void) printf("Validating kernel event: "); assert(event->fd == -1); assert(event->enabled == 1); - assert(event->ctx == NULL); assert(event->event->instrumentation == LTTNG_KERNEL_TRACEPOINT); assert(strlen(event->event->name)); PRINT_OK(); diff --git a/tests/tools/test_ust_data_trace.c b/tests/tools/test_ust_data_trace.c index 69a73b2f2..5d4c91b7e 100644 --- a/tests/tools/test_ust_data_trace.c +++ b/tests/tools/test_ust_data_trace.c @@ -164,7 +164,6 @@ static void create_ust_event(void) printf("Validating UST event: "); assert(event->enabled == 0); - assert(event->ctx != NULL); assert(event->attr.instrumentation == LTTNG_UST_TRACEPOINT); assert(strcmp(event->attr.name, ev.name) == 0); assert(event->attr.name[LTTNG_UST_SYM_NAME_LEN - 1] == '\0'); -- 2.34.1