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