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