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