Use EXTRA_VERSION_NAME and EXTRA_VERSION_DESCRIPTION
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Fri, 4 May 2018 18:52:02 +0000 (14:52 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 8 Oct 2019 17:33:56 +0000 (13:33 -0400)
Add detailed version information to the debug log of lttng-relayd and
lttng-sessiond.

Append the extra version information at the end of the "version" command
of the lttng binary.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-crash/lttng-crash.c
src/bin/lttng-relayd/main.c
src/bin/lttng-sessiond/main.c
src/bin/lttng-sessiond/sessiond-config.c
src/bin/lttng/commands/version.c
src/bin/lttng/lttng.c

index f12ecfaea0a6fe272f2859a9dd57a77a80638d03..de556a30bc9cd20c1a81c20513a0db4e88ae0174 100644 (file)
@@ -227,9 +227,10 @@ static void usage(void)
 static void version(FILE *ofp)
 {
        fprintf(ofp, "%s (LTTng Crash Trace Viewer) " VERSION " - " VERSION_NAME
-"%s\n",
+"%s%s\n",
                        progname,
-                       GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION);
+                       GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION,
+                       EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " EXTRA_VERSION_NAME);
 }
 
 /*
index 6720eca9687f6d9633dc9c5928eb904a2ab36d89..1c272c392cd5cdc135d79ec442ea42e7a4653257 100644 (file)
@@ -62,6 +62,7 @@
 #include <common/buffer-view.h>
 #include <common/string-utils/format.h>
 
+#include "version.h"
 #include "cmd.h"
 #include "ctf-trace.h"
 #include "index.h"
@@ -96,7 +97,7 @@ enum relay_connection_status {
 
 /* command line options */
 char *opt_output_path;
-static int opt_daemon, opt_background;
+static int opt_daemon, opt_background, opt_print_version;
 
 /*
  * We need to wait for listener and live listener threads, as well as
@@ -188,6 +189,20 @@ static struct option long_options[] = {
 
 static const char *config_ignore_options[] = { "help", "config", "version" };
 
+static void print_version(void) {
+       fprintf(stdout, "%s\n", VERSION);
+}
+
+static void relayd_config_log(void)
+{
+       DBG("LTTng-relayd " VERSION " - " VERSION_NAME "%s%s",
+                       GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION,
+                       EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " EXTRA_VERSION_NAME);
+       if (EXTRA_VERSION_DESCRIPTION[0] != '\0') {
+               DBG("LTTng-relayd extra version description:\n\t" EXTRA_VERSION_DESCRIPTION "\n");
+       }
+}
+
 /*
  * Take an option from the getopt output and set it in the right variable to be
  * used later.
@@ -278,8 +293,8 @@ static int set_option(int opt, const char *arg, const char *optname)
                }
                exit(EXIT_FAILURE);
        case 'V':
-               fprintf(stdout, "%s\n", VERSION);
-               exit(EXIT_SUCCESS);
+               opt_print_version = 1;
+               break;
        case 'o':
                if (lttng_is_setuid_setgid()) {
                        WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
@@ -3665,6 +3680,14 @@ int main(int argc, char **argv)
                goto exit_options;
        }
 
+       relayd_config_log();
+
+       if (opt_print_version) {
+               print_version();
+               retval = 0;
+               goto exit_options;
+       }
+
        /* Try to create directory if -o, --output is specified. */
        if (opt_output_path) {
                if (*opt_output_path != '/') {
index a428630f8ba8c17f7aae052d0eca89c6c3ffe379..f7832300a002222428e8b06a21023def90f9cf57 100644 (file)
@@ -95,6 +95,7 @@ NULL
 
 const char *progname;
 static int lockfile_fd = -1;
+static int opt_print_version;
 
 /* Set to 1 when a SIGUSR1 signal is received. */
 static int recv_child_signal;
@@ -433,8 +434,7 @@ static int set_option(int opt, const char *arg, const char *optname)
                }
                exit(ret ? EXIT_FAILURE : EXIT_SUCCESS);
        } else if (string_match(optname, "version") || opt == 'V') {
-               fprintf(stdout, "%s\n", VERSION);
-               exit(EXIT_SUCCESS);
+               opt_print_version = 1;
        } else if (string_match(optname, "sig-parent") || opt == 'S') {
                config.sig_parent = true;
        } else if (string_match(optname, "kconsumerd-err-sock")) {
@@ -789,6 +789,10 @@ end:
        return ret;
 }
 
+static void print_version(void) {
+       fprintf(stdout, "%s\n", VERSION);
+}
+
 /*
  * daemon configuration loading and argument parsing
  */
@@ -1386,6 +1390,12 @@ int main(int argc, char **argv)
        sessiond_config_log(&config);
        sessiond_uuid_log();
 
+       if (opt_print_version) {
+               print_version();
+               retval = 0;
+               goto exit_options;
+       }
+
        if (create_lttng_rundir()) {
                retval = -1;
                goto exit_options;
index 90a3b935400c2d4cdf6f5ea6da35dce0085b94a5..7ab1f5d7bc1c005afe3820a72b2d9ea1e8bd3456 100644 (file)
@@ -15,6 +15,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#include "version.h"
 #include "sessiond-config.h"
 #include <assert.h>
 #include "lttng-ust-ctl.h"
@@ -497,6 +498,16 @@ LTTNG_HIDDEN
 void sessiond_config_log(struct sessiond_config *config)
 {
        DBG_NO_LOC("[sessiond configuration]");
+       DBG_NO_LOC("\tversion                        %s", VERSION);
+       if (GIT_VERSION[0] != '\0') {
+               DBG_NO_LOC("\tgit version                    %s", GIT_VERSION);
+       }
+       if (EXTRA_VERSION_NAME[0] != '\0') {
+               DBG_NO_LOC("\textra version name             %s", EXTRA_VERSION_NAME);
+       }
+       if (EXTRA_VERSION_DESCRIPTION[0] != '\0') {
+               DBG_NO_LOC("\textra version description:\n\t%s", EXTRA_VERSION_DESCRIPTION);
+       }
        DBG_NO_LOC("\tverbose:                       %i", config->verbose);
        DBG_NO_LOC("\tverbose consumer:              %i", config->verbose_consumer);
        DBG_NO_LOC("\tquiet mode:                    %s", config->quiet ? "True" : "False");
index 722804e8e51a875ab5f9f1cd3e6a3b750e02efb2..6459e7b9f09abfe5bd25427eed783b8dad860a7f 100644 (file)
@@ -161,6 +161,12 @@ int cmd_version(int argc, const char **argv)
                MSG("\n" VERSION_DESCRIPTION "\n");
                MSG("Web site: https://lttng.org");
                MSG("\n%s", lttng_license);
+               if (EXTRA_VERSION_NAME[0] != '\0') {
+                       MSG("\nExtra version name: " EXTRA_VERSION_NAME);
+               }
+               if (EXTRA_VERSION_DESCRIPTION[0] != '\0') {
+                       MSG("\nExtra version description:\n\t" EXTRA_VERSION_DESCRIPTION);
+               }
        }
 
 end:
index aaee5a25d243d4c828d4f82434cd508a8a0e80d0..17ab16dc660a94cb27784af3fa6436bffa4765a7 100644 (file)
@@ -104,9 +104,10 @@ static struct cmd_struct commands[] =  {
 
 static void version(FILE *ofp)
 {
-       fprintf(ofp, "%s (LTTng Trace Control) " VERSION" - " VERSION_NAME "%s\n",
+       fprintf(ofp, "%s (LTTng Trace Control) " VERSION" - " VERSION_NAME "%s%s\n",
                        progname,
-                       GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION);
+                       GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION,
+                       EXTRA_VERSION_NAME[0] == '\0' ? "" : " - " EXTRA_VERSION_NAME);
 }
 
 /*
This page took 0.035261 seconds and 4 git commands to generate.