c3529f973d6beb1870b45db15ff6f6d36630e3a0
[lttng-modules.git] / instrumentation / events / lttng-module / signal.h
1 #undef TRACE_SYSTEM
2 #define TRACE_SYSTEM signal
3
4 #if !defined(_TRACE_SIGNAL_H) || defined(TRACE_HEADER_MULTI_READ)
5 #define _TRACE_SIGNAL_H
6
7 #include <linux/tracepoint.h>
8 #include <linux/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 TP_STORE_SIGINFO
15 #define TP_STORE_SIGINFO(info) \
16 tp_assign(errno, \
17 (info == SEND_SIG_NOINFO || info == SEND_SIG_FORCED || info == SEND_SIG_PRIV) ? \
18 0 : \
19 info->si_errno) \
20 tp_assign(code, \
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 */
38 #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
39 TRACE_EVENT(signal_generate,
40
41 TP_PROTO(int sig, struct siginfo *info, struct task_struct *task),
42
43 TP_ARGS(sig, info, task),
44
45 TP_STRUCT__entry(
46 __field( int, sig )
47 __field( int, errno )
48 __field( int, code )
49 __array( char, comm, TASK_COMM_LEN )
50 __field( pid_t, pid )
51 ),
52
53 TP_fast_assign(
54 tp_assign(sig, sig)
55 TP_STORE_SIGINFO(info)
56 tp_memcpy(comm, task->comm, TASK_COMM_LEN)
57 tp_assign(pid, task->pid)
58 ),
59
60 TP_printk("sig=%d errno=%d code=%d comm=%s pid=%d",
61 __entry->sig, __entry->errno, __entry->code,
62 __entry->comm, __entry->pid)
63 )
64 #else
65 TRACE_EVENT(signal_generate,
66
67 TP_PROTO(int sig, struct siginfo *info, struct task_struct *task,
68 int group, int result),
69
70 TP_ARGS(sig, info, task, group, result),
71
72 TP_STRUCT__entry(
73 __field( int, sig )
74 __field( int, errno )
75 __field( int, code )
76 __array( char, comm, TASK_COMM_LEN )
77 __field( pid_t, pid )
78 __field( int, group )
79 __field( int, result )
80 ),
81
82 TP_fast_assign(
83 tp_assign(sig, sig)
84 TP_STORE_SIGINFO(info)
85 tp_memcpy(comm, task->comm, TASK_COMM_LEN)
86 tp_assign(pid, task->pid)
87 tp_assign(group, group)
88 tp_assign(result, result)
89 ),
90
91 TP_printk("sig=%d errno=%d code=%d comm=%s pid=%d grp=%d res=%d",
92 __entry->sig, __entry->errno, __entry->code,
93 __entry->comm, __entry->pid, __entry->group,
94 __entry->result)
95 )
96 #endif
97
98 /**
99 * signal_deliver - called when a signal is delivered
100 * @sig: signal number
101 * @info: pointer to struct siginfo
102 * @ka: pointer to struct k_sigaction
103 *
104 * A 'sig' signal is delivered to current process with 'info' siginfo,
105 * and it will be handled by 'ka'. ka->sa.sa_handler can be SIG_IGN or
106 * SIG_DFL.
107 * Note that some signals reported by signal_generate tracepoint can be
108 * lost, ignored or modified (by debugger) before hitting this tracepoint.
109 * This means, this can show which signals are actually delivered, but
110 * matching generated signals and delivered signals may not be correct.
111 */
112 TRACE_EVENT(signal_deliver,
113
114 TP_PROTO(int sig, struct siginfo *info, struct k_sigaction *ka),
115
116 TP_ARGS(sig, info, ka),
117
118 TP_STRUCT__entry(
119 __field( int, sig )
120 __field( int, errno )
121 __field( int, code )
122 __field( unsigned long, sa_handler )
123 __field( unsigned long, sa_flags )
124 ),
125
126 TP_fast_assign(
127 tp_assign(sig, sig)
128 TP_STORE_SIGINFO(info)
129 tp_assign(sa_handler, (unsigned long)ka->sa.sa_handler)
130 tp_assign(sa_flags, ka->sa.sa_flags)
131 ),
132
133 TP_printk("sig=%d errno=%d code=%d sa_handler=%lx sa_flags=%lx",
134 __entry->sig, __entry->errno, __entry->code,
135 __entry->sa_handler, __entry->sa_flags)
136 )
137
138 DECLARE_EVENT_CLASS(signal_queue_overflow,
139
140 TP_PROTO(int sig, int group, struct siginfo *info),
141
142 TP_ARGS(sig, group, info),
143
144 TP_STRUCT__entry(
145 __field( int, sig )
146 __field( int, group )
147 __field( int, errno )
148 __field( int, code )
149 ),
150
151 TP_fast_assign(
152 tp_assign(sig, sig)
153 tp_assign(group, group)
154 TP_STORE_SIGINFO(info)
155 ),
156
157 TP_printk("sig=%d group=%d errno=%d code=%d",
158 __entry->sig, __entry->group, __entry->errno, __entry->code)
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 DEFINE_EVENT(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 DEFINE_EVENT(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
197 #endif /* _TRACE_SIGNAL_H */
198
199 /* This part must be outside protection */
200 #include "../../../probes/define_trace.h"
This page took 0.032986 seconds and 3 git commands to generate.