lttng UI: read opt_cmd_name opt arg for each command
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sun, 13 Nov 2011 17:12:12 +0000 (12:12 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sun, 13 Nov 2011 17:12:12 +0000 (12:12 -0500)
Ensure all commands are layed out in the same way too.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng/commands/add_context.c
lttng/commands/calibrate.c
lttng/commands/disable_channels.c
lttng/commands/disable_events.c
lttng/commands/enable_channels.c
lttng/commands/enable_events.c
lttng/commands/list.c

index e82678bfccd08054fee3a1f82dd330f45d9db0f6..dd13d223be9e5aac96aab78cc1ba9a5889803995 100644 (file)
@@ -40,11 +40,13 @@ static char *opt_session_name;
 static int *opt_kernel;
 static int opt_pid_all;
 static int opt_userspace;
+static char *opt_cmd_name;
 static pid_t opt_pid;
 
 enum {
        OPT_HELP = 1,
        OPT_TYPE,
+       OPT_USERSPACE,
 };
 
 static struct lttng_handle *handle;
@@ -138,7 +140,7 @@ static struct poptOption long_options[] = {
        {"channel",        'c', POPT_ARG_STRING, &opt_channel_name, 0, 0, 0},
        {"event",          'e', POPT_ARG_STRING, &opt_event_name, 0, 0, 0},
        {"kernel",         'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
-       {"userspace",      'u', POPT_ARG_VAL, &opt_userspace, 1, 0, 0},
+       {"userspace",      'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, 0, OPT_USERSPACE, 0, 0},
        {"all",            0,   POPT_ARG_VAL, &opt_pid_all, 1, 0, 0},
        {"pid",            'p', POPT_ARG_INT, &opt_pid, 0, 0, 0},
        {"type",           't', POPT_ARG_STRING, 0, OPT_TYPE, 0, 0},
@@ -461,6 +463,10 @@ int cmd_add_context(int argc, const char **argv)
                        }
                        free(tmp);
                        break;
+               case OPT_USERSPACE:
+                       opt_userspace = 1;
+                       opt_cmd_name = poptGetOptArg(pc);
+                       break;
                default:
                        usage(stderr);
                        ret = CMD_UNDEFINED;
index e17a2fd73b12b82f11363f1150edc89f1a7a27fe..6979ef6eaa0c765852b938abd779d2c1edbe2397 100644 (file)
 
 static int opt_event_type;
 static char *opt_kernel;
-static char *opt_cmd_name;
 static int opt_pid_all;
 static int opt_userspace;
+static char *opt_cmd_name;
 static pid_t opt_pid;
 
 enum {
        OPT_HELP = 1,
-       OPT_USERSPACE,
        OPT_TRACEPOINT,
        OPT_MARKER,
        OPT_PROBE,
        OPT_FUNCTION,
        OPT_FUNCTION_ENTRY,
        OPT_SYSCALL,
+       OPT_USERSPACE,
 };
 
 static struct lttng_handle *handle;
@@ -181,10 +181,6 @@ int cmd_calibrate(int argc, const char **argv)
                        usage(stderr);
                        ret = CMD_SUCCESS;
                        goto end;
-               case OPT_USERSPACE:
-                       opt_userspace = 1;
-                       opt_cmd_name = poptGetOptArg(pc);
-                       break;
                case OPT_TRACEPOINT:
                        ret = CMD_NOT_IMPLEMENTED;
                        break;
@@ -203,6 +199,10 @@ int cmd_calibrate(int argc, const char **argv)
                case OPT_SYSCALL:
                        ret = CMD_NOT_IMPLEMENTED;
                        break;
+               case OPT_USERSPACE:
+                       opt_userspace = 1;
+                       opt_cmd_name = poptGetOptArg(pc);
+                       break;
                default:
                        usage(stderr);
                        ret = CMD_UNDEFINED;
index 9a816e3efb0bc652663492d224d038dc05dba253..262165eb3f0162f09580b83f9913f621df10c10f 100644 (file)
@@ -34,6 +34,7 @@ static char *opt_kernel;
 static char *opt_session_name;
 static int opt_pid_all;
 static int opt_userspace;
+static char *opt_cmd_name;
 static pid_t opt_pid;
 
 enum {
@@ -48,7 +49,7 @@ static struct poptOption long_options[] = {
        {"help",           'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
        {"session",        's', POPT_ARG_STRING, &opt_session_name, 0, 0, 0},
        {"kernel",         'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
-       {"userspace",      'u', POPT_ARG_NONE, 0, OPT_USERSPACE, 0, 0},
+       {"userspace",      'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, 0, OPT_USERSPACE, 0, 0},
        {"all",            0,   POPT_ARG_VAL, &opt_pid_all, 1, 0, 0},
        {"pid",            'p', POPT_ARG_INT, &opt_pid, 0, 0, 0},
        {0, 0, 0, 0, 0, 0, 0}
@@ -147,6 +148,7 @@ int cmd_disable_channels(int argc, const char **argv)
                        goto end;
                case OPT_USERSPACE:
                        opt_userspace = 1;
+                       opt_cmd_name = poptGetOptArg(pc);
                        break;
                default:
                        usage(stderr);
index f30a2b28ac4ea629f7ea0266b6574b3d4e90630a..09b61cbe25da6f55bb4bed2751bc9befec57bad3 100644 (file)
 
 static char *opt_event_list;
 static char *opt_kernel;
-static char *opt_cmd_name;
 static char *opt_channel_name;
 static char *opt_session_name;
 static int opt_pid_all;
 static int opt_userspace;
+static char *opt_cmd_name;
 static int opt_disable_all;
 static pid_t opt_pid;
 
index 715552b5b706a811a853028cfa9953db31e6c9b8..aac5fa4979c9d274b62f72ee61bcdd67c311dd9b 100644 (file)
@@ -36,6 +36,7 @@ static char *opt_cmd_name;
 static char *opt_session_name;
 static int opt_pid_all;
 static int opt_userspace;
+static char *opt_cmd_name;
 static pid_t opt_pid;
 static struct lttng_channel chan;
 
@@ -208,10 +209,6 @@ int cmd_enable_channels(int argc, const char **argv)
                        usage(stderr);
                        ret = CMD_SUCCESS;
                        goto end;
-               case OPT_USERSPACE:
-                       opt_userspace = 1;
-                       opt_cmd_name = poptGetOptArg(pc);
-                       break;
                case OPT_DISCARD:
                        chan.attr.overwrite = 0;
                        DBG("Channel set to discard");
@@ -236,6 +233,10 @@ int cmd_enable_channels(int argc, const char **argv)
                        chan.attr.read_timer_interval = atoi(poptGetOptArg(pc));
                        DBG("Channel read timer interval set to %d", chan.attr.read_timer_interval);
                        break;
+               case OPT_USERSPACE:
+                       opt_userspace = 1;
+                       opt_cmd_name = poptGetOptArg(pc);
+                       break;
                default:
                        usage(stderr);
                        ret = CMD_UNDEFINED;
index cb53fb0db96094c9736ae181e3bcc3ce27fcd0a9..3bf50fbeaf5c779b58233af5b4bbf4785ac60374 100644 (file)
 static char *opt_event_list;
 static int opt_event_type;
 static char *opt_kernel;
-static char *opt_cmd_name;
 static char *opt_session_name;
 static int opt_pid_all;
 static int opt_userspace;
+static char *opt_cmd_name;
 static int opt_enable_all;
 static pid_t opt_pid;
 static char *opt_probe;
@@ -47,13 +47,13 @@ static char *opt_channel_name;
 
 enum {
        OPT_HELP = 1,
-       OPT_USERSPACE,
        OPT_TRACEPOINT,
        OPT_MARKER,
        OPT_PROBE,
        OPT_FUNCTION,
        OPT_FUNCTION_ENTRY,
        OPT_SYSCALL,
+       OPT_USERSPACE,
 };
 
 static struct lttng_handle *handle;
@@ -388,15 +388,12 @@ int cmd_enable_events(int argc, const char **argv)
        opt_event_type = LTTNG_EVENT_ALL;
 
        while ((opt = poptGetNextOpt(pc)) != -1) {
+               fprintf(stderr, "OPT TEST %d\n", opt);
                switch (opt) {
                case OPT_HELP:
                        usage(stderr);
                        ret = CMD_SUCCESS;
                        goto end;
-               case OPT_USERSPACE:
-                       opt_userspace = 1;
-                       opt_cmd_name = poptGetOptArg(pc);
-                       break;
                case OPT_TRACEPOINT:
                        opt_event_type = LTTNG_EVENT_TRACEPOINT;
                        break;
@@ -418,6 +415,10 @@ int cmd_enable_events(int argc, const char **argv)
                case OPT_SYSCALL:
                        opt_event_type = LTTNG_EVENT_SYSCALL;
                        break;
+               case OPT_USERSPACE:
+                       opt_userspace = 1;
+                       opt_cmd_name = poptGetOptArg(pc);
+                       break;
                default:
                        usage(stderr);
                        ret = CMD_UNDEFINED;
index 808c2a549edbe9519a3b90387fbff845547020bb..e2d5b6643d5df24f15d5a2bb658ae6460604c22e 100644 (file)
@@ -28,6 +28,7 @@
 
 static int opt_pid;
 static int opt_userspace;
+static char *opt_cmd_name;
 static int opt_kernel;
 static char *opt_channel;
 static int opt_domain;
@@ -38,6 +39,7 @@ const char *indent8 = "        ";
 
 enum {
        OPT_HELP = 1,
+       OPT_USERSPACE,
 };
 
 static struct lttng_handle *handle;
@@ -46,7 +48,7 @@ static struct poptOption long_options[] = {
        /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */
        {"help",      'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0},
        {"kernel",    'k', POPT_ARG_VAL, &opt_kernel, 1, 0, 0},
-       {"userspace", 'u', POPT_ARG_VAL, &opt_userspace, 1, 0, 0},
+       {"userspace", 'u', POPT_ARG_STRING | POPT_ARGFLAG_OPTIONAL, 0, OPT_USERSPACE, 0, 0},
        {"pid",       'p', POPT_ARG_INT, &opt_pid, 0, 0, 0},
        {"channel",   'c', POPT_ARG_STRING, &opt_channel, 0, 0, 0},
        {"domain",    'd', POPT_ARG_VAL, &opt_domain, 1, 0, 0},
@@ -477,6 +479,10 @@ int cmd_list(int argc, const char **argv)
                case OPT_HELP:
                        usage(stderr);
                        goto end;
+               case OPT_USERSPACE:
+                       opt_userspace = 1;
+                       opt_cmd_name = poptGetOptArg(pc);
+                       break;
                default:
                        usage(stderr);
                        ret = CMD_UNDEFINED;
This page took 0.043427 seconds and 4 git commands to generate.