Detect unsupported use of .so.0 and .so.1 libraries within same process
[lttng-ust.git] / src / lib / lttng-ust-tracepoint / tracepoint.c
index e43c1aeb312967aefaec9e52757dad447fb7034e..12bc561c3342693cbdafbefac0a87612b5852981 100644 (file)
@@ -12,6 +12,7 @@
 #include <stdint.h>
 #include <stddef.h>
 #include <stdio.h>
+#include <dlfcn.h>
 
 #include <urcu/arch.h>
 #include <lttng/urcu/urcu-ust.h>
@@ -22,6 +23,7 @@
 
 #include <lttng/tracepoint.h>
 #include <lttng/ust-abi.h>     /* for LTTNG_UST_ABI_SYM_NAME_LEN */
+#include <lttng/ust-common.h>
 
 #include "common/logging.h"
 #include "common/macros.h"
 #include "common/err-ptr.h"
 
 /* Test compiler support for weak symbols with hidden visibility. */
-int __tracepoint_test_symbol1 __attribute__((weak, visibility("hidden")));
-void *__tracepoint_test_symbol2 __attribute__((weak, visibility("hidden")));
+int lttng_ust_tracepoint_test_symbol1 __attribute__((weak, visibility("hidden")));
+void *lttng_ust_tracepoint_test_symbol2 __attribute__((weak, visibility("hidden")));
 struct {
        char a[24];
-} __tracepoint_test_symbol3 __attribute__((weak, visibility("hidden")));
+} lttng_ust_tracepoint_test_symbol3 __attribute__((weak, visibility("hidden")));
 
 /* Set to 1 to enable tracepoint debug output */
 static const int tracepoint_debug;
@@ -73,8 +75,8 @@ static CDS_LIST_HEAD(libs);
  * The tracepoint mutex protects the library tracepoints, the hash table, and
  * the library list.
  * All calls to the tracepoint API must be protected by the tracepoint mutex,
- * excepts calls to tracepoint_register_lib and
- * tracepoint_unregister_lib, which take the tracepoint mutex themselves.
+ * excepts calls to lttng_ust_tracepoint_module_register and
+ * lttng_ust_tracepoint_module_unregister, which take the tracepoint mutex themselves.
  */
 
 /*
@@ -103,7 +105,8 @@ struct tracepoint_entry {
        int refcount;   /* Number of times armed. 0 if disarmed. */
        int callsite_refcount;  /* how many libs use this tracepoint */
        char *signature;
