From: Mathieu Desnoyers Date: Tue, 5 Mar 2013 22:04:44 +0000 (-0500) Subject: Fix: ensure all probe providers have their symbols X-Git-Tag: v2.2.0-rc1~60 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=558b9d86247004f8e9bbaf8c982f3b2b182093d1;p=lttng-ust.git Fix: ensure all probe providers have their symbols Following the removal of metadata generation from UST, the probes cannot find the tracepoint_dlopen() symbol. Ensure those probes can be built by declaring this symbol within each probe. Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h index 460ad205..3433560a 100644 --- a/include/lttng/tracepoint.h +++ b/include/lttng/tracepoint.h @@ -215,6 +215,16 @@ extern struct tracepoint_dlopen tracepoint_dlopen; #ifdef TRACEPOINT_DEFINE +/* + * These weak symbols, the constructor, and destructor take care of + * registering only _one_ instance of the tracepoints per shared-ojbect + * (or for the whole main program). + */ +extern struct tracepoint * const __start___tracepoints_ptrs[] + __attribute__((weak, visibility("hidden"))); +extern struct tracepoint * const __stop___tracepoints_ptrs[] + __attribute__((weak, visibility("hidden"))); + /* * When TRACEPOINT_PROBE_DYNAMIC_LINKAGE is defined, we do not emit a * unresolved symbol that requires the provider to be linked in. When @@ -255,15 +265,41 @@ extern struct tracepoint_dlopen tracepoint_dlopen; __attribute__((used, section("__tracepoints_ptrs"))) = \ &__tracepoint_##_provider##___##_name; +static inline void __tracepoints__init_define(void) +{ + tracepoint_dlopen.tracepoint_register_lib(__start___tracepoints_ptrs, + __stop___tracepoints_ptrs - + __start___tracepoints_ptrs); +} + +static inline void __tracepoints__destroy_define(void) +{ + if (tracepoint_dlopen.tracepoint_unregister_lib) + tracepoint_dlopen.tracepoint_unregister_lib(__start___tracepoints_ptrs); +} + + +#else /* TRACEPOINT_DEFINE */ + +#define _DEFINE_TRACEPOINT(_provider, _name, _args) + +static inline void __tracepoints__init_define(void) +{ +} + +static inline void __tracepoints__destroy_define(void) +{ +} + +#endif /* #else TRACEPOINT_DEFINE */ + +#if defined(TRACEPOINT_DEFINE) || defined(TRACEPOINT_CREATE_PROBES) + /* * These weak symbols, the constructor, and destructor take care of * registering only _one_ instance of the tracepoints per shared-ojbect * (or for the whole main program). */ -extern struct tracepoint * const __start___tracepoints_ptrs[] - __attribute__((weak, visibility("hidden"))); -extern struct tracepoint * const __stop___tracepoints_ptrs[] - __attribute__((weak, visibility("hidden"))); int __tracepoint_registered __attribute__((weak, visibility("hidden"))); struct tracepoint_dlopen tracepoint_dlopen @@ -303,9 +339,7 @@ __tracepoints__init(void) dlsym(tracepoint_dlopen.liblttngust_handle, "tp_rcu_dereference_sym_bp")); #endif - tracepoint_dlopen.tracepoint_register_lib(__start___tracepoints_ptrs, - __stop___tracepoints_ptrs - - __start___tracepoints_ptrs); + __tracepoints__init_define(); } static void lttng_ust_notrace __attribute__((destructor)) @@ -317,8 +351,7 @@ __tracepoints__destroy(void) if (--__tracepoint_registered) return; - if (tracepoint_dlopen.tracepoint_unregister_lib) - tracepoint_dlopen.tracepoint_unregister_lib(__start___tracepoints_ptrs); + __tracepoints__destroy_define(); if (tracepoint_dlopen.liblttngust_handle) { ret = dlclose(tracepoint_dlopen.liblttngust_handle); assert(!ret); @@ -326,11 +359,7 @@ __tracepoints__destroy(void) } } -#else /* TRACEPOINT_DEFINE */ - -#define _DEFINE_TRACEPOINT(_provider, _name, _args) - -#endif /* #else TRACEPOINT_DEFINE */ +#endif #ifdef __cplusplus }