2 * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
11 #include <dlfcn.h> /* for dlsym */
12 #include <stdlib.h> /* for getenv */
13 #include <string.h> /* for strncmp */
15 #include "testpoint.h"
17 /* Environment variable used to enable the testpoints facilities. */
18 static const char *lttng_testpoint_env_var
= "LTTNG_TESTPOINT_ENABLE";
20 /* Testpoint toggle flag */
21 int lttng_testpoint_activated
;
24 * Toggle the support for testpoints on the application startup.
26 static void __attribute__((constructor
)) lttng_testpoint_check(void)
28 char *testpoint_env_val
= NULL
;
30 testpoint_env_val
= getenv(lttng_testpoint_env_var
);
31 if (testpoint_env_val
!= NULL
32 && (strncmp(testpoint_env_val
, "1", 1) == 0)) {
33 lttng_testpoint_activated
= 1;
38 * Lookup a symbol by name.
40 * Return the address where the symbol is loaded or NULL if the symbol was not
43 void *lttng_testpoint_lookup(const char *name
)
49 return dlsym(RTLD_DEFAULT
, name
);
52 #endif /* NTESTPOINT */