Remove "etc."
[lttng-docs.git] / contents / using-lttng / controlling-tracing / enabling-disabling-events.md
CommitLineData
5e0cbfb0
PP
1---
2id: enabling-disabling-events
3---
4
5Inside a tracing session, individual events may be enabled or disabled
6so that tracing them may or may not generate trace data.
7
8We sometimes use the term _event_ metonymically throughout this text to
9refer to a specific condition, or _rule_, that could lead, when
10satisfied, to an actual occurring event (a point at a specific position
11in source code/binary program, logical processor and time capturing
12some payload) being recorded as trace data. This specific condition is
13composed of:
14
f11aa623 15 1. A **domain** (kernel, user space, `java.util.logging`, or log4j)
c23b8cb1 16 (required).
5e0cbfb0
PP
17 2. One or many **instrumentation points** in source code or binary
18 program (tracepoint name, address, symbol name, function name,
ba3b1994 19 logger name, amongst other types of probes) to be executed (required).
5e0cbfb0
PP
20 3. A **log level** (each instrumentation point declares its own log
21 level) or log level range to match (optional; only valid for user
22 space domain).
23 4. A **custom user expression**, or **filter**, that must evaluate to
24 _true_ when a tracepoint is executed (optional; only valid for user
25 space domain).
26
27All conditions are specified using arguments passed to the
28`enable-event` command of the `lttng` tool.
29
c23b8cb1
PP
30Condition 1 is specified using either `--kernel`/`-k` (kernel),
31`--userspace`/`-u` (user space), `--jul`/`-j`
32(<abbr title="java.util.logging">JUL</abbr>), or `--log4j`/`-l` (log4j).
33Exactly one of those four arguments must be specified.
5e0cbfb0
PP
34
35Condition 2 is specified using one of:
36
37 * `--tracepoint`: **tracepoint**
38 * `--probe`: **dynamic probe** (address, symbol name or combination
39 of both in binary program; only valid for kernel domain)
40 * `--function`: **function entry/exit** (address, symbol name or
41 combination of both in binary program; only valid for kernel domain)
42 * `--syscall`: **system call entry/exit** (only valid for kernel
43 domain)
44
45When none of the above is specified, `enable-event` defaults to
46using `--tracepoint`.
47
48Condition 3 is specified using one of:
49
50 * `--loglevel`: log level range from 0 to a specific log level
51 * `--loglevel-only`: specific log level
52
53See `lttng enable-event --help` for the complete list of log level
54names.
55
56Condition 4 is specified using the `--filter` option. This filter is
57a C-like expression, potentially reading real-time values of event
58fields, that has to evaluate to _true_ for the condition to be satisfied.
59Event fields are read using plain identifiers while context fields
60must be prefixed with `$ctx.`. See `lttng enable-event --help` for
61all usage details.
62
63The aforementioned arguments are combined to create and enable events.
64Each unique combination of arguments leads to a different
65_enabled event_. The log level and filter arguments are optional, their
66default values being respectively all log levels and a filter which
67always returns _true_.
68
69Here are a few examples (you must
70[create a tracing session](#doc-creating-destroying-tracing-sessions)
71first):
72
73<pre class="term">
74lttng enable-event -u --tracepoint my_app:hello_world
75lttng enable-event -u --tracepoint my_app:hello_you --loglevel TRACE_WARNING
76lttng enable-event -u --tracepoint 'my_other_app:*'
77lttng enable-event -u --tracepoint my_app:foo_bar \
78 --filter 'some_field <= 23 && !other_field'
79lttng enable-event -k --tracepoint sched_switch
80lttng enable-event -k --tracepoint gpio_value
81lttng enable-event -k --function usb_probe_device usb_probe_device
82lttng enable-event -k --syscall --all
83</pre>
84
85The wildcard symbol, `*`, matches _anything_ and may only be used at
86the end of the string when specifying a _tracepoint_. Make sure to
87use it between single quotes in your favorite shell to avoid
88undesired shell expansion.
89
c23b8cb1
PP
90System call events can be enabled individually, too:
91
92<pre class="term">
93lttng enable-event -k --syscall open
94lttng enable-event -k --syscall read
95lttng enable-event -k --syscall fork,chdir,pipe
96</pre>
97
98The complete list of available system call events can be
99obtained using
100
101<pre class="term">
102lttng list --kernel --syscall
103</pre>
104
5e0cbfb0
PP
105You can see a list of events (enabled or disabled) using
106
107<pre class="term">
108lttng list some-session
109</pre>
110
111where `some-session` is the name of the desired tracing session.
112
113What you're actually doing when enabling events with specific conditions
114is creating a **whitelist** of traceable events for a given channel.
115Thus, the following case presents redundancy:
116
117<pre class="term">
118lttng enable-event -u --tracepoint my_app:hello_you
119lttng enable-event -u --tracepoint my_app:hello_you --loglevel TRACE_DEBUG
120</pre>
121
122The second command, matching a log level range, is useless since the first
123command enables all tracepoints matching the same name,
124`my_app:hello_you`.
125
126Disabling an event is simpler: you only need to provide the event
127name to the `disable-event` command:
128
129<pre class="term">
b80ba306 130lttng disable-event --userspace my_app:hello_you
5e0cbfb0
PP
131</pre>
132
133This name has to match a name previously given to `enable-event` (it
134has to be listed in the output of `lttng list some-session`).
135The `*` wildcard is supported, as long as you also used it in a
136previous `enable-event` invocation.
137
138Disabling an event does not add it to some blacklist: it simply removes
139it from its channel's whitelist. This is why you cannot disable an event
140which wasn't previously enabled.
141
47bfcb75 142A disabled event doesn't generate any trace data, even if all its
5e0cbfb0
PP
143specified conditions are met.
144
145Events may be enabled and disabled at will, either when LTTng tracers
146are active or not. Events may be enabled before a user space application
147is even started.
This page took 0.02843 seconds and 4 git commands to generate.