X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=lttng%2Flttng.c;h=e6e657cc1ec4e59438bd011b55f5345de7894d19;hp=09e336803460b4c20c1c97f89056b2fa14174b47;hb=865abf6508f89f0ef1fc37e415cfc49237092516;hpb=f3ed775ef4842019b396f06095b053c3a70bc3c8 diff --git a/lttng/lttng.c b/lttng/lttng.c index 09e336803..e6e657cc1 100644 --- a/lttng/lttng.c +++ b/lttng/lttng.c @@ -27,7 +27,7 @@ #include #include "cmd.h" -#include "config.h" +#include "conf.h" #include "lttngerr.h" /* Variables */ @@ -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,11 @@ 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}, { NULL, NULL} /* Array closure */ }; @@ -78,14 +87,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 +109,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 +392,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;