-/*
- * start_client
- *
- * Process client request from the command line
- * options. Every tracing action is done by the
- * liblttngctl API.
- */
-static int process_client_opt(void)
-{
- int ret;
-
- set_opt_session_info();
-
- if (opt_list_apps) {
- ret = process_opt_list_apps();
- if (ret < 0) {
- goto end;
- }
- goto error;
- }
-
- if (opt_list_session) {
- ret = process_opt_list_sessions();
- if (ret < 0) {
- goto end;
- }
- goto error;
- }
-
- if (opt_list_events) {
- if (opt_trace_kernel) {
- ret = process_opt_kernel_list_events();
- if (ret < 0) {
- goto end;
- }
- } else if (opt_trace_pid != 0) {
- // TODO
- }
- goto error;
- }
-
- /* Session creation or auto session set on */
- if (auto_session || opt_create_session) {
- DBG("Creating a new session");
- ret = process_opt_create_session();
- if (ret < 0) {
- goto end;
- }
- }
-
- ret = set_session_uuid();
- if (ret < 0) {
- ERR("Session %s not found", opt_session_name);
- goto error;
- }
-
- if (opt_destroy_session) {
- ret = lttng_destroy_session(¤t_uuid);
- if (ret < 0) {
- goto end;
- }
- MSG("Session %s destroyed.", opt_session_name);
- }
-
- if (opt_list_traces) {
- ret = process_opt_list_traces();
- if (ret < 0) {
- goto end;
- }
- }
-
- /*
- * Action on traces (kernel or/and userspace).
- */
-
- if (opt_trace_kernel) {
- if (auto_trace || opt_create_trace) {
- DBG("Creating a kernel trace");
- ret = process_kernel_create_trace();
- if (ret < 0) {
- goto end;
- }
- }
-
- if (opt_event_list != NULL || opt_enable_all_event) {
- ret = process_opt_kernel_event();
- if (ret < 0) {
- goto end;
- }
- }
-
- 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) {
- if (auto_trace || opt_create_trace) {
- DBG("Create a userspace trace for pid %d", opt_trace_pid);
- ret = lttng_ust_create_trace(opt_trace_pid);
- if (ret < 0) {
- goto end;
- }
- MSG("Trace created successfully!");
- }
-
- if (auto_trace || opt_start_trace) {
- DBG("Start trace for pid %d", opt_trace_pid);
- ret = lttng_ust_start_trace(opt_trace_pid);
- if (ret < 0) {
- goto end;
- }
- MSG("Trace started successfully!");
- } else if (opt_stop_trace) {
- DBG("Stop trace for pid %d", opt_trace_pid);
- ret = lttng_ust_stop_trace(opt_trace_pid);
- if (ret < 0) {
- goto end;
- }
- MSG("Trace stopped successfully!");
- }
-
- }
-
- return 0;
-
-end:
- ERR("%s", lttng_get_readable_code(ret));
-error: /* fall through */
- return ret;
-}
-
-/*
- * process_kernel_start_trace
- *
- * Start a kernel trace.
- */
-static int process_kernel_start_trace(void)
+int opt_quiet;
+int opt_verbose;
+static int opt_no_sessiond;
+static char *opt_sessiond_path;
+
+enum {
+ OPT_NO_SESSIOND,
+ OPT_SESSION_PATH,
+};
+
+/* Getopt options. No first level command. */
+static struct option long_options[] = {
+ {"help", 0, NULL, 'h'},
+ {"group", 1, NULL, 'g'},
+ {"verbose", 0, NULL, 'v'},
+ {"quiet", 0, NULL, 'q'},
+ {"no-sessiond", 0, NULL, OPT_NO_SESSIOND},
+ {"sessiond-path", 1, NULL, OPT_SESSION_PATH},
+ {NULL, 0, NULL, 0}
+};
+
+/* First level command */
+static struct cmd_struct commands[] = {
+ { "list", cmd_list},
+ { "create", cmd_create},
+ { "destroy", cmd_destroy},
+ { "add-channel", cmd_add_channel},
+ { "start", cmd_start},
+ { "stop", cmd_stop},
+ { "enable-event", cmd_enable_events},
+ { "disable-event", cmd_disable_events},
+ { "enable-channel", cmd_enable_channels},
+ { "disable-channel", cmd_disable_channels},
+ { "add-context", cmd_add_context},
+ { "set-session", cmd_set_session},
+ { NULL, NULL} /* Array closure */
+};
+
+static void usage(FILE *ofp)