From: Mathieu Desnoyers Date: Sun, 13 Nov 2011 17:12:12 +0000 (-0500) Subject: lttng UI: read opt_cmd_name opt arg for each command X-Git-Tag: v2.0-pre15~132 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=eeac7d463a09ac924c3c98f1fa5fa6c19748b4de lttng UI: read opt_cmd_name opt arg for each command Ensure all commands are layed out in the same way too. Signed-off-by: Mathieu Desnoyers --- diff --git a/lttng/commands/add_context.c b/lttng/commands/add_context.c index e82678bfc..dd13d223b 100644 --- a/lttng/commands/add_context.c +++ b/lttng/commands/add_context.c @@ -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; diff --git a/lttng/commands/calibrate.c b/lttng/commands/calibrate.c index e17a2fd73..6979ef6ea 100644 --- a/lttng/commands/calibrate.c +++ b/lttng/commands/calibrate.c @@ -34,20 +34,20 @@ 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; diff --git a/lttng/commands/disable_channels.c b/lttng/commands/disable_channels.c index 9a816e3ef..262165eb3 100644 --- a/lttng/commands/disable_channels.c +++ b/lttng/commands/disable_channels.c @@ -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); diff --git a/lttng/commands/disable_events.c b/lttng/commands/disable_events.c index f30a2b28a..09b61cbe2 100644 --- a/lttng/commands/disable_events.c +++ b/lttng/commands/disable_events.c @@ -31,11 +31,11 @@ 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; diff --git a/lttng/commands/enable_channels.c b/lttng/commands/enable_channels.c index 715552b5b..aac5fa497 100644 --- a/lttng/commands/enable_channels.c +++ b/lttng/commands/enable_channels.c @@ -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; diff --git a/lttng/commands/enable_events.c b/lttng/commands/enable_events.c index cb53fb0db..3bf50fbea 100644 --- a/lttng/commands/enable_events.c +++ b/lttng/commands/enable_events.c @@ -34,10 +34,10 @@ 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; diff --git a/lttng/commands/list.c b/lttng/commands/list.c index 808c2a549..e2d5b6643 100644 --- a/lttng/commands/list.c +++ b/lttng/commands/list.c @@ -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;