liblttng-ust-ctl: Implement SIGBUS handling
[lttng-ust.git] / include / lttng / ust-sigbus.h
1 /*
2 * Copyright (C) 2020 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License only.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
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.
16 */
17
18 #ifndef _LTTNG_UST_SIGBUS_H
19 #define _LTTNG_UST_SIGBUS_H
20
21 #include <urcu/list.h>
22 #include <setjmp.h>
23
24 struct lttng_ust_sigbus_range {
25 void *start; /* inclusive */
26 void *end; /* exclusive */
27 struct cds_list_head node;
28 };
29
30 struct lttng_ust_sigbus_state {
31 int jmp_ready;
32 struct cds_list_head head; /* struct lttng_ust_sigbus_range */
33 sigjmp_buf sj_env;
34 };
35
36 /*
37 * Define the lttng_ust_sigbus_state TLS variable as initial-exec model
38 * to allow using it from the SIGBUS signal handler. This variable must
39 * be defined by the executable using DEFINE_LTTNG_UST_SIGBUS_STATE()
40 * rather than internally within liblttng-ust-ctl.so to ensure we don't
41 * contribute to reach glibc limits of pre-allocated TLS IE model space
42 * for shared objects.
43 */
44 #define DEFINE_LTTNG_UST_SIGBUS_STATE() \
45 __thread __attribute__((tls_model("initial-exec"))) struct lttng_ust_sigbus_state lttng_ust_sigbus_state
46
47 extern __thread __attribute__((tls_model("initial-exec"))) struct lttng_ust_sigbus_state lttng_ust_sigbus_state;
48
49 #endif /* _LTTNG_UST_SIGBUS_H */
This page took 0.029568 seconds and 4 git commands to generate.