static char *opt_viewer;
static char *opt_trace_path;
static const char *babeltrace_bin = CONFIG_BABELTRACE_BIN;
-//static const char *lttv_gui_bin = CONFIG_LTTV_GUI_BIN;
+
+#ifdef LTTNG_EMBED_HELP
+static const char help_msg[] =
+#include <lttng-view.1.h>
+;
+#endif
enum {
OPT_HELP = 1,
* This is needed for each viewer since we are using execvp().
*/
static const char *babeltrace_opts[] = { "babeltrace" };
-//static const char *lttv_gui_opts[] = { "lttv-gui", "-t", };
/*
* Type is also use as the index in the viewers array. So please, make sure
*/
enum viewer_type {
VIEWER_BABELTRACE = 0,
- VIEWER_LTTV_GUI = 1,
- VIEWER_USER_DEFINED = 2,
+ VIEWER_USER_DEFINED = 1,
};
/*
* NOTE: "lttv" is a shell command and it's not working for exec() family
* functions so we might think of removing this wrapper or using bash.
*/
-static struct viewers {
+static const struct viewers {
const char *exec_name;
enum viewer_type type;
} viewers[] = {
{ "babeltrace", VIEWER_BABELTRACE },
- { "lttv-gui", VIEWER_LTTV_GUI },
{ NULL, VIEWER_USER_DEFINED },
};
/* Is the session we are trying to view is in live mode. */
static int session_live_mode;
-static struct viewers *parse_options(void)
+static const struct viewers *parse_options(void)
{
if (opt_viewer == NULL) {
/* Default is babeltrace */
goto error;
}
- memcpy(argv, opts, size);
+ memcpy(argv, opts, sizeof(char *) * opts_len);
if (session_live_mode) {
argv[opts_len] = "-i";
int ret = 0;
struct stat status;
const char *viewer_bin = NULL;
- struct viewers *viewer;
+ const struct viewers *viewer;
char **argv = NULL;
/* Check for --viewer options */
int ret;
char *session_name, *trace_path = NULL;
struct lttng_session *sessions = NULL;
+ bool free_trace_path = false;
/*
* Safety net. If lttng is suid at some point for *any* useless reasons,
ret = CMD_ERROR;
goto free_sessions;
}
+ free_trace_path = true;
} else {
/* Get file system session path. */
trace_path = sessions[i].path;
}
free_sessions:
- if (session_live_mode) {
+ if (session_live_mode && free_trace_path) {
free(trace_path);
}
free(sessions);
{
int opt, ret = CMD_SUCCESS;
static poptContext pc;
+ const char *leftover = NULL;
pc = poptGetContext(NULL, argc, argv, long_options, 0);
poptReadDefaultConfig(pc, 0);
opt_session_name = (char*) poptGetArg(pc);
+ leftover = poptGetArg(pc);
+ if (leftover) {
+ ERR("Unknown argument: %s", leftover);
+ ret = CMD_ERROR;
+ goto end;
+ }
+
ret = view_trace();
end: