projects
/
lttng-ust.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Print compiler warning/runtime warning and truncate too long tracepoint names
[lttng-ust.git]
/
liblttng-ust
/
tracepoint.c
diff --git
a/liblttng-ust/tracepoint.c
b/liblttng-ust/tracepoint.c
index 0393aa467a282b17139a05ae17fd8336e7271fb9..f146d382b7717955875938a1169d8436515ee043 100644
(file)
--- a/
liblttng-ust/tracepoint.c
+++ b/
liblttng-ust/tracepoint.c
@@
-31,6
+31,7
@@
#include <urcu/compiler.h>
#include <lttng/tracepoint.h>
#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>
#include <usterr-signal-safe.h>
#include <helper.h>
@@
-207,11
+208,17
@@
static struct tracepoint_entry *get_tracepoint(const char *name)
struct cds_hlist_head *head;
struct cds_hlist_node *node;
struct tracepoint_entry *e;
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) {
head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)];
cds_hlist_for_each_entry(e, node, head, hlist) {
- if (!str
cmp(name, e->name
))
+ if (!str
ncmp(name, e->name, LTTNG_UST_SYM_NAME_LEN - 1
))
return e;
}
return NULL;
return e;
}
return NULL;
@@
-226,12
+233,17
@@
static struct tracepoint_entry *add_tracepoint(const char *name)
struct cds_hlist_head *head;
struct cds_hlist_node *node;
struct tracepoint_entry *e;
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) {
head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)];
cds_hlist_for_each_entry(e, node, head, hlist) {
- if (!str
cmp(name, e->name
)) {
+ if (!str
ncmp(name, e->name, LTTNG_UST_SYM_NAME_LEN - 1
)) {
DBG("tracepoint %s busy", name);
return ERR_PTR(-EEXIST); /* Already there */
}
DBG("tracepoint %s busy", name);
return ERR_PTR(-EEXIST); /* Already there */
}
@@
-240,10
+252,11
@@
static struct tracepoint_entry *add_tracepoint(const char *name)
* Using zmalloc here to allocate a variable length element. Could
* cause some memory fragmentation if overused.
*/
* 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);
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);
e->probes = NULL;
e->refcount = 0;
cds_hlist_add_head(&e->hlist, head);
@@
-266,7
+279,7
@@
static void remove_tracepoint(struct tracepoint_entry *e)
static void set_tracepoint(struct tracepoint_entry **entry,
struct tracepoint *elem, int active)
{
static void set_tracepoint(struct tracepoint_entry **entry,
struct tracepoint *elem, int active)
{
- WARN_ON(str
cmp((*entry)->name, elem->name
) != 0);
+ WARN_ON(str
ncmp((*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
/*
* rcu_assign_pointer has a cmm_smp_wmb() which makes sure that the new
This page took
0.023645 seconds
and
4
git commands to generate.