X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lttng%2Flttng.c;h=75cb1b47372323c656d59b8851fc41f9bb85b4dc;hb=947308c48c77d6dfd601cfc575d61ea833ed0b6e;hp=10ce2ddfc08539bb121c2a0aa8b3bfe017a93f20;hpb=894be886aae0f1a1f49e63723511fcb15e816e7e;p=lttng-tools.git diff --git a/lttng/lttng.c b/lttng/lttng.c index 10ce2ddfc..75cb1b473 100644 --- a/lttng/lttng.c +++ b/lttng/lttng.c @@ -32,8 +32,8 @@ #include -#include "lttng.h" #include "lttngerr.h" +#include "options.h" /* Variables */ static char *progname; @@ -50,6 +50,7 @@ static int process_opt_list_traces(void); static int process_opt_create_session(void); static int process_kernel_create_trace(void); static int process_opt_kernel_event(void); +static int process_kernel_start_trace(void); static int set_session_uuid(void); static void sighandler(int sig); static int set_signal_handler(void); @@ -131,11 +132,28 @@ static int process_client_opt(void) if (opt_event_list != NULL) { ret = process_opt_kernel_event(); + if (ret < 0) { + goto end; + } } else { // Enable all events } - goto error; + if (auto_trace || opt_start_trace) { + DBG("Starting kernel tracing"); + ret = process_kernel_start_trace(); + if (ret < 0) { + goto end; + } + } + + if (opt_stop_trace) { + DBG("Stopping kernel tracing"); + ret = lttng_kernel_stop_tracing(); + if (ret < 0) { + goto end; + } + } } if (opt_trace_pid != 0) { @@ -174,6 +192,33 @@ error: /* fall through */ return ret; } +/* + * process_kernel_start_trace + * + * Start a kernel trace. + */ +static int process_kernel_start_trace(void) +{ + int ret; + + ret = lttng_kernel_create_stream(); + if (ret < 0) { + goto error; + } + + ret = lttng_kernel_start_tracing(); + if (ret < 0) { + goto error; + } + + MSG("Kernel tracing started"); + + return 0; + +error: + return ret; +} + /* * process_kernel_create_trace * @@ -181,7 +226,30 @@ error: /* fall through */ */ static int process_kernel_create_trace(void) { + int ret; + + /* Setup kernel session */ + ret = lttng_kernel_create_session(); + if (ret < 0) { + goto error; + } + + /* Create an empty channel (with no event) */ + ret = lttng_kernel_create_channel(); + if (ret < 0) { + goto error; + } + + /* Opening metadata for session */ + ret = lttng_kernel_open_metadata(); + if (ret < 0) { + goto error; + } + return 0; + +error: + return ret; } /* @@ -501,10 +569,13 @@ static int validate_options(void) } else if (opt_stop_trace && opt_trace_pid != 0 && opt_trace_name == NULL) { ERR("Please specify a trace name for user-space tracing"); goto error; + } else if (opt_stop_trace && opt_session_name == NULL) { + ERR("Please specify a session to stop tracing"); + goto error; } /* If start trace, auto start tracing */ - if (opt_start_trace) { + if (opt_start_trace || opt_event_list != NULL) { DBG("Requesting auto tracing"); auto_trace = 1; } @@ -574,8 +645,8 @@ static int check_ltt_sessiond(void) int ret; char *pathname = NULL, *alloc_pathname = NULL; - ret = lttng_check_session_daemon(); - if (ret < 0) { + ret = lttng_session_daemon_alive(); + if (ret == 0) { /* not alive */ /* Try command line option path */ if (opt_sessiond_path != NULL) { ret = access(opt_sessiond_path, F_OK | X_OK);