1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM signal
5 #if !defined(_TRACE_SIGNAL_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_SIGNAL_H
8 #include <linux/signal.h>
9 #include <linux/sched.h>
10 #include <linux/tracepoint.h>
12 #define TP_STORE_SIGINFO(__entry, info) \
14 if (info == SEND_SIG_NOINFO || \
15 info == SEND_SIG_FORCED) { \
17 __entry->code = SI_USER; \
18 } else if (info == SEND_SIG_PRIV) { \
20 __entry->code = SI_KERNEL; \
22 __entry->errno = info->si_errno; \
23 __entry->code = info->si_code; \
27 #ifndef TRACE_HEADER_MULTI_READ
29 TRACE_SIGNAL_DELIVERED,
31 TRACE_SIGNAL_ALREADY_PENDING,
32 TRACE_SIGNAL_OVERFLOW_FAIL,
33 TRACE_SIGNAL_LOSE_INFO,
38 * signal_generate - called when a signal is generated
40 * @info: pointer to struct siginfo
41 * @task: pointer to struct task_struct
42 * @group: shared or private
43 * @result: TRACE_SIGNAL_*
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.
51 TRACE_EVENT(signal_generate,
53 TP_PROTO(int sig, struct siginfo *info, struct task_struct *task,
54 int group, int result),
56 TP_ARGS(sig, info, task, group, result),
62 __array( char, comm, TASK_COMM_LEN )
65 __field( int, result )
70 TP_STORE_SIGINFO(__entry, info);
71 memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
72 __entry->pid = task->pid;
73 __entry->group = group;
74 __entry->result = result;
77 TP_printk("sig=%d errno=%d code=%d comm=%s pid=%d grp=%d res=%d",
78 __entry->sig, __entry->errno, __entry->code,
79 __entry->comm, __entry->pid, __entry->group,
84 * signal_deliver - called when a signal is delivered
86 * @info: pointer to struct siginfo
87 * @ka: pointer to struct k_sigaction
89 * A 'sig' signal is delivered to current process with 'info' siginfo,
90 * and it will be handled by 'ka'. ka->sa.sa_handler can be SIG_IGN or
92 * Note that some signals reported by signal_generate tracepoint can be
93 * lost, ignored or modified (by debugger) before hitting this tracepoint.
94 * This means, this can show which signals are actually delivered, but
95 * matching generated signals and delivered signals may not be correct.
97 TRACE_EVENT(signal_deliver,
99 TP_PROTO(int sig, struct siginfo *info, struct k_sigaction *ka),
101 TP_ARGS(sig, info, ka),
105 __field( int, errno )
107 __field( unsigned long, sa_handler )
108 __field( unsigned long, sa_flags )
113 TP_STORE_SIGINFO(__entry, info);
114 __entry->sa_handler = (unsigned long)ka->sa.sa_handler;
115 __entry->sa_flags = ka->sa.sa_flags;
118 TP_printk("sig=%d errno=%d code=%d sa_handler=%lx sa_flags=%lx",
119 __entry->sig, __entry->errno, __entry->code,
120 __entry->sa_handler, __entry->sa_flags)
123 #endif /* _TRACE_SIGNAL_H */
125 /* This part must be outside protection */
126 #include <trace/define_trace.h>