lttng-view: make babeltrace2 the default viewer
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 30 Jan 2020 17:40:08 +0000 (12:40 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 30 Jan 2020 19:46:10 +0000 (14:46 -0500)
Use the `babeltrace2` binary to view traces by default rather than
the legacy `babeltrace`. As the install base of Babeltrace 2.x is
rather small at this point, silently fallback to Babeltrace 1.x
when it is not found on the system.

The man page is updated to reflect this change in behaviour.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie7cd7424f8af1e25238fcc4bb1aa3ee8226da023

configure.ac
doc/man/lttng-view.1.txt
src/bin/lttng/commands/view.c

index 97bb30f2afbce2f865505268a6e541c9dc166b25..ab659691fab0886a3710088366aa24e2d67a32ea 100644 (file)
@@ -245,13 +245,12 @@ AC_ARG_WITH([babeltrace-bin],
        [BABELTRACE_BIN=''])
 AC_SUBST([BABELTRACE_BIN])
 
-# lttv-gui
-AC_ARG_WITH([lttv-gui-bin],
-       AS_HELP_STRING([--with-lttv-gui-bin],
-   [Location of the lttv GUI viewer executable (including the filename)]),
-   [LTTV_GUI_BIN="$withval"],
-   [LTTV_GUI_BIN=''])
-AC_SUBST([LTTV_GUI_BIN])
+AC_ARG_WITH([babeltrace2-bin],
+       AS_HELP_STRING([--with-babeltrace2-bin],
+       [Location of the babeltrace2 viewer executable (including the filename)]),
+       [BABELTRACE2_BIN="$withval"],
+       [BABELTRACE2_BIN=''])
+AC_SUBST([BABELTRACE2_BIN])
 
 AC_ARG_WITH([consumerd32-bin],
        AS_HELP_STRING([--with-consumerd32-bin],
@@ -319,6 +318,7 @@ AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD64_BIN], "$CONSUMERD64_BIN", [Location of th
 AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD32_LIBDIR], "$CONSUMERD32_LIBDIR", [Search for consumerd 32-bit libraries in this location.])
 AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD64_LIBDIR], "$CONSUMERD64_LIBDIR", [Search for consumerd 64-bit libraries in this location.])
 AC_DEFINE_UNQUOTED([CONFIG_BABELTRACE_BIN], "$BABELTRACE_BIN", [Location of the babeltrace viewer executable.])
+AC_DEFINE_UNQUOTED([CONFIG_BABELTRACE2_BIN], "$BABELTRACE2_BIN", [Location of the babeltrace2 viewer executable.])
 AC_DEFINE_UNQUOTED([CONFIG_SESSIOND_BIN], "$SESSIOND_BIN", [Location of the sessiond executable.])
 AC_DEFINE_UNQUOTED([CONFIG_LTTNG_SYSTEM_RUNDIR], ["$LTTNG_SYSTEM_RUNDIR"], [LTTng system runtime directory])
 
index 50dc129d3182782a08ca35b9a10372c77ac4916d..e358c5b632e9ee0bec7034d670ea453a8f8b752e 100644 (file)
@@ -25,7 +25,9 @@ about the current tracing session). Otherwise, it is launched for the
 existing tracing session named 'SESSION'. `lttng list`
 outputs all the existing tracing sessions (see man:lttng-list(1)).
 
-By default, the man:babeltrace(1) trace viewer is launched.
+By default, the man:babeltrace2(1) trace viewer is launched. If it is
+not found on the system, the man:babeltrace(1) trace viewer is
+used.
 Another trace viewer command can be specified using the
 option:--viewer option.
 
index a13cb352510da0e3f2b60cc9a8c74f2b62f66870..3e2ce40ef1591c05143f7b8928427b7dd0da7da9 100644 (file)
@@ -30,6 +30,7 @@ static char *opt_session_name;
 static char *opt_viewer;
 static char *opt_trace_path;
 static const char *babeltrace_bin = CONFIG_BABELTRACE_BIN;
+static const char *babeltrace2_bin = CONFIG_BABELTRACE2_BIN;
 
 #ifdef LTTNG_EMBED_HELP
 static const char help_msg[] =
@@ -55,6 +56,7 @@ static struct poptOption long_options[] = {
  * This is needed for each viewer since we are using execvp().
  */
 static const char *babeltrace_opts[] = { "babeltrace" };
+static const char *babeltrace2_opts[] = { "babeltrace2" };
 
 /*
  * Type is also use as the index in the viewers array. So please, make sure
@@ -62,7 +64,8 @@ static const char *babeltrace_opts[] = { "babeltrace" };
  */
 enum viewer_type {
        VIEWER_BABELTRACE    = 0,
-       VIEWER_USER_DEFINED  = 1,
+       VIEWER_BABELTRACE2   = 1,
+       VIEWER_USER_DEFINED  = 2,
 };
 
 /*
@@ -74,6 +77,7 @@ static const struct viewers {
        enum viewer_type type;
 } viewers[] = {
        { "babeltrace", VIEWER_BABELTRACE },
+       { "babeltrace2", VIEWER_BABELTRACE2 },
        { NULL, VIEWER_USER_DEFINED },
 };
 
@@ -84,7 +88,7 @@ static const struct viewers *parse_options(void)
 {
        if (opt_viewer == NULL) {
                /* Default is babeltrace */
-               return &(viewers[VIEWER_BABELTRACE]);
+               return &(viewers[VIEWER_BABELTRACE2]);
        }
 
        /*
@@ -217,7 +221,17 @@ static int spawn_viewer(const char *trace_path)
                goto error;
        }
 
+retry_viewer:
        switch (viewer->type) {
+       case VIEWER_BABELTRACE2:
+               if (stat(babeltrace2_bin, &status) == 0) {
+                       viewer_bin = babeltrace2_bin;
+               } else {
+                       viewer_bin = viewer->exec_name;
+               }
+               argv = alloc_argv_from_local_opts(babeltrace2_opts,
+                               ARRAY_SIZE(babeltrace2_opts), trace_path);
+               break;
        case VIEWER_BABELTRACE:
                if (stat(babeltrace_bin, &status) == 0) {
                        viewer_bin = babeltrace_bin;
@@ -249,10 +263,20 @@ static int spawn_viewer(const char *trace_path)
 
        ret = execvp(viewer_bin, argv);
        if (ret) {
-               if (errno == ENOENT) {
-                       ERR("%s not found on the system", viewer_bin);
+               if (errno == ENOENT && viewer->exec_name) {
+                       if (viewer->type == VIEWER_BABELTRACE2) {
+                               /* Fallback to legacy babeltrace. */
+                               DBG("babeltrace2 not installed on the system, falling back to babeltrace 1.x");
+                               viewer = &viewers[VIEWER_BABELTRACE];
+                               free(argv);
+                               argv = NULL;
+                               goto retry_viewer;
+                       } else {
+                               ERR("Viewer \"%s\" not found on the system",
+                                               viewer_bin);
+                       }
                } else {
-                       PERROR("exec: %s", viewer_bin);
+                       PERROR("Failed to launch \"%s\" viewer", viewer_bin);
                }
                ret = CMD_FATAL;
                goto error;
This page took 0.039318 seconds and 5 git commands to generate.