- also apply to loglevel names.
- -Wsystem-headers needs to be used to get gcc to show the
warnings from system headers (which is the category in which the
tracepoint event declaration headers falls into).
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
{
struct cds_hlist_head *head;
struct ust_pending_probe *e;
- size_t name_len = strlen(name) + 1;
- uint32_t hash = jhash(name, name_len - 1, 0);
+ size_t name_len = strlen(name);
+ uint32_t hash;
+ if (name_len > LTTNG_UST_SYM_NAME_LEN - 1) {
+ WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_SYM_NAME_LEN - 1);
+ name_len = LTTNG_UST_SYM_NAME_LEN - 1;
+ }
+ hash = jhash(name, name_len, 0);
head = &pending_probe_table[hash & (PENDING_PROBE_HASH_SIZE - 1)];
e = zmalloc(sizeof(struct ust_pending_probe) + name_len);
if (!e)
return -ENOMEM;
- memcpy(&e->name[0], name, name_len);
+ memcpy(&e->name[0], name, name_len + 1);
+ e->name[name_len] = '\0';
cds_hlist_add_head(&e->node, head);
e->event = event;
event->pending_probe = e;
struct cds_hlist_node *node, *p;
struct ust_pending_probe *e;
const char *name = desc->name;
- size_t name_len = strlen(name) + 1;
- uint32_t hash = jhash(name, name_len - 1, 0);
int ret = 0;
struct lttng_ust_event event_param;
+ size_t name_len = strlen(name);
+ uint32_t hash;
/*
* For this event, we need to lookup the loglevel. If active (in
}
}
+ if (name_len > LTTNG_UST_SYM_NAME_LEN - 1) {
+ WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_SYM_NAME_LEN - 1);
+ name_len = LTTNG_UST_SYM_NAME_LEN - 1;
+ }
+ hash = jhash(name, name_len, 0);
head = &pending_probe_table[hash & (PENDING_PROBE_HASH_SIZE - 1)];
cds_hlist_for_each_entry_safe(e, node, p, head, node) {
struct ltt_event *event;
struct ltt_channel *chan;
- if (strcmp(name, e->name))
+ if (strncmp(name, e->name, LTTNG_UST_SYM_NAME_LEN - 1))
continue;
event = e->event;
chan = event->chan;
* creation). Might require a hash if we have lots of events.
*/
cds_list_for_each_entry(event, &chan->session->events, list) {
- if (event->desc && !strcmp(event->desc->name, event_param->name)) {
+ if (event->desc && !strncmp(event->desc->name,
+ event_param->name,
+ LTTNG_UST_SYM_NAME_LEN - 1)) {
ret = -EEXIST;
goto exist;
}
cds_list_for_each_entry(probe_desc, &probe_list, head) {
for (i = 0; i < probe_desc->nr_events; i++) {
- if (!strcmp(probe_desc->event_desc[i]->name, name))
+ if (!strncmp(probe_desc->event_desc[i]->name, name,
+ LTTNG_UST_SYM_NAME_LEN - 1))
return probe_desc->event_desc[i];
}
}
struct cds_hlist_head *head;
struct cds_hlist_node *node;
struct loglevel_entry *e;
- uint32_t hash = jhash(name, strlen(name), 0);
+ size_t name_len = strlen(name);
+ uint32_t hash;
+ if (name_len > LTTNG_UST_SYM_NAME_LEN - 1) {
+ WARN("Truncating loglevel name %s which exceeds size limits of %u chars", name, LTTNG_UST_SYM_NAME_LEN - 1);
+ name_len = LTTNG_UST_SYM_NAME_LEN - 1;
+ }
+ hash = jhash(name, name_len, 0);
head = &loglevel_table[hash & (LOGLEVEL_TABLE_SIZE - 1)];
cds_hlist_for_each_entry(e, node, head, hlist) {
- if (!strcmp(name, e->name))
+ if (!strncmp(name, e->name, LTTNG_UST_SYM_NAME_LEN - 1))
return e;
}
return NULL;
if (atoll(entry->name) == ev_ll->value) {
match = 1;
}
- } else if (!strcmp(ev_ll->identifier, entry->name)) {
+ } else if (!strncmp(ev_ll->identifier, entry->name,
+ LTTNG_UST_SYM_NAME_LEN - 1)) {
match = 1;
}
struct cds_hlist_node *node;
struct loglevel_entry *e;
struct session_loglevel *sl;
- size_t name_len = strlen(name) + 1;
- uint32_t hash = jhash(name, name_len-1, 0);
int found = 0;
+ size_t name_len = strlen(name);
+ uint32_t hash;
+ if (name_len > LTTNG_UST_SYM_NAME_LEN - 1) {
+ WARN("Truncating loglevel name %s which exceeds size limits of %u chars", name, LTTNG_UST_SYM_NAME_LEN - 1);
+ name_len = LTTNG_UST_SYM_NAME_LEN - 1;
+ }
+ hash = jhash(name, name_len, 0);
/* loglevel entry */
head = &loglevel_table[hash & (LOGLEVEL_TABLE_SIZE - 1)];
cds_hlist_for_each_entry(e, node, head, hlist) {
- if (!strcmp(name, e->name)) {
+ if (!strncmp(name, e->name, LTTNG_UST_SYM_NAME_LEN - 1)) {
found = 1;
break;
}
* Using zmalloc here to allocate a variable length element. Could
* cause some memory fragmentation if overused.
*/
- e = zmalloc(sizeof(struct loglevel_entry) + name_len);
+ e = zmalloc(sizeof(struct loglevel_entry) + name_len + 1);
if (!e)
return ERR_PTR(-ENOMEM);
- memcpy(&e->name[0], name, name_len);
+ memcpy(&e->name[0], name, name_len + 1);
+ e->name[name_len] = '\0';
cds_hlist_add_head(&e->hlist, head);
CDS_INIT_LIST_HEAD(&e->session_list);
}
/* wildcard entry */
cds_list_for_each_entry(e, &wildcard_list, list) {
- if (!strcmp(name, e->name)) {
+ if (!strncmp(name, e->name, LTTNG_UST_SYM_NAME_LEN - 1)) {
found = 1;
break;
}
#include <urcu/compiler.h>
#include <lttng/tracepoint.h>
+#include <lttng/ust-abi.h> /* for LTTNG_UST_SYM_NAME_LEN */
#include <usterr-signal-safe.h>
#include <helper.h>
struct cds_hlist_head *head;
struct cds_hlist_node *node;
struct tracepoint_entry *e;
- uint32_t hash = jhash(name, strlen(name), 0);
+ size_t name_len = strlen(name);
+ uint32_t hash;
+ if (name_len > LTTNG_UST_SYM_NAME_LEN - 1) {
+ WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_SYM_NAME_LEN - 1);
+ name_len = LTTNG_UST_SYM_NAME_LEN - 1;
+ }
+ hash = jhash(name, name_len, 0);
head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)];
cds_hlist_for_each_entry(e, node, head, hlist) {
- if (!strcmp(name, e->name))
+ if (!strncmp(name, e->name, LTTNG_UST_SYM_NAME_LEN - 1))
return e;
}
return NULL;
struct cds_hlist_head *head;
struct cds_hlist_node *node;
struct tracepoint_entry *e;
- size_t name_len = strlen(name) + 1;
- uint32_t hash = jhash(name, name_len-1, 0);
+ size_t name_len = strlen(name);
+ uint32_t hash;
+ if (name_len > LTTNG_UST_SYM_NAME_LEN - 1) {
+ WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_SYM_NAME_LEN - 1);
+ name_len = LTTNG_UST_SYM_NAME_LEN - 1;
+ }
+ hash = jhash(name, name_len, 0);
head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)];
cds_hlist_for_each_entry(e, node, head, hlist) {
- if (!strcmp(name, e->name)) {
+ if (!strncmp(name, e->name, LTTNG_UST_SYM_NAME_LEN - 1)) {
DBG("tracepoint %s busy", name);
return ERR_PTR(-EEXIST); /* Already there */
}
* Using zmalloc here to allocate a variable length element. Could
* cause some memory fragmentation if overused.
*/
- e = zmalloc(sizeof(struct tracepoint_entry) + name_len);
+ e = zmalloc(sizeof(struct tracepoint_entry) + name_len + 1);
if (!e)
return ERR_PTR(-ENOMEM);
- memcpy(&e->name[0], name, name_len);
+ memcpy(&e->name[0], name, name_len + 1);
+ e->name[name_len] = '\0';
e->probes = NULL;
e->refcount = 0;
cds_hlist_add_head(&e->hlist, head);
static void set_tracepoint(struct tracepoint_entry **entry,
struct tracepoint *elem, int active)
{
- WARN_ON(strcmp((*entry)->name, elem->name) != 0);
+ WARN_ON(strncmp((*entry)->name, elem->name, LTTNG_UST_SYM_NAME_LEN - 1) != 0);
/*
* rcu_assign_pointer has a cmm_smp_wmb() which makes sure that the new
-AM_CPPFLAGS = -I$(top_srcdir)/include
+# -Wsystem-headers is needed to print warnings in the tracepoint
+# description file.
+AM_CPPFLAGS = -I$(top_srcdir)/include -Wsystem-headers
# We install the plugins into the /tmp/lttng-ust-divert directory to
# please libtool, which absolutely needs a target install location. We
-AM_CPPFLAGS = -I$(top_srcdir)/include
+AM_CPPFLAGS = -I$(top_srcdir)/include -Wsystem-headers
noinst_PROGRAMS = fork fork2
fork_SOURCES = fork.c ust_tests_fork.h
-AM_CPPFLAGS = -I$(top_srcdir)/include
+AM_CPPFLAGS = -I$(top_srcdir)/include -Wsystem-headers
noinst_PROGRAMS = hello
hello_SOURCES = hello.cpp tp.c ust_tests_hello.h
-AM_CPPFLAGS = -I$(top_srcdir)/include
+AM_CPPFLAGS = -I$(top_srcdir)/include -Wsystem-headers
noinst_PROGRAMS = hello
hello_SOURCES = hello.c tp.c ust_tests_hello.h