* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#define _GNU_SOURCE
#define _LGPL_SOURCE
#include <assert.h>
#include <popt.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <ctype.h>
#include <src/common/sessiond-comm/sessiond-comm.h>
+#include <common/compat/string.h>
/* Mi dependancy */
#include <common/mi-lttng.h>
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, " -k, --kernel Apply to 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, " -j, --jul Apply to 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");
char **new_exclusion_list;
/* Excluder is a proper subset of event */
- string = strndup(next_excluder, excluder_length);
+ string = lttng_strndup(next_excluder, excluder_length);
if (!string) {
- PERROR("strndup error");
+ PERROR("lttng_strndup error");
goto error;
}
new_exclusion_list = realloc(exclusion_list,
*exclusion_list_ptr = exclusion_list;
return ret;
}
+
+static void warn_on_truncated_exclusion_names(char **exclusion_list,
+ int exclusion_count, int *warn)
+{
+ size_t i = 0;
+
+ for (i = 0; i < exclusion_count; ++i) {
+ const char *name = exclusion_list[i];
+ size_t len = strlen(name);
+
+ if (len >= LTTNG_SYMBOL_NAME_LEN) {
+ WARN("Event exclusion \"%s\" will be truncated",
+ name);
+ *warn = 1;
+ }
+ }
+}
+
/*
* Enabling event using the lttng API.
* Note: in case of error only the last error code will be return.
/* 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_kernel && opt_exclude) {
- ERR("Event name exclusions are not yet implemented for kernel events");
- ret = CMD_ERROR;
- goto error;
+ if (opt_exclude) {
+ switch (dom.type) {
+ case LTTNG_DOMAIN_KERNEL:
+ case LTTNG_DOMAIN_JUL:
+ case LTTNG_DOMAIN_LOG4J:
+ case LTTNG_DOMAIN_PYTHON:
+ ERR("Event name exclusions are not yet implemented for %s events",
+ get_domain_str(dom.type));
+ ret = CMD_ERROR;
+ goto error;
+ case LTTNG_DOMAIN_UST:
+ /* Exclusions supported */
+ break;
+ default:
+ assert(0);
+ }
}
channel_name = opt_channel_name;
goto error;
}
ev.exclusion = 1;
+
+ warn_on_truncated_exclusion_names(exclusion_list,
+ exclusion_count, &warn);
}
if (!opt_filter) {
ret = lttng_enable_event_with_exclusions(handle,
if (ret == CMD_ERROR) {
goto error;
}
+
+ warn_on_truncated_exclusion_names(
+ exclusion_list, exclusion_count, &warn);
}
ev.loglevel_type = opt_loglevel_type;
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) {
}
error_holder = command_ret;
} else {
- /* So we don't print the default channel name for agent domain. */
- if (dom.type == LTTNG_DOMAIN_JUL ||
- dom.type == LTTNG_DOMAIN_LOG4J) {
- MSG("%s event %s%s enabled.",
- get_domain_str(dom.type), event_name,
- exclusion_string);
- } else {
+ switch (dom.type) {
+ case LTTNG_DOMAIN_KERNEL:
+ case LTTNG_DOMAIN_UST:
MSG("%s event %s%s created in channel %s",
- get_domain_str(dom.type), event_name,
- exclusion_string,
- print_channel_name(channel_name));
+ get_domain_str(dom.type),
+ event_name,
+ exclusion_string,
+ print_channel_name(channel_name));
+ break;
+ case LTTNG_DOMAIN_JUL:
+ case LTTNG_DOMAIN_LOG4J:
+ case LTTNG_DOMAIN_PYTHON:
+ /*
+ * Don't print the default channel
+ * name for agent domains.
+ */
+ MSG("%s event %s%s enabled",
+ get_domain_str(dom.type),
+ event_name,
+ exclusion_string);
+ break;
+ default:
+ assert(0);
}
}
free(exclusion_string);
}
}
+ 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);