X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fenable_channels.c;h=19b6b260bd7065e0b6490d8e247036483ecb14c6;hb=ca1c3607d2f5654163875cda874f43971df0f696;hp=5443d78a3c8826138cf9e3813de8ea88936befa8;hpb=1ab1ea0b77d5fc71765e06b5c84431e403e8bd2e;p=lttng-tools.git diff --git a/src/bin/lttng/commands/enable_channels.c b/src/bin/lttng/commands/enable_channels.c index 5443d78a3..19b6b260b 100644 --- a/src/bin/lttng/commands/enable_channels.c +++ b/src/bin/lttng/commands/enable_channels.c @@ -48,6 +48,7 @@ enum { OPT_SWITCH_TIMER, OPT_READ_TIMER, OPT_USERSPACE, + OPT_LIST_OPTIONS, }; static struct lttng_handle *handle; @@ -70,6 +71,7 @@ static struct poptOption long_options[] = { {"num-subbuf", 0, POPT_ARG_INT, 0, OPT_NUM_SUBBUF, 0, 0}, {"switch-timer", 0, POPT_ARG_INT, 0, OPT_SWITCH_TIMER, 0, 0}, {"read-timer", 0, POPT_ARG_INT, 0, OPT_READ_TIMER, 0, 0}, + {"list-options", 0, POPT_ARG_NONE, NULL, OPT_LIST_OPTIONS, NULL, NULL}, {0, 0, 0, 0, 0, 0, 0} }; @@ -81,6 +83,7 @@ static void usage(FILE *ofp) fprintf(ofp, "usage: lttng enable-channel NAME[,NAME2,...] [options] [channel_options]\n"); fprintf(ofp, "\n"); fprintf(ofp, " -h, --help Show this help\n"); + fprintf(ofp, " --list-options Simple listing of options\n"); fprintf(ofp, " -s, --session Apply on session name\n"); fprintf(ofp, " -k, --kernel Apply on the kernel tracer\n"); #if 0 @@ -159,7 +162,7 @@ static int enable_channel(char *session_name) dom.type = LTTNG_DOMAIN_UST; } else { ERR("Please specify a tracer (-k/--kernel or -u/--userspace)"); - ret = CMD_UNDEFINED; + ret = CMD_ERROR; goto error; } @@ -216,7 +219,7 @@ static void init_channel_config(void) */ int cmd_enable_channels(int argc, const char **argv) { - int opt, ret; + int opt, ret = CMD_SUCCESS; static poptContext pc; char *session_name = NULL; @@ -228,8 +231,7 @@ int cmd_enable_channels(int argc, const char **argv) while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case OPT_HELP: - usage(stderr); - ret = CMD_SUCCESS; + usage(stdout); goto end; case OPT_DISCARD: chan.attr.overwrite = 0; @@ -240,24 +242,31 @@ int cmd_enable_channels(int argc, const char **argv) DBG("Channel set to overwrite"); break; case OPT_SUBBUF_SIZE: + /* TODO Replace atol with strtol and check for errors */ chan.attr.subbuf_size = atol(poptGetOptArg(pc)); DBG("Channel subbuf size set to %" PRIu64, chan.attr.subbuf_size); break; case OPT_NUM_SUBBUF: + /* TODO Replace atoi with strtol and check for errors */ chan.attr.num_subbuf = atoi(poptGetOptArg(pc)); DBG("Channel subbuf num set to %" PRIu64, chan.attr.num_subbuf); break; case OPT_SWITCH_TIMER: + /* TODO Replace atoi with strtol and check for errors */ chan.attr.switch_timer_interval = atoi(poptGetOptArg(pc)); DBG("Channel switch timer interval set to %d", chan.attr.switch_timer_interval); break; case OPT_READ_TIMER: + /* TODO Replace atoi with strtol and check for errors */ 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; break; + case OPT_LIST_OPTIONS: + list_cmd_options(stdout, long_options); + goto end; default: usage(stderr); ret = CMD_UNDEFINED; @@ -269,14 +278,14 @@ int cmd_enable_channels(int argc, const char **argv) if (opt_channels == NULL) { ERR("Missing channel name.\n"); usage(stderr); - ret = CMD_SUCCESS; + ret = CMD_ERROR; goto end; } if (!opt_session_name) { session_name = get_session_name(); if (session_name == NULL) { - ret = -1; + ret = CMD_ERROR; goto end; } } else { @@ -286,5 +295,6 @@ int cmd_enable_channels(int argc, const char **argv) ret = enable_channel(session_name); end: + poptFreeContext(pc); return ret; }