tracepoint: introduce macros to hide tracepoint/provider symbols
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 23 Apr 2021 16:25:53 +0000 (12:25 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 23 Apr 2021 19:40:27 +0000 (15:40 -0400)
Introduce the following macros:

LTTNG_UST_TRACEPOINT_HIDDEN_DEFINITION: Hide symbols associated with
tracepoint module instrumentation.

LTTNG_UST_TRACEPOINT_PROVIDER_HIDDEN_DEFINITION: Hide symbols associated
with tracepoint provider.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I493c325b73c16044dcc117b48cc91df3b05f18b0

include/lttng/tracepoint.h
include/lttng/ust-tracepoint-event.h

index be18e94c7823211b55b94b36fdca70bc97b7774e..23f01547720b67a5068eb940df210c6714c6467e 100644 (file)
@@ -182,7 +182,8 @@ extern "C" {
  * address.
  */
 #define LTTNG_UST__DECLARE_TRACEPOINT(_provider, _name, ...)                                   \
-extern struct lttng_ust_tracepoint lttng_ust_tracepoint_##_provider##___##_name;               \
+extern struct lttng_ust_tracepoint lttng_ust_tracepoint_##_provider##___##_name                \
+               LTTNG_UST__TRACEPOINT_DEFINITION_VISIBILITY;                            \
 static inline                                                                          \
 void lttng_ust_tracepoint_cb_##_provider##___##_name(LTTNG_UST__TP_ARGS_PROTO(__VA_ARGS__))            \
        __attribute__((always_inline, unused)) lttng_ust_notrace;                       \
@@ -482,7 +483,8 @@ extern struct lttng_ust_tracepoint * const __stop_lttng_ust_tracepoints_ptrs[]
 
 #define LTTNG_UST__DEFINE_TRACEPOINT(_provider, _name, _args)                          \
        lttng_ust_tracepoint_validate_name_len(_provider, _name);               \
-       extern int lttng_ust_tracepoint_provider_##_provider;                           \
+       extern int lttng_ust_tracepoint_provider_##_provider                    \
+               LTTNG_UST__TRACEPOINT_PROVIDER_DEFINITION_VISIBILITY;           \
        static const char lttng_ust_tp_provider_strtab_##_provider##___##_name[]        \
                __attribute__((section("lttng_ust_tracepoints_strings"))) =             \
                        #_provider;                                             \
@@ -490,7 +492,8 @@ extern struct lttng_ust_tracepoint * const __stop_lttng_ust_tracepoints_ptrs[]
                __attribute__((section("lttng_ust_tracepoints_strings"))) =             \
                        #_name;                                                 \
        struct lttng_ust_tracepoint lttng_ust_tracepoint_##_provider##___##_name        \
-               __attribute__((section("lttng_ust_tracepoints"))) = {                   \
+               __attribute__((section("lttng_ust_tracepoints")))               \
+               LTTNG_UST__TRACEPOINT_DEFINITION_VISIBILITY = {                 \
                        sizeof(struct lttng_ust_tracepoint),                    \
                        lttng_ust_tp_provider_strtab_##_provider##___##_name,           \
                        lttng_ust_tp_name_strtab_##_provider##___##_name,               \
@@ -596,6 +599,39 @@ lttng_ust__tracepoints__ptrs_destroy(void)
 
 /* The following declarations must be outside re-inclusion protection. */
 
+/*
+ * LTTNG_UST_TRACEPOINT_HIDDEN_DEFINITION: Define this before including
+ * a tracepoint instrumentation header to hide symbols associated with
+ * tracepoint module instrumentation. This is useful if all compile
+ * units using the lttng_ust_tracepoint(),
+ * lttng_ust_tracepoint_enabled() and lttng_ust_do_tracepoint() macros
+ * is within the same module as the compile unit including the
+ * tracepoint header after defining LTTNG_UST_TRACEPOINT_DEFINE.
+ */
+
+#undef LTTNG_UST__TRACEPOINT_DEFINITION_VISIBILITY
+#ifdef LTTNG_UST_TRACEPOINT_HIDDEN_DEFINITION
+#define LTTNG_UST__TRACEPOINT_DEFINITION_VISIBILITY            __attribute__((visibility("hidden")))
+#else
+#define LTTNG_UST__TRACEPOINT_DEFINITION_VISIBILITY            __attribute__((visibility("default")))
+#endif
+
+/*
+ * LTTNG_UST_TRACEPOINT_PROVIDER_HIDDEN_DEFINITION: Define this before
+ * including a tracepoint instrumentation header to hide symbols
+ * associated with the tracepoint provider. This is useful if the
+ * tracepoint definition (including the header after defining
+ * LTTNG_UST_TRACEPOINT_DEFINE) is in the same module as the provider
+ * (including the header after defining
+ * LTTNG_UST_TRACEPOINT_CREATE_PROBES).
+ */
+#undef LTTNG_UST__TRACEPOINT_PROVIDER_DEFINITION_VISIBILITY
+#ifdef LTTNG_UST_TRACEPOINT_PROVIDER_HIDDEN_DEFINITION
+#define LTTNG_UST__TRACEPOINT_PROVIDER_DEFINITION_VISIBILITY   __attribute__((visibility("hidden")))
+#else
+#define LTTNG_UST__TRACEPOINT_PROVIDER_DEFINITION_VISIBILITY   __attribute__((visibility("default")))
+#endif
+
 #ifndef LTTNG_UST_TRACEPOINT_ENUM
 
 /*
index 10ff52b0181c3d05c098c823ae0bd57b96a0065a..654b367f173c7fa3c738e7f333e02bb3f539b823 100644 (file)
@@ -1211,5 +1211,21 @@ LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__events_exit__, LTTNG_UST_TRACEPOINT_PROV
        LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust__probe_register_cookie___, LTTNG_UST_TRACEPOINT_PROVIDER) = NULL;
 }
 
+/*
+ * LTTNG_UST_TRACEPOINT_PROVIDER_HIDDEN_DEFINITION: Define this before
+ * including a tracepoint instrumentation header to hide symbols
+ * associated with the tracepoint provider. This is useful if the
+ * tracepoint definition (including the header after defining
+ * LTTNG_UST_TRACEPOINT_DEFINE) is in the same module as the provider
+ * (including the header after defining
+ * LTTNG_UST_TRACEPOINT_CREATE_PROBES).
+ */
+#undef LTTNG_UST__TRACEPOINT_PROVIDER_DEFINITION_VISIBILITY
+#ifdef LTTNG_UST_TRACEPOINT_PROVIDER_HIDDEN_DEFINITION
+#define LTTNG_UST__TRACEPOINT_PROVIDER_DEFINITION_VISIBILITY   __attribute__((visibility("hidden")))
+#else
+#define LTTNG_UST__TRACEPOINT_PROVIDER_DEFINITION_VISIBILITY   __attribute__((visibility("default")))
+#endif
+
 int LTTNG_UST__TP_COMBINE_TOKENS(lttng_ust_tracepoint_provider_, LTTNG_UST_TRACEPOINT_PROVIDER)
-       __attribute__((visibility("default")));
+       LTTNG_UST__TRACEPOINT_PROVIDER_DEFINITION_VISIBILITY;
This page took 0.027188 seconds and 4 git commands to generate.