listing and activation of loglevel by number
[lttng-tools.git] / lttng-sessiond / main.c
index 56a12518ec97821a6810135e02a8bf1849f17df7..0a6319f357ac99c2ddf8d3ddf33efe6bf8de7189 100644 (file)
@@ -171,10 +171,10 @@ static struct ltt_session_list *session_list_ptr;
 int ust_consumerd64_fd = -1;
 int ust_consumerd32_fd = -1;
 
-static const char *consumerd32_path =
-       __stringify(CONFIG_CONSUMERD32_PATH);
-static const char *consumerd64_path =
-       __stringify(CONFIG_CONSUMERD64_PATH);
+static const char *consumerd32_bin =
+       __stringify(CONFIG_CONSUMERD32_BIN);
+static const char *consumerd64_bin =
+       __stringify(CONFIG_CONSUMERD64_BIN);
 static const char *consumerd32_libdir =
        __stringify(CONFIG_CONSUMERD32_LIBDIR);
 static const char *consumerd64_libdir =
@@ -183,7 +183,7 @@ static const char *consumerd64_libdir =
 static
 void setup_consumerd_path(void)
 {
-       const char *path, *libdir;
+       const char *bin, *libdir;
 
        /*
         * Allow INSTALL_BIN_PATH to be used as a target path for the
@@ -191,15 +191,15 @@ void setup_consumerd_path(void)
         * has not been defined.
         */
 #if (CAA_BITS_PER_LONG == 32)
-       if (!consumerd32_path[0]) {
-               consumerd32_path = INSTALL_BIN_PATH "/" CONSUMERD_FILE;
+       if (!consumerd32_bin[0]) {
+               consumerd32_bin = INSTALL_BIN_PATH "/" CONSUMERD_FILE;
        }
        if (!consumerd32_libdir[0]) {
                consumerd32_libdir = INSTALL_LIB_PATH;
        }
 #elif (CAA_BITS_PER_LONG == 64)
-       if (!consumerd64_path[0]) {
-               consumerd64_path = INSTALL_BIN_PATH "/" CONSUMERD_FILE;
+       if (!consumerd64_bin[0]) {
+               consumerd64_bin = INSTALL_BIN_PATH "/" CONSUMERD_FILE;
        }
        if (!consumerd64_libdir[0]) {
                consumerd64_libdir = INSTALL_LIB_PATH;
@@ -211,13 +211,13 @@ void setup_consumerd_path(void)
        /*
         * runtime env. var. overrides the build default.
         */
-       path = getenv("LTTNG_CONSUMERD32_PATH");
-       if (path) {
-               consumerd32_path = path;
+       bin = getenv("LTTNG_CONSUMERD32_BIN");
+       if (bin) {
+               consumerd32_bin = bin;
        }
-       path = getenv("LTTNG_CONSUMERD64_PATH");
-       if (path) {
-               consumerd64_path = path;
+       bin = getenv("LTTNG_CONSUMERD64_BIN");
+       if (bin) {
+               consumerd64_bin = bin;
        }
        libdir = getenv("LTTNG_TOOLS_CONSUMERD32_LIBDIR");
        if (libdir) {
@@ -1508,7 +1508,9 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data)
 {
        int ret;
        pid_t pid;
+       const char *consumer_to_use;
        const char *verbosity;
+       struct stat st;
 
        DBG("Spawning consumerd");
 
@@ -1524,11 +1526,26 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data)
                }
                switch (consumer_data->type) {
                case LTTNG_CONSUMER_KERNEL:
-                       execl(INSTALL_BIN_PATH "/lttng-consumerd",
-                                       "lttng-consumerd", verbosity, "-k",
-                                       "--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path,
-                                       "--consumerd-err-sock", consumer_data->err_unix_sock_path,
-                                       NULL);
+                       /*
+                        * Find out which consumerd to execute. We will first
+                        * try the 64-bit path, then the 32-bit one, then
+                        * fallback on sessiond's installation directory.
+                        */
+                       if (stat(consumerd64_bin, &st) == 0) {
+                               consumer_to_use = consumerd64_bin;
+                       } else if (stat(consumerd32_bin, &st) == 0) {
+                               consumer_to_use = consumerd32_bin;
+                       } else if (stat(INSTALL_BIN_PATH "/" CONSUMERD_FILE, &st) == 0) {
+                               consumer_to_use = INSTALL_BIN_PATH "/" CONSUMERD_FILE;
+                       } else {
+                               break;
+                       }
+                       DBG("Using kernel consumer at: %s",  consumer_to_use);
+                       execl(consumer_to_use,
+                               "lttng-consumerd", verbosity, "-k",
+                               "--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path,
+                               "--consumerd-err-sock", consumer_data->err_unix_sock_path,
+                               NULL);
                        break;
                case LTTNG_CONSUMER64_UST:
                {
@@ -1561,7 +1578,8 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data)
                                        goto error;
                                }
                        }
-                       ret = execl(consumerd64_path, verbosity, "-u",
+                       DBG("Using 64-bit UST consumer at: %s",  consumerd64_bin);
+                       ret = execl(consumerd64_bin, verbosity, "-u",
                                        "--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path,
                                        "--consumerd-err-sock", consumer_data->err_unix_sock_path,
                                        NULL);
@@ -1604,7 +1622,8 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data)
                                        goto error;
                                }
                        }
-                       ret = execl(consumerd32_path, verbosity, "-u",
+                       DBG("Using 32-bit UST consumer at: %s",  consumerd32_bin);
+                       ret = execl(consumerd32_bin, verbosity, "-u",
                                        "--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path,
                                        "--consumerd-err-sock", consumer_data->err_unix_sock_path,
                                        NULL);
@@ -2073,6 +2092,9 @@ 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:
+                       tmp[i].type = LTTNG_EVENT_TRACEPOINT_LOGLEVEL;
+                       break;
                }
                i++;
        }
@@ -2543,6 +2565,12 @@ error:
 
 /*
  * Command LTTNG_ENABLE_EVENT processed by the client thread.
+ *
+ * TODO: currently, both events and loglevels are kept within the same
+ * namespace for UST global registry/app registery, so if an event
+ * happen to have the same name as the loglevel (very unlikely though),
+ * and an attempt is made to enable/disable both in the same session,
+ * the first to be created will be the only one allowed to exist.
  */
 static int cmd_enable_event(struct ltt_session *session, int domain,
                char *channel_name, struct lttng_event *event)
@@ -2672,15 +2700,16 @@ static int cmd_enable_event_all(struct ltt_session *session, int domain,
                        if (ret != LTTCOMM_OK) {
                                goto error;
                        }
-               }
 
-               /* Get the newly created kernel channel pointer */
-               kchan = trace_kernel_get_channel_by_name(channel_name,
-                               session->kernel_session);
-               if (kchan == NULL) {
-                       /* This sould not happen... */
-                       ret = LTTCOMM_FATAL;
-                       goto error;
+                       /* Get the newly created kernel channel pointer */
+                       kchan = trace_kernel_get_channel_by_name(channel_name,
+                                       session->kernel_session);
+                       if (kchan == NULL) {
+                               /* This sould not happen... */
+                               ret = LTTCOMM_FATAL;
+                               goto error;
+                       }
+
                }
 
                switch (event_type) {
@@ -2705,6 +2734,8 @@ static int cmd_enable_event_all(struct ltt_session *session, int domain,
                        ret = LTTCOMM_KERN_ENABLE_FAIL;
                        goto error;
                }
+
+               /* Manage return value */
                if (ret != LTTCOMM_OK) {
                        goto error;
                }
@@ -3257,7 +3288,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
                        /* Start the UST consumer daemons */
                        /* 64-bit */
                        pthread_mutex_lock(&ustconsumer64_data.pid_mutex);
-                       if (consumerd64_path[0] != '\0' &&
+                       if (consumerd64_bin[0] != '\0' &&
                                        ustconsumer64_data.pid == 0 &&
                                        cmd_ctx->lsm->cmd_type != LTTNG_REGISTER_CONSUMER) {
                                pthread_mutex_unlock(&ustconsumer64_data.pid_mutex);
@@ -3273,7 +3304,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
                                pthread_mutex_unlock(&ustconsumer64_data.pid_mutex);
                        }
                        /* 32-bit */
-                       if (consumerd32_path[0] != '\0' &&
+                       if (consumerd32_bin[0] != '\0' &&
                                        ustconsumer32_data.pid == 0 &&
                                        cmd_ctx->lsm->cmd_type != LTTNG_REGISTER_CONSUMER) {
                                pthread_mutex_unlock(&ustconsumer32_data.pid_mutex);
@@ -3822,13 +3853,13 @@ static int parse_args(int argc, char **argv)
                        opt_verbose_consumer += 1;
                        break;
                case 'u':
-                       consumerd32_path= optarg;
+                       consumerd32_bin= optarg;
                        break;
                case 'U':
                        consumerd32_libdir = optarg;
                        break;
                case 't':
-                       consumerd64_path = optarg;
+                       consumerd64_bin = optarg;
                        break;
                case 'T':
                        consumerd64_libdir = optarg;
This page took 0.02588 seconds and 4 git commands to generate.