From 18a720cd7bbc2eeea6d075903668e21337b5d916 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 10 Sep 2014 16:50:58 -0400 Subject: [PATCH] Cleanup: Remove LTTNG_ENABLE_ALL_EVENT and LTTNG_DISABLE_ALL_EVENT Cleanup lttng-ctl to session daemon communication protocol, and cleanup session daemon code (remove dead code). Signed-off-by: Mathieu Desnoyers Signed-off-by: David Goulet --- src/bin/lttng-sessiond/cmd.c | 218 +++++------------------ src/bin/lttng-sessiond/cmd.h | 7 - src/bin/lttng-sessiond/main.c | 21 --- src/common/sessiond-comm/sessiond-comm.h | 4 +- src/lib/lttng-ctl/lttng-ctl.c | 16 +- 5 files changed, 54 insertions(+), 212 deletions(-) diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 872a6cea1..bbc122152 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -47,6 +47,21 @@ static pthread_mutex_t relayd_net_seq_idx_lock = PTHREAD_MUTEX_INITIALIZER; static uint64_t relayd_net_seq_idx; +/* + * Both functions below are special case for the Kernel domain when + * enabling/disabling all events. + */ +static +int enable_kevent_all(struct ltt_session *session, + struct lttng_domain *domain, char *channel_name, + struct lttng_event *event, + char *filter_expression, + struct lttng_filter_bytecode *filter, int wpipe); +static +int disable_kevent_all(struct ltt_session *session, int domain, + char *channel_name, + struct lttng_event *event); + /* * Create a session path used by list_lttng_sessions for the case that the * session consumer is on the network. @@ -1006,12 +1021,18 @@ int cmd_disable_event(struct ltt_session *session, int domain, int ret; char *event_name; + DBG("Disable event command for event \'%s\'", event->name); + event_name = event->name; if (event->loglevel_type || event->loglevel || event->enabled || event->pid || event->filter || event->exclusion) { return LTTNG_ERR_UNK; } + /* Special handling for kernel domain all events. */ + if (domain == LTTNG_DOMAIN_KERNEL && !strcmp(event_name, "*")) { + return disable_kevent_all(session, domain, channel_name, event); + } rcu_read_lock(); @@ -1119,8 +1140,12 @@ int cmd_disable_event(struct ltt_session *session, int domain, ret = -LTTNG_ERR_UST_EVENT_NOT_FOUND; goto error; } - - ret = event_agent_disable(usess, agt, event_name); + /* The wild card * means that everything should be disabled. */ + if (strncmp(event->name, "*", 1) == 0 && strlen(event->name) == 1) { + ret = event_agent_disable_all(usess, agt); + } else { + ret = event_agent_disable(usess, agt, event_name); + } if (ret != LTTNG_OK) { goto error; } @@ -1145,9 +1170,10 @@ error: } /* - * Command LTTNG_DISABLE_ALL_EVENT processed by the client thread. + * Command LTTNG_DISABLE_EVENT for event "*" processed by the client thread. */ -int cmd_disable_event_all(struct ltt_session *session, int domain, +static +int disable_kevent_all(struct ltt_session *session, int domain, char *channel_name, struct lttng_event *event) { @@ -1200,80 +1226,6 @@ int cmd_disable_event_all(struct ltt_session *session, int domain, kernel_wait_quiescent(kernel_tracer_fd); break; } - case LTTNG_DOMAIN_UST: - { - struct ltt_ust_session *usess; - struct ltt_ust_channel *uchan; - - usess = session->ust_session; - - /* - * If a non-default channel has been created in the - * session, explicitely require that -c chan_name needs - * to be provided. - */ - if (usess->has_non_default_channel && channel_name[0] == '\0') { - ret = LTTNG_ERR_NEED_CHANNEL_NAME; - goto error; - } - - uchan = trace_ust_find_channel_by_name(usess->domain_global.channels, - channel_name); - if (uchan == NULL) { - ret = LTTNG_ERR_UST_CHAN_NOT_FOUND; - goto error; - } - - switch (event->type) { - case LTTNG_EVENT_ALL: - ret = event_ust_disable_all_tracepoints(usess, uchan); - if (ret != 0) { - goto error; - } - break; - default: - ret = LTTNG_ERR_UNK; - goto error; - } - - DBG3("Disable all UST events in channel %s completed", channel_name); - - break; - } - case LTTNG_DOMAIN_LOG4J: - case LTTNG_DOMAIN_JUL: - { - struct agent *agt; - struct ltt_ust_session *usess = session->ust_session; - - assert(usess); - - switch (event->type) { - case LTTNG_EVENT_ALL: - break; - default: - ret = LTTNG_ERR_UNK; - goto error; - } - - agt = trace_ust_find_agent(usess, domain); - if (!agt) { - ret = -LTTNG_ERR_UST_EVENT_NOT_FOUND; - goto error; - } - - ret = event_agent_disable_all(usess, agt); - if (ret != LTTNG_OK) { - goto error; - } - - break; - } -#if 0 - case LTTNG_DOMAIN_UST_EXEC_NAME: - case LTTNG_DOMAIN_UST_PID: - case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN: -#endif default: ret = LTTNG_ERR_UND; goto error; @@ -1430,6 +1382,14 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain, assert(event); assert(channel_name); + DBG("Enable event command for event \'%s\'", event->name); + + /* Special handling for kernel domain all events. */ + if (domain->type == LTTNG_DOMAIN_KERNEL && !strcmp(event->name, "*")) { + return enable_kevent_all(session, domain, channel_name, event, + filter_expression, filter, wpipe); + } + ret = validate_event_name(event->name); if (ret) { goto error; @@ -1640,10 +1600,12 @@ error: } /* - * Command LTTNG_ENABLE_ALL_EVENT processed by the client thread. + * Command LTTNG_ENABLE_EVENT for event "*" processed by the client thread. */ -int cmd_enable_event_all(struct ltt_session *session, - struct lttng_domain *domain, char *channel_name, int event_type, +static +int enable_kevent_all(struct ltt_session *session, + struct lttng_domain *domain, char *channel_name, + struct lttng_event *event, char *filter_expression, struct lttng_filter_bytecode *filter, int wpipe) { @@ -1698,7 +1660,7 @@ int cmd_enable_event_all(struct ltt_session *session, assert(kchan); } - switch (event_type) { + switch (event->type) { case LTTNG_EVENT_SYSCALL: ret = event_kernel_enable_syscall(kchan, ""); break; @@ -1730,98 +1692,6 @@ int cmd_enable_event_all(struct ltt_session *session, kernel_wait_quiescent(kernel_tracer_fd); break; } - case LTTNG_DOMAIN_UST: - { - struct ltt_ust_channel *uchan; - struct ltt_ust_session *usess = session->ust_session; - - assert(usess); - - /* - * If a non-default channel has been created in the - * session, explicitely require that -c chan_name needs - * to be provided. - */ - if (usess->has_non_default_channel && channel_name[0] == '\0') { - ret = LTTNG_ERR_NEED_CHANNEL_NAME; - goto error; - } - - /* Get channel from global UST domain */ - uchan = trace_ust_find_channel_by_name(usess->domain_global.channels, - channel_name); - if (uchan == NULL) { - /* Create default channel */ - attr = channel_new_default_attr(LTTNG_DOMAIN_UST, - usess->buffer_type); - if (attr == NULL) { - ret = LTTNG_ERR_FATAL; - goto error; - } - strncpy(attr->name, channel_name, sizeof(attr->name)); - - ret = cmd_enable_channel(session, domain, attr, wpipe); - if (ret != LTTNG_OK) { - free(attr); - goto error; - } - free(attr); - - /* Get the newly created channel reference back */ - uchan = trace_ust_find_channel_by_name( - usess->domain_global.channels, channel_name); - assert(uchan); - } - - /* At this point, the session and channel exist on the tracer */ - - switch (event_type) { - case LTTNG_EVENT_ALL: - case LTTNG_EVENT_TRACEPOINT: - ret = event_ust_enable_all_tracepoints(usess, uchan, - filter_expression, filter); - if (ret != LTTNG_OK) { - goto error; - } - break; - default: - ret = LTTNG_ERR_UST_ENABLE_FAIL; - goto error; - } - - /* Manage return value */ - if (ret != LTTNG_OK) { - goto error; - } - - break; - } - case LTTNG_DOMAIN_LOG4J: - case LTTNG_DOMAIN_JUL: - { - struct lttng_event event; - struct ltt_ust_session *usess = session->ust_session; - - assert(usess); - - event.loglevel = LTTNG_LOGLEVEL_JUL_ALL; - event.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL; - strncpy(event.name, "*", sizeof(event.name)); - event.name[sizeof(event.name) - 1] = '\0'; - - ret = cmd_enable_event(session, domain, NULL, &event, - filter_expression, filter, NULL, wpipe); - if (ret != LTTNG_OK && ret != LTTNG_ERR_UST_EVENT_ENABLED) { - goto error; - } - - break; - } -#if 0 - case LTTNG_DOMAIN_UST_EXEC_NAME: - case LTTNG_DOMAIN_UST_PID: - case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN: -#endif default: ret = LTTNG_ERR_UND; goto error; diff --git a/src/bin/lttng-sessiond/cmd.h b/src/bin/lttng-sessiond/cmd.h index 5312eca61..509fb34a6 100644 --- a/src/bin/lttng-sessiond/cmd.h +++ b/src/bin/lttng-sessiond/cmd.h @@ -45,9 +45,6 @@ int cmd_enable_channel(struct ltt_session *session, int cmd_disable_event(struct ltt_session *session, int domain, char *channel_name, struct lttng_event *event); -int cmd_disable_event_all(struct ltt_session *session, int domain, - char *channel_name, - struct lttng_event *event); int cmd_add_context(struct ltt_session *session, int domain, char *channel_name, struct lttng_event_context *ctx, int kwpipe); int cmd_set_filter(struct ltt_session *session, int domain, @@ -59,10 +56,6 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain, struct lttng_filter_bytecode *filter, struct lttng_event_exclusion *exclusion, int wpipe); -int cmd_enable_event_all(struct ltt_session *session, - struct lttng_domain *domain, char *channel_name, int event_type, - char *filter_expression, - struct lttng_filter_bytecode *filter, int wpipe); /* Trace session action commands */ int cmd_start_trace(struct ltt_session *session); diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 22dd28e1e..a7f2394fd 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -2876,7 +2876,6 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock, switch (cmd_ctx->lsm->cmd_type) { case LTTNG_DISABLE_CHANNEL: case LTTNG_DISABLE_EVENT: - case LTTNG_DISABLE_ALL_EVENT: switch (cmd_ctx->lsm->domain.type) { case LTTNG_DOMAIN_KERNEL: if (!cmd_ctx->session->kernel_session) { @@ -3129,16 +3128,6 @@ skip_domain: &cmd_ctx->lsm->u.disable.event); break; } - case LTTNG_DISABLE_ALL_EVENT: - { - DBG("Disabling all events"); - - /* FIXME: passing packed structure to non-packed pointer */ - ret = cmd_disable_event_all(cmd_ctx->session, cmd_ctx->lsm->domain.type, - cmd_ctx->lsm->u.disable.channel_name, - &cmd_ctx->lsm->u.disable.event); - break; - } case LTTNG_ENABLE_CHANNEL: { ret = cmd_enable_channel(cmd_ctx->session, &cmd_ctx->lsm->domain, @@ -3251,16 +3240,6 @@ skip_domain: kernel_poll_pipe[1]); break; } - case LTTNG_ENABLE_ALL_EVENT: - { - DBG("Enabling all events"); - - ret = cmd_enable_event_all(cmd_ctx->session, &cmd_ctx->lsm->domain, - cmd_ctx->lsm->u.enable.channel_name, - cmd_ctx->lsm->u.enable.event.type, NULL, NULL, - kernel_poll_pipe[1]); - break; - } case LTTNG_LIST_TRACEPOINTS: { struct lttng_event *events; diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index ee3f99253..b571e5d92 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -60,10 +60,10 @@ enum lttcomm_sessiond_command { LTTNG_CALIBRATE = 1, LTTNG_DISABLE_CHANNEL = 2, LTTNG_DISABLE_EVENT = 3, - LTTNG_DISABLE_ALL_EVENT = 4, + /* 4 */ LTTNG_ENABLE_CHANNEL = 5, LTTNG_ENABLE_EVENT = 6, - LTTNG_ENABLE_ALL_EVENT = 7, + /* 7 */ /* Session daemon command */ LTTNG_CREATE_SESSION = 8, LTTNG_DESTROY_SESSION = 9, diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index c5aada5be..a398e34d6 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -919,10 +919,10 @@ int lttng_enable_event_with_exclusions(struct lttng_handle *handle, sizeof(lsm.u.enable.channel_name)); } - if (ev->name[0] != '\0') { - lsm.cmd_type = LTTNG_ENABLE_EVENT; - } else { - lsm.cmd_type = LTTNG_ENABLE_ALL_EVENT; + lsm.cmd_type = LTTNG_ENABLE_EVENT; + if (ev->name[0] == '\0') { + /* Enable all events */ + lttng_ctl_copy_string(ev->name, "*", sizeof(ev->name)); } lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain); @@ -1081,10 +1081,10 @@ int lttng_disable_event_ext(struct lttng_handle *handle, sizeof(lsm.u.disable.channel_name)); } - if (ev->name[0] != '\0') { - lsm.cmd_type = LTTNG_DISABLE_EVENT; - } else { - lsm.cmd_type = LTTNG_DISABLE_ALL_EVENT; + lsm.cmd_type = LTTNG_DISABLE_EVENT; + if (ev->name[0] == '\0') { + /* Disable all events */ + lttng_ctl_copy_string(ev->name, "*", sizeof(ev->name)); } lttng_ctl_copy_lttng_domain(&lsm.domain, &handle->domain); -- 2.34.1