actions: introduce stop session action
[lttng-tools.git] / src / common / testpoint / testpoint.c
1 /*
2 * Copyright (C) 2012 Christian Babeux <christian.babeux@efficios.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8 #ifndef NTESTPOINT
9
10 #define _LGPL_SOURCE
11 #include <dlfcn.h> /* for dlsym */
12 #include <stdlib.h> /* for getenv */
13 #include <string.h> /* for strncmp */
14
15 #include "testpoint.h"
16
17 /* Environment variable used to enable the testpoints facilities. */
18 static const char *lttng_testpoint_env_var = "LTTNG_TESTPOINT_ENABLE";
19
20 /* Testpoint toggle flag */
21 int lttng_testpoint_activated;
22
23 /*
24 * Toggle the support for testpoints on the application startup.
25 */
26 static void __attribute__((constructor)) lttng_testpoint_check(void)
27 {
28 char *testpoint_env_val = NULL;
29
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;
34 }
35 }
36
37 /*
38 * Lookup a symbol by name.
39 *
40 * Return the address where the symbol is loaded or NULL if the symbol was not
41 * found.
42 */
43 void *lttng_testpoint_lookup(const char *name)
44 {
45 if (!name) {
46 return NULL;
47 }
48
49 return dlsym(RTLD_DEFAULT, name);
50 }
51
52 #endif /* NTESTPOINT */
This page took 0.094038 seconds and 4 git commands to generate.