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