2 * Copyright (C) 2012 - Christian Babeux <christian.babeux@efficios.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2 only,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include <dlfcn.h> /* for dlsym */
22 #include <stdlib.h> /* for getenv */
23 #include <string.h> /* for strncmp */
25 #include "testpoint.h"
27 /* Environment variable used to enable the testpoints facilities. */
28 static const char *lttng_testpoint_env_var
= "LTTNG_TESTPOINT_ENABLE";
30 /* Testpoint toggle flag */
31 int lttng_testpoint_activated
;
34 * Toggle the support for testpoints on the application startup.
36 static void __attribute__((constructor
)) lttng_testpoint_check(void)
38 char *testpoint_env_val
= NULL
;
40 testpoint_env_val
= getenv(lttng_testpoint_env_var
);
41 if (testpoint_env_val
!= NULL
42 && (strncmp(testpoint_env_val
, "1", 1) == 0)) {
43 lttng_testpoint_activated
= 1;
48 * Lookup a symbol by name.
50 * Return the address where the symbol is loaded or NULL if the symbol was not
53 void *lttng_testpoint_lookup(const char *name
)
59 return dlsym(RTLD_DEFAULT
, name
);
62 #endif /* NTESTPOINT */