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