X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Flttng.c;h=dc9dd9241b9847eb12466fefdefa8120314321ad;hb=9c48cab3239afea25eba069a9869a59ecd310c03;hp=90c031fafaaf655cd124d494ef207e2ba8b7c0c2;hpb=4ce78777c3ffcdd42e635ed45aa5dd3a7c7bd22d;p=lttng-tools.git diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c index 90c031faf..dc9dd9241 100644 --- a/src/bin/lttng/lttng.c +++ b/src/bin/lttng/lttng.c @@ -47,6 +47,7 @@ enum { /* Getopt options. No first level command. */ static struct option long_options[] = { + {"version", 0, NULL, 'V'}, {"help", 0, NULL, 'h'}, {"group", 1, NULL, 'g'}, {"verbose", 0, NULL, 'v'}, @@ -74,8 +75,9 @@ static struct cmd_struct commands[] = { { "version", cmd_version}, { "calibrate", cmd_calibrate}, { "view", cmd_view}, - { "enable-consumer", cmd_enable_consumer}, /* OBSELETE */ - { "disable-consumer", cmd_disable_consumer}, /*OBSELETE */ + { "snapshot", cmd_snapshot}, + { "enable-consumer", cmd_enable_consumer}, /* OBSOLETE */ + { "disable-consumer", cmd_disable_consumer}, /* OBSOLETE */ { NULL, NULL} /* Array closure */ }; @@ -85,6 +87,7 @@ static void usage(FILE *ofp) fprintf(ofp, "usage: lttng [OPTIONS] []\n"); fprintf(ofp, "\n"); fprintf(ofp, "Options:\n"); + fprintf(ofp, " -V, --version Show version\n"); fprintf(ofp, " -h, --help Show this help\n"); fprintf(ofp, " --list-options Simple listing of lttng options\n"); fprintf(ofp, " --list-commands Simple listing of lttng commands\n"); @@ -105,6 +108,7 @@ static void usage(FILE *ofp) 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, " snapshot Snapshot buffers of current session name\n"); fprintf(ofp, " start Start tracing\n"); fprintf(ofp, " stop Stop tracing\n"); fprintf(ofp, " version Show version information\n"); @@ -116,6 +120,12 @@ static void usage(FILE *ofp) fprintf(ofp, "See http://lttng.org for updates, bug reports and news.\n"); } +static void version(FILE *ofp) +{ + fprintf(ofp, "%s (LTTng Trace Control) " VERSION" - " VERSION_NAME"\n", + progname); +} + /* * list_options * @@ -140,25 +150,6 @@ static void list_options(FILE *ofp) } } -/* - * 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 */ @@ -426,8 +417,12 @@ static int parse_args(int argc, char **argv) clean_exit(EXIT_FAILURE); } - while ((opt = getopt_long(argc, argv, "+hnvqg:", long_options, NULL)) != -1) { + while ((opt = getopt_long(argc, argv, "+Vhnvqg:", long_options, NULL)) != -1) { switch (opt) { + case 'V': + version(stdout); + ret = 0; + goto end; case 'h': usage(stdout); ret = 0; @@ -452,7 +447,7 @@ static int parse_args(int argc, char **argv) ret = 0; goto end; case OPT_DUMP_COMMANDS: - list_commands(stdout); + list_commands(commands, stdout); ret = 0; goto end; default: