From: David Goulet Date: Mon, 2 May 2011 15:23:29 +0000 (-0400) Subject: Add create trace option validation X-Git-Tag: v2.0-pre1~162 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8548ff30b847b76f7f62770ad5512883ee1e775a;p=lttng-tools.git Add create trace option validation Can't create a trace without a session ID for now. Future works will create a session automatically. Signed-off-by: David Goulet --- diff --git a/lttng/lttng.c b/lttng/lttng.c index 52c3e3873..9751621ff 100644 --- a/lttng/lttng.c +++ b/lttng/lttng.c @@ -46,6 +46,7 @@ static int process_opt_create_session(void); static void sighandler(int sig); static int set_signal_handler(void); static int get_cmdline_by_pid(pid_t pid, char **cmdline); +static int validate_options(void); /* * start_client @@ -104,7 +105,7 @@ static int process_client_opt(void) if (ret < 0) { goto end; } - MSG("Trace created successfully!\nUse --start PID to start tracing"); + MSG("Trace created successfully!\nUse --start PID to start tracing."); } return 0; @@ -242,6 +243,29 @@ not_running: return 0; } +/* + * validate_options + * + * Make sure that all options passed to the command line + * are compatible with each others. + * + * On error, return -1 + * On success, return 0 + */ +static int validate_options(void) +{ + if ((opt_session_uuid == NULL) && + (opt_create_trace)) { + ERR("Can't create trace without a session ID.\nPlease specify using --session UUID"); + goto error; + } + + return 0; + +error: + return -1; +} + /* * spawn_sessiond * @@ -421,6 +445,11 @@ int main(int argc, char *argv[]) clean_exit(EXIT_FAILURE); } + ret = validate_options(); + if (ret < 0) { + return EXIT_FAILURE; + } + ret = set_signal_handler(); if (ret < 0) { clean_exit(ret);