X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=libust%2Ftracepoint.c;h=a006f700cc18af292d3061e622b6fb1a9ba46f3b;hb=a5fd9b038fa5034ade759ca1338d2b93153ba217;hp=3bc5795afc17ce2f811e69015ac338b62ecd5519;hpb=b27f8e75a6e762ed01b889560431476516786d9f;p=lttng-ust.git diff --git a/libust/tracepoint.c b/libust/tracepoint.c index 3bc5795a..a006f700 100644 --- a/libust/tracepoint.c +++ b/libust/tracepoint.c @@ -27,16 +27,9 @@ #include #include #include +#include -#include "usterr_signal_safe.h" - -extern struct tracepoint * const __start___tracepoints_ptrs[] - __attribute__((visibility("hidden"))); -extern struct tracepoint * const __stop___tracepoints_ptrs[] - __attribute__((visibility("hidden"))); - -static struct tracepoint * __tracepoint_ptr_dummy - __attribute__((used, section("__tracepoints_ptrs"))); +#include /* Set to 1 to enable tracepoint debug output */ static const int tracepoint_debug; @@ -637,6 +630,8 @@ int tracepoint_register_lib(struct tracepoint * const *tracepoints_start, { struct tracepoint_lib *pl, *iter; + init_tracepoint(); + pl = (struct tracepoint_lib *) zmalloc(sizeof(struct tracepoint_lib)); pl->tracepoints_start = tracepoints_start; @@ -664,8 +659,8 @@ lib_added: /* TODO: update just the loaded lib */ lib_update_tracepoints(); - /* tracepoints_count - 1: skip dummy */ - DBG("just registered a tracepoints section from %p and having %d tracepoints (minus dummy tracepoints)", tracepoints_start, tracepoints_count); + DBG("just registered a tracepoints section from %p and having %d tracepoints", + tracepoints_start, tracepoints_count); return 0; } @@ -688,17 +683,13 @@ int tracepoint_unregister_lib(struct tracepoint * const *tracepoints_start) return 0; } -void __attribute__((constructor)) init_tracepoint(void) +void init_tracepoint(void) { - if (!initialized) { - tracepoint_register_lib(__start___tracepoints_ptrs, - __stop___tracepoints_ptrs - - __start___tracepoints_ptrs); - initialized = 1; - } + if (uatomic_xchg(&initialized, 1) == 1) + return; + init_usterr(); } -void __attribute__((destructor)) destroy_tracepoint(void) +void exit_tracepoint(void) { - tracepoint_unregister_lib(__start___tracepoints_ptrs); }