Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #undef TRACE_SYSTEM
0003 #define TRACE_SYSTEM signal
0004 
0005 #if !defined(_TRACE_SIGNAL_H) || defined(TRACE_HEADER_MULTI_READ)
0006 #define _TRACE_SIGNAL_H
0007 
0008 #include <linux/signal.h>
0009 #include <linux/sched.h>
0010 #include <linux/tracepoint.h>
0011 
0012 #define TP_STORE_SIGINFO(__entry, info)             \
0013     do {                            \
0014         if (info == SEND_SIG_NOINFO) {          \
0015             __entry->errno  = 0;            \
0016             __entry->code   = SI_USER;      \
0017         } else if (info == SEND_SIG_PRIV) {     \
0018             __entry->errno  = 0;            \
0019             __entry->code   = SI_KERNEL;        \
0020         } else {                    \
0021             __entry->errno  = info->si_errno;   \
0022             __entry->code   = info->si_code;    \
0023         }                       \
0024     } while (0)
0025 
0026 #ifndef TRACE_HEADER_MULTI_READ
0027 enum {
0028     TRACE_SIGNAL_DELIVERED,
0029     TRACE_SIGNAL_IGNORED,
0030     TRACE_SIGNAL_ALREADY_PENDING,
0031     TRACE_SIGNAL_OVERFLOW_FAIL,
0032     TRACE_SIGNAL_LOSE_INFO,
0033 };
0034 #endif
0035 
0036 /**
0037  * signal_generate - called when a signal is generated
0038  * @sig: signal number
0039  * @info: pointer to struct siginfo
0040  * @task: pointer to struct task_struct
0041  * @group: shared or private
0042  * @result: TRACE_SIGNAL_*
0043  *
0044  * Current process sends a 'sig' signal to 'task' process with
0045  * 'info' siginfo. If 'info' is SEND_SIG_NOINFO or SEND_SIG_PRIV,
0046  * 'info' is not a pointer and you can't access its field. Instead,
0047  * SEND_SIG_NOINFO means that si_code is SI_USER, and SEND_SIG_PRIV
0048  * means that si_code is SI_KERNEL.
0049  */
0050 TRACE_EVENT(signal_generate,
0051 
0052     TP_PROTO(int sig, struct kernel_siginfo *info, struct task_struct *task,
0053             int group, int result),
0054 
0055     TP_ARGS(sig, info, task, group, result),
0056 
0057     TP_STRUCT__entry(
0058         __field(    int,    sig         )
0059         __field(    int,    errno           )
0060         __field(    int,    code            )
0061         __array(    char,   comm,   TASK_COMM_LEN   )
0062         __field(    pid_t,  pid         )
0063         __field(    int,    group           )
0064         __field(    int,    result          )
0065     ),
0066 
0067     TP_fast_assign(
0068         __entry->sig    = sig;
0069         TP_STORE_SIGINFO(__entry, info);
0070         memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
0071         __entry->pid    = task->pid;
0072         __entry->group  = group;
0073         __entry->result = result;
0074     ),
0075 
0076     TP_printk("sig=%d errno=%d code=%d comm=%s pid=%d grp=%d res=%d",
0077           __entry->sig, __entry->errno, __entry->code,
0078           __entry->comm, __entry->pid, __entry->group,
0079           __entry->result)
0080 );
0081 
0082 /**
0083  * signal_deliver - called when a signal is delivered
0084  * @sig: signal number
0085  * @info: pointer to struct siginfo
0086  * @ka: pointer to struct k_sigaction
0087  *
0088  * A 'sig' signal is delivered to current process with 'info' siginfo,
0089  * and it will be handled by 'ka'. ka->sa.sa_handler can be SIG_IGN or
0090  * SIG_DFL.
0091  * Note that some signals reported by signal_generate tracepoint can be
0092  * lost, ignored or modified (by debugger) before hitting this tracepoint.
0093  * This means, this can show which signals are actually delivered, but
0094  * matching generated signals and delivered signals may not be correct.
0095  */
0096 TRACE_EVENT(signal_deliver,
0097 
0098     TP_PROTO(int sig, struct kernel_siginfo *info, struct k_sigaction *ka),
0099 
0100     TP_ARGS(sig, info, ka),
0101 
0102     TP_STRUCT__entry(
0103         __field(    int,        sig     )
0104         __field(    int,        errno       )
0105         __field(    int,        code        )
0106         __field(    unsigned long,  sa_handler  )
0107         __field(    unsigned long,  sa_flags    )
0108     ),
0109 
0110     TP_fast_assign(
0111         __entry->sig    = sig;
0112         TP_STORE_SIGINFO(__entry, info);
0113         __entry->sa_handler = (unsigned long)ka->sa.sa_handler;
0114         __entry->sa_flags   = ka->sa.sa_flags;
0115     ),
0116 
0117     TP_printk("sig=%d errno=%d code=%d sa_handler=%lx sa_flags=%lx",
0118           __entry->sig, __entry->errno, __entry->code,
0119           __entry->sa_handler, __entry->sa_flags)
0120 );
0121 
0122 #endif /* _TRACE_SIGNAL_H */
0123 
0124 /* This part must be outside protection */
0125 #include <trace/define_trace.h>