#undef TRACE_SYSTEM1#define TRACE_SYSTEM signal23#if !defined(_TRACE_SIGNAL_H) || defined(TRACE_HEADER_MULTI_READ)4#define _TRACE_SIGNAL_H56#include <linux/signal.h>7#include <linux/sched.h>8#include <linux/tracepoint.h>910#define TP_STORE_SIGINFO(__entry, info) \11do { \12if (info == SEND_SIG_NOINFO || \13info == SEND_SIG_FORCED) { \14__entry->errno = 0; \15__entry->code = SI_USER; \16} else if (info == SEND_SIG_PRIV) { \17__entry->errno = 0; \18__entry->code = SI_KERNEL; \19} else { \20__entry->errno = info->si_errno; \21__entry->code = info->si_code; \22} \23} while (0)2425/**26* signal_generate - called when a signal is generated27* @sig: signal number28* @info: pointer to struct siginfo29* @task: pointer to struct task_struct30*31* Current process sends a 'sig' signal to 'task' process with32* 'info' siginfo. If 'info' is SEND_SIG_NOINFO or SEND_SIG_PRIV,33* 'info' is not a pointer and you can't access its field. Instead,34* SEND_SIG_NOINFO means that si_code is SI_USER, and SEND_SIG_PRIV35* means that si_code is SI_KERNEL.36*/37TRACE_EVENT(signal_generate,3839TP_PROTO(int sig, struct siginfo *info, struct task_struct *task),4041TP_ARGS(sig, info, task),4243TP_STRUCT__entry(44__field( int, sig )45__field( int, errno )46__field( int, code )47__array( char, comm, TASK_COMM_LEN )48__field( pid_t, pid )49),5051TP_fast_assign(52__entry->sig = sig;53TP_STORE_SIGINFO(__entry, info);54memcpy(__entry->comm, task->comm, TASK_COMM_LEN);55__entry->pid = task->pid;56),5758TP_printk("sig=%d errno=%d code=%d comm=%s pid=%d",59__entry->sig, __entry->errno, __entry->code,60__entry->comm, __entry->pid)61);6263/**64* signal_deliver - called when a signal is delivered65* @sig: signal number66* @info: pointer to struct siginfo67* @ka: pointer to struct k_sigaction68*69* A 'sig' signal is delivered to current process with 'info' siginfo,70* and it will be handled by 'ka'. ka->sa.sa_handler can be SIG_IGN or71* SIG_DFL.72* Note that some signals reported by signal_generate tracepoint can be73* lost, ignored or modified (by debugger) before hitting this tracepoint.74* This means, this can show which signals are actually delivered, but75* matching generated signals and delivered signals may not be correct.76*/77TRACE_EVENT(signal_deliver,7879TP_PROTO(int sig, struct siginfo *info, struct k_sigaction *ka),8081TP_ARGS(sig, info, ka),8283TP_STRUCT__entry(84__field( int, sig )85__field( int, errno )86__field( int, code )87__field( unsigned long, sa_handler )88__field( unsigned long, sa_flags )89),9091TP_fast_assign(92__entry->sig = sig;93TP_STORE_SIGINFO(__entry, info);94__entry->sa_handler = (unsigned long)ka->sa.sa_handler;95__entry->sa_flags = ka->sa.sa_flags;96),9798TP_printk("sig=%d errno=%d code=%d sa_handler=%lx sa_flags=%lx",99__entry->sig, __entry->errno, __entry->code,100__entry->sa_handler, __entry->sa_flags)101);102103DECLARE_EVENT_CLASS(signal_queue_overflow,104105TP_PROTO(int sig, int group, struct siginfo *info),106107TP_ARGS(sig, group, info),108109TP_STRUCT__entry(110__field( int, sig )111__field( int, group )112__field( int, errno )113__field( int, code )114),115116TP_fast_assign(117__entry->sig = sig;118__entry->group = group;119TP_STORE_SIGINFO(__entry, info);120),121122TP_printk("sig=%d group=%d errno=%d code=%d",123__entry->sig, __entry->group, __entry->errno, __entry->code)124);125126/**127* signal_overflow_fail - called when signal queue is overflow128* @sig: signal number129* @group: signal to process group or not (bool)130* @info: pointer to struct siginfo131*132* Kernel fails to generate 'sig' signal with 'info' siginfo, because133* siginfo queue is overflow, and the signal is dropped.134* 'group' is not 0 if the signal will be sent to a process group.135* 'sig' is always one of RT signals.136*/137DEFINE_EVENT(signal_queue_overflow, signal_overflow_fail,138139TP_PROTO(int sig, int group, struct siginfo *info),140141TP_ARGS(sig, group, info)142);143144/**145* signal_lose_info - called when siginfo is lost146* @sig: signal number147* @group: signal to process group or not (bool)148* @info: pointer to struct siginfo149*150* Kernel generates 'sig' signal but loses 'info' siginfo, because siginfo151* queue is overflow.152* 'group' is not 0 if the signal will be sent to a process group.153* 'sig' is always one of non-RT signals.154*/155DEFINE_EVENT(signal_queue_overflow, signal_lose_info,156157TP_PROTO(int sig, int group, struct siginfo *info),158159TP_ARGS(sig, group, info)160);161162#endif /* _TRACE_SIGNAL_H */163164/* This part must be outside protection */165#include <trace/define_trace.h>166167168