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