fix: signal instrumentation for CentOS >= 4.18.0-147
[lttng-modules.git] / instrumentation / events / lttng-module / signal.h
CommitLineData
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
f9a00b2e
MJ
15#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0) || \
16 LTTNG_RHEL_KERNEL_RANGE(4,18,0,147,0,0, 4,19,0,0,0,0))
26bc064a
MJ
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))
26bc064a 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 */
f9a00b2e
MJ
51#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0) || \
52 LTTNG_RHEL_KERNEL_RANGE(4,18,0,147,0,0, 4,19,0,0,0,0))
3bc29f0a 53LTTNG_TRACEPOINT_EVENT(signal_generate,
0ec73ddc 54
0a0d736e
MJ
55 TP_PROTO(int sig, struct kernel_siginfo *info, struct task_struct *task,
56 int group, int result),
0ec73ddc 57
0a0d736e 58 TP_ARGS(sig, info, task, group, result),
0ec73ddc 59
f127e61e
MD
60 TP_FIELDS(
61 ctf_integer(int, sig, sig)
62 LTTNG_FIELDS_SIGINFO(info)
63 ctf_array_text(char, comm, task->comm, TASK_COMM_LEN)
64 ctf_integer(pid_t, pid, task->pid)
0a0d736e
MJ
65 ctf_integer(int, group, group)
66 ctf_integer(int, result, result)
f127e61e 67 )
0ec73ddc 68)
0a0d736e 69#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
3bc29f0a 70LTTNG_TRACEPOINT_EVENT(signal_generate,
6bd5e64e
MD
71
72 TP_PROTO(int sig, struct siginfo *info, struct task_struct *task,
73 int group, int result),
74
75 TP_ARGS(sig, info, task, group, result),
76
f127e61e
MD
77 TP_FIELDS(
78 ctf_integer(int, sig, sig)
79 LTTNG_FIELDS_SIGINFO(info)
80 ctf_array_text(char, comm, task->comm, TASK_COMM_LEN)
81 ctf_integer(pid_t, pid, task->pid)
82 ctf_integer(int, group, group)
83 ctf_integer(int, result, result)
84 )
6bd5e64e 85)
0a0d736e
MJ
86#else
87LTTNG_TRACEPOINT_EVENT(signal_generate,
88
89 TP_PROTO(int sig, struct siginfo *info, struct task_struct *task),
90
91 TP_ARGS(sig, info, task),
92
93 TP_FIELDS(
94 ctf_integer(int, sig, sig)
95 LTTNG_FIELDS_SIGINFO(info)
96 ctf_array_text(char, comm, task->comm, TASK_COMM_LEN)
97 ctf_integer(pid_t, pid, task->pid)
98 )
99)
6bd5e64e 100#endif
0ec73ddc
MD
101
102/**
103 * signal_deliver - called when a signal is delivered
104 * @sig: signal number
105 * @info: pointer to struct siginfo
106 * @ka: pointer to struct k_sigaction
107 *
108 * A 'sig' signal is delivered to current process with 'info' siginfo,
109 * and it will be handled by 'ka'. ka->sa.sa_handler can be SIG_IGN or
110 * SIG_DFL.
111 * Note that some signals reported by signal_generate tracepoint can be
112 * lost, ignored or modified (by debugger) before hitting this tracepoint.
113 * This means, this can show which signals are actually delivered, but
114 * matching generated signals and delivered signals may not be correct.
115 */
f9a00b2e
MJ
116#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,20,0) || \
117 LTTNG_RHEL_KERNEL_RANGE(4,18,0,147,0,0, 4,19,0,0,0,0))
0a0d736e
MJ
118LTTNG_TRACEPOINT_EVENT(signal_deliver,
119
120 TP_PROTO(int sig, struct kernel_siginfo *info, struct k_sigaction *ka),
121
122 TP_ARGS(sig, info, ka),
123
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 )
130)
131#else
3bc29f0a 132LTTNG_TRACEPOINT_EVENT(signal_deliver,
0ec73ddc
MD
133
134 TP_PROTO(int sig, struct siginfo *info, struct k_sigaction *ka),
135
136 TP_ARGS(sig, info, ka),
137
f127e61e
MD
138 TP_FIELDS(
139 ctf_integer(int, sig, sig)
140 LTTNG_FIELDS_SIGINFO(info)
141 ctf_integer(unsigned long, sa_handler, (unsigned long) ka->sa.sa_handler)
142 ctf_integer(unsigned long, sa_flags, ka->sa.sa_flags)
143 )
0ec73ddc 144)
0a0d736e 145#endif
0ec73ddc 146
7c68b363 147#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
3bc29f0a 148LTTNG_TRACEPOINT_EVENT_CLASS(signal_queue_overflow,
0ec73ddc
MD
149
150 TP_PROTO(int sig, int group, struct siginfo *info),
151
152 TP_ARGS(sig, group, info),
153
f127e61e
MD
154 TP_FIELDS(
155 ctf_integer(int, sig, sig)
156 ctf_integer(int, group, group)
157 LTTNG_FIELDS_SIGINFO(info)
158 )
0ec73ddc
MD
159)
160
161/**
162 * signal_overflow_fail - called when signal queue is overflow
163 * @sig: signal number
164 * @group: signal to process group or not (bool)
165 * @info: pointer to struct siginfo
166 *
167 * Kernel fails to generate 'sig' signal with 'info' siginfo, because
168 * siginfo queue is overflow, and the signal is dropped.
169 * 'group' is not 0 if the signal will be sent to a process group.
170 * 'sig' is always one of RT signals.
171 */
3bc29f0a 172LTTNG_TRACEPOINT_EVENT_INSTANCE(signal_queue_overflow, signal_overflow_fail,
0ec73ddc
MD
173
174 TP_PROTO(int sig, int group, struct siginfo *info),
175
176 TP_ARGS(sig, group, info)
177)
178
179/**
180 * signal_lose_info - called when siginfo is lost
181 * @sig: signal number
182 * @group: signal to process group or not (bool)
183 * @info: pointer to struct siginfo
184 *
185 * Kernel generates 'sig' signal but loses 'info' siginfo, because siginfo
186 * queue is overflow.
187 * 'group' is not 0 if the signal will be sent to a process group.
188 * 'sig' is always one of non-RT signals.
189 */
3bc29f0a 190LTTNG_TRACEPOINT_EVENT_INSTANCE(signal_queue_overflow, signal_lose_info,
0ec73ddc
MD
191
192 TP_PROTO(int sig, int group, struct siginfo *info),
193
194 TP_ARGS(sig, group, info)
195)
7c68b363 196#endif
0ec73ddc 197
3bc29f0a 198#endif /* LTTNG_TRACE_SIGNAL_H */
0ec73ddc
MD
199
200/* This part must be outside protection */
6ec43db8 201#include <probes/define_trace.h>
This page took 0.041476 seconds and 4 git commands to generate.