X-Git-Url: https://git.lttng.org/?p=lttngtop.git;a=blobdiff_plain;f=src%2Flttngtop.c;h=a2b552c6242bd4816c6c5d2eca8ec896c2897945;hp=9cf3a55d9c80bc4565dc6c5abd4aa5f4fded88f9;hb=6a1b139cec6513cb5d423d27a1a61c4424886bf1;hpb=f248b7d81143c5ff7b51a616e0c7394e26bac831 diff --git a/src/lttngtop.c b/src/lttngtop.c index 9cf3a55..a2b552c 100644 --- a/src/lttngtop.c +++ b/src/lttngtop.c @@ -109,6 +109,7 @@ enum { OPT_VERBOSE, OPT_GUI_TEST, OPT_CREATE_LOCAL_SESSION, + OPT_CREATE_LIVE_SESSION, }; static struct poptOption long_options[] = { @@ -127,6 +128,7 @@ static struct poptOption long_options[] = { { "verbose", 'v', POPT_ARG_NONE, NULL, OPT_VERBOSE, NULL, NULL }, { "gui-test", 'g', POPT_ARG_NONE, NULL, OPT_GUI_TEST, NULL, NULL }, { "create-local-session", 0, POPT_ARG_NONE, NULL, OPT_CREATE_LOCAL_SESSION, NULL, NULL }, + { "create-live-session", 0, POPT_ARG_NONE, NULL, OPT_CREATE_LIVE_SESSION, NULL, NULL }, { NULL, 0, 0, NULL, 0, NULL, NULL }, }; @@ -695,6 +697,8 @@ void usage(FILE *fp) fprintf(fp, " -b, --begin Network live streaming : read the trace for the beginning of the recording\n"); fprintf(fp, " -o, --output In textdump, output the log in \n"); fprintf(fp, " -g, --gui-test Test if the ncurses support is compiled in (return 0 if it is)\n"); + fprintf(fp, " --create-local-session Setup a LTTng local session with all the right parameters\n"); + fprintf(fp, " --create-live-session Setup a LTTng live session on localhost with all the right parameters\n"); } /* @@ -805,6 +809,9 @@ static int parse_options(int argc, char **argv) case OPT_CREATE_LOCAL_SESSION: ret = create_local_session(); exit(ret); + case OPT_CREATE_LIVE_SESSION: + ret = create_live_local_session(NULL, NULL, 1); + exit(ret); case OPT_TEXTDUMP: opt_textdump = 1; break; @@ -1239,6 +1246,7 @@ int main(int argc, char **argv, char **envp) { int ret; struct bt_context *bt_ctx = NULL; + char *live_session_name = NULL; init_lttngtop(); ret = parse_options(argc, argv); @@ -1257,28 +1265,13 @@ int main(int argc, char **argv, char **envp) if (!opt_input_path && !remote_live && !opt_exec_name) { /* mmap live */ -#ifdef LTTNGTOP_MMAP_LIVE - if (opt_textdump) { - signal(SIGTERM, handle_textdump_sigterm); - signal(SIGINT, handle_textdump_sigterm); - } - mmap_live_loop(bt_ctx); - pthread_join(timer_thread, NULL); - quit = 1; - pthread_join(display_thread, NULL); - - lttng_stop_tracing("test"); - lttng_destroy_session("test"); - - goto end; -#else - fprintf(stderr, "[ERROR] Mmap live support not compiled, specify a " - "trace directory or -r \n"); - usage(stdout); - ret = -1; - goto end; -#endif /* LTTNGTOP_MMAP_LIVE */ - } else if (!opt_input_path && remote_live) { + ret = create_live_local_session(&opt_relay_hostname, + &live_session_name, 0); + if (ret < 0) + goto end; + remote_live = 1; + } + if (!opt_input_path && remote_live) { /* network live */ bt_ctx = bt_context_create(); ret = bt_context_add_traces_recursive(bt_ctx, opt_relay_hostname, @@ -1288,8 +1281,6 @@ int main(int argc, char **argv, char **envp) goto end; } } else { - //init_lttngtop(); - bt_ctx = bt_context_create(); ret = bt_context_add_traces_recursive(bt_ctx, opt_input_path, "ctf", NULL); if (ret < 0) { @@ -1331,5 +1322,12 @@ end: if (bt_ctx) bt_context_put(bt_ctx); + if (live_session_name) { + ret = destroy_live_local_session(live_session_name); + if (ret < 0) { + fprintf(stderr, "Error destroying %s\n", live_session_name); + } + } + return ret; }