X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fenable_events.c;h=05f20f72de03309afda2add9c268a9d934fbe77f;hp=68d49769bcfdc5834422b73c7c68c8c2062287ab;hb=68c7f6e55254fd6e54d7bb4a6c1316bb77843a6e;hpb=895707daf3f9a3cbe4eb9915a42e1677d221c218 diff --git a/src/bin/lttng/commands/enable_events.c b/src/bin/lttng/commands/enable_events.c index 68d49769b..05f20f72d 100644 --- a/src/bin/lttng/commands/enable_events.c +++ b/src/bin/lttng/commands/enable_events.c @@ -15,20 +15,20 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE #define _LGPL_SOURCE #include #include #include #include -#include #include #include #include #include #include -#include +#include +#include +#include /* Mi dependancy */ #include @@ -56,6 +56,12 @@ static char *opt_channel_name; static char *opt_filter; static char *opt_exclude; +#ifdef LTTNG_EMBED_HELP +static const char help_msg[] = +#include +; +#endif + enum { OPT_HELP = 1, OPT_TRACEPOINT, @@ -96,147 +102,6 @@ static struct poptOption long_options[] = { {0, 0, 0, 0, 0, 0, 0} }; -/* - * usage - */ -static void usage(FILE *ofp) -{ - fprintf(ofp, "usage: lttng enable-event NAME[,NAME2,...] (-k | -u | -j | -l | -p) [OPTIONS] \n"); - fprintf(ofp, "\n"); - fprintf(ofp, "Options:\n"); - fprintf(ofp, " -h, --help Show this help\n"); - fprintf(ofp, " --list-options Simple listing of options\n"); - fprintf(ofp, " -s, --session NAME Apply to session name\n"); - fprintf(ofp, " -c, --channel NAME Apply to this channel\n"); - fprintf(ofp, " -a, --all Enable all tracepoints and syscalls\n"); - fprintf(ofp, " -k, --kernel Apply for the kernel tracer\n"); - fprintf(ofp, " -u, --userspace Apply to the user-space tracer\n"); - fprintf(ofp, " -j, --jul Apply for Java application using JUL\n"); - fprintf(ofp, " -l, --log4j Apply for Java application using LOG4j\n"); - fprintf(ofp, " -p, --python Apply for Python application\n"); - fprintf(ofp, "\n"); - fprintf(ofp, "Event options:\n"); - fprintf(ofp, " --tracepoint Tracepoint event (default)\n"); - fprintf(ofp, " - userspace tracer supports wildcards at end of string.\n"); - fprintf(ofp, " Don't forget to quote to deal with bash expansion.\n"); - fprintf(ofp, " e.g.:\n"); - fprintf(ofp, " \"*\"\n"); - fprintf(ofp, " \"app_component:na*\"\n"); - fprintf(ofp, " --probe (addr | symbol | symbol+offset)\n"); - fprintf(ofp, " Dynamic probe.\n"); - fprintf(ofp, " Addr and offset can be octal (0NNN...),\n"); - fprintf(ofp, " decimal (NNN...) or hexadecimal (0xNNN...)\n"); - fprintf(ofp, " --function (addr | symbol | symbol+offset)\n"); - fprintf(ofp, " Dynamic function entry/return probe.\n"); - fprintf(ofp, " Addr and offset can be octal (0NNN...),\n"); - fprintf(ofp, " decimal (NNN...) or hexadecimal (0xNNN...)\n"); - fprintf(ofp, " --syscall System call event\n"); - fprintf(ofp, "\n"); - fprintf(ofp, " --loglevel name\n"); - fprintf(ofp, " Tracepoint loglevel range from 0 to loglevel.\n"); - fprintf(ofp, " For JUL/LOG4j/Python domains, see the table below for the range values.\n"); - fprintf(ofp, " --loglevel-only name\n"); - fprintf(ofp, " Tracepoint loglevel (only this loglevel)\n"); - fprintf(ofp, "\n"); - fprintf(ofp, " The loglevel or loglevel-only options should be\n"); - fprintf(ofp, " combined with a tracepoint name or tracepoint\n"); - fprintf(ofp, " wildcard.\n"); - fprintf(ofp, " Available loglevels:\n"); - fprintf(ofp, " (higher value is more verbose)\n"); - fprintf(ofp, " TRACE_EMERG = 0\n"); - fprintf(ofp, " TRACE_ALERT = 1\n"); - fprintf(ofp, " TRACE_CRIT = 2\n"); - fprintf(ofp, " TRACE_ERR = 3\n"); - fprintf(ofp, " TRACE_WARNING = 4\n"); - fprintf(ofp, " TRACE_NOTICE = 5\n"); - fprintf(ofp, " TRACE_INFO = 6\n"); - fprintf(ofp, " TRACE_DEBUG_SYSTEM = 7\n"); - fprintf(ofp, " TRACE_DEBUG_PROGRAM = 8\n"); - fprintf(ofp, " TRACE_DEBUG_PROCESS = 9\n"); - fprintf(ofp, " TRACE_DEBUG_MODULE = 10\n"); - fprintf(ofp, " TRACE_DEBUG_UNIT = 11\n"); - fprintf(ofp, " TRACE_DEBUG_FUNCTION = 12\n"); - fprintf(ofp, " TRACE_DEBUG_LINE = 13\n"); - fprintf(ofp, " TRACE_DEBUG = 14\n"); - fprintf(ofp, " (shortcuts such as \"system\" are allowed)\n"); - fprintf(ofp, "\n"); - fprintf(ofp, " Available JUL domain loglevels:\n"); - fprintf(ofp, " JUL_OFF = INT32_MAX\n"); - fprintf(ofp, " JUL_SEVERE = %d\n", LTTNG_LOGLEVEL_JUL_SEVERE); - fprintf(ofp, " JUL_WARNING = %d\n", LTTNG_LOGLEVEL_JUL_WARNING); - fprintf(ofp, " JUL_INFO = %d\n", LTTNG_LOGLEVEL_JUL_INFO); - fprintf(ofp, " JUL_CONFIG = %d\n", LTTNG_LOGLEVEL_JUL_CONFIG); - fprintf(ofp, " JUL_FINE = %d\n", LTTNG_LOGLEVEL_JUL_FINE); - fprintf(ofp, " JUL_FINER = %d\n", LTTNG_LOGLEVEL_JUL_FINER); - fprintf(ofp, " JUL_FINEST = %d\n", LTTNG_LOGLEVEL_JUL_FINEST); - fprintf(ofp, " JUL_ALL = INT32_MIN\n"); - fprintf(ofp, " (shortcuts such as \"severe\" are allowed)\n"); - fprintf(ofp, "\n"); - fprintf(ofp, " Available LOG4j domain loglevels:\n"); - fprintf(ofp, " LOG4J_OFF = INT32_MAX\n"); - fprintf(ofp, " LOG4J_FATAL = %d\n", LTTNG_LOGLEVEL_LOG4J_FATAL); - fprintf(ofp, " LOG4J_ERROR = %d\n", LTTNG_LOGLEVEL_LOG4J_ERROR); - fprintf(ofp, " LOG4J_WARN = %d\n", LTTNG_LOGLEVEL_LOG4J_WARN); - fprintf(ofp, " LOG4J_INFO = %d\n", LTTNG_LOGLEVEL_LOG4J_INFO); - fprintf(ofp, " LOG4J_DEBUG = %d\n", LTTNG_LOGLEVEL_LOG4J_DEBUG); - fprintf(ofp, " LOG4J_TRACE = %d\n", LTTNG_LOGLEVEL_LOG4J_TRACE); - fprintf(ofp, " LOG4J_ALL = INT32_MIN\n"); - fprintf(ofp, " (shortcuts such as \"severe\" are allowed)\n"); - fprintf(ofp, "\n"); - fprintf(ofp, " Available Python domain loglevels:\n"); - fprintf(ofp, " PYTHON_CRITICAL = %d\n", LTTNG_LOGLEVEL_PYTHON_CRITICAL); - fprintf(ofp, " PYTHON_ERROR = %d\n", LTTNG_LOGLEVEL_PYTHON_ERROR); - fprintf(ofp, " PYTHON_WARNING = %d\n", LTTNG_LOGLEVEL_PYTHON_WARNING); - fprintf(ofp, " PYTHON_INFO = %d\n", LTTNG_LOGLEVEL_PYTHON_INFO); - fprintf(ofp, " PYTHON_DEBUG = %d\n", LTTNG_LOGLEVEL_PYTHON_DEBUG); - fprintf(ofp, " PYTHON_NOTSET = %d\n", LTTNG_LOGLEVEL_PYTHON_NOTSET); - fprintf(ofp, " (shortcuts such as \"critical\" are allowed)\n"); - fprintf(ofp, "\n"); - fprintf(ofp, " -f, --filter \'expression\'\n"); - fprintf(ofp, " Filter expression on event fields and context.\n"); - fprintf(ofp, " Event recording depends on evaluation.\n"); - fprintf(ofp, " Only specify on first activation of\n"); - fprintf(ofp, " a given event within a session.\n"); - fprintf(ofp, " Filter only allowed when enabling\n"); - fprintf(ofp, " events within a session before tracing\n"); - fprintf(ofp, " is started. If the filter fails to link\n"); - fprintf(ofp, " with the event within the traced domain,\n"); - fprintf(ofp, " the event will be discarded. Currently,\n"); - fprintf(ofp, " filter is only implemented for the user-space\n"); - fprintf(ofp, " tracer.\n"); - fprintf(ofp, " Expression examples:.\n"); - fprintf(ofp, " \n"); - fprintf(ofp, " 'intfield > 500 && intfield < 503'\n"); - fprintf(ofp, " '(strfield == \"test\" || intfield != 10) && intfield > 33'\n"); - fprintf(ofp, " 'doublefield > 1.1 && intfield < 5.3'\n"); - fprintf(ofp, " \n"); - fprintf(ofp, " Wildcards are allowed at the end of strings:\n"); - fprintf(ofp, " 'seqfield1 == \"te*\"'\n"); - fprintf(ofp, " In string literals, the escape character is '\\'.\n"); - fprintf(ofp, " Use '\\*' for the '*' character, and '\\\\' for\n"); - fprintf(ofp, " the '\\' character. Wildcard match any sequence of,\n"); - fprintf(ofp, " characters including an empty sub-string (match 0 or\n"); - fprintf(ofp, " more characters).\n"); - fprintf(ofp, "\n"); - fprintf(ofp, " Context information can be used for filtering. The\n"); - fprintf(ofp, " examples below show usage of context filtering on\n"); - fprintf(ofp, " process name (with a wildcard), process ID range, and\n"); - fprintf(ofp, " unique thread ID for filtering. The process and\n"); - fprintf(ofp, " thread ID of running applications can be found under\n"); - fprintf(ofp, " columns \"PID\" and \"LWP\" of the \"ps -eLf\" command.\n"); - fprintf(ofp, "\n"); - fprintf(ofp, " '$ctx.procname == \"demo*\"'\n"); - fprintf(ofp, " '$ctx.vpid >= 4433 && $ctx.vpid < 4455'\n"); - fprintf(ofp, " '$ctx.vtid == 1234'\n"); - fprintf(ofp, " -x, --exclude LIST\n"); - fprintf(ofp, " Add exclusions to UST tracepoints:\n"); - fprintf(ofp, " Events that match any of the items\n"); - fprintf(ofp, " in the comma-separated LIST are not\n"); - fprintf(ofp, " enabled, even if they match a wildcard\n"); - fprintf(ofp, " definition of the event.\n"); - fprintf(ofp, "\n"); -} - /* * Parse probe options. */ @@ -508,9 +373,10 @@ const char *print_raw_channel_name(const char *name) * Mi print exlcusion list */ static -int mi_print_exclusion(int count, char **names) +int mi_print_exclusion(char **names) { int i, ret; + int count = names ? strutils_array_of_strings_len(names) : 0; assert(writer); @@ -542,12 +408,13 @@ end: * Return allocated string for pretty-printing exclusion names. */ static -char *print_exclusions(int count, char **names) +char *print_exclusions(char **names) { int length = 0; int i; const char *preamble = " excluding "; char *ret; + int count = names ? strutils_array_of_strings_len(names) : 0; if (count == 0) { return strdup(""); @@ -555,128 +422,154 @@ char *print_exclusions(int count, char **names) /* calculate total required length */ for (i = 0; i < count; i++) { - length += strlen(names[i]) + 1; + length += strlen(names[i]) + 4; } /* add length of preamble + one for NUL - one for last (missing) comma */ length += strlen(preamble); - ret = zmalloc(length); + ret = zmalloc(length + 1); if (!ret) { return NULL; } strncpy(ret, preamble, length); for (i = 0; i < count; i++) { + strcat(ret, "\""); strcat(ret, names[i]); + strcat(ret, "\""); if (i != count - 1) { - strcat(ret, ","); + strcat(ret, ", "); } } return ret; } -/* - * Compare list of exclusions against an event name. - * Return a list of legal exclusion names. - * Produce an error or a warning about others (depending on the situation) - */ static -int check_exclusion_subsets(const char *event_name, - const char *exclusions, - int *exclusion_count_ptr, - char ***exclusion_list_ptr) +int check_exclusion_subsets(const char *event_name, const char *exclusion) { - const char *excluder_ptr; - const char *event_ptr; - const char *next_excluder; - int excluder_length; - int exclusion_count = 0; - char **exclusion_list = NULL; - int ret = CMD_SUCCESS; + bool warn = false; + int ret = 0; + const char *e = event_name; + const char *x = exclusion; + + /* Scan both the excluder and the event letter by letter */ + while (true) { + if (*e == '\\') { + if (*x != *e) { + warn = true; + goto end; + } - if (event_name[strlen(event_name) - 1] != '*') { - ERR("Event %s: Excluders can only be used with wildcarded events", event_name); - goto error; + e++; + x++; + goto cmp_chars; + } + + if (*x == '*') { + /* Event is a subset of the excluder */ + ERR("Event %s: %s excludes all events from %s", + event_name, exclusion, event_name); + goto error; + } + + if (*e == '*') { + /* + * Reached the end of the event name before the + * end of the exclusion: this is valid. + */ + goto end; + } + +cmp_chars: + if (*x != *e) { + warn = true; + break; + } + + x++; + e++; } - next_excluder = exclusions; - while (*next_excluder != 0) { - event_ptr = event_name; - excluder_ptr = next_excluder; - excluder_length = strcspn(next_excluder, ","); + goto end; - /* Scan both the excluder and the event letter by letter */ - while (1) { - char e, x; +error: + ret = -1; - e = *event_ptr; - x = *excluder_ptr; +end: + if (warn) { + WARN("Event %s: %s does not exclude any events from %s", + event_name, exclusion, event_name); + } - if (x == '*') { - /* Event is a subset of the excluder */ - ERR("Event %s: %.*s excludes all events from %s", - event_name, - excluder_length, - next_excluder, - event_name); - goto error; - } - if (e == '*') { - char *string; - char **new_exclusion_list; - - /* Excluder is a proper subset of event */ - string = strndup(next_excluder, excluder_length); - if (!string) { - PERROR("strndup error"); - goto error; - } - new_exclusion_list = realloc(exclusion_list, - sizeof(char *) * (exclusion_count + 1)); - if (!new_exclusion_list) { - PERROR("realloc"); - free(string); + return ret; +} + +static +int create_exclusion_list_and_validate(const char *event_name, + const char *exclusions_arg, + char ***exclusion_list) +{ + int ret = 0; + char **exclusions = NULL; + + /* Event name must be a valid globbing pattern to allow exclusions. */ + if (!strutils_is_star_glob_pattern(event_name)) { + ERR("Event %s: Exclusions can only be used with a globbing pattern", + event_name); + goto error; + } + + /* Split exclusions. */ + exclusions = strutils_split(exclusions_arg, ',', true); + if (!exclusions) { + goto error; + } + + /* + * If the event name is a star-at-end only globbing pattern, + * then we can validate the individual exclusions. Otherwise + * all exclusions are passed to the session daemon. + */ + if (strutils_is_star_at_the_end_only_glob_pattern(event_name)) { + char * const *exclusion; + + for (exclusion = exclusions; *exclusion; exclusion++) { + if (!strutils_is_star_glob_pattern(*exclusion) || + strutils_is_star_at_the_end_only_glob_pattern(*exclusion)) { + ret = check_exclusion_subsets(event_name, *exclusion); + if (ret) { goto error; } - exclusion_list = new_exclusion_list; - exclusion_count++; - exclusion_list[exclusion_count - 1] = string; - break; - } - if (x != e) { - /* Excluder and event sets have no common elements */ - WARN("Event %s: %.*s does not exclude any events from %s", - event_name, - excluder_length, - next_excluder, - event_name); - break; } - excluder_ptr++; - event_ptr++; - } - /* next excluder */ - next_excluder += excluder_length; - if (*next_excluder == ',') { - next_excluder++; } } + + *exclusion_list = exclusions; + goto end; + error: - while (exclusion_count--) { - free(exclusion_list[exclusion_count]); - } - if (exclusion_list != NULL) { - free(exclusion_list); - } - exclusion_list = NULL; - exclusion_count = 0; - ret = CMD_ERROR; + ret = -1; + strutils_free_null_terminated_array_of_strings(exclusions); + end: - *exclusion_count_ptr = exclusion_count; - *exclusion_list_ptr = exclusion_list; return ret; } + +static void warn_on_truncated_exclusion_names(char * const *exclusion_list, + int *warn) +{ + char * const *exclusion; + + for (exclusion = exclusion_list; *exclusion; exclusion++) { + if (strlen(*exclusion) >= LTTNG_SYMBOL_NAME_LEN) { + WARN("Event exclusion \"%s\" will be truncated", + *exclusion); + *warn = 1; + } + } +} + /* * Enabling event using the lttng API. * Note: in case of error only the last error code will be return. @@ -688,7 +581,6 @@ static int enable_events(char *session_name) char *event_name, *channel_name = NULL; struct lttng_event ev; struct lttng_domain dom; - int exclusion_count = 0; char **exclusion_list = NULL; memset(&ev, 0, sizeof(ev)); @@ -721,9 +613,8 @@ static int enable_events(char *session_name) /* Default. */ dom.buf_type = LTTNG_BUFFER_PER_UID; } else { - print_missing_domain(); - ret = CMD_ERROR; - goto error; + /* Checked by the caller. */ + assert(0); } if (opt_exclude) { @@ -804,18 +695,23 @@ static int enable_events(char *session_name) } if (opt_exclude) { - ret = check_exclusion_subsets("*", opt_exclude, - &exclusion_count, &exclusion_list); - if (ret == CMD_ERROR) { + ret = create_exclusion_list_and_validate("*", + opt_exclude, &exclusion_list); + if (ret) { + ret = CMD_ERROR; goto error; } + ev.exclusion = 1; + warn_on_truncated_exclusion_names(exclusion_list, + &warn); } if (!opt_filter) { ret = lttng_enable_event_with_exclusions(handle, &ev, channel_name, NULL, - exclusion_count, exclusion_list); + exclusion_list ? strutils_array_of_strings_len(exclusion_list) : 0, + exclusion_list); if (ret < 0) { switch (-ret) { case LTTNG_ERR_KERN_EVENT_EXIST: @@ -849,7 +745,7 @@ static int enable_events(char *session_name) switch (opt_event_type) { case LTTNG_EVENT_TRACEPOINT: if (opt_loglevel && dom.type != LTTNG_DOMAIN_KERNEL) { - char *exclusion_string = print_exclusions(exclusion_count, exclusion_list); + char *exclusion_string = print_exclusions(exclusion_list); if (!exclusion_string) { PERROR("Cannot allocate exclusion_string"); @@ -863,7 +759,7 @@ static int enable_events(char *session_name) opt_loglevel); free(exclusion_string); } else { - char *exclusion_string = print_exclusions(exclusion_count, exclusion_list); + char *exclusion_string = print_exclusions(exclusion_list); if (!exclusion_string) { PERROR("Cannot allocate exclusion_string"); @@ -886,7 +782,7 @@ static int enable_events(char *session_name) break; case LTTNG_EVENT_ALL: if (opt_loglevel && dom.type != LTTNG_DOMAIN_KERNEL) { - char *exclusion_string = print_exclusions(exclusion_count, exclusion_list); + char *exclusion_string = print_exclusions(exclusion_list); if (!exclusion_string) { PERROR("Cannot allocate exclusion_string"); @@ -900,7 +796,7 @@ static int enable_events(char *session_name) opt_loglevel); free(exclusion_string); } else { - char *exclusion_string = print_exclusions(exclusion_count, exclusion_list); + char *exclusion_string = print_exclusions(exclusion_list); if (!exclusion_string) { PERROR("Cannot allocate exclusion_string"); @@ -925,7 +821,9 @@ static int enable_events(char *session_name) if (opt_filter) { command_ret = lttng_enable_event_with_exclusions(handle, &ev, channel_name, - opt_filter, exclusion_count, exclusion_list); + opt_filter, + exclusion_list ? strutils_array_of_strings_len(exclusion_list) : 0, + exclusion_list); if (command_ret < 0) { switch (-command_ret) { case LTTNG_ERR_FILTER_EXIST: @@ -985,7 +883,7 @@ static int enable_events(char *session_name) } /* print exclusion */ - ret = mi_print_exclusion(exclusion_count, exclusion_list); + ret = mi_print_exclusion(exclusion_list); if (ret) { ret = CMD_ERROR; goto error; @@ -1089,19 +987,19 @@ static int enable_events(char *session_name) goto error; } /* Free previously allocated items */ - if (exclusion_list != NULL) { - while (exclusion_count--) { - free(exclusion_list[exclusion_count]); - } - free(exclusion_list); - exclusion_list = NULL; - } - /* Check for proper subsets */ - ret = check_exclusion_subsets(event_name, opt_exclude, - &exclusion_count, &exclusion_list); - if (ret == CMD_ERROR) { + strutils_free_null_terminated_array_of_strings( + exclusion_list); + exclusion_list = NULL; + ret = create_exclusion_list_and_validate( + event_name, opt_exclude, + &exclusion_list); + if (ret) { + ret = CMD_ERROR; goto error; } + + warn_on_truncated_exclusion_names( + exclusion_list, &warn); } ev.loglevel_type = opt_loglevel_type; @@ -1150,9 +1048,7 @@ static int enable_events(char *session_name) strncpy(ev.name, event_name, LTTNG_SYMBOL_NAME_LEN); ev.name[LTTNG_SYMBOL_NAME_LEN - 1] = '\0'; } else { - print_missing_domain(); - ret = CMD_ERROR; - goto error; + assert(0); } if (!opt_filter) { @@ -1160,8 +1056,10 @@ static int enable_events(char *session_name) command_ret = lttng_enable_event_with_exclusions(handle, &ev, channel_name, - NULL, exclusion_count, exclusion_list); - exclusion_string = print_exclusions(exclusion_count, exclusion_list); + NULL, + exclusion_list ? strutils_array_of_strings_len(exclusion_list) : 0, + exclusion_list); + exclusion_string = print_exclusions(exclusion_list); if (!exclusion_string) { PERROR("Cannot allocate exclusion_string"); error = 1; @@ -1236,8 +1134,10 @@ static int enable_events(char *session_name) ev.filter = 1; command_ret = lttng_enable_event_with_exclusions(handle, &ev, channel_name, - opt_filter, exclusion_count, exclusion_list); - exclusion_string = print_exclusions(exclusion_count, exclusion_list); + opt_filter, + exclusion_list ? strutils_array_of_strings_len(exclusion_list) : 0, + exclusion_list); + exclusion_string = print_exclusions(exclusion_list); if (!exclusion_string) { PERROR("Cannot allocate exclusion_string"); error = 1; @@ -1300,7 +1200,7 @@ static int enable_events(char *session_name) } /* print exclusion */ - ret = mi_print_exclusion(exclusion_count, exclusion_list); + ret = mi_print_exclusion(exclusion_list); if (ret) { ret = CMD_ERROR; goto error; @@ -1346,13 +1246,7 @@ error: ret = CMD_ERROR; } lttng_destroy_handle(handle); - - if (exclusion_list != NULL) { - while (exclusion_count--) { - free(exclusion_list[exclusion_count]); - } - free(exclusion_list); - } + strutils_free_null_terminated_array_of_strings(exclusion_list); /* Overwrite ret with error_holder if there was an actual error with * enabling an event. @@ -1370,6 +1264,7 @@ int cmd_enable_events(int argc, const char **argv) int opt, ret = CMD_SUCCESS, command_ret = CMD_SUCCESS, success = 1; static poptContext pc; char *session_name = NULL; + const char *leftover = NULL; int event_type = -1; pc = poptGetContext(NULL, argc, argv, long_options, 0); @@ -1381,7 +1276,7 @@ int cmd_enable_events(int argc, const char **argv) while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case OPT_HELP: - usage(stdout); + SHOW_HELP(); goto end; case OPT_TRACEPOINT: opt_event_type = LTTNG_EVENT_TRACEPOINT; @@ -1414,7 +1309,6 @@ int cmd_enable_events(int argc, const char **argv) case OPT_EXCLUDE: break; default: - usage(stderr); ret = CMD_UNDEFINED; goto end; } @@ -1431,6 +1325,13 @@ int cmd_enable_events(int argc, const char **argv) } } + ret = print_missing_or_multiple_domains( + opt_kernel + opt_userspace + opt_jul + opt_log4j + opt_python); + if (ret) { + ret = CMD_ERROR; + goto end; + } + /* Mi check */ if (lttng_opt_mi) { writer = mi_lttng_writer_create(fileno(stdout), lttng_opt_mi); @@ -1459,7 +1360,13 @@ int cmd_enable_events(int argc, const char **argv) opt_event_list = (char*) poptGetArg(pc); if (opt_event_list == NULL && opt_enable_all == 0) { ERR("Missing event name(s).\n"); - usage(stderr); + ret = CMD_ERROR; + goto end; + } + + leftover = poptGetArg(pc); + if (leftover) { + ERR("Unknown argument: %s", leftover); ret = CMD_ERROR; goto end; } @@ -1523,3 +1430,4 @@ end: poptFreeContext(pc); return ret; } +