X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=include%2Flttng%2Ftracepoint.h;h=b10c514e21c86fae23f8f91b37d14adbb66b1bf7;hb=a24e542a16596ad69bfde5cd9844e65c41ffeb77;hp=1f8b9209de0c1ec4992af786f32ef623230fbc28;hpb=5b675300cd432c3dff378ac5b78eb6b56d4294e6;p=lttng-ust.git diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h index 1f8b9209..b10c514e 100644 --- a/include/lttng/tracepoint.h +++ b/include/lttng/tracepoint.h @@ -11,16 +11,25 @@ #include #include #include +#include +#include +#include + #include #include #include /* for dlopen */ #include /* for memset */ +#include #include /* for sdt */ #include #include #include +#if (defined(__cplusplus) && (__cplusplus <= 199711L)) +#error "C++11 support is required to build tracepoints and providers as C++" +#endif + #define LTTNG_UST_TRACEPOINT_NAME_LEN_MAX 256 #ifdef LTTNG_UST_HAVE_SDT_INTEGRATION @@ -386,6 +395,55 @@ lttng_ust_tracepoint__init_urcu_sym(void) } #endif +/* + * Use getenv() directly and bypass lttng-ust helper functions + * because we may not have access to lttng-ust shared libraries. + */ +#ifdef LTTNG_UST_DEBUG +static inline +bool lttng_ust_tracepoint_logging_debug_enabled(void) +{ + return true; +} +#else /* #ifdef LTTNG_UST_DEBUG */ +static inline +bool lttng_ust_tracepoint_logging_debug_enabled(void) +{ + return getenv("LTTNG_UST_DEBUG"); +} +#endif /* #ifdef LTTNG_UST_DEBUG */ + +#ifdef LTTNG_UST_ABORT_ON_CRITICAL +static inline +bool lttng_ust_tracepoint_logging_abort_on_critical_enabled(void) +{ + return true; +} +#else /* #ifdef LTTNG_UST_ABORT_ON_CRITICAL */ +static inline +bool lttng_ust_tracepoint_logging_abort_on_critical_enabled(void) +{ + return getenv("LTTNG_UST_ABORT_ON_CRITICAL"); +} +#endif + +#define LTTNG_UST_TRACEPOINT_THIS_IP \ + ({ __label__ here; here: &&here; }) + +static void +lttng_ust_tracepoints_print_disabled_message(void) +{ + if (lttng_ust_tracepoint_logging_debug_enabled()) + fprintf(stderr, "lttng-ust-tracepoint [%ld]: Critical: dlopen() failed to find '%s', tracepoints in this binary won't be registered. " + "(at addr=%p in %s() at " __FILE__ ":" lttng_ust_stringify(__LINE__) ")\n", + (long) getpid(), + LTTNG_UST_TRACEPOINT_LIB_SONAME, + LTTNG_UST_TRACEPOINT_THIS_IP, + __func__); + if (lttng_ust_tracepoint_logging_abort_on_critical_enabled()) + abort(); +} + static void lttng_ust__tracepoints__init(void) lttng_ust_notrace __attribute__((constructor)); @@ -404,8 +462,10 @@ lttng_ust__tracepoints__init(void) if (!lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle) lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle = dlopen(LTTNG_UST_TRACEPOINT_LIB_SONAME, RTLD_NOW | RTLD_GLOBAL); - if (!lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle) + if (!lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle) { + lttng_ust_tracepoints_print_disabled_message(); return; + } lttng_ust_tracepoint__init_urcu_sym(); } @@ -534,8 +594,10 @@ lttng_ust__tracepoints__ptrs_init(void) if (!lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle) lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle = dlopen(LTTNG_UST_TRACEPOINT_LIB_SONAME, RTLD_NOW | RTLD_GLOBAL); - if (!lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle) + if (!lttng_ust_tracepoint_dlopen_ptr->liblttngust_handle) { + lttng_ust_tracepoints_print_disabled_message(); return; + } if (!lttng_ust_tracepoint_destructors_syms_ptr) lttng_ust_tracepoint_destructors_syms_ptr = <tng_ust_tracepoint_destructors_syms; lttng_ust_tracepoint_dlopen_ptr->lttng_ust_tracepoint_module_register =