LTTNG-ENABLE-EVENT(1) | LTTng Manual | LTTNG-ENABLE-EVENT(1) |
lttng-enable-event - Create or enable LTTng event rules
Create or enable Linux kernel event rules:
lttng [GENERAL OPTIONS] enable-event --kernel
[--probe=SOURCE | --function=SOURCE | --syscall |
--userspace-probe=SOURCE]
[--filter=EXPR] [--session=SESSION]
[--channel=CHANNEL] EVENT[,EVENT]...
Create or enable an "all" Linux kernel event rule:
lttng [GENERAL OPTIONS] enable-event --kernel --all [--syscall]
[--filter=EXPR] [--session=SESSION] [--channel=CHANNEL]
Create or enable application/library event rules:
lttng [GENERAL OPTIONS] enable-event
(--userspace | --jul | --log4j | --python)
[--filter=EXPR] [--exclude=EVENT[,EVENT]...]
[--loglevel=LOGLEVEL | --loglevel-only=LOGLEVEL]
[--session=SESSION] [--channel=CHANNEL] (--all | EVENT[,EVENT]...)
The lttng enable-event command can create a new event rule, or enable one or more existing and disabled ones.
An event rule created by lttng enable-event is a set of conditions that must be satisfied in order for an actual event to be emitted by an LTTng tracer when the execution of an application or a library or the Linux kernel reaches an event source (tracepoint, system call, dynamic probe). Event sources can be listed with the lttng-list(1) command.
The lttng-disable-event(1) command can be used to disable existing event rules.
Event rules are always assigned to a channel when they are created. If the --channel option is omitted, a default channel named channel0 is used (and created automatically if it does not exist for the specified domain in the selected tracing session).
If the --session option is omitted, the chosen channel is picked from the current tracing session.
Events can be enabled while tracing is active (use lttng-start(1) to make a tracing session active).
Five types of event sources are available in the Linux kernel tracing domain (--kernel option):
Tracepoint (--tracepoint option; default)
Dynamic kernel probe (--probe option)
Dynamic user space probe (--userspace-probe option)
See the Dynamic user space probes section for more information.
Function probe (--function option)
System call (--syscall option)
The application tracing domains (--userspace, --jul, --log4j, or --python options) only support tracepoints. In the cases of the JUL, Apache log4j, and Python domains, the event names correspond to logger names.
When creating an event rule with lttng enable-event, conditions are specified using options. The logical conjunction (logical AND) of all those conditions must be true when an event source is reached by an application or by the Linux kernel in order for an actual event to be emitted by an LTTng tracer.
Any condition that is not explicitly specified on creation is considered a don’t care.
For example, consider the following commands:
$ lttng enable-event --userspace hello:world $ lttng enable-event --userspace hello:world --loglevel=TRACE_INFO
Here, two event rules are created. The first one has a single condition: the tracepoint name must match hello:world. The second one has two conditions:
In this case, the second event rule is pointless because the first one is more general: it does not care about the tracepoint’s log level. If an event source matching both event rules is reached by the application’s execution, only one event is emitted.
The available conditions for the Linux kernel domain are:
You can use * characters at any place in the tracepoint or system call name as wildcards to match zero or more characters. To use a literal * character, use \*.
The available conditions for the application domains are:
You can use * characters at any place in the tracepoint name as wildcards to match zero or more characters. To use a literal * character, use \*. When you create an event rule with a tracepoint name containing a wildcard, you can exclude specific tracepoint names from the match with the --exclude option.
When using lttng enable-event with a set of conditions that does not currently exist for the chosen tracing session, domain, and channel, a new event rule is created. Otherwise, the existing event rule is enabled if it is currently disabled (see lttng-disable-event(1)).
The --all option can be used alongside the --tracepoint or --syscall options. When this option is used, no EVENT argument must be specified. This option defines a single event rule matching all the possible events of a given tracing domain for the chosen channel and tracing session. It is the equivalent of an EVENT argument named * (wildcard).
A filter expression can be specified with the --filter option when creating a new event rule. If the filter expression evaluates to true when executed against the dynamic values of an event’s fields when tracing, the filtering condition passes.
Make sure to single-quote the filter expression when running the command from a shell, as filter expressions typically include characters having a special meaning for most shells.
The filter expression syntax is similar to C language conditional expressions (expressions that can be evaluated by an if statement), albeit with a few differences:
Examples: 32, -0x17, 0755, 12.34, "a \"literal string\"", "src/*/*.h".
The dot and square bracket notations are available, like in the C language, to access nested structure and array/sequence fields. Only a constant, positive integer number can be used within square brackets. If the index is out of bounds, the whole filter expression evaluates to false (the event is discarded).
An enumeration field’s value is an integer.
When the expression’s field does not exist, the whole filter expression evaluates to false.
Examples: my_field, target_cpu, seq[7], msg.user[1].data[2][17].
When the expression’s statically-known context field does not exist, the whole filter expression evaluates to false.
Examples: $ctx.prio, $ctx.preemptible, $ctx.perf:cpu:stalled-cycles-frontend.
When the expression’s application-specific context field does not exist, the whole filter expression evaluates to false.
Example: $app.server:cur_user.
The following precedence table shows the operators which are supported in a filter expression. In this table, the highest precedence is 1. Parentheses are supported to bypass the default order.
Unlike the C language, the lttng enable-event filter expression syntax’s bitwise AND and OR operators (& and |) take precedence over relational operators (<, <=, >, >=, ==, and !=). This means the filter expression 2 & 2 == 2 is true while the equivalent C expression is false.
Precedence | Operator | Description | Associativity |
1 | - | Unary minus | Right-to-left |
1 | + | Unary plus | Right-to-left |
1 | ! | Logical NOT | Right-to-left |
1 | ~ | Bitwise NOT | Right-to-left |
2 | << | Bitwise left shift | Left-to-right |
2 | >> | Bitwise right shift | Left-to-right |
3 | & | Bitwise AND | Left-to-right |
4 | ^ | Bitwise XOR | Left-to-right |
5 | | | Bitwise OR | Left-to-right |
6 | < | Less than | Left-to-right |
6 | <= | Less than or equal to | Left-to-right |
6 | > | Greater than | Left-to-right |
6 | >= | Greater than or equal to | Left-to-right |
7 | == | Equal to | Left-to-right |
7 | != | Not equal to | Left-to-right |
8 | && | Logical AND | Left-to-right |
9 | || | Logical OR | Left-to-right |
The arithmetic operators are NOT supported.
All integer constants and fields are first casted to signed 64-bit integers. The representation of negative integers is two’s complement. This means that, for example, the signed 8-bit integer field 0xff (-1) becomes 0xffffffffffffffff (still -1) once casted.
Before a bitwise operator is applied, all its operands are casted to unsigned 64-bit integers, and the result is casted back to a signed 64-bit integer. For the bitwise NOT operator, it is the equivalent of this C expression:
(int64_t) ~((uint64_t) val)
For the binary bitwise operators, it is the equivalent of those C expressions:
(int64_t) ((uint64_t) lhs >> (uint64_t) rhs) (int64_t) ((uint64_t) lhs << (uint64_t) rhs) (int64_t) ((uint64_t) lhs & (uint64_t) rhs) (int64_t) ((uint64_t) lhs ^ (uint64_t) rhs) (int64_t) ((uint64_t) lhs | (uint64_t) rhs)
If the right-hand side of a bitwise shift operator (<< and >>) is not in the [0, 63] range, the whole filter expression evaluates to false.
Although it is possible to filter the process ID of an event when the pid context has been added to its channel using, for example, $ctx.pid == 2832, it is recommended to use the PID tracker instead, which is much more efficient (see lttng-track(1)).
Filter expression examples:
msg_id == 23 && size >= 2048
$ctx.procname == "lttng*" && (!flag || poel < 34)
$app.my_provider:my_context == 17.34e9 || some_enum >= 14
$ctx.cpu_id == 2 && filename != "*.log"
eax_reg & 0xff7 == 0x240 && x[4] >> 12 <= 0x1234
Tracepoints and log statements in applications have an attached log level. Application event rules can contain a log level condition.
With the --loglevel option, the event source’s log level must be at least as severe as the option’s argument. With the --loglevel-only option, the event source’s log level must match the option’s argument.
The available log levels are:
User space domain (--userspace option)
java.util.logging domain (--jul option)
Apache log4j domain (--log4j option)
Python domain (--python option)
With the --userspace-probe option, you can instrument function entries of any user space binary (application or library) using either an available symbol name or a SystemTap User-level Statically Defined Tracing (USDT, a DTrace-style marker) probe’s provider and probe names. As of this version, only USDT probes that are NOT surrounded by a reference counter (semaphore) are supported.
The --userspace-probe option must be specified with the --kernel option because it uses Linux’s uprobe feature to dynamically instrument a user space application or library.
As of this version, dynamic probe events do not record any payload field.
General options are described in lttng(1).
One of:
-j, --jul
-k, --kernel
-l, --log4j
-p, --python
-u, --userspace
-c CHANNEL, --channel=CHANNEL
-s SESSION, --session=SESSION
One of:
--function=SOURCE
--probe=SOURCE
--userspace-probe=SOURCE
SOURCE is one of:
[elf:]PATH:SYMBOL
PATH
This can be:
SYMBOL
This can be any defined code symbol listed by the nm(1) command (including with its --dynamic option which lists dynamic symbols).
As of this version, not specifying elf: is equivalent to specifying it.
Examples:
sdt:PATH:PROVIDER:NAME
PATH
This can be:
PROVIDER:NAME
For example, with the following USDT probe:
DTRACE_PROBE2("server", "accept_request",
request_id, ip_addr);
The provider/probe name pair is server:accept_request.
Example:
--syscall
--tracepoint
One of:
--loglevel=LOGLEVEL
--loglevel-only=LOGLEVEL
-x EVENT[,EVENT]..., --exclude=EVENT[,EVENT]...
-f EXPR, --filter=EXPR
-a, --all
-h, --help
This option, like lttng-help(1), attempts to launch /usr/bin/man to view the command’s man page. The path to the man pager can be overridden by the LTTNG_MAN_BIN_PATH environment variable.
--list-options
LTTNG_ABORT_ON_ERROR
LTTNG_HOME
LTTNG_MAN_BIN_PATH
LTTNG_SESSION_CONFIG_XSD_PATH
LTTNG_SESSIOND_PATH
The --sessiond-path option has precedence over this environment variable.
Note that the lttng-create(1) command can spawn an LTTng session daemon automatically if none is running. See lttng-sessiond(8) for the environment variables influencing the execution of the session daemon.
$LTTNG_HOME/.lttngrc
This is where the per-user current tracing session is stored between executions of lttng(1). The current tracing session can be set with lttng-set-session(1). See lttng-create(1) for more information about tracing sessions.
$LTTNG_HOME/lttng-traces
$LTTNG_HOME/.lttng
$LTTNG_HOME/.lttng/sessions
/etc/lttng/sessions
$LTTNG_HOME defaults to $HOME when not explicitly set.
0
1
2
3
4
If you encounter any issue or usability problem, please report it on the LTTng bug tracker <https://bugs.lttng.org/projects/lttng-tools>.
This program is part of the LTTng-tools project.
LTTng-tools is distributed under the GNU General Public License version 2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html>. See the LICENSE <https://github.com/lttng/lttng-tools/blob/master/LICENSE> file for details.
Special thanks to Michel Dagenais and the DORSAL laboratory <http://www.dorsal.polymtl.ca/> at École Polytechnique de Montréal for the LTTng journey.
Also thanks to the Ericsson teams working on tracing which helped us greatly with detailed bug reports and unusual test cases.
4 April 2019 | LTTng 2.12.3 |