From: Jonathan Rajotte Date: Fri, 4 May 2018 18:52:02 +0000 (-0400) Subject: Use EXTRA_VERSION_NAME and EXTRA_VERSION_DESCRIPTION X-Git-Tag: v2.12.0-rc1~320 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=a3bc3918a3e9f219cc54adcc41dd6b37381b30ff;p=lttng-tools.git Use EXTRA_VERSION_NAME and EXTRA_VERSION_DESCRIPTION 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 Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-crash/lttng-crash.c b/src/bin/lttng-crash/lttng-crash.c index f12ecfaea..de556a30b 100644 --- a/src/bin/lttng-crash/lttng-crash.c +++ b/src/bin/lttng-crash/lttng-crash.c @@ -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); } /* diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index 6720eca96..1c272c392 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -62,6 +62,7 @@ #include #include +#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 != '/') { diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index a428630f8..f7832300a 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -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; diff --git a/src/bin/lttng-sessiond/sessiond-config.c b/src/bin/lttng-sessiond/sessiond-config.c index 90a3b9354..7ab1f5d7b 100644 --- a/src/bin/lttng-sessiond/sessiond-config.c +++ b/src/bin/lttng-sessiond/sessiond-config.c @@ -15,6 +15,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "version.h" #include "sessiond-config.h" #include #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"); diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c index 722804e8e..6459e7b9f 100644 --- a/src/bin/lttng/commands/version.c +++ b/src/bin/lttng/commands/version.c @@ -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: diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c index aaee5a25d..17ab16dc6 100644 --- a/src/bin/lttng/lttng.c +++ b/src/bin/lttng/lttng.c @@ -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); } /*