Add signal instrumentation
[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
9 #ifndef _TRACE_SIGNAL_DEF
10 #define _TRACE_SIGNAL_DEF
11 #include <linux/signal.h>
12 #include <linux/sched.h>
13 #define TP_STORE_SIGINFO(info) \
14 tp_assign(errno, \
15 (info == SEND_SIG_NOINFO || info == SEND_SIG_FORCED || info == SEND_SIG_PRIV) ? \
16 0 : \
17 info->si_errno) \
18 tp_assign(code, \
19 (info == SEND_SIG_NOINFO || info == SEND_SIG_FORCED) ? \
20 SI_USER : \
21 ((info == SEND_SIG_PRIV) ? SI_KERNEL : info->si_code))
22 #endif /* _TRACE_SIGNAL_DEF */
23
24 /**
25 * signal_generate - called when a signal is generated
26 * @sig: signal number
27 * @info: pointer to struct siginfo
28 * @task: pointer to struct task_struct
29 *
30 * Current process sends a 'sig' signal to 'task' process with
31 * 'info' siginfo. If 'info' is SEND_SIG_NOINFO or SEND_SIG_PRIV,
32 * 'info' is not a pointer and you can't access its field. Instead,
33 * SEND_SIG_NOINFO means that si_code is SI_USER, and SEND_SIG_PRIV
34 * means that si_code is SI_KERNEL.
35 */
36 TRACE_EVENT(signal_generate,
37
38 TP_PROTO(int sig, struct siginfo *info, struct task_struct *task),
39
40 TP_ARGS(sig, info, task),
41
42 TP_STRUCT__entry(
43 __field( int, sig )
44 __field( int, errno )
45 __field( int, code )
46 __array( char, comm, TASK_COMM_LEN )
47 __field( pid_t, pid )
48 ),
49
50 TP_fast_assign(
51 tp_assign(sig, sig)
52 TP_STORE_SIGINFO(info)
53 tp_memcpy(comm, task->comm, TASK_COMM_LEN)
54 tp_assign(pid, task->pid)
55 ),
56
57 TP_printk("sig=%d errno=%d code=%d comm=%s pid=%d",
58 __entry->sig, __entry->errno, __entry->code,
59 __entry->comm, __entry->pid)
60 )
61
62 /**
63 * signal_deliver - called when a signal is delivered
64 * @sig: signal number
65 * @info: pointer to struct siginfo
66 * @ka: pointer to struct k_sigaction
67 *
68 * A 'sig' signal is delivered to current process with 'info' siginfo,
69 * and it will be handled by 'ka'. ka->sa.sa_handler can be SIG_IGN or
70 * SIG_DFL.
71 * Note that some signals reported by signal_generate tracepoint can be
72 * lost, ignored or modified (by debugger) before hitting this tracepoint.
73 * This means, this can show which signals are actually delivered, but
74 * matching generated signals and delivered signals may not be correct.
75 */
76 TRACE_EVENT(signal_deliver,
77
78 TP_PROTO(int sig, struct siginfo *info, struct k_sigaction *ka),
79
80 TP_ARGS(sig, info, ka),
81
82 TP_STRUCT__entry(
83 __field( int, sig )
84 __field( int, errno )
85 __field( int, code )
86 __field( unsigned long, sa_handler )
87 __field( unsigned long, sa_flags )
88 ),
89
90 TP_fast_assign(
91 tp_assign(sig, sig)
92 TP_STORE_SIGINFO(info)
93 tp_assign(sa_handler, (unsigned long)ka->sa.sa_handler)
94 tp_assign(sa_flags, ka->sa.sa_flags)
95 ),
96
97 TP_printk("sig=%d errno=%d code=%d sa_handler=%lx sa_flags=%lx",
98 __entry->sig, __entry->errno, __entry->code,
99 __entry->sa_handler, __entry->sa_flags)
100 )
101
102 DECLARE_EVENT_CLASS(signal_queue_overflow,
103
104 TP_PROTO(int sig, int group, struct siginfo *info),
105
106 TP_ARGS(sig, group, info),
107
108 TP_STRUCT__entry(
109 __field( int, sig )
110 __field( int, group )
111 __field( int, errno )
112 __field( int, code )
113 ),
114
115 TP_fast_assign(
116 tp_assign(sig, sig)
117 tp_assign(group, group)
118 TP_STORE_SIGINFO(info)
119 ),
120
121 TP_printk("sig=%d group=%d errno=%d code=%d",
122 __entry->sig, __entry->group, __entry->errno, __entry->code)
123 )
124
125 /**
126 * signal_overflow_fail - called when signal queue is overflow
127 * @sig: signal number
128 * @group: signal to process group or not (bool)
129 * @info: pointer to struct siginfo
130 *
131 * Kernel fails to generate 'sig' signal with 'info' siginfo, because
132 * siginfo queue is overflow, and the signal is dropped.
133 * 'group' is not 0 if the signal will be sent to a process group.
134 * 'sig' is always one of RT signals.
135 */
136 DEFINE_EVENT(signal_queue_overflow, signal_overflow_fail,
137
138 TP_PROTO(int sig, int group, struct siginfo *info),
139
140 TP_ARGS(sig, group, info)
141 )
142
143 /**
144 * signal_lose_info - called when siginfo is lost
145 * @sig: signal number
146 * @group: signal to process group or not (bool)
147 * @info: pointer to struct siginfo
148 *
149 * Kernel generates 'sig' signal but loses 'info' siginfo, because siginfo
150 * queue is overflow.
151 * 'group' is not 0 if the signal will be sent to a process group.
152 * 'sig' is always one of non-RT signals.
153 */
154 DEFINE_EVENT(signal_queue_overflow, signal_lose_info,
155
156 TP_PROTO(int sig, int group, struct siginfo *info),
157
158 TP_ARGS(sig, group, info)
159 )
160
161 #endif /* _TRACE_SIGNAL_H */
162
163 /* This part must be outside protection */
164 #include "../../../probes/define_trace.h"
This page took 0.033153 seconds and 5 git commands to generate.