Add a git version information in LTTng versions compiled from git sources
PATCH 1/1 Add a git version information in LTTng versions compiled from git sources
In reply to a message not in the archive--- .gitignore | 2 ++ Makefile.am | 4 +-- include/Makefile.am | 46 +++++++++++++++++++++++++++++++ include/version.h.tmpl | 27 ++++++++++++++++++ src/bin/lttng-sessiond/lttng-sessiond.h | 14 ++++++++++ src/bin/lttng-sessiond/main.c | 2 +- src/bin/lttng/commands/version.c | 4 ++- src/bin/lttng/lttng.c | 5 +++- src/bin/lttng/utils.h | 13 +++++++++ 9 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 include/version.h.tmpl
.gitignore +2 -0
@@ -31,6 +31,8 @@ config/ !config/epoll.m4 !config/config_feature.m4 +include/version.h + src/bin/lttng-sessiond/lttng-sessiond src/bin/lttng/lttng src/bin/lttng-consumerd/lttng-consumerd
Makefile.am +2 -2
@@ -1,9 +1,9 @@ ACLOCAL_AMFLAGS = -I config -SUBDIRS = src \ +SUBDIRS = include \ + src \ tests \ extras \ - include \ doc dist_doc_DATA = LICENSE \
include/Makefile.am +46 -0
47 lines not on this page · raw message
include/version.h.tmpl new file +27 -0
@@ -0,0 +1,27 @@ +/* + * version.h + * + * Linux Trace Toolkit version header file + * + * Copyright (C) 2013 - Raphaël Beamonte <[email protected]> + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License, version 2.1 only, + * as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef VERSION_H +#define VERSION_H + +#define GIT_VERSION + +#endif /* VERSION_H */
src/bin/lttng-sessiond/lttng-sessiond.h +14 -0
@@ -1,5 +1,6 @@/* * Copyright (C) 2011 - David Goulet <[email protected]> +* Copyright (C) 2013 - Raphaël Beamonte <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2 only,
@@ -28,6 +29,8 @@#include "session.h" #include "ust-app.h" +#include "version.h" +extern const char default_home_dir[], default_tracing_group[],
@@ -74,4 +77,15 @@ extern int apps_cmd_notify_pipe[2];int sessiond_set_thread_pollset (struct lttng_poll_event *events,size_t size);int sessiond_check_thread_quit_pipe (int fd,uint32_t events); +/* +* This static const char allows to return the version number depending +* whether or not the GIT_VERSION value is available +*/ +#ifdef GIT_VERSION +static const char lttng_sessiond_version[] =VERSION " (Git: " GIT_VERSION ")" ; +#else /* GIT_VERSION */ +static const char lttng_sessiond_version[] =VERSION ; +#endif /* GIT_VERSION */ + +#endif /* _LTT_SESSIOND_H */
src/bin/lttng-sessiond/main.c +1 -1
@@ -3555,7 +3555,7 @@ static int parse_args(int argc, char **argv)usage ();exit (EXIT_FAILURE );case 'V' : -fprintf (stdout,"%s\n" ,VERSION ); +fprintf (stdout,"%s\n" , lttng_sessiond_version);exit (EXIT_SUCCESS );case 'S' : opt_sig_parent =1 ;
src/bin/lttng/commands/version.c +3 -1
@@ -26,6 +26,7 @@#include <config.h> #include "../command.h" +#include "../utils.h" enum {OPT_HELP =1 ,
@@ -79,7 +80,8 @@ int cmd_version(int argc, const char **argv) }MSG ("lttng version " VERSION " - " VERSION_NAME ); -MSG ("\n" VERSION_DESCRIPTION "\n" ); +MSG ("%s" , lttng_version); +MSG (VERSION_DESCRIPTION "\n" );MSG ("Web site: http://lttng.org" );MSG ("\nlttng is free software and under the GPL license and part LGPL" );
src/bin/lttng/lttng.c +4 -1
@@ -31,6 +31,7 @@#include <common/error.h> #include "command.h" +#include "utils.h" /* Variables */ static char *progname;
@@ -81,7 +82,9 @@ static struct cmd_struct commands[] = {static void usage (FILE *ofp) { -fprintf (ofp,"LTTng Trace Control " VERSION " - " VERSION_NAME "\n\n" ); +fprintf (ofp,"LTTng Trace Control " VERSION " - " VERSION_NAME "\n" ); +fprintf (ofp,"%s" , lttng_version); +fprintf (ofp,"\n" );fprintf (ofp,"usage: lttng [OPTIONS] <COMMAND> [<ARGS>]\n" );fprintf (ofp,"\n" );fprintf (ofp,"Options:\n" );
src/bin/lttng/utils.h +13 -0
@@ -1,5 +1,6 @@/* * Copyright (C) 2011 - David Goulet <[email protected]> +* Copyright (C) 2013 - Raphaël Beamonte <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License, version 2 only,
@@ -19,8 +20,20 @@#define _LTTNG_UTILS_H#include <popt.h> +#include <version.h> char *get_session_name (void );void list_cmd_options (FILE *ofp,struct poptOption *options); +/* +* This static const char allows to return the version number depending +* whether or not the GIT_VERSION value is available +*/ +#ifdef GIT_VERSION +static const char lttng_version[] ="Git version: " GIT_VERSION "\n" ; +#else /* GIT_VERSION */ +static const char lttng_version[] ="" ; +#endif /* GIT_VERSION */ + +#endif /* _LTTNG_UTILS_H */
Signature · 7 lines
1.7.10.4 _______________________________________________ lttng-dev mailing list [email protected] http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
On 2013-03-25 10:30, David Goulet wrote:> Hi,
Quoted 3 lines
Two things. First, the version.h.tmpl has to be added to
EXTRA_DISTininclude/Makefile.am
Done. And changed the "version.h" to "nodist_*_headers".
Quoted 10 lines
Second thing, on line 86 of
lttng.c, *never* *never* *never* pass a variable to printf without a format.
fprintf(ofp, lttng_version);This is a huge vector attack to format strings. Furthermore, outside of the git tree, there is a warning:
lttng.c:86:2: warning: zero-length
gnu_printfformat string [-Wformat-zero-length]
My mistake, forgot to correct that... It's ok in the new patch.
Raphaël
_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev