Print DBG() message about compiler weak hidden symbol behavior
[lttng-ust.git] / liblttng-ust / tracepoint.c
index a4a79ba59b3f8298b30a2889bf6e7e30ef04aad2..a594d73ddd7bc6a3c893acd3d645635d23bc6c73 100644 (file)
@@ -30,6 +30,7 @@
 #include <urcu/hlist.h>
 #include <urcu/uatomic.h>
 #include <urcu/compiler.h>
+#include <urcu/system.h>
 
 #include <lttng/tracepoint.h>
 #include <lttng/ust-abi.h>     /* for LTTNG_UST_SYM_NAME_LEN */
@@ -42,6 +43,9 @@
 #include "jhash.h"
 #include "error.h"
 
+/* Test compiler support for weak symbols with hidden visibility. */
+char __tracepoint_test_symbol[9] __attribute__((weak, visibility("hidden")));
+
 /* Set to 1 to enable tracepoint debug output */
 static const int tracepoint_debug;
 static int initialized;
@@ -347,7 +351,7 @@ static void set_tracepoint(struct tracepoint_entry **entry,
         * is used.
         */
        rcu_assign_pointer(elem->probes, (*entry)->probes);
-       elem->state = active;
+       CMM_STORE_SHARED(elem->state, active);
 }
 
 /*
@@ -358,7 +362,7 @@ static void set_tracepoint(struct tracepoint_entry **entry,
  */
 static void disable_tracepoint(struct lttng_ust_tracepoint *elem)
 {
-       elem->state = 0;
+       CMM_STORE_SHARED(elem->state, 0);
        rcu_assign_pointer(elem->probes, NULL);
 }
 
@@ -802,11 +806,26 @@ int tracepoint_unregister_lib(struct lttng_ust_tracepoint * const *tracepoints_s
        return 0;
 }
 
+/*
+ * Report in debug message whether the compiler correctly supports weak
+ * hidden symbols. This test checks that the address associated with two
+ * weak symbols with hidden visibility is the same when declared within
+ * two compile units part of the same module.
+ */
+static void check_weak_hidden(void)
+{
+       DBG("Your compiler support for weak symbols with hidden visibility is %s",
+               __tracepoint_test_symbol == lttng_ust_tp_check_weak_hidden() ?
+                       "OK" :
+                       "BROKEN. Please upgrade or fix your compiler to use LTTng-UST tracepoints.");
+}
+
 void init_tracepoint(void)
 {
        if (uatomic_xchg(&initialized, 1) == 1)
                return;
        init_usterr();
+       check_weak_hidden();
 }
 
 void exit_tracepoint(void)
This page took 0.024022 seconds and 4 git commands to generate.