X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=lttng-sessiond%2Fmain.c;h=fcae0235c099751af1f4119466d26f3a382d15d4;hp=7e58ff781ee86d481458657ddba725f30c102d49;hb=ac3bd9c0d406b3230680d06ab189bcb95337b9cc;hpb=ebaeda9495ef97ec81d9f7dd66eccdb32f116cee diff --git a/lttng-sessiond/main.c b/lttng-sessiond/main.c index 7e58ff781..fcae0235c 100644 --- a/lttng-sessiond/main.c +++ b/lttng-sessiond/main.c @@ -50,7 +50,7 @@ #include "event.h" #include "futex.h" #include "hashtable.h" -#include "kernel-ctl.h" +#include "kernel.h" #include "lttng-sessiond.h" #include "shm.h" #include "ust-app.h" @@ -192,7 +192,7 @@ void setup_consumerd_path(void) */ #if (CAA_BITS_PER_LONG == 32) if (!consumerd32_path[0]) { - consumerd32_bindir = INSTALL_BIN_PATH "/" CONSUMERD_FILE; + consumerd32_path = INSTALL_BIN_PATH "/" CONSUMERD_FILE; } if (!consumerd32_libdir[0]) { consumerd32_libdir = INSTALL_LIB_PATH; @@ -1532,18 +1532,88 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) break; case LTTNG_CONSUMER64_UST: { - execl(consumerd64_path, verbosity, "-u", + char *tmpnew = NULL; + + if (consumerd64_libdir[0] != '\0') { + char *tmp; + size_t tmplen; + + tmp = getenv("LD_LIBRARY_PATH"); + if (!tmp) { + tmp = ""; + } + tmplen = strlen("LD_LIBRARY_PATH=") + + strlen(consumerd64_libdir) + 1 /* : */ + strlen(tmp); + tmpnew = zmalloc(tmplen + 1 /* \0 */); + if (!tmpnew) { + ret = -ENOMEM; + goto error; + } + strcpy(tmpnew, "LD_LIBRARY_PATH="); + strcat(tmpnew, consumerd64_libdir); + if (tmp[0] != '\0') { + strcat(tmpnew, ":"); + strcat(tmpnew, tmp); + } + ret = putenv(tmpnew); + if (ret) { + ret = -errno; + goto error; + } + } + ret = execl(consumerd64_path, verbosity, "-u", "--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path, "--consumerd-err-sock", consumer_data->err_unix_sock_path, NULL); + if (consumerd64_libdir[0] != '\0') { + free(tmpnew); + } + if (ret) { + goto error; + } break; } case LTTNG_CONSUMER32_UST: { - execl(consumerd32_path, verbosity, "-u", + char *tmpnew = NULL; + + if (consumerd32_libdir[0] != '\0') { + char *tmp; + size_t tmplen; + + tmp = getenv("LD_LIBRARY_PATH"); + if (!tmp) { + tmp = ""; + } + tmplen = strlen("LD_LIBRARY_PATH=") + + strlen(consumerd32_libdir) + 1 /* : */ + strlen(tmp); + tmpnew = zmalloc(tmplen + 1 /* \0 */); + if (!tmpnew) { + ret = -ENOMEM; + goto error; + } + strcpy(tmpnew, "LD_LIBRARY_PATH="); + strcat(tmpnew, consumerd32_libdir); + if (tmp[0] != '\0') { + strcat(tmpnew, ":"); + strcat(tmpnew, tmp); + } + ret = putenv(tmpnew); + if (ret) { + ret = -errno; + goto error; + } + } + ret = execl(consumerd32_path, verbosity, "-u", "--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path, "--consumerd-err-sock", consumer_data->err_unix_sock_path, NULL); + if (consumerd32_libdir[0] != '\0') { + free(tmpnew); + } + if (ret) { + goto error; + } break; } default: @@ -1560,6 +1630,7 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data) perror("start consumer fork"); ret = -errno; } +error: return ret; } @@ -2002,6 +2073,11 @@ static int list_lttng_ust_global_events(char *channel_name, case LTTNG_UST_FUNCTION: tmp[i].type = LTTNG_EVENT_FUNCTION; break; + case LTTNG_UST_TRACEPOINT_LOGLEVEL: + /* TODO */ + ret = -LTTCOMM_NOT_IMPLEMENTED; + goto error; + break; } i++; } @@ -2120,7 +2196,13 @@ static int cmd_disable_channel(struct ltt_session *session, goto error; } - ret = ust_app_disable_channel_all(usess, uchan); + /* Already disabled */ + if (!uchan->enabled) { + DBG2("UST channel %s already disabled", channel_name); + break; + } + + ret = ust_app_disable_channel_glb(usess, uchan); if (ret < 0) { ret = LTTCOMM_UST_DISABLE_FAIL; goto error; @@ -2228,28 +2310,32 @@ static int cmd_enable_channel(struct ltt_session *session, goto error; } - rcu_read_lock(); - hashtable_add_unique(usess->domain_global.channels, &uchan->node); - rcu_read_unlock(); - DBG2("UST channel %s added to global domain HT", attr->name); - /* Add channel to all registered applications */ - ret = ust_app_create_channel_all(usess, uchan); + ret = ust_app_create_channel_glb(usess, uchan); if (ret != 0) { ret = LTTCOMM_UST_CHAN_FAIL; goto error; } + + rcu_read_lock(); + hashtable_add_unique(usess->domain_global.channels, &uchan->node); + rcu_read_unlock(); + + DBG2("UST channel %s added to global domain HT", attr->name); } else { /* If already enabled, everything is OK */ if (uchan->enabled) { - ret = LTTCOMM_OK; - goto error; + break; } - ret = ust_app_enable_channel_all(usess, uchan); + ret = ust_app_enable_channel_glb(usess, uchan); if (ret < 0) { - ret = LTTCOMM_UST_ENABLE_FAIL; - goto error; + if (ret != -EEXIST) { + ret = LTTCOMM_UST_CHAN_ENABLE_FAIL; + goto error; + } else { + ret = LTTCOMM_OK; + } } } @@ -2307,6 +2393,7 @@ static int cmd_disable_event(struct ltt_session *session, int domain, { struct ltt_ust_session *usess; struct ltt_ust_channel *uchan; + struct ltt_ust_event *uevent; usess = session->ust_session; @@ -2317,12 +2404,20 @@ static int cmd_disable_event(struct ltt_session *session, int domain, goto error; } - ret = ust_app_disable_event(usess, uchan, event_name); + uevent = trace_ust_find_event_by_name(uchan->events, event_name); + if (uevent == NULL) { + ret = LTTCOMM_UST_EVENT_NOT_FOUND; + goto error; + } + + ret = ust_app_disable_event_glb(usess, uchan, uevent); if (ret < 0) { ret = LTTCOMM_UST_DISABLE_FAIL; goto error; } + uevent->enabled = 0; + DBG2("Disable UST event %s in channel %s completed", event_name, channel_name); @@ -2386,7 +2481,7 @@ static int cmd_disable_event_all(struct ltt_session *session, int domain, goto error; } - ret = ust_app_disable_event_all(usess, uchan); + ret = ust_app_disable_all_event_glb(usess, uchan); if (ret < 0) { ret = LTTCOMM_UST_DISABLE_FAIL; goto error; @@ -2429,21 +2524,18 @@ static int cmd_add_context(struct ltt_session *session, int domain, break; case LTTNG_DOMAIN_UST: { - /* - struct ltt_ust_session *usess; + struct ltt_ust_session *usess = session->ust_session; - cds_list_for_each_entry(usess, &session->ust_session_list.head, list) { - ret = context_ust_add(usess, ctx, - event_name, channel_name, domain); - if (ret != LTTCOMM_OK) { - goto error; - } + ret = context_ust_add(usess, domain, ctx, event_name, channel_name); + if (ret != LTTCOMM_OK) { + goto error; } break; - */ } + case LTTNG_DOMAIN_UST_EXEC_NAME: + case LTTNG_DOMAIN_UST_PID: + case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN: default: - /* TODO: UST other domains */ ret = LTTCOMM_NOT_IMPLEMENTED; goto error; } @@ -2509,10 +2601,10 @@ static int cmd_enable_event(struct ltt_session *session, int domain, } case LTTNG_DOMAIN_UST: { - struct ltt_ust_channel *uchan; - struct ltt_ust_event *uevent; struct lttng_channel *attr; + struct ltt_ust_channel *uchan; + /* Get channel from global UST domain */ uchan = trace_ust_find_channel_by_name(usess->domain_global.channels, channel_name); if (uchan == NULL) { @@ -2523,14 +2615,14 @@ static int cmd_enable_event(struct ltt_session *session, int domain, goto error; } snprintf(attr->name, NAME_MAX, "%s", channel_name); + attr->name[NAME_MAX - 1] = '\0'; /* Use the internal command enable channel */ ret = cmd_enable_channel(session, domain, attr); - if (ret < 0) { + if (ret != LTTCOMM_OK) { free(attr); goto error; } - free(attr); /* Get the newly created channel reference back */ @@ -2543,31 +2635,12 @@ static int cmd_enable_event(struct ltt_session *session, int domain, } } - uevent = trace_ust_find_event_by_name(uchan->events, event->name); - if (uevent == NULL) { - uevent = trace_ust_create_event(event); - if (uevent == NULL) { - ret = LTTCOMM_FATAL; - goto error; - } - - } + /* At this point, the session and channel exist on the tracer */ - ret = ust_app_create_event_all(usess, uchan, uevent); - if (ret < 0) { - ret = LTTCOMM_UST_ENABLE_FAIL; + ret = event_ust_enable_tracepoint(usess, domain, uchan, event); + if (ret != LTTCOMM_OK) { goto error; } - - /* Add ltt ust event to channel */ - rcu_read_lock(); - hashtable_add_unique(uchan->events, &uevent->node); - rcu_read_unlock(); - - uevent->enabled = 1; - - DBG3("UST ltt event %s added to channel %s", uevent->attr.name, - uchan->name); break; } case LTTNG_DOMAIN_UST_EXEC_NAME: