[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],
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])
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[] =
* 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
*/
enum viewer_type {
VIEWER_BABELTRACE = 0,
- VIEWER_USER_DEFINED = 1,
+ VIEWER_BABELTRACE2 = 1,
+ VIEWER_USER_DEFINED = 2,
};
/*
enum viewer_type type;
} viewers[] = {
{ "babeltrace", VIEWER_BABELTRACE },
+ { "babeltrace2", VIEWER_BABELTRACE2 },
{ NULL, VIEWER_USER_DEFINED },
};
{
if (opt_viewer == NULL) {
/* Default is babeltrace */
- return &(viewers[VIEWER_BABELTRACE]);
+ return &(viewers[VIEWER_BABELTRACE2]);
}
/*
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;
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;