Namespace kernel version macros
[lttng-modules.git] / instrumentation / events / lttng-module / signal.h
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM signal
3
4 #if !defined(LTTNG_TRACE_SIGNAL_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define LTTNG_TRACE_SIGNAL_H
6
7 #include <probes/lttng-tracepoint-event.h>
8 #include <lttng-kernel-version.h>
9
10 #ifndef _TRACE_SIGNAL_DEF
11 #define _TRACE_SIGNAL_DEF
12 #include <linux/signal.h>
13 #include <linux/sched.h>
14 #undef LTTNG_FIELDS_SIGINFO
15 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,20,0) || \
16 LTTNG_RHEL_KERNEL_RANGE(4,18,0,147,0,0, 4,19,0,0,0,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 /* LTTNG_LINUX_VERSION_CODE >= LTTNG_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 /* LTTNG_LINUX_VERSION_CODE >= LTTNG_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 (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,20,0) || \
52 LTTNG_RHEL_KERNEL_RANGE(4,18,0,147,0,0, 4,19,0,0,0,0))
53 LTTNG_TRACEPOINT_EVENT(signal_generate,
54
55 TP_PROTO(int sig, struct kernel_siginfo *info, struct task_struct *task,
56 int group, int result),
57
58 TP_ARGS(sig, info, task, group, result),
59
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)
65 ctf_integer(int, group, group)
66 ctf_integer(int, result, result)
67 )
68 )
69 #elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,4,0))
70 LTTNG_TRACEPOINT_EVENT(signal_generate,
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
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 )
85 )
86 #else
87 LTTNG_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 )
100 #endif
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 */
116 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,20,0) || \
117 LTTNG_RHEL_KERNEL_RANGE(4,18,0,147,0,0, 4,19,0,0,0,0))
118 LTTNG_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
132 LTTNG_TRACEPOINT_EVENT(signal_deliver,
133
134 TP_PROTO(int sig, struct siginfo *info, struct k_sigaction *ka),
135
136 TP_ARGS(sig, info, ka),
137
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 )
144 )
145 #endif
146
147 #if (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(3,4,0))
148 LTTNG_TRACEPOINT_EVENT_CLASS(signal_queue_overflow,
149
150 TP_PROTO(int sig, int group, struct siginfo *info),
151
152 TP_ARGS(sig, group, info),
153
154 TP_FIELDS(
155 ctf_integer(int, sig, sig)
156 ctf_integer(int, group, group)
157 LTTNG_FIELDS_SIGINFO(info)
158 )
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 */
172 LTTNG_TRACEPOINT_EVENT_INSTANCE(signal_queue_overflow, signal_overflow_fail,
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 */
190 LTTNG_TRACEPOINT_EVENT_INSTANCE(signal_queue_overflow, signal_lose_info,
191
192 TP_PROTO(int sig, int group, struct siginfo *info),
193
194 TP_ARGS(sig, group, info)
195 )
196 #endif
197
198 #endif /* LTTNG_TRACE_SIGNAL_H */
199
200 /* This part must be outside protection */
201 #include <probes/define_trace.h>
This page took 0.034349 seconds and 4 git commands to generate.