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