}
}
- if (opt_enable_all) {
- /* Default setup for enable all */
- if (opt_kernel) {
- ev->type = (lttng_event_type) opt_event_type;
- strcpy(ev->name, "*");
- /* kernel loglevels not implemented */
- ev->loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
- } else {
- ev->type = LTTNG_EVENT_TRACEPOINT;
- strcpy(ev->name, "*");
- ev->loglevel_type = (lttng_loglevel_type) opt_loglevel_type;
- if (opt_loglevel) {
- int name_search_ret;
-
- LTTNG_ASSERT(opt_userspace || opt_jul || opt_log4j || opt_python);
-
- if (opt_userspace) {
- enum lttng_loglevel loglevel;
-
- name_search_ret =
- loglevel_name_to_value(opt_loglevel, &loglevel);
- ev->loglevel = (int) loglevel;
- } else if (opt_jul) {
- enum lttng_loglevel_jul loglevel;
-
- name_search_ret =
- loglevel_jul_name_to_value(opt_loglevel, &loglevel);
- ev->loglevel = (int) loglevel;
- } else if (opt_log4j) {
- enum lttng_loglevel_log4j loglevel;
-
- name_search_ret = loglevel_log4j_name_to_value(opt_loglevel,
- &loglevel);
- ev->loglevel = (int) loglevel;
- } else {
- /* python domain. */
- enum lttng_loglevel_python loglevel;
-
- name_search_ret = loglevel_python_name_to_value(
- opt_loglevel, &loglevel);
- ev->loglevel = (int) loglevel;
- }
-
- if (name_search_ret == -1) {
- ERR("Unknown loglevel %s", opt_loglevel);
- ret = -LTTNG_ERR_INVALID;
- goto error;
- }
- } else {
- LTTNG_ASSERT(opt_userspace || opt_jul || opt_log4j || opt_python);
- if (opt_userspace) {
- ev->loglevel = -1;
- } else if (opt_jul) {
- ev->loglevel = LTTNG_LOGLEVEL_JUL_ALL;
- } else if (opt_log4j) {
- ev->loglevel = LTTNG_LOGLEVEL_LOG4J_ALL;
- } else if (opt_python) {
- ev->loglevel = LTTNG_LOGLEVEL_PYTHON_DEBUG;
- }
- }
- }
-
- if (opt_exclude) {
- ret = create_exclusion_list_and_validate("*", opt_exclude, &exclusions);
- if (ret) {
- ret = CMD_ERROR;
- goto error;
- }
-
- ev->exclusion = 1;
- warn_on_truncated_exclusion_names(&exclusions, &warn);
- }
- if (!opt_filter) {
- ret = lttng_enable_event_with_exclusions(
- handle,
- ev,
- channel_name,
- nullptr,
- lttng_dynamic_pointer_array_get_count(&exclusions),
- (char **) exclusions.array.buffer.data);
- if (ret < 0) {
- switch (-ret) {
- case LTTNG_ERR_KERN_EVENT_EXIST:
- WARN("Kernel events already enabled (channel %s, session %s)",
- print_channel_name(channel_name),
- session_name.c_str());
- warn = 1;
- break;
- case LTTNG_ERR_TRACE_ALREADY_STARTED:
- {
- const char *msg =
- "The command tried to enable an event in a new domain for a session that has already been started once.";
- ERR("Events: %s (channel %s, session %s)",
- msg,
- print_channel_name(channel_name),
- session_name.c_str());
- error = 1;
- break;
- }
- default:
- ERR("Events: %s (channel %s, session %s)",
- lttng_strerror(ret),
- ret == -LTTNG_ERR_NEED_CHANNEL_NAME ?
- print_raw_channel_name(channel_name) :
- print_channel_name(channel_name),
- session_name.c_str());
- error = 1;
- break;
- }
- goto end;
- }
-
- switch (opt_event_type) {
- case LTTNG_EVENT_TRACEPOINT:
- if (opt_loglevel && dom.type != LTTNG_DOMAIN_KERNEL) {
- char *exclusion_string = print_exclusions(&exclusions);
-
- if (!exclusion_string) {
- PERROR("Cannot allocate exclusion_string");
- error = 1;
- goto end;
- }
- MSG("All %s tracepoints%s are enabled in channel %s for loglevel %s",
- lttng_domain_type_str(dom.type),
- exclusion_string,
- print_channel_name(channel_name),
- opt_loglevel);
- free(exclusion_string);
- } else {
- char *exclusion_string = print_exclusions(&exclusions);
-
- if (!exclusion_string) {
- PERROR("Cannot allocate exclusion_string");
- error = 1;
- goto end;
- }
- MSG("All %s tracepoints%s are enabled in channel %s",
- lttng_domain_type_str(dom.type),
- exclusion_string,
- print_channel_name(channel_name));
- free(exclusion_string);
- }
- break;
- case LTTNG_EVENT_SYSCALL:
- if (opt_kernel) {
- MSG("All %s system calls are enabled in channel %s",
- lttng_domain_type_str(dom.type),
- print_channel_name(channel_name));
- }
- break;
- case LTTNG_EVENT_ALL:
- if (opt_loglevel && dom.type != LTTNG_DOMAIN_KERNEL) {
- char *exclusion_string = print_exclusions(&exclusions);
-
- if (!exclusion_string) {
- PERROR("Cannot allocate exclusion_string");
- error = 1;
- goto end;
- }
- MSG("All %s events%s are enabled in channel %s for loglevel %s",
- lttng_domain_type_str(dom.type),
- exclusion_string,
- print_channel_name(channel_name),
- opt_loglevel);
- free(exclusion_string);
- } else {
- char *exclusion_string = print_exclusions(&exclusions);
-
- if (!exclusion_string) {
- PERROR("Cannot allocate exclusion_string");
- error = 1;
- goto end;
- }
- MSG("All %s events%s are enabled in channel %s",
- lttng_domain_type_str(dom.type),
- exclusion_string,
- print_channel_name(channel_name));
- free(exclusion_string);
- }
- break;
- default:
- /*
- * We should not be here since lttng_enable_event should have
- * failed on the event type.
- */
- goto error;
- }
- }
-
- if (opt_filter) {
- command_ret = lttng_enable_event_with_exclusions(
- handle,
- ev,
- channel_name,
- opt_filter,
- lttng_dynamic_pointer_array_get_count(&exclusions),
- (char **) exclusions.array.buffer.data);
- if (command_ret < 0) {
- switch (-command_ret) {
- case LTTNG_ERR_FILTER_EXIST:
- WARN("Filter on all events is already enabled"
- " (channel %s, session %s)",
- print_channel_name(channel_name),
- session_name.c_str());
- warn = 1;
- break;
- case LTTNG_ERR_TRACE_ALREADY_STARTED:
- {
- const char *msg =
- "The command tried to enable an event in a new domain for a session that has already been started once.";
- ERR("All events: %s (channel %s, session %s, filter \'%s\')",
- msg,
- print_channel_name(channel_name),
- session_name.c_str(),
- opt_filter);
- error = 1;
- break;
- }
- default:
- ERR("All events: %s (channel %s, session %s, filter \'%s\')",
- lttng_strerror(command_ret),
- command_ret == -LTTNG_ERR_NEED_CHANNEL_NAME ?
- print_raw_channel_name(channel_name) :
- print_channel_name(channel_name),
- session_name.c_str(),
- opt_filter);
- error = 1;
- break;
- }
- error_holder = command_ret;
- } else {
- ev->filter = 1;
- MSG("Filter '%s' successfully set", opt_filter);
- }
- }
-
- if (lttng_opt_mi) {
- /* The wildcard * is used for kernel and ust domain to
- * represent ALL. We copy * in event name to force the wildcard use
- * for kernel domain
- *
- * Note: this is strictly for semantic and printing while in
- * machine interface mode.
- */
- strcpy(ev->name, "*");
-
- /* If we reach here the events are enabled */
- if (!error && !warn) {
- ev->enabled = 1;
- } else {
- ev->enabled = 0;
- success = 0;
- }
- ret = mi_lttng_event(writer.get(), ev, 1, handle->domain.type);
- if (ret) {
- ret = CMD_ERROR;
- goto error;
- }
-
- /* print exclusion */
- ret = mi_print_exclusion(&exclusions);
- if (ret) {
- ret = CMD_ERROR;
- goto error;
- }
-
- /* Success ? */
- ret = mi_lttng_writer_write_element_bool(
- writer.get(), mi_lttng_element_command_success, success);
- if (ret) {
- ret = CMD_ERROR;
- goto error;
- }
-
- /* Close event element */
- ret = mi_lttng_writer_close_element(writer.get());
- if (ret) {
- ret = CMD_ERROR;
- goto error;
- }
- }
-
- goto end;
- }
-
- /* Strip event list */
for (const auto& pattern : patterns) {
/* Copy name and type of the event */
strncpy(ev->name, pattern.c_str(), LTTNG_SYMBOL_NAME_LEN);
const char *leftover = nullptr;
int event_type = -1;
event_rule_patterns patterns;
- std::stringstream event_list_arg_stream(arg_event_list);
auto pc = lttng::make_unique_wrapper<poptContext_s, _poptContextFree_deleter_func>(
poptGetContext(nullptr, argc, argv, long_options, 0));
return CMD_ERROR;
}
- for (std::string line; std::getline(event_list_arg_stream, line, ',');) {
- patterns.emplace_back(std::move(line));
+ if (opt_enable_all) {
+ patterns.emplace_back("*");
+ } else {
+ std::stringstream event_list_arg_stream(arg_event_list);
+
+ for (std::string line; std::getline(event_list_arg_stream, line, ',');) {
+ patterns.emplace_back(std::move(line));
+ }
}
leftover = poptGetArg(pc.get());