Commit | Line | Data |
---|---|---|
9f36eaed | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
0ec73ddc MD |
2 | #undef TRACE_SYSTEM |
3 | #define TRACE_SYSTEM signal | |
4 | ||
3bc29f0a MD |
5 | #if !defined(LTTNG_TRACE_SIGNAL_H) || defined(TRACE_HEADER_MULTI_READ) |
6 | #define LTTNG_TRACE_SIGNAL_H | |
0ec73ddc | 7 | |
6ec43db8 | 8 | #include <probes/lttng-tracepoint-event.h> |
6bd5e64e | 9 | #include <linux/version.h> |
0ec73ddc MD |
10 | |
11 | #ifndef _TRACE_SIGNAL_DEF | |
12 | #define _TRACE_SIGNAL_DEF | |
13 | #include <linux/signal.h> | |
14 | #include <linux/sched.h> | |
f127e61e | 15 | #undef LTTNG_FIELDS_SIGINFO |
68023bef MJ |
16 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0) || \ |
17 | LTTNG_RHEL_KERNEL_RANGE(4,18,0,147,0,0, 4,19,0,0,0,0)) | |
cef5d79e MJ |
18 | #define LTTNG_FIELDS_SIGINFO(info) \ |
19 | ctf_integer(int, errno, \ | |
20 | (info == SEND_SIG_NOINFO || info == SEND_SIG_PRIV) ? \ | |
21 | 0 : \ | |
22 | info->si_errno) \ | |
23 | ctf_integer(int, code, \ | |
24 | (info == SEND_SIG_NOINFO) ? \ | |
25 | SI_USER : \ | |
26 | ((info == SEND_SIG_PRIV) ? SI_KERNEL : info->si_code)) | |
27 | #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0) */ | |
f127e61e MD |
28 | #define LTTNG_FIELDS_SIGINFO(info) \ |
29 | ctf_integer(int, errno, \ | |
0ec73ddc MD |
30 | (info == SEND_SIG_NOINFO || info == SEND_SIG_FORCED || info == SEND_SIG_PRIV) ? \ |
31 | 0 : \ | |
32 | info->si_errno) \ | |
f127e61e | 33 | ctf_integer(int, code, \ |
0ec73ddc MD |
34 | (info == SEND_SIG_NOINFO || info == SEND_SIG_FORCED) ? \ |
35 | SI_USER : \ | |
36 | ((info == SEND_SIG_PRIV) ? SI_KERNEL : info->si_code)) | |
cef5d79e | 37 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0) */ |
0ec73ddc MD |
38 | #endif /* _TRACE_SIGNAL_DEF */ |
39 | ||
40 | /** | |
41 | * signal_generate - called when a signal is generated | |
42 | * @sig: signal number | |
43 | * @info: pointer to struct siginfo | |
44 | * @task: pointer to struct task_struct | |
45 | * | |
46 | * Current process sends a 'sig' signal to 'task' process with | |
47 | * 'info' siginfo. If 'info' is SEND_SIG_NOINFO or SEND_SIG_PRIV, | |
48 | * 'info' is not a pointer and you can't access its field. Instead, | |
49 | * SEND_SIG_NOINFO means that si_code is SI_USER, and SEND_SIG_PRIV | |
50 | * means that si_code is SI_KERNEL. | |
51 | */ | |
68023bef MJ |
52 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0) || \ |
53 | LTTNG_RHEL_KERNEL_RANGE(4,18,0,147,0,0, 4,19,0,0,0,0)) | |
3bc29f0a | 54 | LTTNG_TRACEPOINT_EVENT(signal_generate, |
0ec73ddc | 55 | |
b90a7f30 MJ |
56 | TP_PROTO(int sig, struct kernel_siginfo *info, struct task_struct *task, |
57 | int group, int result), | |
0ec73ddc | 58 | |
b90a7f30 | 59 | TP_ARGS(sig, info, task, group, result), |
0ec73ddc | 60 | |
f127e61e MD |
61 | TP_FIELDS( |
62 | ctf_integer(int, sig, sig) | |
63 | LTTNG_FIELDS_SIGINFO(info) | |
64 | ctf_array_text(char, comm, task->comm, TASK_COMM_LEN) | |
65 | ctf_integer(pid_t, pid, task->pid) | |
b90a7f30 MJ |
66 | ctf_integer(int, group, group) |
67 | ctf_integer(int, result, result) | |
f127e61e | 68 | ) |
0ec73ddc | 69 | ) |
b90a7f30 | 70 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) |
3bc29f0a | 71 | LTTNG_TRACEPOINT_EVENT(signal_generate, |
6bd5e64e MD |
72 | |
73 | TP_PROTO(int sig, struct siginfo *info, struct task_struct *task, | |
74 | int group, int result), | |
75 | ||
76 | TP_ARGS(sig, info, task, group, result), | |
77 | ||
f127e61e MD |
78 | TP_FIELDS( |
79 | ctf_integer(int, sig, sig) | |
80 | LTTNG_FIELDS_SIGINFO(info) | |
81 | ctf_array_text(char, comm, task->comm, TASK_COMM_LEN) | |
82 | ctf_integer(pid_t, pid, task->pid) | |
83 | ctf_integer(int, group, group) | |
84 | ctf_integer(int, result, result) | |
85 | ) | |
6bd5e64e | 86 | ) |
b90a7f30 MJ |
87 | #else |
88 | LTTNG_TRACEPOINT_EVENT(signal_generate, | |
89 | ||
90 | TP_PROTO(int sig, struct siginfo *info, struct task_struct *task), | |
91 | ||
92 | TP_ARGS(sig, info, task), | |
93 | ||
94 | TP_FIELDS( | |
95 | ctf_integer(int, sig, sig) | |
96 | LTTNG_FIELDS_SIGINFO(info) | |
97 | ctf_array_text(char, comm, task->comm, TASK_COMM_LEN) | |
98 | ctf_integer(pid_t, pid, task->pid) | |
99 | ) | |
100 | ) | |
6bd5e64e | 101 | #endif |
0ec73ddc MD |
102 | |
103 | /** | |
104 | * signal_deliver - called when a signal is delivered | |
105 | * @sig: signal number | |
106 | * @info: pointer to struct siginfo | |
107 | * @ka: pointer to struct k_sigaction | |
108 | * | |
109 | * A 'sig' signal is delivered to current process with 'info' siginfo, | |
110 | * and it will be handled by 'ka'. ka->sa.sa_handler can be SIG_IGN or | |
111 | * SIG_DFL. | |
112 | * Note that some signals reported by signal_generate tracepoint can be | |
113 | * lost, ignored or modified (by debugger) before hitting this tracepoint. | |
114 | * This means, this can show which signals are actually delivered, but | |
115 | * matching generated signals and delivered signals may not be correct. | |
116 | */ | |
68023bef MJ |
117 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0) || \ |
118 | LTTNG_RHEL_KERNEL_RANGE(4,18,0,147,0,0, 4,19,0,0,0,0)) | |
b90a7f30 MJ |
119 | LTTNG_TRACEPOINT_EVENT(signal_deliver, |
120 | ||
121 | TP_PROTO(int sig, struct kernel_siginfo *info, struct k_sigaction *ka), | |
122 | ||
123 | TP_ARGS(sig, info, ka), | |
124 | ||
125 | TP_FIELDS( | |
126 | ctf_integer(int, sig, sig) | |
127 | LTTNG_FIELDS_SIGINFO(info) | |
128 | ctf_integer(unsigned long, sa_handler, (unsigned long) ka->sa.sa_handler) | |
129 | ctf_integer(unsigned long, sa_flags, ka->sa.sa_flags) | |
130 | ) | |
131 | ) | |
132 | #else | |
3bc29f0a | 133 | LTTNG_TRACEPOINT_EVENT(signal_deliver, |
0ec73ddc MD |
134 | |
135 | TP_PROTO(int sig, struct siginfo *info, struct k_sigaction *ka), | |
136 | ||
137 | TP_ARGS(sig, info, ka), | |
138 | ||
f127e61e MD |
139 | TP_FIELDS( |
140 | ctf_integer(int, sig, sig) | |
141 | LTTNG_FIELDS_SIGINFO(info) | |
142 | ctf_integer(unsigned long, sa_handler, (unsigned long) ka->sa.sa_handler) | |
143 | ctf_integer(unsigned long, sa_flags, ka->sa.sa_flags) | |
144 | ) | |
0ec73ddc | 145 | ) |
b90a7f30 | 146 | #endif |
0ec73ddc | 147 | |
7c68b363 | 148 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
3bc29f0a | 149 | LTTNG_TRACEPOINT_EVENT_CLASS(signal_queue_overflow, |
0ec73ddc MD |
150 | |
151 | TP_PROTO(int sig, int group, struct siginfo *info), | |
152 | ||
153 | TP_ARGS(sig, group, info), | |
154 | ||
f127e61e MD |
155 | TP_FIELDS( |
156 | ctf_integer(int, sig, sig) | |
157 | ctf_integer(int, group, group) | |
158 | LTTNG_FIELDS_SIGINFO(info) | |
159 | ) | |
0ec73ddc MD |
160 | ) |
161 | ||
162 | /** | |
163 | * signal_overflow_fail - called when signal queue is overflow | |
164 | * @sig: signal number | |
165 | * @group: signal to process group or not (bool) | |
166 | * @info: pointer to struct siginfo | |
167 | * | |
168 | * Kernel fails to generate 'sig' signal with 'info' siginfo, because | |
169 | * siginfo queue is overflow, and the signal is dropped. | |
170 | * 'group' is not 0 if the signal will be sent to a process group. | |
171 | * 'sig' is always one of RT signals. | |
172 | */ | |
3bc29f0a | 173 | LTTNG_TRACEPOINT_EVENT_INSTANCE(signal_queue_overflow, signal_overflow_fail, |
0ec73ddc MD |
174 | |
175 | TP_PROTO(int sig, int group, struct siginfo *info), | |
176 | ||
177 | TP_ARGS(sig, group, info) | |
178 | ) | |
179 | ||
180 | /** | |
181 | * signal_lose_info - called when siginfo is lost | |
182 | * @sig: signal number | |
183 | * @group: signal to process group or not (bool) | |
184 | * @info: pointer to struct siginfo | |
185 | * | |
186 | * Kernel generates 'sig' signal but loses 'info' siginfo, because siginfo | |
187 | * queue is overflow. | |
188 | * 'group' is not 0 if the signal will be sent to a process group. | |
189 | * 'sig' is always one of non-RT signals. | |
190 | */ | |
3bc29f0a | 191 | LTTNG_TRACEPOINT_EVENT_INSTANCE(signal_queue_overflow, signal_lose_info, |
0ec73ddc MD |
192 | |
193 | TP_PROTO(int sig, int group, struct siginfo *info), | |
194 | ||
195 | TP_ARGS(sig, group, info) | |
196 | ) | |
7c68b363 | 197 | #endif |
0ec73ddc | 198 | |
3bc29f0a | 199 | #endif /* LTTNG_TRACE_SIGNAL_H */ |
0ec73ddc MD |
200 | |
201 | /* This part must be outside protection */ | |
6ec43db8 | 202 | #include <probes/define_trace.h> |