Introduce LTTNG_UST_MAP_POPULATE_POLICY environment variable
[lttng-ust.git] / include / lttng / tracepoint.h
index 17fa2a0c68ef884857cc6dfa5066172e425d2b0d..9342c5c1f5a09e1c2db375b285f4679c5e81c22a 100644 (file)
@@ -1,8 +1,6 @@
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright (C) 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- */
+// SPDX-FileCopyrightText: 2011-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+//
+// SPDX-License-Identifier: MIT
 
 #ifndef _LTTNG_UST_TRACEPOINT_H
 #define _LTTNG_UST_TRACEPOINT_H
@@ -413,25 +411,40 @@ 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
 lttng_ust__tracepoints__init(void)
-       lttng_ust_notrace __attribute__((constructor));
+       lttng_ust_notrace __attribute__((constructor(LTTNG_UST_CONSTRUCTOR_PRIO)));
 static void
 lttng_ust__tracepoints__init(void)
 {
@@ -456,7 +469,7 @@ lttng_ust__tracepoints__init(void)
 
 static void
 lttng_ust__tracepoints__destroy(void)
-       lttng_ust_notrace __attribute__((destructor));
+       lttng_ust_notrace __attribute__((destructor(LTTNG_UST_CONSTRUCTOR_PRIO)));
 static void
 lttng_ust__tracepoints__destroy(void)
 {
@@ -498,8 +511,30 @@ lttng_ust__tracepoints__destroy(void)
 # endif
 #endif /* #if LTTNG_UST_COMPAT_API(0) */
 
+#if LTTNG_UST_COMPAT_API(0)
+#define tracepoint                     lttng_ust_tracepoint
+#define do_tracepoint                  lttng_ust_do_tracepoint
+#define tracepoint_enabled             lttng_ust_tracepoint_enabled
+#define TP_ARGS                                LTTNG_UST_TP_ARGS
+#endif /* #if LTTNG_UST_COMPAT_API(0) */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LTTNG_UST_TRACEPOINT_H */
+
+/* The following declarations must be outside re-inclusion protection. */
+
 #ifdef LTTNG_UST_TRACEPOINT_DEFINE
 
+#ifndef _LTTNG_UST_TRACEPOINT_DEFINE_ONCE
+#define _LTTNG_UST_TRACEPOINT_DEFINE_ONCE
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*
  * These weak symbols, the constructor, and destructor take care of
  * registering only _one_ instance of the tracepoints per shared-ojbect
@@ -539,6 +574,7 @@ extern struct lttng_ust_tracepoint * const __stop_lttng_ust_tracepoints_ptrs[]
  */
 #define LTTNG_UST__TP_EXTRACT_STRING(...)      #__VA_ARGS__
 
+#undef LTTNG_UST__DEFINE_TRACEPOINT
 #define LTTNG_UST__DEFINE_TRACEPOINT(_provider, _name, _args)                          \
        lttng_ust_tracepoint_validate_name_len(_provider, _name);               \
        extern int lttng_ust_tracepoint_provider_##_provider                    \
@@ -568,7 +604,7 @@ extern struct lttng_ust_tracepoint * const __stop_lttng_ust_tracepoints_ptrs[]
 
 static void
 lttng_ust__tracepoints__ptrs_init(void)
-       lttng_ust_notrace __attribute__((constructor));
+       lttng_ust_notrace __attribute__((constructor(LTTNG_UST_CONSTRUCTOR_PRIO)));
 static void
 lttng_ust__tracepoints__ptrs_init(void)
 {
@@ -611,7 +647,7 @@ lttng_ust__tracepoints__ptrs_init(void)
 
 static void
 lttng_ust__tracepoints__ptrs_destroy(void)
-       lttng_ust_notrace __attribute__((destructor));
+       lttng_ust_notrace __attribute__((destructor(LTTNG_UST_CONSTRUCTOR_PRIO)));
 static void
 lttng_ust__tracepoints__ptrs_destroy(void)
 {
@@ -638,26 +674,18 @@ lttng_ust__tracepoints__ptrs_destroy(void)
        }
 }
 
-#else /* LTTNG_UST_TRACEPOINT_DEFINE */
-
-#define LTTNG_UST__DEFINE_TRACEPOINT(_provider, _name, _args)
-
-#endif /* #else LTTNG_UST_TRACEPOINT_DEFINE */
-
-#if LTTNG_UST_COMPAT_API(0)
-#define tracepoint                     lttng_ust_tracepoint
-#define do_tracepoint                  lttng_ust_do_tracepoint
-#define tracepoint_enabled             lttng_ust_tracepoint_enabled
-#define TP_ARGS                                LTTNG_UST_TP_ARGS
-#endif /* #if LTTNG_UST_COMPAT_API(0) */
-
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* _LTTNG_UST_TRACEPOINT_H */
+#endif /* _LTTNG_UST_TRACEPOINT_DEFINE_ONCE */
 
-/* The following declarations must be outside re-inclusion protection. */
+#else /* LTTNG_UST_TRACEPOINT_DEFINE */
+
+#undef LTTNG_UST__DEFINE_TRACEPOINT
+#define LTTNG_UST__DEFINE_TRACEPOINT(_provider, _name, _args)
+
+#endif /* #else LTTNG_UST_TRACEPOINT_DEFINE */
 
 /*
  * LTTNG_UST_TRACEPOINT_HIDDEN_DEFINITION: Define this before including
This page took 0.026302 seconds and 4 git commands to generate.