X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lttng%2Flttng.c;h=5319c13d3dd9e33d7f3cddc70f1adf739f89d518;hb=6d8076ad2a383e3a1d9a5c78fa67e882751bbb1a;hp=9714e8a3476c10ad721362bca4d019c1c2fc62ae;hpb=a5c5a2bd8c78b788f6094d80c188af0db78c17ec;p=lttng-tools.git diff --git a/lttng/lttng.c b/lttng/lttng.c index 9714e8a34..5319c13d3 100644 --- a/lttng/lttng.c +++ b/lttng/lttng.c @@ -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); @@ -137,6 +138,22 @@ static int process_client_opt(void) } else { // Enable all events } + + 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) { @@ -175,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 * @@ -525,6 +569,9 @@ 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 */