Commit | Line | Data |
---|---|---|
0ec73ddc MD |
1 | #undef TRACE_SYSTEM |
2 | #define TRACE_SYSTEM signal | |
3 | ||
3bc29f0a MD |
4 | #if !defined(LTTNG_TRACE_SIGNAL_H) || defined(TRACE_HEADER_MULTI_READ) |
5 | #define LTTNG_TRACE_SIGNAL_H | |
0ec73ddc | 6 | |
6ec43db8 | 7 | #include <probes/lttng-tracepoint-event.h> |
6bd5e64e | 8 | #include <linux/version.h> |
0ec73ddc MD |
9 | |
10 | #ifndef _TRACE_SIGNAL_DEF | |
11 | #define _TRACE_SIGNAL_DEF | |
12 | #include <linux/signal.h> | |
13 | #include <linux/sched.h> | |
f127e61e MD |
14 | #undef LTTNG_FIELDS_SIGINFO |
15 | #define LTTNG_FIELDS_SIGINFO(info) \ | |
16 | ctf_integer(int, errno, \ | |
0ec73ddc MD |
17 | (info == SEND_SIG_NOINFO || info == SEND_SIG_FORCED || info == SEND_SIG_PRIV) ? \ |
18 | 0 : \ | |
19 | info->si_errno) \ | |
f127e61e | 20 | ctf_integer(int, code, \ |
0ec73ddc MD |
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 | */ | |
6bd5e64e | 38 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
3bc29f0a | 39 | LTTNG_TRACEPOINT_EVENT(signal_generate, |
0ec73ddc MD |
40 | |
41 | TP_PROTO(int sig, struct siginfo *info, struct task_struct *task), | |
42 | ||
43 | TP_ARGS(sig, info, task), | |
44 | ||
f127e61e MD |
45 | TP_FIELDS( |
46 | ctf_integer(int, sig, sig) | |
47 | LTTNG_FIELDS_SIGINFO(info) | |
48 | ctf_array_text(char, comm, task->comm, TASK_COMM_LEN) | |
49 | ctf_integer(pid_t, pid, task->pid) | |
50 | ) | |
0ec73ddc | 51 | ) |
6bd5e64e | 52 | #else |
3bc29f0a | 53 | LTTNG_TRACEPOINT_EVENT(signal_generate, |
6bd5e64e MD |
54 | |
55 | TP_PROTO(int sig, struct siginfo *info, struct task_struct *task, | |
56 | int group, int result), | |
57 | ||
58 | TP_ARGS(sig, info, task, group, result), | |
59 | ||
f127e61e MD |
60 | TP_FIELDS( |
61 | ctf_integer(int, sig, sig) | |
62 | LTTNG_FIELDS_SIGINFO(info) | |
63 | ctf_array_text(char, comm, task->comm, TASK_COMM_LEN) | |
64 | ctf_integer(pid_t, pid, task->pid) | |
65 | ctf_integer(int, group, group) | |
66 | ctf_integer(int, result, result) | |
67 | ) | |
6bd5e64e MD |
68 | ) |
69 | #endif | |
0ec73ddc MD |
70 | |
71 | /** | |
72 | * signal_deliver - called when a signal is delivered | |
73 | * @sig: signal number | |
74 | * @info: pointer to struct siginfo | |
75 | * @ka: pointer to struct k_sigaction | |
76 | * | |
77 | * A 'sig' signal is delivered to current process with 'info' siginfo, | |
78 | * and it will be handled by 'ka'. ka->sa.sa_handler can be SIG_IGN or | |
79 | * SIG_DFL. | |
80 | * Note that some signals reported by signal_generate tracepoint can be | |
81 | * lost, ignored or modified (by debugger) before hitting this tracepoint. | |
82 | * This means, this can show which signals are actually delivered, but | |
83 | * matching generated signals and delivered signals may not be correct. | |
84 | */ | |
3bc29f0a | 85 | LTTNG_TRACEPOINT_EVENT(signal_deliver, |
0ec73ddc MD |
86 | |
87 | TP_PROTO(int sig, struct siginfo *info, struct k_sigaction *ka), | |
88 | ||
89 | TP_ARGS(sig, info, ka), | |
90 | ||
f127e61e MD |
91 | TP_FIELDS( |
92 | ctf_integer(int, sig, sig) | |
93 | LTTNG_FIELDS_SIGINFO(info) | |
94 | ctf_integer(unsigned long, sa_handler, (unsigned long) ka->sa.sa_handler) | |
95 | ctf_integer(unsigned long, sa_flags, ka->sa.sa_flags) | |
96 | ) | |
0ec73ddc MD |
97 | ) |
98 | ||
7c68b363 | 99 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) |
3bc29f0a | 100 | LTTNG_TRACEPOINT_EVENT_CLASS(signal_queue_overflow, |
0ec73ddc MD |
101 | |
102 | TP_PROTO(int sig, int group, struct siginfo *info), | |
103 | ||
104 | TP_ARGS(sig, group, info), | |
105 | ||
f127e61e MD |
106 | TP_FIELDS( |
107 | ctf_integer(int, sig, sig) | |
108 | ctf_integer(int, group, group) | |
109 | LTTNG_FIELDS_SIGINFO(info) | |
110 | ) | |
0ec73ddc MD |
111 | ) |
112 | ||
113 | /** | |
114 | * signal_overflow_fail - called when signal queue is overflow | |
115 | * @sig: signal number | |
116 | * @group: signal to process group or not (bool) | |
117 | * @info: pointer to struct siginfo | |
118 | * | |
119 | * Kernel fails to generate 'sig' signal with 'info' siginfo, because | |
120 | * siginfo queue is overflow, and the signal is dropped. | |
121 | * 'group' is not 0 if the signal will be sent to a process group. | |
122 | * 'sig' is always one of RT signals. | |
123 | */ | |
3bc29f0a | 124 | LTTNG_TRACEPOINT_EVENT_INSTANCE(signal_queue_overflow, signal_overflow_fail, |
0ec73ddc MD |
125 | |
126 | TP_PROTO(int sig, int group, struct siginfo *info), | |
127 | ||
128 | TP_ARGS(sig, group, info) | |
129 | ) | |
130 | ||
131 | /** | |
132 | * signal_lose_info - called when siginfo is lost | |
133 | * @sig: signal number | |
134 | * @group: signal to process group or not (bool) | |
135 | * @info: pointer to struct siginfo | |
136 | * | |
137 | * Kernel generates 'sig' signal but loses 'info' siginfo, because siginfo | |
138 | * queue is overflow. | |
139 | * 'group' is not 0 if the signal will be sent to a process group. | |
140 | * 'sig' is always one of non-RT signals. | |
141 | */ | |
3bc29f0a | 142 | LTTNG_TRACEPOINT_EVENT_INSTANCE(signal_queue_overflow, signal_lose_info, |
0ec73ddc MD |
143 | |
144 | TP_PROTO(int sig, int group, struct siginfo *info), | |
145 | ||
146 | TP_ARGS(sig, group, info) | |
147 | ) | |
7c68b363 | 148 | #endif |
0ec73ddc | 149 | |
3bc29f0a | 150 | #endif /* LTTNG_TRACE_SIGNAL_H */ |
0ec73ddc MD |
151 | |
152 | /* This part must be outside protection */ | |
6ec43db8 | 153 | #include <probes/define_trace.h> |