X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lttng%2Flttng.c;h=77006bc7f63ab11834bb3b6286e8d69f7af58f55;hb=1fff1faa8195b6959cd53ca9cd7a51aa512db4ac;hp=5f0699119cc89614644a1cf1bc5ef176d4eeb3f7;hpb=beb8c75afd91bc32f2e7a9c124c9a21ecffd1486;p=lttng-tools.git diff --git a/lttng/lttng.c b/lttng/lttng.c index 5f0699119..77006bc7f 100644 --- a/lttng/lttng.c +++ b/lttng/lttng.c @@ -41,6 +41,8 @@ static char *opt_sessiond_path; enum { OPT_NO_SESSIOND, OPT_SESSION_PATH, + OPT_DUMP_OPTIONS, + OPT_DUMP_COMMANDS, }; /* Getopt options. No first level command. */ @@ -51,6 +53,8 @@ static struct option long_options[] = { {"quiet", 0, NULL, 'q'}, {"no-sessiond", 0, NULL, OPT_NO_SESSIOND}, {"sessiond-path", 1, NULL, OPT_SESSION_PATH}, + {"list-options", 0, NULL, OPT_DUMP_OPTIONS}, + {"list-commands", 0, NULL, OPT_DUMP_COMMANDS}, {NULL, 0, NULL, 0} }; @@ -63,6 +67,12 @@ static struct cmd_struct commands[] = { { "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}, + { "version", cmd_version}, { NULL, NULL} /* Array closure */ }; @@ -78,14 +88,20 @@ static void usage(FILE *ofp) fprintf(ofp, " -q, --quiet Quiet mode\n"); fprintf(ofp, " --no-sessiond Don't spawn a session daemon\n"); fprintf(ofp, " --sessiond-path Session daemon full path\n"); + fprintf(ofp, " --list-options Simple listing of lttng options\n"); + fprintf(ofp, " --list-commands Simple listing of lttng commands\n"); fprintf(ofp, "\n"); fprintf(ofp, "Commands:\n"); fprintf(ofp, " add-channel Add channel to tracer\n"); + fprintf(ofp, " add-context Add context to event or/and channel\n"); fprintf(ofp, " create Create tracing session\n"); fprintf(ofp, " destroy Teardown tracing session\n"); + fprintf(ofp, " enable-channel Enable tracing channel\n"); fprintf(ofp, " enable-event Enable tracing event\n"); + fprintf(ofp, " disable-channel Disable tracing channel\n"); fprintf(ofp, " disable-event Disable tracing event\n"); fprintf(ofp, " list List possible tracing options\n"); + fprintf(ofp, " set-session Set current session name\n"); fprintf(ofp, " start Start tracing\n"); fprintf(ofp, " stop Stop tracing\n"); fprintf(ofp, " version Show version information\n"); @@ -94,6 +110,49 @@ static void usage(FILE *ofp) fprintf(ofp, "See http://lttng.org for updates, bug reports and news.\n"); } +/* + * list_options + * + * List options line by line. This is mostly for bash auto completion and to + * avoid difficult parsing. + */ +static void list_options(FILE *ofp) +{ + int i = 0; + struct option *option = NULL; + + option = &long_options[i]; + while (option->name != NULL) { + fprintf(ofp, "--%s\n", option->name); + + if (isprint(option->val)) { + fprintf(ofp, "-%c\n", option->val); + } + + i++; + option = &long_options[i]; + } +} + +/* + * list_commands + * + * List commands line by line. This is mostly for bash auto completion and to + * avoid difficult parsing. + */ +static void list_commands(FILE *ofp) +{ + int i = 0; + struct cmd_struct *cmd = NULL; + + cmd = &commands[i]; + while (cmd->name != NULL) { + fprintf(ofp, "%s\n", cmd->name); + i++; + cmd = &commands[i]; + } +} + /* * clean_exit */ @@ -334,6 +393,14 @@ static int parse_args(int argc, char **argv) case OPT_SESSION_PATH: opt_sessiond_path = strdup(optarg); break; + case OPT_DUMP_OPTIONS: + list_options(stdout); + ret = 0; + goto error; + case OPT_DUMP_COMMANDS: + list_commands(stdout); + ret = 0; + goto error; default: usage(stderr); goto error; @@ -364,13 +431,13 @@ static int parse_args(int argc, char **argv) if (ret < 0) { if (ret == -1) { usage(stderr); - goto error; } else { ERR("%s", lttng_get_readable_code(ret)); } + goto error; } - return ret; + return 0; error: return -1; @@ -397,7 +464,9 @@ int main(int argc, char *argv[]) } ret = parse_args(argc, argv); - clean_exit(ret); + if (ret < 0) { + clean_exit(EXIT_FAILURE); + } return 0; }