Fix: signal: Remove SEND_SIG_FORCED (v4.20)
[lttng-modules.git] / instrumentation / events / lttng-module / signal.h
CommitLineData
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
cef5d79e
MJ
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) */
f127e61e
MD
27#define LTTNG_FIELDS_SIGINFO(info) \
28 ctf_integer(int, errno, \
0ec73ddc
MD
29 (info == SEND_SIG_NOINFO || info == SEND_SIG_FORCED || info == SEND_SIG_PRIV) ? \
30 0 : \
31 info->si_errno) \
f127e61e 32 ctf_integer(int, code, \
0ec73ddc
MD
33 (info == SEND_SIG_NOINFO || info == SEND_SIG_FORCED) ? \
34 SI_USER : \
35 ((info == SEND_SIG_PRIV) ? SI_KERNEL : info->si_code))
cef5d79e 36#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0) */
0ec73ddc
MD
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 */
b90a7f30 51#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0))
3bc29f0a 52LTTNG_TRACEPOINT_EVENT(signal_generate,
0ec73ddc 53
b90a7f30
MJ
54 TP_PROTO(int sig, struct kernel_siginfo *info, struct task_struct *task,
55 int group, int result),
0ec73ddc 56
b90a7f30 57 TP_ARGS(sig, info, task, group, result),
0ec73ddc 58
f127e61e
MD
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)
b90a7f30
MJ
64 ctf_integer(int, group, group)
65 ctf_integer(int, result, result)
f127e61e 66 )
0ec73ddc 67)
b90a7f30 68#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
3bc29f0a 69LTTNG_TRACEPOINT_EVENT(signal_generate,
6bd5e64e
MD
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
f127e61e
MD
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 )
6bd5e64e 84)
b90a7f30
MJ
85#else
86LTTNG_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)
6bd5e64e 99#endif
0ec73ddc
MD
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 */
b90a7f30
MJ
115#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0))
116LTTNG_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
3bc29f0a 130LTTNG_TRACEPOINT_EVENT(signal_deliver,
0ec73ddc
MD
131
132 TP_PROTO(int sig, struct siginfo *info, struct k_sigaction *ka),
133
134 TP_ARGS(sig, info, ka),
135
f127e61e
MD
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 )
0ec73ddc 142)
b90a7f30 143#endif
0ec73ddc 144
7c68b363 145#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
3bc29f0a 146LTTNG_TRACEPOINT_EVENT_CLASS(signal_queue_overflow,
0ec73ddc
MD
147
148 TP_PROTO(int sig, int group, struct siginfo *info),
149
150 TP_ARGS(sig, group, info),
151
f127e61e
MD
152 TP_FIELDS(
153 ctf_integer(int, sig, sig)
154 ctf_integer(int, group, group)
155 LTTNG_FIELDS_SIGINFO(info)
156 )
0ec73ddc
MD
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 */
3bc29f0a 170LTTNG_TRACEPOINT_EVENT_INSTANCE(signal_queue_overflow, signal_overflow_fail,
0ec73ddc
MD
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 */
3bc29f0a 188LTTNG_TRACEPOINT_EVENT_INSTANCE(signal_queue_overflow, signal_lose_info,
0ec73ddc
MD
189
190 TP_PROTO(int sig, int group, struct siginfo *info),
191
192 TP_ARGS(sig, group, info)
193)
7c68b363 194#endif
0ec73ddc 195
3bc29f0a 196#endif /* LTTNG_TRACE_SIGNAL_H */
0ec73ddc
MD
197
198/* This part must be outside protection */
6ec43db8 199#include <probes/define_trace.h>
This page took 0.041125 seconds and 4 git commands to generate.