tracepoint: Declare tracepoint module register/unregister API
[lttng-ust.git] / include / lttng / tracepoint.h
index a8532796a95dc4f016ecee74f093db5cfe26c657..c59a96c990218dce0f6ded3a90f9344a95b28bae 100644 (file)
@@ -4,8 +4,8 @@
  * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  */
 
-#ifndef _LTTNG_TRACEPOINT_H
-#define _LTTNG_TRACEPOINT_H
+#ifndef _LTTNG_UST_TRACEPOINT_H
+#define _LTTNG_UST_TRACEPOINT_H
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -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;                       \
@@ -215,7 +216,7 @@ static inline                                                                               \
 void lttng_ust_tracepoint_register_##_provider##___##_name(char *provider_name, char *event_name, \
                void (*func)(void), void *data)                                         \
 {                                                                                      \
-       lttng_ust_tracepoint_probe_register(provider_name, event_name, func, data,              \
+       lttng_ust_tracepoint_provider_register(provider_name, event_name, func, data,           \
                lttng_ust_tracepoint_##_provider##___##_name.signature);                        \
 }                                                                                      \
 static inline                                                                          \
@@ -226,14 +227,27 @@ static inline                                                                             \
 void lttng_ust_tracepoint_unregister_##_provider##___##_name(char *provider_name, char *event_name, \
                void (*func)(void), void *data)                                         \
 {                                                                                      \
-       lttng_ust_tracepoint_probe_unregister(provider_name, event_name, func, data);           \
+       lttng_ust_tracepoint_provider_unregister(provider_name, event_name, func, data);                \
 }
 
-extern int lttng_ust_tracepoint_probe_register(const char *provider_name, const char *event_name,
+/*
+ * Registration of tracepoint provider probe functions with
+ * lttng_ust_tracepoint_provider_register, unregistration with
+ * lttng_ust_tracepoint_provider_unregister.
+ */
+int lttng_ust_tracepoint_provider_register(const char *provider_name, const char *event_name,
                void (*func)(void), void *data, const char *signature);
-extern int lttng_ust_tracepoint_probe_unregister(const char *provider_name, const char *event_name,
+int lttng_ust_tracepoint_provider_unregister(const char *provider_name, const char *event_name,
                void (*func)(void), void *data);
 
+/*
+ * Registration of tracepoint instrumentation modules with lttng_ust_tracepoint_module_register,
+ * unregistration with lttng_ust_tracepoint_module_unregister.
+ */
+int lttng_ust_tracepoint_module_register(struct lttng_ust_tracepoint * const *tracepoints_start,
+                             int tracepoints_count);
+int lttng_ust_tracepoint_module_unregister(struct lttng_ust_tracepoint * const *tracepoints_start);
+
 /*
  * tracepoint dynamic linkage handling (callbacks). Hidden visibility:
  * shared across objects in a module/main executable.
@@ -251,9 +265,9 @@ struct lttng_ust_tracepoint_dlopen {
 
        void *liblttngust_handle;
 
-       int (*lttng_ust_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 (*lttng_ust_tracepoint_unregister_lib)(struct lttng_ust_tracepoint * const *tracepoints_start);
+       int (*lttng_ust_tracepoint_module_unregister)(struct lttng_ust_tracepoint * const *tracepoints_start);
        void (*rcu_read_lock_sym)(void);
        void (*rcu_read_unlock_sym)(void);
        void *(*rcu_dereference_sym)(void *p);
@@ -482,7 +496,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 +505,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,               \
@@ -522,14 +538,14 @@ lttng_ust__tracepoints__ptrs_init(void)
                return;
        if (!lttng_ust_tracepoint_destructors_syms_ptr)
                lttng_ust_tracepoint_destructors_syms_ptr = &lttng_ust_tracepoint_destructors_syms;
-       lttng_ust_tracepoint_dlopen_ptr->lttng_ust_tracepoint_register_lib =
+       lttng_ust_tracepoint_dlopen_ptr->lttng_ust_tracepoint_module_register =
                URCU_FORCE_CAST(int (*)(struct lttng_ust_tracepoint * const *, int),
                                dlsym(lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle,
-                                       "lttng_ust_tracepoint_register_lib"));
-       lttng_ust_tracepoint_dlopen_ptr->lttng_ust_tracepoint_unregister_lib =
+                                       "lttng_ust_tracepoint_module_register"));
+       lttng_ust_tracepoint_dlopen_ptr->lttng_ust_tracepoint_module_unregister =
                URCU_FORCE_CAST(int (*)(struct lttng_ust_tracepoint * const *),
                                dlsym(lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle,
-                                       "lttng_ust_tracepoint_unregister_lib"));
+                                       "lttng_ust_tracepoint_module_unregister"));
        lttng_ust_tracepoint_destructors_syms_ptr->tracepoint_disable_destructors =
                URCU_FORCE_CAST(void (*)(void),
                                dlsym(lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle,
@@ -539,8 +555,8 @@ lttng_ust__tracepoints__ptrs_init(void)
                                dlsym(lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle,
                                        "lttng_ust_tp_get_destructors_state"));
        lttng_ust_tracepoint__init_urcu_sym();
-       if (lttng_ust_tracepoint_dlopen_ptr->lttng_ust_tracepoint_register_lib) {
-               lttng_ust_tracepoint_dlopen_ptr->lttng_ust_tracepoint_register_lib(__start_lttng_ust_tracepoints_ptrs,
+       if (lttng_ust_tracepoint_dlopen_ptr->lttng_ust_tracepoint_module_register) {
+               lttng_ust_tracepoint_dlopen_ptr->lttng_ust_tracepoint_module_register(__start_lttng_ust_tracepoints_ptrs,
                                __stop_lttng_ust_tracepoints_ptrs -
                                __start_lttng_ust_tracepoints_ptrs);
        }
@@ -560,8 +576,8 @@ lttng_ust__tracepoints__ptrs_destroy(void)
                lttng_ust_tracepoint_dlopen_ptr = &lttng_ust_tracepoint_dlopen;
        if (!lttng_ust_tracepoint_destructors_syms_ptr)
                lttng_ust_tracepoint_destructors_syms_ptr = &lttng_ust_tracepoint_destructors_syms;
-       if (lttng_ust_tracepoint_dlopen_ptr->lttng_ust_tracepoint_unregister_lib)
-               lttng_ust_tracepoint_dlopen_ptr->lttng_ust_tracepoint_unregister_lib(__start_lttng_ust_tracepoints_ptrs);
+       if (lttng_ust_tracepoint_dlopen_ptr->lttng_ust_tracepoint_module_unregister)
+               lttng_ust_tracepoint_dlopen_ptr->lttng_ust_tracepoint_module_unregister(__start_lttng_ust_tracepoints_ptrs);
        if (lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle
                        && lttng_ust_tracepoint_destructors_syms_ptr->tracepoint_get_destructors_state
                        && lttng_ust_tracepoint_destructors_syms_ptr->tracepoint_get_destructors_state()
@@ -586,60 +602,49 @@ lttng_ust__tracepoints__ptrs_destroy(void)
 #define do_tracepoint                  lttng_ust_do_tracepoint
 #define tracepoint_enabled             lttng_ust_tracepoint_enabled
 #define TP_ARGS                                LTTNG_UST_TP_ARGS
-#define TP_FIELDS                      LTTNG_UST_TP_FIELDS
-
-#define ctf_integer                    lttng_ust_field_integer
-#define ctf_integer_hex                        lttng_ust_field_integer_hex
-#define ctf_integer_network            lttng_ust_field_integer_network
-#define ctf_integer_network_hex                lttng_ust_field_integer_network_hex
-#define ctf_integer_nowrite            lttng_ust_field_integer_nowrite
-
-#define ctf_float                      lttng_ust_field_float
-#define ctf_float_nowrite              lttng_ust_field_float_nowrite
-
-#define ctf_array                      lttng_ust_field_array
-#define ctf_array_hex                  lttng_ust_field_array_hex
-#define ctf_array_network              lttng_ust_field_array_network
-#define ctf_array_network_hex          lttng_ust_field_array_network_hex
-#define ctf_array_text                 lttng_ust_field_array_text
-#define ctf_array_nowrite              lttng_ust_field_array_nowrite
-#define ctf_array_nowrite_hex          lttng_ust_field_array_nowrite_hex
-#define ctf_array_network_nowrite      lttng_ust_field_array_network_nowrite
-#define ctf_array_network_nowrite_hex  lttng_ust_field_array_network_nowrite_hex
-#define ctf_array_text_nowrite         lttng_ust_field_array_text_nowrite
-
-#define ctf_sequence                   lttng_ust_field_sequence
-#define ctf_sequence_hex               lttng_ust_field_sequence_hex
-#define ctf_sequence_network           lttng_ust_field_sequence_network
-#define ctf_sequence_network_hex       lttng_ust_field_sequence_network_hex
-#define ctf_sequence_text              lttng_ust_field_sequence_text
-#define ctf_sequence_nowrite           lttng_ust_field_sequence_nowrite
-#define ctf_sequence_nowrite_hex       lttng_ust_field_sequence_nowrite_hex
-#define ctf_sequence_network_nowrite   lttng_ust_field_sequence_network_nowrite
-#define ctf_sequence_network_nowrite_hex lttng_ust_field_sequence_network_nowrite_hex
-#define ctf_sequence_text_nowrite      lttng_ust_field_sequence_text_nowrite
-
-#define ctf_string                     lttng_ust_field_string
-#define ctf_string_nowrite             lttng_ust_field_string_nowrite
-
-#define ctf_unused                     lttng_ust_field_unused
-#define ctf_unused_nowrite             lttng_ust_field_unused_nowrite
-
-#define ctf_enum                       lttng_ust_field_enum
-#define ctf_enum_nowrite               lttng_ust_field_enum_nowrite
-#define ctf_enum_value                 lttng_ust_field_enum_value
-#define ctf_enum_range                 lttng_ust_field_enum_range
-#define ctf_enum_auto                  lttng_ust_field_enum_auto
 #endif /* #if LTTNG_UST_COMPAT_API(0) */
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* _LTTNG_TRACEPOINT_H */
+#endif /* _LTTNG_UST_TRACEPOINT_H */
 
 /* 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
 
 /*
This page took 0.025489 seconds and 4 git commands to generate.