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