-       char *name;
+       char *provider_name;
+       char *event_name;
 };
 
 struct tp_probes {
@@ -134,6 +137,15 @@ lttng_ust_static_assert(LTTNG_UST_TRACEPOINT_NAME_LEN_MAX == LTTNG_UST_ABI_SYM_N
                "Tracepoint name max length mismatch between UST ABI and tracepoint API",
                Tracepoint_name_max_length_mismatch);
 
+static
+bool lttng_ust_tp_validate_event_name(const struct lttng_ust_tracepoint *tp)
+{
+       if (strlen(tp->provider_name) + 1 +
+                       strlen(tp->event_name) >= LTTNG_UST_TRACEPOINT_NAME_LEN_MAX)
+               return false;
+       return true;
+}
+
 /* coverity[+alloc] */
 static void *allocate_probes(int count)
 {
@@ -252,22 +264,18 @@ tracepoint_entry_remove_probe(struct tracepoint_entry *entry,
  * Must be called with tracepoint mutex held.
  * Returns NULL if not present.
  */
-static struct tracepoint_entry *get_tracepoint(const char *name)
+static struct tracepoint_entry *get_tracepoint(const char *provider_name, const char *event_name)
 {
        struct cds_hlist_head *head;
        struct cds_hlist_node *node;
        struct tracepoint_entry *e;
-       size_t name_len = strlen(name);
        uint32_t hash;
 
-       if (name_len > LTTNG_UST_ABI_SYM_NAME_LEN - 1) {
-               WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_ABI_SYM_NAME_LEN - 1);
-               name_len = LTTNG_UST_ABI_SYM_NAME_LEN - 1;
-       }
-       hash = jhash(name, name_len, 0);
+       hash = jhash(provider_name, strlen(provider_name), 0) ^
+               jhash(event_name, strlen(event_name), 0);
        head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)];
        cds_hlist_for_each_entry(e, node, head, hlist) {
-               if (!strncmp(name, e->name, LTTNG_UST_ABI_SYM_NAME_LEN - 1))
+               if (!strcmp(event_name, e->event_name) && !strcmp(provider_name, e->provider_name))
                        return e;
        }
        return NULL;
@@ -277,26 +285,24 @@ static struct tracepoint_entry *get_tracepoint(const char *name)
  * Add the tracepoint to the tracepoint hash table. Must be called with
  * tracepoint mutex held.
  */
-static struct tracepoint_entry *add_tracepoint(const char *name,
+static struct tracepoint_entry *add_tracepoint(const char *provider_name, const char *event_name,
                const char *signature)
 {
        struct cds_hlist_head *head;
        struct cds_hlist_node *node;
        struct tracepoint_entry *e;
-       size_t name_len = strlen(name);
        size_t sig_len = strlen(signature);
-       size_t sig_off, name_off;
+       size_t sig_off, provider_name_off, event_name_off;
+       size_t provider_name_len = strlen(provider_name);
+       size_t event_name_len = strlen(event_name);
        uint32_t hash;
 
-       if (name_len > LTTNG_UST_ABI_SYM_NAME_LEN - 1) {
-               WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_ABI_SYM_NAME_LEN - 1);
-               name_len = LTTNG_UST_ABI_SYM_NAME_LEN - 1;
-       }
-       hash = jhash(name, name_len, 0);
+       hash = jhash(provider_name, provider_name_len, 0) ^
+               jhash(event_name, event_name_len, 0);
        head = &tracepoint_table[hash & (TRACEPOINT_TABLE_SIZE - 1)];
        cds_hlist_for_each_entry(e, node, head, hlist) {
-               if (!strncmp(name, e->name, LTTNG_UST_ABI_SYM_NAME_LEN - 1)) {
-                       DBG("tracepoint %s busy", name);
+               if (!strcmp(event_name, e->event_name) && !strcmp(provider_name, e->provider_name)) {
+                       DBG("tracepoint \"%s:%s\" busy", provider_name, event_name);
                        return ERR_PTR(-EEXIST);        /* Already there */
                }
        }
@@ -305,15 +311,21 @@ static struct tracepoint_entry *add_tracepoint(const char *name,
         * Using zmalloc here to allocate a variable length elements: name and
         * signature. Could cause some memory fragmentation if overused.
         */
-       name_off = sizeof(struct tracepoint_entry);
-       sig_off = name_off + name_len + 1;
+       provider_name_off = sizeof(struct tracepoint_entry);
+       event_name_off = provider_name_off + provider_name_len + 1;
+       sig_off = event_name_off + event_name_len + 1;
 
-       e = zmalloc(sizeof(struct tracepoint_entry) + name_len + 1 + sig_len + 1);
+       e = zmalloc(sizeof(struct tracepoint_entry) + provider_name_len + 1 +
+                       event_name_len + 1 + sig_len + 1);
        if (!e)
                return ERR_PTR(-ENOMEM);
-       e->name = (char *) e + name_off;
-       memcpy(e->name, name, name_len + 1);
-       e->name[name_len] = '\0';
+       e->provider_name = (char *) e + provider_name_off;
+       memcpy(e->provider_name, provider_name, provider_name_len + 1);
+       e->provider_name[provider_name_len] = '\0';
+
+       e->event_name = (char *) e + event_name_off;
+       memcpy(e->event_name, event_name, event_name_len + 1);
+       e->event_name[event_name_len] = '\0';
 
        e->signature = (char *) e + sig_off;
        memcpy(e->signature, signature, sig_len + 1);
@@ -343,7 +355,8 @@ static void remove_tracepoint(struct tracepoint_entry *e)
 static void set_tracepoint(struct tracepoint_entry **entry,
        struct lttng_ust_tracepoint *elem, int active)
 {
-       WARN_ON(strncmp((*entry)->name, elem->name, LTTNG_UST_ABI_SYM_NAME_LEN - 1) != 0);
+       WARN_ON(strcmp((*entry)->provider_name, elem->provider_name) != 0);
+       WARN_ON(strcmp((*entry)->event_name, elem->event_name) != 0);
        /*
         * Check that signatures match before connecting a probe to a
         * tracepoint. Warn the user if they don't.
@@ -354,8 +367,8 @@ static void set_tracepoint(struct tracepoint_entry **entry,
                /* Only print once, don't flood console. */
                if (!warned) {
                        WARN("Tracepoint signature mismatch, not enabling one or more tracepoints. Ensure that the tracepoint probes prototypes match the application.");
-                       WARN("Tracepoint \"%s\" signatures: call: \"%s\" vs probe: \"%s\".",
-                               elem->name, elem->signature, (*entry)->signature);
+                       WARN("Tracepoint \"%s:%s\" signatures: call: \"%s\" vs probe: \"%s\".",
+                               elem->provider_name, elem->event_name, elem->signature, (*entry)->signature);
                        warned = 1;
                }
                /* Don't accept connecting non-matching signatures. */
@@ -393,27 +406,27 @@ static void add_callsite(struct tracepoint_lib * lib, struct lttng_ust_tracepoin
 {
        struct cds_hlist_head *head;
        struct callsite_entry *e;
-       const char *name = tp->name;
-       size_t name_len = strlen(name);
        uint32_t hash;
        struct tracepoint_entry *tp_entry;
 
-       if (name_len > LTTNG_UST_ABI_SYM_NAME_LEN - 1) {
-               WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_ABI_SYM_NAME_LEN - 1);
-               name_len = LTTNG_UST_ABI_SYM_NAME_LEN - 1;
+       if (!lttng_ust_tp_validate_event_name(tp)) {
+               WARN("Rejecting tracepoint name \"%s:%s\" which exceeds size limits of %u chars",
+                       tp->provider_name, tp->event_name, LTTNG_UST_TRACEPOINT_NAME_LEN_MAX - 1);
+               return;
        }
-       hash = jhash(name, name_len, 0);
+       hash = jhash(tp->provider_name, strlen(tp->provider_name), 0) ^
+               jhash(tp->event_name, strlen(tp->event_name), 0);
        head = &callsite_table[hash & (CALLSITE_TABLE_SIZE - 1)];
        e = zmalloc(sizeof(struct callsite_entry));
        if (!e) {
-               PERROR("Unable to add callsite for tracepoint \"%s\"", name);
+               PERROR("Unable to add callsite for tracepoint \"%s:%s\"", tp->provider_name, tp->event_name);
                return;
        }
        cds_hlist_add_head(&e->hlist, head);
        e->tp = tp;
        cds_list_add(&e->node, &lib->callsites);
 
-       tp_entry = get_tracepoint(name);
+       tp_entry = get_tracepoint(tp->provider_name, tp->event_name);
        if (!tp_entry)
                return;
        tp_entry->callsite_refcount++;
@@ -428,7 +441,7 @@ static void remove_callsite(struct callsite_entry *e)
 {
        struct tracepoint_entry *tp_entry;
 
-       tp_entry = get_tracepoint(e->tp->name);
+       tp_entry = get_tracepoint(e->tp->provider_name, e->tp->event_name);
        if (tp_entry) {
                if (e->tp_entry_callsite_ref)
                        tp_entry->callsite_refcount--;
@@ -445,26 +458,24 @@ static void remove_callsite(struct callsite_entry *e)
  * tracepoint entry.
  * Must be called with tracepoint mutex held.
  */
-static void tracepoint_sync_callsites(const char *name)
+static void tracepoint_sync_callsites(const char *provider_name, const char *event_name)
 {
+       struct tracepoint_entry *tp_entry;
        struct cds_hlist_head *head;
        struct cds_hlist_node *node;
        struct callsite_entry *e;
-       size_t name_len = strlen(name);
        uint32_t hash;
-       struct tracepoint_entry *tp_entry;
 
-       tp_entry = get_tracepoint(name);
-       if (name_len > LTTNG_UST_ABI_SYM_NAME_LEN - 1) {
-               WARN("Truncating tracepoint name %s which exceeds size limits of %u chars", name, LTTNG_UST_ABI_SYM_NAME_LEN - 1);
-               name_len = LTTNG_UST_ABI_SYM_NAME_LEN - 1;
-       }
-       hash = jhash(name, name_len, 0);
+       tp_entry = get_tracepoint(provider_name, event_name);
+       hash = jhash(provider_name, strlen(provider_name), 0) ^
+               jhash(event_name, strlen(event_name), 0);
        head = &callsite_table[hash & (CALLSITE_TABLE_SIZE - 1)];
        cds_hlist_for_each_entry(e, node, head, hlist) {
                struct lttng_ust_tracepoint *tp = e->tp;
 
-               if (strncmp(name, tp->name, LTTNG_UST_ABI_SYM_NAME_LEN - 1))
+               if (strcmp(event_name, tp->event_name))
+                       continue;
+               if (strcmp(provider_name, tp->provider_name))
                        continue;
                if (tp_entry) {
                        if (!e->tp_entry_callsite_ref) {
@@ -497,11 +508,17 @@ void tracepoint_update_probe_range(struct lttng_ust_tracepoint * const *begin,
        for (iter = begin; iter < end; iter++) {
                if (!*iter)
                        continue;       /* skip dummy */
-               if (!(*iter)->name) {
+               if (!(*iter)->provider_name || !(*iter)->event_name) {
+                       disable_tracepoint(*iter);
+                       continue;
+               }
+               if (!lttng_ust_tp_validate_event_name(*iter)) {
+                       WARN("Rejecting tracepoint name \"%s:%s\" which exceeds size limits of %u chars",
+                               (*iter)->provider_name, (*iter)->event_name, LTTNG_UST_TRACEPOINT_NAME_LEN_MAX - 1);
                        disable_tracepoint(*iter);
                        continue;
                }
-               mark_entry = get_tracepoint((*iter)->name);
+               mark_entry = get_tracepoint((*iter)->provider_name, (*iter)->event_name);
                if (mark_entry) {
                        set_tracepoint(&mark_entry, *iter,
                                        !!mark_entry->refcount);
@@ -529,7 +546,7 @@ static void lib_register_callsites(struct tracepoint_lib *lib)
        for (iter = begin; iter < end; iter++) {
                if (!*iter)
                        continue;       /* skip dummy */
-               if (!(*iter)->name) {
+               if (!(*iter)->provider_name || !(*iter)->event_name) {
                        continue;
                }
                add_callsite(lib, *iter);
@@ -557,20 +574,21 @@ static void tracepoint_update_probes(void)
 }
 
 static struct lttng_ust_tracepoint_probe *
-tracepoint_add_probe(const char *name, void (*probe)(void), void *data,
-               const char *signature)
+tracepoint_add_probe(const char *provider_name, const char *event_name,
+               void (*probe)(void), void *data, const char *signature)
 {
        struct tracepoint_entry *entry;
        struct lttng_ust_tracepoint_probe *old;
 
-       entry = get_tracepoint(name);
+       entry = get_tracepoint(provider_name, event_name);
        if (entry) {
                if (strcmp(entry->signature, signature) != 0) {
-                       ERR("Tracepoint and probe signature do not match.");
+                       ERR("Tracepoint \"%s:%s\": tracepoint and probe signature do not match: \"%s\" vs \"%s\".",
+                               provider_name, event_name, entry->signature, signature);
                        return ERR_PTR(-EINVAL);
                }
        } else {
-               entry = add_tracepoint(name, signature);
+               entry = add_tracepoint(provider_name, event_name, signature);
                if (IS_ERR(entry))
                        return (struct lttng_ust_tracepoint_probe *)entry;
        }
@@ -590,31 +608,73 @@ static void tracepoint_release_queue_add_old_probes(void *old)
        }
 }
 
+/*
+ * Use a symbol of the previous ABI to detect if liblttng-ust-tracepoint.so.0
+ * is loaded in the current process.
+ */
+#define LTTNG_UST_TRACEPOINT_SONAME_0_SYM      "tracepoint_unregister_lib"
+
+static
+void lttng_ust_tracepoint_check_soname_0(void)
+{
+       if (!dlsym(RTLD_DEFAULT, LTTNG_UST_TRACEPOINT_SONAME_0_SYM))
+               return;
+
+       CRIT("Incompatible library ABIs detected within the same process. "
+               "The process is likely linked against different major soname of LTTng-UST which is unsupported. "
+               "The detection was triggered by lookup of ABI 0 symbol \"%s\" in the Global Symbol Table\n",
+               LTTNG_UST_TRACEPOINT_SONAME_0_SYM);
+}
+
+/*
+ * Expose a canary symbol of the previous ABI to ensure we catch uses of a
+ * liblttng-ust-tracepoint.so.0 dlopen'd after .so.1 has been loaded. Use a
+ * different symbol than the detection code to ensure we don't detect ourself.
+ */
+int tracepoint_register_lib(void *arg0 __attribute__((unused)), int arg1 __attribute__((unused)));
+int tracepoint_register_lib(void *arg0 __attribute__((unused)), int arg1 __attribute__((unused)))
+{
+       CRIT("Incompatible library ABIs detected within the same process. "
+               "The process is likely linked against different major soname of LTTng-UST which is unsupported. "
+               "The detection was triggered by canary symbol \"%s\"\n", __func__);
+
+       return -1;
+}
+
 /**
- * __tracepoint_probe_register -  Connect a probe to a tracepoint
- * @name: tracepoint name
+ * lttng_ust_tracepoint_provider_register -  Connect a probe to a tracepoint
+ * @name: tracepoint provider name
+ * @name: tracepoint event name
  * @probe: probe handler
  *
  * Returns 0 if ok, error value on error.
  * The probe address must at least be aligned on the architecture pointer size.
  * Called with the tracepoint mutex held.
  */
-int __tracepoint_probe_register(const char *name, void (*probe)(void),
-               void *data, const char *signature)
+int lttng_ust_tracepoint_provider_register(const char *provider_name, const char *event_name,
+               void (*probe)(void), void *data, const char *signature)
 {
        void *old;
        int ret = 0;
 
-       DBG("Registering probe to tracepoint %s", name);
+       /*
+        * Check if we find a symbol of the previous ABI in the current process
+        * as different ABIs of liblttng-ust can't co-exist in a process. If we
+        * do so, emit a critical log message which will also abort if the
+        * LTTNG_UST_ABORT_ON_CRITICAL environment variable is set.
+        */
+       lttng_ust_tracepoint_check_soname_0();
+
+       DBG("Registering probe to tracepoint \"%s:%s\"", provider_name, event_name);
 
        pthread_mutex_lock(&tracepoint_mutex);
-       old = tracepoint_add_probe(name, probe, data, signature);
+       old = tracepoint_add_probe(provider_name, event_name, probe, data, signature);
        if (IS_ERR(old)) {
                ret = PTR_ERR(old);
                goto end;
        }
 
-       tracepoint_sync_callsites(name);
+       tracepoint_sync_callsites(provider_name, event_name);
        release_probes(old);
 end:
        pthread_mutex_unlock(&tracepoint_mutex);
@@ -622,39 +682,39 @@ end:
 }
 
 /*
- * Caller needs to invoke __tracepoint_probe_release_queue() after
+ * Caller needs to invoke lttng_ust_tracepoint_probe_release_queue() after
  * calling lttng_ust_tp_probe_register_queue_release() one or multiple
  * times to ensure it does not leak memory.
  */
-int lttng_ust_tp_probe_register_queue_release(const char *name,
+int lttng_ust_tp_probe_register_queue_release(const char *provider_name, const char *event_name,
                void (*probe)(void), void *data, const char *signature)
 {
        void *old;
        int ret = 0;
 
-       DBG("Registering probe to tracepoint %s. Queuing release.", name);
+       DBG("Registering probe to tracepoint \"%s:%s\". Queuing release.", provider_name, event_name);
 
        pthread_mutex_lock(&tracepoint_mutex);
-       old = tracepoint_add_probe(name, probe, data, signature);
+       old = tracepoint_add_probe(provider_name, event_name, probe, data, signature);
        if (IS_ERR(old)) {
                ret = PTR_ERR(old);
                goto end;
        }
 
-       tracepoint_sync_callsites(name);
+       tracepoint_sync_callsites(provider_name, event_name);
        tracepoint_release_queue_add_old_probes(old);
 end:
        pthread_mutex_unlock(&tracepoint_mutex);
        return ret;
 }
 
-static void *tracepoint_remove_probe(const char *name, void (*probe)(void),
-               void *data)
+static void *tracepoint_remove_probe(const char *provider_name, const char *event_name,
+               void (*probe)(void), void *data)
 {
        struct tracepoint_entry *entry;
        void *old;
 
-       entry = get_tracepoint(name);
+       entry = get_tracepoint(provider_name, event_name);
        if (!entry)
                return ERR_PTR(-ENOENT);
        old = tracepoint_entry_remove_probe(entry, probe, data);
@@ -667,25 +727,26 @@ static void *tracepoint_remove_probe(const char *name, void (*probe)(void),
 
 /**
  * tracepoint_probe_unregister -  Disconnect a probe from a tracepoint
- * @name: tracepoint name
+ * @provider_name: tracepoint provider name
+ * @event_name: tracepoint event name
  * @probe: probe function pointer
  * @probe: probe data pointer
  */
-int __tracepoint_probe_unregister(const char *name, void (*probe)(void),
-               void *data)
+int lttng_ust_tracepoint_provider_unregister(const char *provider_name, const char *event_name,
+               void (*probe)(void), void *data)
 {
        void *old;
        int ret = 0;
 
-       DBG("Un-registering probe from tracepoint %s", name);
+       DBG("Un-registering probe \"%s:%s\" from tracepoint %p", provider_name, event_name, probe);
 
        pthread_mutex_lock(&tracepoint_mutex);
-       old = tracepoint_remove_probe(name, probe, data);
+       old = tracepoint_remove_probe(provider_name, event_name, probe, data);
        if (IS_ERR(old)) {
                ret = PTR_ERR(old);
                goto end;
        }
-       tracepoint_sync_callsites(name);
+       tracepoint_sync_callsites(provider_name, event_name);
        release_probes(old);
 end:
        pthread_mutex_unlock(&tracepoint_mutex);
@@ -693,25 +754,25 @@ end:
 }
 
 /*
- * Caller needs to invoke __tracepoint_probe_release_queue() after
+ * Caller needs to invoke lttng_ust_tracepoint_probe_release_queue() after
  * calling lttng_ust_tp_probe_unregister_queue_release() one or multiple
  * times to ensure it does not leak memory.
  */
-int lttng_ust_tp_probe_unregister_queue_release(const char *name,
+int lttng_ust_tp_probe_unregister_queue_release(const char *provider_name, const char *event_name,
                void (*probe)(void), void *data)
 {
        void *old;
        int ret = 0;
 
-       DBG("Un-registering probe from tracepoint %s. Queuing release.", name);
+       DBG("Un-registering probe from tracepoint \"%s:%s\". Queuing release.", provider_name, event_name);
 
        pthread_mutex_lock(&tracepoint_mutex);
-       old = tracepoint_remove_probe(name, probe, data);
+       old = tracepoint_remove_probe(provider_name, event_name, probe, data);
        if (IS_ERR(old)) {
                ret = PTR_ERR(old);
                goto end;
        }
-       tracepoint_sync_callsites(name);
+       tracepoint_sync_callsites(provider_name, event_name);
        tracepoint_release_queue_add_old_probes(old);
 end:
        pthread_mutex_unlock(&tracepoint_mutex);
@@ -760,14 +821,14 @@ static void tracepoint_add_old_probes(void *old)
  *
  * caller must call tracepoint_probe_update_all()
  */
-int tracepoint_probe_register_noupdate(const char *name, void (*probe)(void),
-                                      void *data, const char *signature)
+int tracepoint_probe_register_noupdate(const char *provider_name, const char *event_name,
+                                      void (*probe)(void), void *data, const char *signature)
 {
        void *old;
        int ret = 0;
 
        pthread_mutex_lock(&tracepoint_mutex);
-       old = tracepoint_add_probe(name, probe, data, signature);
+       old = tracepoint_add_probe(provider_name, event_name, probe, data, signature);
        if (IS_ERR(old)) {
                ret = PTR_ERR(old);
                goto end;
@@ -786,16 +847,16 @@ end:
  * caller must call tracepoint_probe_update_all()
  * Called with the tracepoint mutex held.
  */
-int tracepoint_probe_unregister_noupdate(const char *name, void (*probe)(void),
-                                        void *data)
+int tracepoint_probe_unregister_noupdate(const char *provider_name, const char *event_name,
+                                        void (*probe)(void), void *data)
 {
        void *old;
        int ret = 0;
 
-       DBG("Un-registering probe from tracepoint %s", name);
+       DBG("Un-registering probe from tracepoint \"%s:%s\"", provider_name, event_name);
 
        pthread_mutex_lock(&tracepoint_mutex);
-       old = tracepoint_remove_probe(name, probe, data);
+       old = tracepoint_remove_probe(provider_name, event_name, probe, data);
        if (IS_ERR(old)) {
                ret = PTR_ERR(old);
                goto end;
@@ -858,9 +919,9 @@ static void new_tracepoints(struct lttng_ust_tracepoint * const *start,
  * against recent liblttng-ust headers require a recent liblttng-ust
  * runtime for those tracepoints to be taken into account.
  */
-int tracepoint_register_lib(struct lttng_ust_tracepoint * const *tracepoints_start,
+int lttng_ust_tracepoint_module_register(struct lttng_ust_tracepoint * const *tracepoints_start,
                             int tracepoints_count);
-int tracepoint_register_lib(struct lttng_ust_tracepoint * const *tracepoints_start,
+int lttng_ust_tracepoint_module_register(struct lttng_ust_tracepoint * const *tracepoints_start,
                             int tracepoints_count)
 {
        struct tracepoint_lib *pl, *iter;
@@ -902,15 +963,19 @@ lib_added:
                int i;
 
                for (i = 0; i < tracepoints_count; i++) {
-                       DBG("registered tracepoint: %s", tracepoints_start[i]->name);
+                       if (!lttng_ust_tp_validate_event_name(tracepoints_start[i]))
+                               continue;
+                       DBG("registered tracepoint: \"%s:%s\"",
+                               tracepoints_start[i]->provider_name,
+                               tracepoints_start[i]->event_name);
                }
        }
 
        return 0;
 }
 
-int tracepoint_unregister_lib(struct lttng_ust_tracepoint * const *tracepoints_start);
-int tracepoint_unregister_lib(struct lttng_ust_tracepoint * const *tracepoints_start)
+int lttng_ust_tracepoint_module_unregister(struct lttng_ust_tracepoint * const *tracepoints_start);
+int lttng_ust_tracepoint_module_unregister(struct lttng_ust_tracepoint * const *tracepoints_start)
 {
        struct tracepoint_lib *lib;
 
@@ -945,15 +1010,15 @@ int tracepoint_unregister_lib(struct lttng_ust_tracepoint * const *tracepoints_s
 static void check_weak_hidden(void)
 {
        DBG("Your compiler treats weak symbols with hidden visibility for integer objects as %s between compile units part of the same module.",
-               &__tracepoint_test_symbol1 == lttng_ust_tp_check_weak_hidden1() ?
+               &lttng_ust_tracepoint_test_symbol1 == lttng_ust_tp_check_weak_hidden1() ?
                        "SAME address" :
                        "DIFFERENT addresses");
        DBG("Your compiler treats weak symbols with hidden visibility for pointer objects as %s between compile units part of the same module.",
-               &__tracepoint_test_symbol2 == lttng_ust_tp_check_weak_hidden2() ?
+               &lttng_ust_tracepoint_test_symbol2 == lttng_ust_tp_check_weak_hidden2() ?
                        "SAME address" :
                        "DIFFERENT addresses");
        DBG("Your compiler treats weak symbols with hidden visibility for 24-byte structure objects as %s between compile units part of the same module.",
-               &__tracepoint_test_symbol3 == lttng_ust_tp_check_weak_hidden3() ?
+               &lttng_ust_tracepoint_test_symbol3 == lttng_ust_tp_check_weak_hidden3() ?
                        "SAME address" :
                        "DIFFERENT addresses");
 }
@@ -963,6 +1028,7 @@ void lttng_ust_tp_init(void)
        if (uatomic_xchg(&initialized, 1) == 1)
                return;
        lttng_ust_logging_init();
+       lttng_ust_common_ctor();
        check_weak_hidden();
 }
 
@@ -974,24 +1040,24 @@ void lttng_ust_tp_exit(void)
 /*
  * Create the wrapper symbols.
  */
-#undef tp_rcu_read_lock
-#undef tp_rcu_read_unlock
-#undef tp_rcu_dereference
+#undef lttng_ust_tp_rcu_read_lock
+#undef lttng_ust_tp_rcu_read_unlock
+#undef lttng_ust_tp_rcu_dereference
 
-void tp_rcu_read_lock(void);
-void tp_rcu_read_lock(void)
+void lttng_ust_tp_rcu_read_lock(void);
+void lttng_ust_tp_rcu_read_lock(void)
 {
        lttng_ust_urcu_read_lock();
 }
 
-void tp_rcu_read_unlock(void);
-void tp_rcu_read_unlock(void)
+void lttng_ust_tp_rcu_read_unlock(void);
+void lttng_ust_tp_rcu_read_unlock(void)
 {
        lttng_ust_urcu_read_unlock();
 }
 
-void *tp_rcu_dereference_sym(void *p);
-void *tp_rcu_dereference_sym(void *p)
+void *lttng_ust_tp_rcu_dereference_sym(void *p);
+void *lttng_ust_tp_rcu_dereference_sym(void *p)
 {
        return lttng_ust_rcu_dereference(p);
 }
@@ -999,16 +1065,16 @@ void *tp_rcu_dereference_sym(void *p)
 /*
  * Programs that have threads that survive after they exit, and therefore call
  * library destructors, should disable the tracepoint destructors by calling
- * tp_disable_destructors(). This will leak the tracepoint
+ * lttng_ust_tp_disable_destructors(). This will leak the tracepoint
  * instrumentation library shared object, leaving its teardown to the operating
  * system process teardown.
  *
  * To access and/or modify this value, users need to use a combination of
  * dlopen(3) and dlsym(3) to get an handle on the
- * tp_disable_destructors and tp_get_destructors_state symbols below.
+ * lttng_ust_tp_disable_destructors and lttng_ust_tp_get_destructors_state symbols below.
  */
-void tp_disable_destructors(void);
-void tp_disable_destructors(void)
+void lttng_ust_tp_disable_destructors(void);
+void lttng_ust_tp_disable_destructors(void)
 {
        uatomic_set(&tracepoint_destructors_state, 0);
 }
@@ -1017,8 +1083,8 @@ void tp_disable_destructors(void)
  * Returns 1 if the destructors are enabled and should be executed.
  * Returns 0 if the destructors are disabled.
  */
-int tp_get_destructors_state(void);
-int tp_get_destructors_state(void)
+int lttng_ust_tp_get_destructors_state(void);
+int lttng_ust_tp_get_destructors_state(void)
 {
        return uatomic_read(&tracepoint_destructors_state);
 }
This page took 0.04942 seconds and 4 git commands to generate.