| 1 | #undef TRACE_SYSTEM |
| 2 | #define TRACE_SYSTEM signal |
| 3 | |
| 4 | #if !defined(LTTNG_TRACE_SIGNAL_H) || defined(TRACE_HEADER_MULTI_READ) |
| 5 | #define LTTNG_TRACE_SIGNAL_H |
| 6 | |
| 7 | #include "../../../probes/lttng-tracepoint-event.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 | LTTNG_TRACEPOINT_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_text( 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 | LTTNG_TRACEPOINT_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_text( 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 | LTTNG_TRACEPOINT_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 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
| 139 | LTTNG_TRACEPOINT_EVENT_CLASS(signal_queue_overflow, |
| 140 | |
| 141 | TP_PROTO(int sig, int group, struct siginfo *info), |
| 142 | |
| 143 | TP_ARGS(sig, group, info), |
| 144 | |
| 145 | TP_STRUCT__entry( |
| 146 | __field( int, sig ) |
| 147 | __field( int, group ) |
| 148 | __field( int, errno ) |
| 149 | __field( int, code ) |
| 150 | ), |
| 151 | |
| 152 | TP_fast_assign( |
| 153 | tp_assign(sig, sig) |
| 154 | tp_assign(group, group) |
| 155 | TP_STORE_SIGINFO(info) |
| 156 | ), |
| 157 | |
| 158 | TP_printk("sig=%d group=%d errno=%d code=%d", |
| 159 | __entry->sig, __entry->group, __entry->errno, __entry->code) |
| 160 | ) |
| 161 | |
| 162 | /** |
| 163 | * signal_overflow_fail - called when signal queue is overflow |
| 164 | * @sig: signal number |
| 165 | * @group: signal to process group or not (bool) |
| 166 | * @info: pointer to struct siginfo |
| 167 | * |
| 168 | * Kernel fails to generate 'sig' signal with 'info' siginfo, because |
| 169 | * siginfo queue is overflow, and the signal is dropped. |
| 170 | * 'group' is not 0 if the signal will be sent to a process group. |
| 171 | * 'sig' is always one of RT signals. |
| 172 | */ |
| 173 | LTTNG_TRACEPOINT_EVENT_INSTANCE(signal_queue_overflow, signal_overflow_fail, |
| 174 | |
| 175 | TP_PROTO(int sig, int group, struct siginfo *info), |
| 176 | |
| 177 | TP_ARGS(sig, group, info) |
| 178 | ) |
| 179 | |
| 180 | /** |
| 181 | * signal_lose_info - called when siginfo is lost |
| 182 | * @sig: signal number |
| 183 | * @group: signal to process group or not (bool) |
| 184 | * @info: pointer to struct siginfo |
| 185 | * |
| 186 | * Kernel generates 'sig' signal but loses 'info' siginfo, because siginfo |
| 187 | * queue is overflow. |
| 188 | * 'group' is not 0 if the signal will be sent to a process group. |
| 189 | * 'sig' is always one of non-RT signals. |
| 190 | */ |
| 191 | LTTNG_TRACEPOINT_EVENT_INSTANCE(signal_queue_overflow, signal_lose_info, |
| 192 | |
| 193 | TP_PROTO(int sig, int group, struct siginfo *info), |
| 194 | |
| 195 | TP_ARGS(sig, group, info) |
| 196 | ) |
| 197 | #endif |
| 198 | |
| 199 | #endif /* LTTNG_TRACE_SIGNAL_H */ |
| 200 | |
| 201 | /* This part must be outside protection */ |
| 202 | #include "../../../probes/define_trace.h" |