From a24e542a16596ad69bfde5cd9844e65c41ffeb77 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 5 Oct 2021 13:26:46 -0400 Subject: [PATCH] tracepoints: increase dlopen failure message level from debug to critical Print the failure message associated with failing to find lttng-ust-tracepoint.so as a "Critical: " message, because when this situation occurs, it indeeds makes part of that application's instrumentation invisible to the tracer. Similarly to debug message, this critical message is only shown if LTTNG_UST_DEBUG is defined for the compile unit or if the LTTNG_UST_DEBUG environment variable is set. In addition however, if LTTNG_UST_ABORT_ON_CRITICAL is defined at compile-time, or if the application is run with the LTTNG_UST_ABORT_ON_CRITICAL environment variable set, the construction will call abort() on failure to find lttng-ust-tracepoint.so. This should make it easier for end-users to identify deployment issues which prevent the lttng-ust tracer from being aware of application tracepoints. Signed-off-by: Mathieu Desnoyers Change-Id: I2ddcfd593eae699a2c18ef85049ac2239dd41411 --- include/lttng/tracepoint.h | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h index 17fa2a0c..b10c514e 100644 --- a/include/lttng/tracepoint.h +++ b/include/lttng/tracepoint.h @@ -413,20 +413,35 @@ bool lttng_ust_tracepoint_logging_debug_enabled(void) } #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()) - return; - fprintf(stderr, "lttng-ust-tracepoint [%ld]: 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_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 -- 2.34.1