1 The LTTng Documentation
2 =======================
3 Philippe Proulx <pproulx@efficios.com>
7 include::../common/copyright.txt[]
10 include::../common/welcome.txt[]
13 include::../common/audience.txt[]
17 === What's in this documentation?
19 The LTTng Documentation is divided into the following sections:
21 * **<<nuts-and-bolts,Nuts and bolts>>** explains the
22 rudiments of software tracing and the rationale behind the
25 You can skip this section if you’re familiar with software tracing and
26 with the LTTng project.
28 * **<<installing-lttng,Installation>>** describes the steps to
29 install the LTTng packages on common Linux distributions and from
32 You can skip this section if you already properly installed LTTng on
35 * **<<getting-started,Quick start>>** is a concise guide to
36 getting started quickly with LTTng kernel and user space tracing.
38 We recommend this section if you're new to LTTng or to software tracing
41 You can skip this section if you're not new to LTTng.
43 * **<<core-concepts,Core concepts>>** explains the concepts at
46 It's a good idea to become familiar with the core concepts
47 before attempting to use the toolkit.
49 * **<<plumbing,Components of LTTng>>** describes the various components
50 of the LTTng machinery, like the daemons, the libraries, and the
51 command-line interface.
52 * **<<instrumenting,Instrumentation>>** shows different ways to
53 instrument user applications and the Linux kernel.
55 Instrumenting source code is essential to provide a meaningful
58 You can skip this section if you do not have a programming background.
60 * **<<controlling-tracing,Tracing control>>** is divided into topics
61 which demonstrate how to use the vast array of features that
62 LTTng{nbsp}{revision} offers.
63 * **<<reference,Reference>>** contains reference links and tables.
64 * **<<glossary,Glossary>>** is a specialized dictionary of terms related
65 to LTTng or to the field of software tracing.
68 include::../common/convention.txt[]
71 include::../common/acknowledgements.txt[]
75 == What's new in LTTng {revision}?
77 * **Tracing control**:
78 ** Dynamic filter support for <<event,event rules>> in the Linux kernel
79 <<domain,tracing domain>>. For example:
84 lttng enable-event --kernel irq_handler_entry --filter='irq == 28'
88 ** Wildcard support in the instrumentation point name of an event rule
89 in the Linux kernel tracing domain. For example:
94 lttng enable-event --kernel 'sched_*'
98 ** New `lttng track` and `lttng untrack` commands to make
99 <<pid-tracking,PID tracking>> super-fast for both the Linux kernel
100 and the user space tracing domains.
102 When LTTng _tracks_ one or more PIDs, only the processes having those PIDs
103 can emit events for a given tracing session.
105 ** New `--shm-path` option of the `lttng create` command to specify the
106 path where LTTng creates the shared memory holding the ring buffers.
108 This feature is useful when used with persistent memory file systems to
109 extract the latest recorded trace data in the event of a crash requiring
112 The new man:lttng-crash(1) command-line utility can extract trace data
113 from such a file (see <<persistent-memory-file-systems,Record trace data
114 on persistent memory file systems>>).
116 * **User space tracing**:
117 ** New <<python-application,LTTng-UST Python agent>> which makes it easy
118 to trace existing Python applications that are using the standard
119 https://docs.python.org/3/howto/logging.html[`logging` package].
121 This agent is compatible with both the Python 2 and Python 3 languages.
123 ** New <<tracelog,`tracelog()`>> facility to ease the migration from
126 `tracelog()` is similar to <<tracef,`tracef()`>>,
127 but it accepts an additional log level parameter.
129 ** Plugin support in LTTng-UST to provide a custom clock source and to
130 retrieve the current CPU number.
132 This feature exists for very advanced use cases.
135 https://github.com/lttng/lttng-ust/tree/stable-{revision}/doc/examples/clock-override[clock-override]
137 https://github.com/lttng/lttng-ust/tree/stable-{revision}/doc/examples/getcpu-override[getcpu-override]
138 examples for more details.
140 Moreover, LTTng{nbsp}{revision} boasts great stability, benifiting from
141 piles of bug fixes and more-than-welcome internal refactorings.
143 To learn more about the new features of LTTng{nbsp}{revision}, see
144 https://lttng.org/blog/2015/10/14/lttng-2.7-released/[the release announcement].
150 What is LTTng? As its name suggests, the _Linux Trace Toolkit: next
151 generation_ is a modern toolkit for tracing Linux systems and
152 applications. So your first question might be:
159 As the history of software engineering progressed and led to what
160 we now take for granted--complex, numerous and
161 interdependent software applications running in parallel on
162 sophisticated operating systems like Linux--the authors of such
163 components, software developers, began feeling a natural
164 urge to have tools that would ensure the robustness and good performance
165 of their masterpieces.
167 One major achievement in this field is, inarguably, the
168 https://www.gnu.org/software/gdb/[GNU debugger (GDB)],
169 an essential tool for developers to find and fix bugs. But even the best
170 debugger won't help make your software run faster, and nowadays, faster
171 software means either more work done by the same hardware, or cheaper
172 hardware for the same work.
174 A _profiler_ is often the tool of choice to identify performance
175 bottlenecks. Profiling is suitable to identify _where_ performance is
176 lost in a given software. The profiler outputs a profile, a statistical
177 summary of observed events, which you may use to discover which
178 functions took the most time to execute. However, a profiler won't
179 report _why_ some identified functions are the bottleneck. Bottlenecks
180 might only occur when specific conditions are met, conditions that are
181 sometimes impossible to capture by a statistical profiler, or impossible
182 to reproduce with an application altered by the overhead of an
183 event-based profiler. For a thorough investigation of software
184 performance issues, a history of execution is essential, with the
185 recorded values of variables and context fields you choose, and
186 with as little influence as possible on the instrumented software. This
187 is where tracing comes in handy.
189 _Tracing_ is a technique used to understand what goes on in a running
190 software system. The software used for tracing is called a _tracer_,
191 which is conceptually similar to a tape recorder. When recording,
192 specific instrumentation points placed in the software source code
193 generate events that are saved on a giant tape: a _trace_ file. You
194 can trace user applications and the operating system at the same time,
195 opening the possibility of resolving a wide range of problems that would
196 otherwise be extremely challenging.
198 Tracing is often compared to _logging_. However, tracers and loggers are
199 two different tools, serving two different purposes. Tracers are
200 designed to record much lower-level events that occur much more
201 frequently than log messages, often in the range of thousands per
202 second, with very little execution overhead. Logging is more appropriate
203 for a very high-level analysis of less frequent events: user accesses,
204 exceptional conditions (errors and warnings, for example), database
205 transactions, instant messaging communications, and such. Simply put,
206 logging is one of the many use cases that can be satisfied with tracing.
208 The list of recorded events inside a trace file can be read manually
209 like a log file for the maximum level of detail, but it is generally
210 much more interesting to perform application-specific analyses to
211 produce reduced statistics and graphs that are useful to resolve a
212 given problem. Trace viewers and analyzers are specialized tools
215 In the end, this is what LTTng is: a powerful, open source set of
216 tools to trace the Linux kernel and user applications at the same time.
217 LTTng is composed of several components actively maintained and
218 developed by its link:/community/#where[community].
221 [[lttng-alternatives]]
222 === Alternatives to noch:{LTTng}
224 Excluding proprietary solutions, a few competing software tracers
227 * https://github.com/dtrace4linux/linux[dtrace4linux] is a port of
228 Sun Microsystems's DTrace to Linux. The cmd:dtrace tool interprets
229 user scripts and is responsible for loading code into the
230 Linux kernel for further execution and collecting the outputted data.
231 * https://en.wikipedia.org/wiki/Berkeley_Packet_Filter[eBPF] is a
232 subsystem in the Linux kernel in which a virtual machine can execute
233 programs passed from the user space to the kernel. You can attach
234 such programs to tracepoints and KProbes thanks to a system call, and
235 they can output data to the user space when executed thanks to
236 different mechanisms (pipe, VM register values, and eBPF maps, to name
238 * https://www.kernel.org/doc/Documentation/trace/ftrace.txt[ftrace]
239 is the de facto function tracer of the Linux kernel. Its user
240 interface is a set of special files in sysfs.
241 * https://perf.wiki.kernel.org/[perf] is
242 a performance analyzing tool for Linux which supports hardware
243 performance counters, tracepoints, as well as other counters and
244 types of probes. perf's controlling utility is the cmd:perf command
246 * http://linux.die.net/man/1/strace[strace]
247 is a command-line utility which records system calls made by a
248 user process, as well as signal deliveries and changes of process
249 state. strace makes use of https://en.wikipedia.org/wiki/Ptrace[ptrace]
250 to fulfill its function.
251 * http://www.sysdig.org/[sysdig], like SystemTap, uses scripts to
252 analyze Linux kernel events. You write scripts, or _chisels_ in
253 sysdig's jargon, in Lua and sysdig executes them while the system is
254 being traced or afterwards. sysdig's interface is the cmd:sysdig
255 command-line tool as well as the curses-based cmd:csysdig tool.
256 * https://sourceware.org/systemtap/[SystemTap] is a Linux kernel and
257 user space tracer which uses custom user scripts to produce plain text
258 traces. SystemTap converts the scripts to the C language, and then
259 compiles them as Linux kernel modules which are loaded to produce
260 trace data. SystemTap's primary user interface is the cmd:stap
263 The main distinctive features of LTTng is that it produces correlated
264 kernel and user space traces, as well as doing so with the lowest
265 overhead amongst other solutions. It produces trace files in the
266 http://diamon.org/ctf[CTF] format, a file format optimized
267 for the production and analyses of multi-gigabyte data.
269 LTTng is the result of more than 10 years of active open source
270 development by a community of passionate developers.
271 LTTng{nbsp}{revision} is currently available on major desktop and server
274 The main interface for tracing control is a single command-line tool
275 named cmd:lttng. The latter can create several tracing sessions, enable
276 and disable events on the fly, filter events efficiently with custom
277 user expressions, start and stop tracing, and much more. LTTng can
278 record the traces on the file system or send them over the network, and
279 keep them totally or partially. You can view the traces once tracing
280 becomes inactive or in real-time.
282 <<installing-lttng,Install LTTng now>> and
283 <<getting-started,start tracing>>!
289 **LTTng** is a set of software <<plumbing,components>> which interact to
290 <<instrumenting,instrument>> the Linux kernel and user applications, and
291 to <<controlling-tracing,control tracing>> (start and stop
292 tracing, enable and disable event rules, and the rest). Those
293 components are bundled into the following packages:
295 * **LTTng-tools**: Libraries and command-line interface to
297 * **LTTng-modules**: Linux kernel modules to instrument and
299 * **LTTng-UST**: Libraries and Java/Python packages to instrument and
300 trace user applications.
302 Most distributions mark the LTTng-modules and LTTng-UST packages as
303 optional when installing LTTng-tools (which is always required). In the
304 following sections, we always provide the steps to install all three,
307 * You only need to install LTTng-modules if you intend to trace the
309 * You only need to install LTTng-UST if you intend to trace user
313 .Availability of LTTng{nbsp}{revision} for major Linux distributions.
315 |Distribution |Available in releases |Alternatives
318 |<<ubuntu,Ubuntu{nbsp}16.04 _Xenial Xerus_>>
319 |LTTng{nbsp}2.8 for Ubuntu{nbsp}16.10 _Yakkety Yak_.
321 LTTng{nbsp}{revision} for Ubuntu{nbsp}12.04 _Precise Pangolin_,
322 Ubuntu{nbsp}14.04 _Trusty Tahr_, and Ubuntu{nbsp}16.04 _Xenial Xerus_:
323 <<ubuntu-ppa,use the LTTng Stable{nbsp}{revision} PPA>>.
325 <<building-from-source,Build LTTng{nbsp}{revision} from source>> for
326 other Ubuntu releases.
330 |LTTng-tools{nbsp}{revision} and LTTng-UST{nbsp}{revision} for
331 Fedora{nbsp}25 and Fedora{nbsp}26 (both are not released yet).
333 <<building-from-source,Build LTTng-modules{nbsp}{revision} from
336 <<building-from-source,Build LTTng{nbsp}{revision} from source>> for
337 other Fedora releases.
341 |LTTng{nbsp}2.8 for Debian "stretch" (testing).
343 <<building-from-source,Build LTTng{nbsp}{revision} from source>> for
344 other Debian releases.
347 |<<opensuse,openSUSE Leap{nbsp}42.1>>
348 |<<building-from-source,Build LTTng{nbsp}{revision} from source>> for
349 other openSUSE releases.
353 |<<building-from-source,Build LTTng{nbsp}{revision} from source>>.
357 |LTTng{nbsp}2.8 for Alpine Linux "edge".
359 LTTng{nbsp}2.8 for Alpine Linux{nbsp}3.5 (not released yet).
361 <<building-from-source,Build LTTng{nbsp}{revision} from source>> for
362 other Alpine Linux releases.
365 |See http://packages.efficios.com/[EfficiOS Enterprise Packages].
369 |<<"buildroot","Buildroot{nbsp}2016.02, Buildroot{nbsp}2016.05,
370 and Buildroot{nbsp}2016.08">>
371 |LTTng{nbsp}2.8 for Buildroot{nbsp}2016.11 (not released yet).
373 <<building-from-source,Build LTTng{nbsp}{revision} from source>> for
374 other Buildroot releases.
376 |OpenEmbedded and Yocto
377 |<<oe-yocto,Yocto Project{nbsp}2.1 _Krogoth_>> (`openembedded-core` layer)
378 |LTTng{nbsp}2.8 for Yocto Project{nbsp}2.2 _Morty_.
380 <<building-from-source,Build LTTng{nbsp}{revision} from source>> for
381 other Yocto releases.
386 === [[ubuntu-official-repositories]]Ubuntu
388 LTTng{nbsp}{revision} is available on Ubuntu 16.04 _Xenial Xerus_. For
389 previous releases of Ubuntu, <<ubuntu-ppa,use the LTTng
390 Stable{nbsp}{revision} PPA>>.
392 To install LTTng{nbsp}{revision} on Ubuntu{nbsp}16.04 _Xenial Xerus_:
394 . Install the main LTTng{nbsp}{revision} packages:
399 sudo apt-get install lttng-tools
400 sudo apt-get install lttng-modules-dkms
401 sudo apt-get install liblttng-ust-dev
405 . **If you need to instrument and trace
406 <<java-application,Java applications>>**, install the LTTng-UST
412 sudo apt-get install liblttng-ust-agent-java
416 . **If you need to instrument and trace
417 <<python-application,Python applications>>**, install the
418 LTTng-UST Python agent:
423 sudo apt-get install python3-lttngust
429 ==== noch:{LTTng} Stable {revision} PPA
432 https://launchpad.net/~lttng/+archive/ubuntu/stable-{revision}[LTTng Stable{nbsp}{revision} PPA]
433 offers the latest stable LTTng{nbsp}{revision} packages for:
435 * Ubuntu{nbsp}12.04 _Precise Pangolin_
436 * Ubuntu{nbsp}14.04 _Trusty Tahr_
437 * Ubuntu{nbsp}16.04 _Xenial Xerus_
439 To install LTTng{nbsp}{revision} from the LTTng Stable{nbsp}{revision}
442 . Add the LTTng Stable{nbsp}{revision} PPA repository and update the
448 sudo apt-add-repository ppa:lttng/stable-2.7
453 . Install the main LTTng{nbsp}{revision} packages:
458 sudo apt-get install lttng-tools
459 sudo apt-get install lttng-modules-dkms
460 sudo apt-get install liblttng-ust-dev
464 . **If you need to instrument and trace
465 <<java-application,Java applications>>**, install the LTTng-UST
471 sudo apt-get install liblttng-ust-agent-java
475 . **If you need to instrument and trace
476 <<python-application,Python applications>>**, install the
477 LTTng-UST Python agent:
482 sudo apt-get install python3-lttngust
488 === noch:{openSUSE}/RPM
490 To install LTTng{nbsp}{revision} on openSUSE Leap{nbsp}42.1:
492 * Install the main LTTng{nbsp}{revision} packages:
497 sudo zypper install lttng-tools
498 sudo zypper install lttng-modules
499 sudo zypper install lttng-ust-devel
504 .Java and Python application instrumentation and tracing
506 If you need to instrument and trace <<java-application,Java
507 applications>> on openSUSE, you need to build and install
508 LTTng-UST{nbsp}{revision} <<building-from-source,from source>> and pass
509 the `--enable-java-agent-jul`, `--enable-java-agent-log4j`, or
510 `--enable-java-agent-all` options to the `configure` script, depending
511 on which Java logging framework you use.
513 If you need to instrument and trace <<python-application,Python
514 applications>> on openSUSE, you need to build and install
515 LTTng-UST{nbsp}{revision} from source and pass the
516 `--enable-python-agent` option to the `configure` script.
523 To install LTTng{nbsp}{revision} on Buildroot{nbsp}2016.02,
524 Buildroot{nbsp}2016.05, or Buildroot{nbsp}2016.08:
526 . Launch the Buildroot configuration tool:
535 . In **Kernel**, check **Linux kernel**.
536 . In **Toolchain**, check **Enable WCHAR support**.
537 . In **Target packages**{nbsp}→ **Debugging, profiling and benchmark**,
538 check **lttng-modules** and **lttng-tools**.
539 . In **Target packages**{nbsp}→ **Libraries**{nbsp}→
540 **Other**, check **lttng-libust**.
544 === OpenEmbedded and Yocto
546 LTTng{nbsp}{revision} recipes are available in the
547 http://layers.openembedded.org/layerindex/branch/master/layer/openembedded-core/[`openembedded-core`]
548 layer for Yocto Project{nbsp}2.1 _Krogoth_ under the following names:
554 With BitBake, the simplest way to include LTTng recipes in your target
555 image is to add them to `IMAGE_INSTALL_append` in path:{conf/local.conf}:
558 IMAGE_INSTALL_append = " lttng-tools lttng-modules lttng-ust"
563 . Select a machine and an image recipe.
564 . Click **Edit image recipe**.
565 . Under the **All recipes** tab, search for **lttng**.
566 . Check the desired LTTng recipes.
569 .Java and Python application instrumentation and tracing
571 If you need to instrument and trace <<java-application,Java
572 applications>> on openSUSE, you need to build and install
573 LTTng-UST{nbsp}{revision} <<building-from-source,from source>> and pass
574 the `--enable-java-agent-jul`, `--enable-java-agent-log4j`, or
575 `--enable-java-agent-all` options to the `configure` script, depending
576 on which Java logging framework you use.
578 If you need to instrument and trace <<python-application,Python
579 applications>> on openSUSE, you need to build and install
580 LTTng-UST{nbsp}{revision} from source and pass the
581 `--enable-python-agent` option to the `configure` script.
585 [[enterprise-distributions]]
586 === RHEL, SUSE, and other enterprise distributions
588 To install LTTng on enterprise Linux distributions, such as Red Hat
589 Enterprise Linux (RHEL) and SUSE Linux Enterprise Server (SUSE), please
590 see http://packages.efficios.com/[EfficiOS Enterprise Packages].
593 [[building-from-source]]
594 === Build from source
596 To build and install LTTng{nbsp}{revision} from source:
598 . Using your distribution's package manager, or from source, install
599 the following dependencies of LTTng-tools and LTTng-UST:
602 * https://sourceforge.net/projects/libuuid/[libuuid]
603 * http://directory.fsf.org/wiki/Popt[popt]
604 * http://liburcu.org/[Userspace RCU]
605 * http://www.xmlsoft.org/[libxml2]
608 . Download, build, and install the latest LTTng-modules{nbsp}{revision}:
614 wget http://lttng.org/files/lttng-modules/lttng-modules-latest-2.7.tar.bz2 &&
615 tar -xf lttng-modules-latest-2.7.tar.bz2 &&
616 cd lttng-modules-2.7.* &&
618 sudo make modules_install &&
623 . Download, build, and install the latest LTTng-UST{nbsp}{revision}:
629 wget http://lttng.org/files/lttng-ust/lttng-ust-latest-2.7.tar.bz2 &&
630 tar -xf lttng-ust-latest-2.7.tar.bz2 &&
631 cd lttng-ust-2.7.* &&
641 .Java and Python application tracing
643 If you need to instrument and trace <<java-application,Java
644 applications>>, pass the `--enable-java-agent-jul`,
645 `--enable-java-agent-log4j`, or `--enable-java-agent-all` options to the
646 `configure` script, depending on which Java logging framework you use.
648 If you need to instrument and trace <<python-application,Python
649 applications>>, pass the `--enable-python-agent` option to the
650 `configure` script. You can set the `PYTHON` environment variable to the
651 path to the Python interpreter for which to install the LTTng-UST Python
659 By default, LTTng-UST libraries are installed to
660 dir:{/usr/local/lib}, which is the de facto directory in which to
661 keep self-compiled and third-party libraries.
663 When <<building-tracepoint-providers-and-user-application,linking an
664 instrumented user application with `liblttng-ust`>>:
666 * Append `/usr/local/lib` to the env:LD_LIBRARY_PATH environment
668 * Pass the `-L/usr/local/lib` and `-Wl,-rpath,/usr/local/lib` options to
669 man:gcc(1), man:g++(1), or man:clang(1).
673 . Download, build, and install the latest LTTng-tools{nbsp}{revision}:
679 wget http://lttng.org/files/lttng-tools/lttng-tools-latest-2.7.tar.bz2 &&
680 tar -xf lttng-tools-latest-2.7.tar.bz2 &&
681 cd lttng-tools-2.7.* &&
689 TIP: The https://github.com/eepp/vlttng[vlttng tool] can do all the
690 previous steps automatically for a given version of LTTng and confine
691 the installed files in a specific directory. This can be useful to test
692 LTTng without installing it on your system.
698 This is a short guide to get started quickly with LTTng kernel and user
701 Before you follow this guide, make sure to <<installing-lttng,install>>
704 This tutorial walks you through the steps to:
706 . <<tracing-the-linux-kernel,Trace the Linux kernel>>.
707 . <<tracing-your-own-user-application,Trace a user application>> written
709 . <<viewing-and-analyzing-your-traces,View and analyze the
713 [[tracing-the-linux-kernel]]
714 === Trace the Linux kernel
716 The following command lines start with cmd:sudo because you need root
717 privileges to trace the Linux kernel. You can avoid using cmd:sudo if
718 your Unix user is a member of the <<lttng-sessiond,tracing group>>.
720 . Create a <<tracing-session,tracing session>>:
725 sudo lttng create my-kernel-session
729 . List the available kernel tracepoints and system calls:
738 . Create an <<event,event rule>> which matches the desired event names,
739 for example `sched_switch` and `sched_process_fork`:
744 sudo lttng enable-event --kernel sched_switch,sched_process_fork
748 You can also create an event rule which _matches_ all the Linux kernel
749 tracepoints (this will generate a lot of data when tracing):
754 sudo lttng enable-event --kernel --all
767 . Do some operation on your system for a few seconds. For example,
768 load a website, or list the files of a directory.
769 . Stop tracing and destroy the tracing session:
779 The `destroy` command does not destroy the trace data; it only destroys
780 the state of the tracing session.
782 By default, LTTng saves the traces in
783 +$LTTNG_HOME/lttng-traces/__name__-__date__-__time__+,
784 where +__name__+ is the tracing session name. Note that the
785 env:LTTNG_HOME environment variable defaults to `$HOME` if not set.
787 See <<viewing-and-analyzing-your-traces,View and analyze the
788 recorded events>> to view the recorded events.
791 [[tracing-your-own-user-application]]
792 === Trace a user application
794 This section steps you through a simple example to trace a
795 _Hello world_ program written in C.
797 To create the traceable user application:
799 . Create the tracepoint provider header file, which defines the
800 tracepoints and the events they can generate:
806 #undef TRACEPOINT_PROVIDER
807 #define TRACEPOINT_PROVIDER hello_world
809 #undef TRACEPOINT_INCLUDE
810 #define TRACEPOINT_INCLUDE "./hello-tp.h"
812 #if !defined(_HELLO_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
815 #include <lttng/tracepoint.h>
825 ctf_string(my_string_field, my_string_arg)
826 ctf_integer(int, my_integer_field, my_integer_arg)
830 #endif /* _HELLO_TP_H */
832 #include <lttng/tracepoint-event.h>
836 . Create the tracepoint provider package source file:
842 #define TRACEPOINT_CREATE_PROBES
843 #define TRACEPOINT_DEFINE
845 #include "hello-tp.h"
849 . Build the tracepoint provider package:
854 gcc -c -I. hello-tp.c
858 . Create the _Hello World_ application source file:
865 #include "hello-tp.h"
867 int main(int argc, char *argv[])
871 puts("Hello, World!\nPress Enter to continue...");
874 * The following getchar() call is only placed here for the purpose
875 * of this demonstration, to pause the application in order for
876 * you to have time to list its tracepoints. It is not
882 * A tracepoint() call.
884 * Arguments, as defined in hello-tp.h:
886 * 1. Tracepoint provider name (required)
887 * 2. Tracepoint name (required)
888 * 3. my_integer_arg (first user-defined argument)
889 * 4. my_string_arg (second user-defined argument)
891 * Notice the tracepoint provider and tracepoint names are
892 * NOT strings: they are in fact parts of variables that the
893 * macros in hello-tp.h create.
895 tracepoint(hello_world, my_first_tracepoint, 23, "hi there!");
897 for (x = 0; x < argc; ++x) {
898 tracepoint(hello_world, my_first_tracepoint, x, argv[x]);
901 puts("Quitting now!");
902 tracepoint(hello_world, my_first_tracepoint, x * x, "x^2");
909 . Build the application:
918 . Link the application with the tracepoint provider package,
919 `liblttng-ust`, and `libdl`:
924 gcc -o hello hello.o hello-tp.o -llttng-ust -ldl
928 Here's the whole build process:
931 .User space tracing tutorial's build steps.
932 image::ust-flow.png[]
934 To trace the user application:
936 . Run the application with a few arguments:
941 ./hello world and beyond
950 Press Enter to continue...
954 . Start an LTTng <<lttng-sessiond,session daemon>>:
959 lttng-sessiond --daemonize
963 Note that a session daemon might already be running, for example as
964 a service that the distribution's service manager started.
966 . List the available user space tracepoints:
971 lttng list --userspace
975 You see the `hello_world:my_first_tracepoint` tracepoint listed
976 under the `./hello` process.
978 . Create a <<tracing-session,tracing session>>:
983 lttng create my-user-space-session
987 . Create an <<event,event rule>> which matches the
988 `hello_world:my_first_tracepoint` event name:
993 lttng enable-event --userspace hello_world:my_first_tracepoint
1006 . Go back to the running `hello` application and press Enter. The
1007 program executes all `tracepoint()` instrumentation points and exits.
1008 . Stop tracing and destroy the tracing session:
1018 The `destroy` command does not destroy the trace data; it only destroys
1019 the state of the tracing session.
1021 By default, LTTng saves the traces in
1022 +$LTTNG_HOME/lttng-traces/__name__-__date__-__time__+,
1023 where +__name__+ is the tracing session name. Note that the
1024 env:LTTNG_HOME environment variable defaults to `$HOME` if not set.
1026 See <<viewing-and-analyzing-your-traces,View and analyze the
1027 recorded events>> to view the recorded events.
1030 [[viewing-and-analyzing-your-traces]]
1031 === View and analyze the recorded events
1033 Once you have completed the <<tracing-the-linux-kernel,Trace the Linux
1034 kernel>> and <<tracing-your-own-user-application,Trace a user
1035 application>> tutorials, you can inspect the recorded events.
1037 Many tools are available to read LTTng traces:
1039 * **cmd:babeltrace** is a command-line utility which converts trace
1040 formats; it supports the format that LTTng produces, CTF, as well as a
1041 basic text output which can be ++grep++ed. The cmd:babeltrace command
1042 is part of the http://diamon.org/babeltrace[Babeltrace] project.
1043 * Babeltrace also includes
1044 **https://www.python.org/[Python] bindings** so
1045 that you can easily open and read an LTTng trace with your own script,
1046 benefiting from the power of Python.
1047 * http://tracecompass.org/[**Trace Compass**]
1048 is a graphical user interface for viewing and analyzing any type of
1049 logs or traces, including LTTng's.
1050 * https://github.com/lttng/lttng-analyses[**LTTng analyses**] is a
1051 project which includes many high-level analyses of LTTng kernel
1052 traces, like scheduling statistics, interrupt frequency distribution,
1053 top CPU usage, and more.
1055 NOTE: This section assumes that the traces recorded during the previous
1056 tutorials were saved to their default location, in the
1057 dir:{$LTTNG_HOME/lttng-traces} directory. Note that the env:LTTNG_HOME
1058 environment variable defaults to `$HOME` if not set.
1061 [[viewing-and-analyzing-your-traces-bt]]
1062 ==== Use the cmd:babeltrace command-line tool
1064 The simplest way to list all the recorded events of a trace is to pass
1065 its path to cmd:babeltrace with no options:
1069 babeltrace ~/lttng-traces/my-user-space-session*
1072 cmd:babeltrace finds all traces recursively within the given path and
1073 prints all their events, merging them in chronological order.
1075 You can pipe the output of cmd:babeltrace into a tool like man:grep(1) for
1080 babeltrace ~/lttng-traces/my-kernel-session* | grep sys_
1083 You can pipe the output of cmd:babeltrace into a tool like man:wc(1) to
1084 count the recorded events:
1088 babeltrace ~/lttng-traces/my-kernel-session* | grep sys_read | wc --lines
1092 [[viewing-and-analyzing-your-traces-bt-python]]
1093 ==== Use the Babeltrace Python bindings
1095 The <<viewing-and-analyzing-your-traces-bt,text output of cmd:babeltrace>>
1096 is useful to isolate events by simple matching using man:grep(1) and
1097 similar utilities. However, more elaborate filters, such as keeping only
1098 event records with a field value falling within a specific range, are
1099 not trivial to write using a shell. Moreover, reductions and even the
1100 most basic computations involving multiple event records are virtually
1101 impossible to implement.
1103 Fortunately, Babeltrace ships with Python 3 bindings which makes it easy
1104 to read the event records of an LTTng trace sequentially and compute the
1105 desired information.
1107 The following script accepts an LTTng Linux kernel trace path as its
1108 first argument and prints the short names of the top 5 running processes
1109 on CPU 0 during the whole trace:
1114 from collections import Counter
1120 if len(sys.argv) != 2:
1121 msg = 'Usage: python3 {} TRACEPATH'.format(sys.argv[0])
1122 print(msg, file=sys.stderr)
1125 # A trace collection contains one or more traces
1126 col = babeltrace.TraceCollection()
1128 # Add the trace provided by the user (LTTng traces always have
1130 if col.add_trace(sys.argv[1], 'ctf') is None:
1131 raise RuntimeError('Cannot add trace')
1133 # This counter dict contains execution times:
1135 # task command name -> total execution time (ns)
1136 exec_times = Counter()
1138 # This contains the last `sched_switch` timestamp
1142 for event in col.events:
1143 # Keep only `sched_switch` events
1144 if event.name != 'sched_switch':
1147 # Keep only events which happened on CPU 0
1148 if event['cpu_id'] != 0:
1152 cur_ts = event.timestamp
1158 # Previous task command (short) name
1159 prev_comm = event['prev_comm']
1161 # Initialize entry in our dict if not yet done
1162 if prev_comm not in exec_times:
1163 exec_times[prev_comm] = 0
1165 # Compute previous command execution time
1166 diff = cur_ts - last_ts
1168 # Update execution time of this command
1169 exec_times[prev_comm] += diff
1171 # Update last timestamp
1175 for name, ns in exec_times.most_common(5):
1177 print('{:20}{} s'.format(name, s))
1182 if __name__ == '__main__':
1183 sys.exit(0 if top5proc() else 1)
1190 python3 top5proc.py ~/lttng-traces/my-kernel-session*/kernel
1196 swapper/0 48.607245889 s
1197 chromium 7.192738188 s
1198 pavucontrol 0.709894415 s
1199 Compositor 0.660867933 s
1200 Xorg.bin 0.616753786 s
1203 Note that `swapper/0` is the "idle" process of CPU 0 on Linux; since we
1204 weren't using the CPU that much when tracing, its first position in the
1209 == [[understanding-lttng]]Core concepts
1211 From a user's perspective, the LTTng system is built on a few concepts,
1212 or objects, on which the <<lttng-cli,cmd:lttng command-line tool>>
1213 operates by sending commands to the <<lttng-sessiond,session daemon>>.
1214 Understanding how those objects relate to eachother is key in mastering
1217 The core concepts are:
1219 * <<tracing-session,Tracing session>>
1220 * <<domain,Tracing domain>>
1221 * <<channel,Channel and ring buffer>>
1222 * <<"event","Instrumentation point, event rule, event, and event record">>
1228 A _tracing session_ is a stateful dialogue between you and
1229 a <<lttng-sessiond,session daemon>>. You can
1230 <<creating-destroying-tracing-sessions,create a new tracing
1231 session>> with the `lttng create` command.
1233 Anything that you do when you control LTTng tracers happens within a
1234 tracing session. In particular, a tracing session:
1237 * Has its own set of trace files.
1238 * Has its own state of activity (started or stopped).
1239 * Has its own <<tracing-session-mode,mode>> (local, network streaming,
1241 * Has its own <<channel,channels>> which have their own
1242 <<event,event rules>>.
1245 .A _tracing session_ contains <<channel,channels>> that are members of <<domain,tracing domains>> and contain <<event,event rules>>.
1246 image::concepts.png[]
1248 Those attributes and objects are completely isolated between different
1251 A tracing session is analogous to a cash machine session:
1252 the operations you do on the banking system through the cash machine do
1253 not alter the data of other users of the same system. In the case of
1254 the cash machine, a session lasts as long as your bank card is inside.
1255 In the case of LTTng, a tracing session lasts from the `lttng create`
1256 command to the `lttng destroy` command.
1259 .Each Unix user has its own set of tracing sessions.
1260 image::many-sessions.png[]
1263 [[tracing-session-mode]]
1264 ==== Tracing session mode
1266 LTTng can send the generated trace data to different locations. The
1267 _tracing session mode_ dictates where to send it. The following modes
1268 are available in LTTng{nbsp}{revision}:
1271 LTTng writes the traces to the file system of the machine being traced
1274 Network streaming mode::
1275 LTTng sends the traces over the network to a
1276 <<lttng-relayd,relay daemon>> running on a remote system.
1279 LTTng does not write the traces by default. Instead, you can request
1280 LTTng to <<taking-a-snapshot,take a snapshot>>, that is, a copy of the
1281 current tracing buffers, and to write it to the target's file system
1282 or to send it over the network to a <<lttng-relayd,relay daemon>>
1283 running on a remote system.
1286 This mode is similar to the network streaming mode, but a live
1287 trace viewer can connect to the distant relay daemon to
1288 <<lttng-live,view event records as LTTng generates them>> by
1295 A _tracing domain_ is a namespace for event sources. A tracing domain
1296 has its own properties and features.
1298 There are currently five available tracing domains:
1302 * `java.util.logging` (JUL)
1306 You must specify a tracing domain when using some commands to avoid
1307 ambiguity. For example, since all the domains support named tracepoints
1308 as event sources (instrumentation points that you manually insert in the
1309 source code), you need to specify a tracing domain when
1310 <<enabling-disabling-events,creating an event rule>> because all the
1311 tracing domains could have tracepoints with the same names.
1313 Some features are reserved to specific tracing domains. Dynamic function
1314 entry and return instrumentation points, for example, are currently only
1315 supported in the Linux kernel tracing domain, but support for other
1316 tracing domains could be added in the future.
1318 You can create <<channel,channels>> in the Linux kernel and user space
1319 tracing domains. The other tracing domains have a single default
1324 === Channel and ring buffer
1326 A _channel_ is an object which is responsible for a set of ring buffers.
1327 Each ring buffer is divided into multiple sub-buffers. When an LTTng
1328 tracer emits an event, it can record it to one or more
1329 sub-buffers. The attributes of a channel determine what to do when
1330 there's no space left for a new event record because all sub-buffers
1331 are full, where to send a full sub-buffer, and other behaviours.
1333 A channel is always associated to a <<domain,tracing domain>>. The
1334 `java.util.logging` (JUL), log4j, and Python tracing domains each have
1335 a default channel which you cannot configure.
1337 A channel also owns <<event,event rules>>. When an LTTng tracer emits
1338 an event, it records it to the sub-buffers of all
1339 the enabled channels with a satisfied event rule, as long as those
1340 channels are part of active <<tracing-session,tracing sessions>>.
1343 [[channel-buffering-schemes]]
1344 ==== Per-user vs. per-process buffering schemes
1346 A channel has at least one ring buffer _per CPU_. LTTng always
1347 records an event to the ring buffer associated to the CPU on which it
1350 Two _buffering schemes_ are available when you
1351 <<enabling-disabling-channels,create a channel>> in the
1352 user space <<domain,tracing domain>>:
1354 Per-user buffering::
1355 Allocate one set of ring buffers--one per CPU--shared by all the
1356 instrumented processes of each Unix user.
1360 .Per-user buffering scheme.
1361 image::per-user-buffering.png[]
1364 Per-process buffering::
1365 Allocate one set of ring buffers--one per CPU--for each
1366 instrumented process.
1370 .Per-process buffering scheme.
1371 image::per-process-buffering.png[]
1374 The per-process buffering scheme tends to consume more memory than the
1375 per-user option because systems generally have more instrumented
1376 processes than Unix users running instrumented processes. However, the
1377 per-process buffering scheme ensures that one process having a high
1378 event throughput won't fill all the shared sub-buffers of the same
1381 The Linux kernel tracing domain has only one available buffering scheme
1382 which is to allocate a single set of ring buffers for the whole system.
1383 This scheme is similar to the per-user option, but with a single, global
1384 user "running" the kernel.
1387 [[channel-overwrite-mode-vs-discard-mode]]
1388 ==== Overwrite vs. discard event loss modes
1390 When an event occurs, LTTng records it to a specific sub-buffer (yellow
1391 arc in the following animation) of a specific channel's ring buffer.
1392 When there's no space left in a sub-buffer, the tracer marks it as
1393 consumable (red) and another, empty sub-buffer starts receiving the
1394 following event records. A <<lttng-consumerd,consumer daemon>>
1395 eventually consumes the marked sub-buffer (returns to white).
1398 [role="docsvg-channel-subbuf-anim"]
1403 In an ideal world, sub-buffers are consumed faster than they are filled,
1404 as is the case in the previous animation. In the real world,
1405 however, all sub-buffers can be full at some point, leaving no space to
1406 record the following events.
1408 By design, LTTng is a _non-blocking_ tracer: when no empty sub-buffer is
1409 available, it is acceptable to lose event records when the alternative
1410 would be to cause substantial delays in the instrumented application's
1411 execution. LTTng privileges performance over integrity; it aims at
1412 perturbing the traced system as little as possible in order to make
1413 tracing of subtle race conditions and rare interrupt cascades possible.
1415 When it comes to losing event records because no empty sub-buffer is
1416 available, the channel's _event loss mode_ determines what to do. The
1417 available event loss modes are:
1420 Drop the newest event records until a the tracer
1421 releases a sub-buffer.
1424 Clear the sub-buffer containing the oldest event records and start
1425 writing the newest event records there.
1427 This mode is sometimes called _flight recorder mode_ because it's
1429 https://en.wikipedia.org/wiki/Flight_recorder[flight recorder]:
1430 always keep a fixed amount of the latest data.
1432 Which mechanism you should choose depends on your context: prioritize
1433 the newest or the oldest event records in the ring buffer?
1435 Beware that, in overwrite mode, the tracer abandons a whole sub-buffer
1436 as soon as a there's no space left for a new event record, whereas in
1437 discard mode, the tracer only discards the event record that doesn't
1440 In discard mode, LTTng increments a count of lost event records when
1441 an event record is lost and saves this count to the trace. In
1442 overwrite mode, LTTng keeps no information when it overwrites a
1443 sub-buffer before consuming it.
1445 There are a few ways to decrease your probability of losing event
1447 <<channel-subbuf-size-vs-subbuf-count,Sub-buffer count and size>> shows
1448 how you can fine-une the sub-buffer count and size of a channel to
1449 virtually stop losing event records, though at the cost of greater
1453 [[channel-subbuf-size-vs-subbuf-count]]
1454 ==== Sub-buffer count and size
1456 When you <<enabling-disabling-channels,create a channel>>, you can
1457 set its number of sub-buffers and their size.
1459 Note that there is noticeable CPU overhead introduced when
1460 switching sub-buffers (marking a full one as consumable and switching
1461 to an empty one for the following events to be recorded). Knowing this,
1462 the following list presents a few practical situations along with how
1463 to configure the sub-buffer count and size for them:
1465 * **High event throughput**: In general, prefer bigger sub-buffers to
1466 lower the risk of losing event records.
1468 Having bigger sub-buffers also ensures a lower sub-buffer switching
1471 The number of sub-buffers is only meaningful if you create the channel
1472 in overwrite mode: in this case, if a sub-buffer overwrite happens, the
1473 other sub-buffers are left unaltered.
1475 * **Low event throughput**: In general, prefer smaller sub-buffers
1476 since the risk of losing event records is low.
1478 Because events occur less frequently, the sub-buffer switching frequency
1479 should remain low and thus the tracer's overhead should not be a
1482 * **Low memory system**: If your target system has a low memory
1483 limit, prefer fewer first, then smaller sub-buffers.
1485 Even if the system is limited in memory, you want to keep the
1486 sub-buffers as big as possible to avoid a high sub-buffer switching
1489 Note that LTTng uses http://diamon.org/ctf/[CTF] as its trace format,
1490 which means event data is very compact. For example, the average
1491 LTTng kernel event record weights about 32{nbsp}bytes. Thus, a
1492 sub-buffer size of 1{nbsp}MiB is considered big.
1494 The previous situations highlight the major trade-off between a few big
1495 sub-buffers and more, smaller sub-buffers: sub-buffer switching
1496 frequency vs. how much data is lost in overwrite mode. Assuming a
1497 constant event throughput and using the overwrite mode, the two
1498 following configurations have the same ring buffer total size:
1501 [role="docsvg-channel-subbuf-size-vs-count-anim"]
1506 * **2 sub-buffers of 4{nbsp}MiB each**: Expect a very low sub-buffer
1507 switching frequency, but if a sub-buffer overwrite happens, half of
1508 the event records so far (4{nbsp}MiB) are definitely lost.
1509 * **8 sub-buffers of 1{nbsp}MiB each**: Expect 4{nbsp}times the tracer's
1510 overhead as the previous configuration, but if a sub-buffer
1511 overwrite happens, only the eighth of event records so far are
1514 In discard mode, the sub-buffers count parameter is pointless: use two
1515 sub-buffers and set their size according to the requirements of your
1519 [[channel-switch-timer]]
1520 ==== Switch timer period
1522 The _switch timer period_ is an important configurable attribute of
1523 a channel to ensure periodic sub-buffer flushing.
1525 When the _switch timer_ expires, a sub-buffer switch happens. You can
1526 set the switch timer period attribute when you
1527 <<enabling-disabling-channels,create a channel>> to ensure that event
1528 data is consumed and committed to trace files or to a distant relay
1529 daemon periodically in case of a low event throughput.
1532 [role="docsvg-channel-switch-timer"]
1537 This attribute is also convenient when you use big sub-buffers to cope
1538 with a sporadic high event throughput, even if the throughput is
1542 [[channel-read-timer]]
1543 ==== Read timer period
1545 By default, the LTTng tracers use a notification mechanism to signal a
1546 full sub-buffer so that a consumer daemon can consume it. When such
1547 notifications must be avoided, for example in real-time applications,
1548 you can use the channel's _read timer_ instead. When the read timer
1549 fires, the <<lttng-consumerd,consumer daemon>> checks for full,
1550 consumable sub-buffers.
1553 [[tracefile-rotation]]
1554 ==== Trace file count and size
1556 By default, trace files can grow as large as needed. You can set the
1557 maximum size of each trace file that a channel writes when you
1558 <<enabling-disabling-channels,create a channel>>. When the size of
1559 a trace file reaches the channel's fixed maximum size, LTTng creates
1560 another file to contain the next event records. LTTng appends a file
1561 count to each trace file name in this case.
1563 If you set the trace file size attribute when you create a channel, the
1564 maximum number of trace files that LTTng creates is _unlimited_ by
1565 default. To limit them, you can also set a maximum number of trace
1566 files. When the number of trace files reaches the channel's fixed
1567 maximum count, the oldest trace file is overwritten. This mechanism is
1568 called _trace file rotation_.
1572 === Instrumentation point, event rule, event, and event record
1574 An _event rule_ is a set of conditions which must be **all** satisfied
1575 for LTTng to record an occuring event.
1577 You set the conditions when you <<enabling-disabling-events,create
1580 You always attach an event rule to <<channel,channel>> when you create
1583 When an event passes the conditions of an event rule, LTTng records it
1584 in one of the attached channel's sub-buffers.
1586 The available conditions, as of LTTng{nbsp}{revision}, are:
1588 * The event rule _is enabled_.
1589 * The instrumentation point's type _is{nbsp}T_.
1590 * The instrumentation point's name (sometimes called _event name_)
1591 _matches{nbsp}N_, but _is not{nbsp}E_.
1592 * The instrumentation point's log level _is as severe as{nbsp}L_, or
1593 _is exactly{nbsp}L_.
1594 * The fields of the event's payload _satisfy_ a filter
1595 expression{nbsp}__F__.
1597 As you can see, all the conditions but the dynamic filter are related to
1598 the event rule's status or to the instrumentation point, not to the
1599 occurring events. This is why, without a filter, checking if an event
1600 passes an event rule is not a dynamic task: when you create or modify an
1601 event rule, all the tracers of its tracing domain enable or disable the
1602 instrumentation points themselves once. This is possible because the
1603 attributes of an instrumentation point (type, name, and log level) are
1604 defined statically. In other words, without a dynamic filter, the tracer
1605 _does not evaluate_ the arguments of an instrumentation point unless it
1606 matches an enabled event rule.
1608 Note that, for LTTng to record an event, the <<channel,channel>> to
1609 which a matching event rule is attached must also be enabled, and the
1610 tracing session owning this channel must be active.
1613 .Logical path from an instrumentation point to an event record.
1614 image::event-rule.png[]
1616 .Event, event record, or event rule?
1618 With so many similar terms, it's easy to get confused.
1620 An **event** is the consequence of the execution of an _instrumentation
1621 point_, like a tracepoint that you manually place in some source code,
1622 or a Linux kernel KProbe. An event is said to _occur_ at a specific
1623 time. Different actions can be taken upon the occurance of an event,
1624 like record the event's payload to a buffer.
1626 An **event record** is the representation of an event in a sub-buffer. A
1627 tracer is responsible for capturing the payload of an event, current
1628 context variables, the event's ID, and the event's timestamp. LTTng
1629 can append this sub-buffer to a trace file.
1631 An **event rule** is a set of conditions which must all be satisfied for
1632 LTTng to record an occuring event. Events still occur without
1633 satisfying event rules, but LTTng does not record them.
1638 == Components of noch:{LTTng}
1640 The second _T_ in _LTTng_ stands for _toolkit_: it would be wrong
1641 to call LTTng a simple _tool_ since it is composed of multiple
1642 interacting components. This section describes those components,
1643 explains their respective roles, and shows how they connect together to
1644 form the LTTng ecosystem.
1646 The following diagram shows how the most important components of LTTng
1647 interact with user applications, the Linux kernel, and you:
1650 .Control and trace data paths between LTTng components.
1651 image::plumbing.png[]
1653 The LTTng project incorporates:
1655 * **LTTng-tools**: Libraries and command-line interface to
1656 control tracing sessions.
1657 ** <<lttng-sessiond,Session daemon>> (man:lttng-sessiond(8)).
1658 ** <<lttng-consumerd,Consumer daemon>> (man:lttng-consumerd(8)).
1659 ** <<lttng-relayd,Relay daemon>> (man:lttng-relayd(8)).
1660 ** <<liblttng-ctl-lttng,Tracing control library>> (`liblttng-ctl`).
1661 ** <<lttng-cli,Tracing control command-line tool>> (man:lttng(1)).
1662 * **LTTng-UST**: Libraries and Java/Python packages to trace user
1664 ** <<lttng-ust,User space tracing library>> (`liblttng-ust`) and its
1665 headers to instrument and trace any native user application.
1666 ** <<prebuilt-ust-helpers,Preloadable user space tracing helpers>>:
1667 *** `liblttng-ust-libc-wrapper`
1668 *** `liblttng-ust-pthread-wrapper`
1669 *** `liblttng-ust-cyg-profile`
1670 *** `liblttng-ust-cyg-profile-fast`
1671 *** `liblttng-ust-dl`
1672 ** User space tracepoint provider source files generator command-line
1673 tool (man:lttng-gen-tp(1)).
1674 ** <<lttng-ust-agents,LTTng-UST Java agent>> to instrument and trace
1675 Java applications using `java.util.logging` or
1676 Apache log4j 1.2 logging.
1677 ** <<lttng-ust-agents,LTTng-UST Python agent>> to instrument
1678 Python applications using the standard `logging` package.
1679 * **LTTng-modules**: <<lttng-modules,Linux kernel modules>> to trace
1681 ** LTTng kernel tracer module.
1682 ** Tracing ring buffer kernel modules.
1683 ** Probe kernel modules.
1684 ** LTTng logger kernel module.
1688 === Tracing control command-line interface
1691 .The tracing control command-line interface.
1692 image::plumbing-lttng-cli.png[]
1694 The _man:lttng(1) command-line tool_ is the standard user interface to
1695 control LTTng <<tracing-session,tracing sessions>>. The cmd:lttng tool
1696 is part of LTTng-tools.
1698 The cmd:lttng tool is linked with
1699 <<liblttng-ctl-lttng,`liblttng-ctl`>> to communicate with
1700 one or more <<lttng-sessiond,session daemons>> behind the scenes.
1702 The cmd:lttng tool has a Git-like interface:
1706 lttng <general options> <command> <command options>
1709 The <<controlling-tracing,Tracing control>> section explores the
1710 available features of LTTng using the cmd:lttng tool.
1713 [[liblttng-ctl-lttng]]
1714 === Tracing control library
1717 .The tracing control library.
1718 image::plumbing-liblttng-ctl.png[]
1720 The _LTTng control library_, `liblttng-ctl`, is used to communicate
1721 with a <<lttng-sessiond,session daemon>> using a C API that hides the
1722 underlying protocol's details. `liblttng-ctl` is part of LTTng-tools.
1724 The <<lttng-cli,cmd:lttng command-line tool>>
1725 is linked with `liblttng-ctl`.
1727 You can use `liblttng-ctl` in C or $$C++$$ source code by including its
1732 #include <lttng/lttng.h>
1735 Some objects are referenced by name (C string), such as tracing
1736 sessions, but most of them require to create a handle first using
1737 `lttng_create_handle()`.
1739 The best available developer documentation for `liblttng-ctl` is, as of
1740 LTTng{nbsp}{revision}, its installed header files. Every function and
1741 structure is thoroughly documented.
1745 === User space tracing library
1748 .The user space tracing library.
1749 image::plumbing-liblttng-ust.png[]
1751 The _user space tracing library_, `liblttng-ust` (see man:lttng-ust(3)),
1752 is the LTTng user space tracer. It receives commands from a
1753 <<lttng-sessiond,session daemon>>, for example to
1754 enable and disable specific instrumentation points, and writes event
1755 records to ring buffers shared with a
1756 <<lttng-consumerd,consumer daemon>>.
1757 `liblttng-ust` is part of LTTng-UST.
1759 Public C header files are installed beside `liblttng-ust` to
1760 instrument any <<c-application,C or $$C++$$ application>>.
1762 <<lttng-ust-agents,LTTng-UST agents>>, which are regular Java and Python
1763 packages, use their own library providing tracepoints which is
1764 linked with `liblttng-ust`.
1766 An application or library does not have to initialize `liblttng-ust`
1767 manually: its constructor does the necessary tasks to properly register
1768 to a session daemon. The initialization phase also enables the
1769 instrumentation points matching the <<event,event rules>> that you
1773 [[lttng-ust-agents]]
1774 === User space tracing agents
1777 .The user space tracing agents.
1778 image::plumbing-lttng-ust-agents.png[]
1780 The _LTTng-UST Java and Python agents_ are regular Java and Python
1781 packages which add LTTng tracing capabilities to the
1782 native logging frameworks. The LTTng-UST agents are part of LTTng-UST.
1784 In the case of Java, the
1785 https://docs.oracle.com/javase/7/docs/api/java/util/logging/package-summary.html[`java.util.logging`
1786 core logging facilities] and
1787 https://logging.apache.org/log4j/1.2/[Apache log4j 1.2] are supported.
1788 Note that Apache Log4{nbsp}2 is not supported.
1790 In the case of Python, the standard
1791 https://docs.python.org/3/library/logging.html[`logging`] package
1792 is supported. Both Python 2 and Python 3 modules can import the
1793 LTTng-UST Python agent package.
1795 The applications using the LTTng-UST agents are in the
1796 `java.util.logging` (JUL),
1797 log4j, and Python <<domain,tracing domains>>.
1799 Both agents use the same mechanism to trace the log statements. When an
1800 agent is initialized, it creates a log handler that attaches to the root
1801 logger. The agent also registers to a <<lttng-sessiond,session daemon>>.
1802 When the application executes a log statement, it is passed to the
1803 agent's log handler by the root logger. The agent's log handler calls a
1804 native function in a tracepoint provider package shared library linked
1805 with <<lttng-ust,`liblttng-ust`>>, passing the formatted log message and
1806 other fields, like its logger name and its log level. This native
1807 function contains a user space instrumentation point, hence tracing the
1810 The log level condition of an
1811 <<event,event rule>> is considered when tracing
1812 a Java or a Python application, and it's compatible with the standard
1813 JUL, log4j, and Python log levels.
1817 === LTTng kernel modules
1820 .The LTTng kernel modules.
1821 image::plumbing-lttng-modules.png[]
1823 The _LTTng kernel modules_ are a set of Linux kernel modules
1824 which implement the kernel tracer of the LTTng project. The LTTng
1825 kernel modules are part of LTTng-modules.
1827 The LTTng kernel modules include:
1829 * A set of _probe_ modules.
1831 Each module attaches to a specific subsystem
1832 of the Linux kernel using its tracepoint instrument points. There are
1833 also modules to attach to the entry and return points of the Linux
1834 system call functions.
1836 * _Ring buffer_ modules.
1838 A ring buffer implementation is provided as kernel modules. The LTTng
1839 kernel tracer writes to the ring buffer; a
1840 <<lttng-consumerd,consumer daemon>> reads from the ring buffer.
1842 * The _LTTng kernel tracer_ module.
1843 * The _LTTng logger_ module.
1845 The LTTng logger module implements the special path:{/proc/lttng-logger}
1846 file so that any executable can generate LTTng events by opening and
1847 writing to this file.
1849 See <<proc-lttng-logger-abi,LTTng logger>>.
1851 Generally, you do not have to load the LTTng kernel modules manually
1852 (using man:modprobe(8), for example): a root <<lttng-sessiond,session
1853 daemon>> loads the necessary modules when starting. If you have extra
1854 probe modules, you can specify to load them to the session daemon on
1857 The LTTng kernel modules are installed in
1858 +/usr/lib/modules/__release__/extra+ by default, where +__release__+ is
1859 the kernel release (see `uname --kernel-release`).
1866 .The session daemon.
1867 image::plumbing-sessiond.png[]
1869 The _session daemon_, man:lttng-sessiond(8), is a daemon responsible for
1870 managing tracing sessions and for controlling the various components of
1871 LTTng. The session daemon is part of LTTng-tools.
1873 The session daemon sends control requests to and receives control
1876 * The <<lttng-ust,user space tracing library>>.
1878 Any instance of the user space tracing library first registers to
1879 a session daemon. Then, the session daemon can send requests to
1880 this instance, such as:
1883 ** Get the list of tracepoints.
1884 ** Share an <<event,event rule>> so that the user space tracing library
1885 can enable or disable tracepoints. Amongst the possible conditions
1886 of an event rule is a filter expression which `liblttng-ust` evalutes
1887 when an event occurs.
1888 ** Share <<channel,channel>> attributes and ring buffer locations.
1891 The session daemon and the user space tracing library use a Unix
1892 domain socket for their communication.
1894 * The <<lttng-ust-agents,user space tracing agents>>.
1896 Any instance of a user space tracing agent first registers to
1897 a session daemon. Then, the session daemon can send requests to
1898 this instance, such as:
1901 ** Get the list of loggers.
1902 ** Enable or disable a specific logger.
1905 The session daemon and the user space tracing agent use a TCP connection
1906 for their communication.
1908 * The <<lttng-modules,LTTng kernel tracer>>.
1909 * The <<lttng-consumerd,consumer daemon>>.
1911 The session daemon sends requests to the consumer daemon to instruct
1912 it where to send the trace data streams, amongst other information.
1914 * The <<lttng-relayd,relay daemon>>.
1916 The session daemon receives commands from the
1917 <<liblttng-ctl-lttng,tracing control library>>.
1919 The root session daemon loads the appropriate
1920 <<lttng-modules,LTTng kernel modules>> on startup. It also spawns
1921 a <<lttng-consumerd,consumer daemon>> as soon as you create
1922 an <<event,event rule>>.
1924 The session daemon does not send and receive trace data: this is the
1925 role of the <<lttng-consumerd,consumer daemon>> and
1926 <<lttng-relayd,relay daemon>>. It does, however, generate the
1927 http://diamon.org/ctf/[CTF] metadata stream.
1929 Each Unix user can have its own session daemon instance. The
1930 tracing sessions managed by different session daemons are completely
1933 The root user's session daemon is the only one which is
1934 allowed to control the LTTng kernel tracer, and its spawned consumer
1935 daemon is the only one which is allowed to consume trace data from the
1936 LTTng kernel tracer. Note, however, that any Unix user which is a member
1937 of the <<tracing-group,tracing group>> is allowed
1938 to create <<channel,channels>> in the
1939 Linux kernel <<domain,tracing domain>>, and thus to trace the Linux
1942 The <<lttng-cli,cmd:lttng command-line tool>> automatically starts a
1943 session daemon when using its `create` command if none is currently
1944 running. You can also start the session daemon manually.
1951 .The consumer daemon.
1952 image::plumbing-consumerd.png[]
1954 The _consumer daemon_, man:lttng-consumerd(8), is a daemon which shares
1955 ring buffers with user applications or with the LTTng kernel modules to
1956 collect trace data and send it to some location (on disk or to a
1957 <<lttng-relayd,relay daemon>> over the network). The consumer daemon
1958 is part of LTTng-tools.
1960 You do not start a consumer daemon manually: a consumer daemon is always
1961 spawned by a <<lttng-sessiond,session daemon>> as soon as you create an
1962 <<event,event rule>>, that is, before you start tracing. When you kill
1963 its owner session daemon, the consumer daemon also exits because it is
1964 the session daemon's child process. Command-line options of
1965 man:lttng-sessiond(8) target the consumer daemon process.
1967 There are up to two running consumer daemons per Unix user, whereas only
1968 one session daemon can run per user. This is because each process can be
1969 either 32-bit or 64-bit: if the target system runs a mixture of 32-bit
1970 and 64-bit processes, it is more efficient to have separate
1971 corresponding 32-bit and 64-bit consumer daemons. The root user is an
1972 exception: it can have up to _three_ running consumer daemons: 32-bit
1973 and 64-bit instances for its user applications, and one more
1974 reserved for collecting kernel trace data.
1982 image::plumbing-relayd.png[]
1984 The _relay daemon_, man:lttng-relayd(8), is a daemon acting as a bridge
1985 between remote session and consumer daemons, local trace files, and a
1986 remote live trace viewer. The relay daemon is part of LTTng-tools.
1988 The main purpose of the relay daemon is to implement a receiver of
1989 <<sending-trace-data-over-the-network,trace data over the network>>.
1990 This is useful when the target system does not have much file system
1991 space to record trace files locally.
1993 The relay daemon is also a server to which a
1994 <<lttng-live,live trace viewer>> can
1995 connect. The live trace viewer sends requests to the relay daemon to
1996 receive trace data as the target system emits events. The
1997 communication protocol is named _LTTng live_; it is used over TCP
2000 Note that you can start the relay daemon on the target system directly.
2001 This is the setup of choice when the use case is to view events as
2002 the target system emits them without the need of a remote system.
2006 == [[using-lttng]]Instrumentation
2008 There are many examples of tracing and monitoring in our everyday life:
2010 * You have access to real-time and historical weather reports and
2011 forecasts thanks to weather stations installed around the country.
2012 * You know your heart is safe thanks to an electrocardiogram.
2013 * You make sure not to drive your car too fast and to have enough fuel
2014 to reach your destination thanks to gauges visible on your dashboard.
2016 All the previous examples have something in common: they rely on
2017 **instruments**. Without the electrodes attached to the surface of your
2018 body's skin, cardiac monitoring is futile.
2020 LTTng, as a tracer, is no different from those real life examples. If
2021 you're about to trace a software system or, in other words, record its
2022 history of execution, you better have **instrumentation points** in the
2023 subject you're tracing, that is, the actual software.
2025 Various ways were developed to instrument a piece of software for LTTng
2026 tracing. The most straightforward one is to manually place
2027 instrumentation points, called _tracepoints_, in the software's source
2028 code. It is also possible to add instrumentation points dynamically in
2029 the Linux kernel <<domain,tracing domain>>.
2031 If you're only interested in tracing the Linux kernel, your
2032 instrumentation needs are probably already covered by LTTng's built-in
2033 <<lttng-modules,Linux kernel tracepoints>>. You may also wish to trace a
2034 user application which is already instrumented for LTTng tracing.
2035 In such cases, you can skip this whole section and read the topics of
2036 the <<controlling-tracing,Tracing control>> section.
2038 Many methods are available to instrument a piece of software for LTTng
2041 * <<c-application,User space instrumentation for C and $$C++$$
2043 * <<prebuilt-ust-helpers,Prebuilt user space tracing helpers>>.
2044 * <<java-application,User space Java agent>>.
2045 * <<python-application,User space Python agent>>.
2046 * <<proc-lttng-logger-abi,LTTng logger>>.
2047 * <<instrumenting-linux-kernel,LTTng kernel tracepoints>>.
2051 === [[cxx-application]]User space instrumentation for C and $$C++$$ applications
2053 The procedure to instrument a C or $$C++$$ user application with
2054 the <<lttng-ust,LTTng user space tracing library>>, `liblttng-ust`, is:
2056 . <<tracepoint-provider,Create the source files of a tracepoint provider
2058 . <<probing-the-application-source-code,Add tracepoints to
2059 the application's source code>>.
2060 . <<building-tracepoint-providers-and-user-application,Build and link
2061 a tracepoint provider package and the user application>>.
2063 If you need quick, man:printf(3)-like instrumentation, you can skip
2064 those steps and use <<tracef,`tracef()`>> or <<tracelog,`tracelog()`>>
2067 IMPORTANT: You need to <<installing-lttng,install>> LTTng-UST to
2068 instrument a user application with `liblttng-ust`.
2071 [[tracepoint-provider]]
2072 ==== Create the source files of a tracepoint provider package
2074 A _tracepoint provider_ is a set of compiled functions which provide
2075 **tracepoints** to an application, the type of instrumentation point
2076 supported by LTTng-UST. Those functions can emit events with
2077 user-defined fields and serialize those events as event records to one
2078 or more LTTng-UST <<channel,channel>> sub-buffers. The `tracepoint()`
2079 macro, which you <<probing-the-application-source-code,insert in a user
2080 application's source code>>, calls those functions.
2082 A _tracepoint provider package_ is an object file (`.o`) or a shared
2083 library (`.so`) which contains one or more tracepoint providers.
2084 Its source files are:
2086 * One or more <<tpp-header,tracepoint provider header>> (`.h`).
2087 * A <<tpp-source,tracepoint provider package source>> (`.c`).
2089 A tracepoint provider package is dynamically linked with `liblttng-ust`,
2090 the LTTng user space tracer, at run time.
2093 .User application linked with `liblttng-ust` and containing a tracepoint provider.
2094 image::ust-app.png[]
2096 NOTE: If you need quick, man:printf(3)-like instrumentation, you can
2097 skip creating and using a tracepoint provider and use
2098 <<tracef,`tracef()`>> or <<tracelog,`tracelog()`>> instead.
2102 ===== Create a tracepoint provider header file template
2104 A _tracepoint provider header file_ contains the tracepoint
2105 definitions of a tracepoint provider.
2107 To create a tracepoint provider header file:
2109 . Start from this template:
2113 .Tracepoint provider header file template (`.h` file extension).
2115 #undef TRACEPOINT_PROVIDER
2116 #define TRACEPOINT_PROVIDER provider_name
2118 #undef TRACEPOINT_INCLUDE
2119 #define TRACEPOINT_INCLUDE "./tp.h"
2121 #if !defined(_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
2124 #include <lttng/tracepoint.h>
2127 * Use TRACEPOINT_EVENT(), TRACEPOINT_EVENT_CLASS(),
2128 * TRACEPOINT_EVENT_INSTANCE(), and TRACEPOINT_LOGLEVEL() here.
2133 #include <lttng/tracepoint-event.h>
2139 * `provider_name` with the name of your tracepoint provider.
2140 * `"tp.h"` with the name of your tracepoint provider header file.
2142 . Below the `#include <lttng/tracepoint.h>` line, put your
2143 <<defining-tracepoints,tracepoint definitions>>.
2145 Your tracepoint provider name must be unique amongst all the possible
2146 tracepoint provider names used on the same target system. We
2147 suggest to include the name of your project or company in the name,
2148 for example, `org_lttng_my_project_tpp`.
2150 TIP: [[lttng-gen-tp]]You can use the man:lttng-gen-tp(1) tool to create
2151 this boilerplate for you. When using cmd:lttng-gen-tp, all you need to
2152 write are the <<defining-tracepoints,tracepoint definitions>>.
2155 [[defining-tracepoints]]
2156 ===== Create a tracepoint definition
2158 A _tracepoint definition_ defines, for a given tracepoint:
2160 * Its **input arguments**. They are the macro parameters that the
2161 `tracepoint()` macro accepts for this particular tracepoint
2162 in the user application's source code.
2163 * Its **output event fields**. They are the sources of event fields
2164 that form the payload of any event that the execution of the
2165 `tracepoint()` macro emits for this particular tracepoint.
2167 You can create a tracepoint definition by using the
2168 `TRACEPOINT_EVENT()` macro below the `#include <lttng/tracepoint.h>`
2170 <<tpp-header,tracepoint provider header file template>>.
2172 The syntax of the `TRACEPOINT_EVENT()` macro is:
2175 .`TRACEPOINT_EVENT()` macro syntax.
2178 /* Tracepoint provider name */
2181 /* Tracepoint name */
2184 /* Input arguments */
2189 /* Output event fields */
2198 * `provider_name` with your tracepoint provider name.
2199 * `tracepoint_name` with your tracepoint name.
2200 * `arguments` with the <<tpp-def-input-args,input arguments>>.
2201 * `fields` with the <<tpp-def-output-fields,output event field>>
2204 This tracepoint emits events named `provider_name:tracepoint_name`.
2207 .Event name's length limitation
2209 The concatenation of the tracepoint provider name and the
2210 tracepoint name must not exceed **254 characters**. If it does, the
2211 instrumented application compiles and runs, but LTTng throws multiple
2212 warnings and you could experience serious issues.
2215 [[tpp-def-input-args]]The syntax of the `TP_ARGS()` macro is:
2218 .`TP_ARGS()` macro syntax.
2227 * `type` with the C type of the argument.
2228 * `arg_name` with the argument name.
2230 You can repeat `type` and `arg_name` up to 10 times to have
2231 more than one argument.
2233 .`TP_ARGS()` usage with three arguments.
2245 The `TP_ARGS()` and `TP_ARGS(void)` forms are valid to create a
2246 tracepoint definition with no input arguments.
2248 [[tpp-def-output-fields]]The `TP_FIELDS()` macro contains a list of
2249 `ctf_*()` macros. Each `ctf_*()` macro defines one event field.
2250 See <<liblttng-ust-tp-fields,Tracepoint fields macros>> for a
2251 complete description of the available `ctf_*()` macros.
2252 A `ctf_*()` macro specifies the type, size, and byte order of
2255 Each `ctf_*()` macro takes an _argument expression_ parameter. This is a
2256 C expression that the tracer evalutes at the `tracepoint()` macro site
2257 in the application's source code. This expression provides a field's
2258 source of data. The argument expression can include input argument names
2259 listed in the `TP_ARGS()` macro.
2261 Each `ctf_*()` macro also takes a _field name_ parameter. Field names
2262 must be unique within a given tracepoint definition.
2264 Here's a complete tracepoint definition example:
2266 .Tracepoint definition.
2268 The following tracepoint definition defines a tracepoint which takes
2269 three input arguments and has four output event fields.
2273 #include "my-custom-structure.h"
2279 const struct my_custom_structure*, my_custom_structure,
2284 ctf_string(query_field, query)
2285 ctf_float(double, ratio_field, ratio)
2286 ctf_integer(int, recv_size, my_custom_structure->recv_size)
2287 ctf_integer(int, send_size, my_custom_structure->send_size)
2292 You can refer to this tracepoint definition with the `tracepoint()`
2293 macro in your application's source code like this:
2297 tracepoint(my_provider, my_tracepoint,
2298 my_structure, some_ratio, the_query);
2302 NOTE: The LTTng tracer only evaluates tracepoint arguments at run time
2303 if they satisfy an enabled <<event,event rule>>.
2306 [[using-tracepoint-classes]]
2307 ===== Use a tracepoint class
2309 A _tracepoint class_ is a class of tracepoints which share the same
2310 output event field definitions. A _tracepoint instance_ is one
2311 instance of such a defined tracepoint class, with its own tracepoint
2314 The <<defining-tracepoints,`TRACEPOINT_EVENT()` macro>> is actually a
2315 shorthand which defines both a tracepoint class and a tracepoint
2316 instance at the same time.
2318 When you build a tracepoint provider package, the C or $$C++$$ compiler
2319 creates one serialization function for each **tracepoint class**. A
2320 serialization function is responsible for serializing the event fields
2321 of a tracepoint to a sub-buffer when tracing.
2323 For various performance reasons, when your situation requires multiple
2324 tracepoint definitions with different names, but with the same event
2325 fields, we recommend that you manually create a tracepoint class
2326 and instantiate as many tracepoint instances as needed. One positive
2327 effect of such a design, amongst other advantages, is that all
2328 tracepoint instances of the same tracepoint class reuse the same
2329 serialization function, thus reducing
2330 https://en.wikipedia.org/wiki/Cache_pollution[cache pollution].
2332 .Use a tracepoint class and tracepoint instances.
2334 Consider the following three tracepoint definitions:
2346 ctf_integer(int, userid, userid)
2347 ctf_integer(size_t, len, len)
2359 ctf_integer(int, userid, userid)
2360 ctf_integer(size_t, len, len)
2372 ctf_integer(int, userid, userid)
2373 ctf_integer(size_t, len, len)
2378 In this case, we create three tracepoint classes, with one implicit
2379 tracepoint instance for each of them: `get_account`, `get_settings`, and
2380 `get_transaction`. However, they all share the same event field names
2381 and types. Hence three identical, yet independent serialization
2382 functions are created when you build the tracepoint provider package.
2384 A better design choice is to define a single tracepoint class and three
2385 tracepoint instances:
2389 /* The tracepoint class */
2390 TRACEPOINT_EVENT_CLASS(
2391 /* Tracepoint provider name */
2394 /* Tracepoint class name */
2397 /* Input arguments */
2403 /* Output event fields */
2405 ctf_integer(int, userid, userid)
2406 ctf_integer(size_t, len, len)
2410 /* The tracepoint instances */
2411 TRACEPOINT_EVENT_INSTANCE(
2412 /* Tracepoint provider name */
2415 /* Tracepoint class name */
2418 /* Tracepoint name */
2421 /* Input arguments */
2427 TRACEPOINT_EVENT_INSTANCE(
2436 TRACEPOINT_EVENT_INSTANCE(
2449 [[assigning-log-levels]]
2450 ===== Assign a log level to a tracepoint definition
2452 You can assign an optional _log level_ to a
2453 <<defining-tracepoints,tracepoint definition>>.
2455 Assigning different levels of severity to tracepoint definitions can
2456 be useful: when you <<enabling-disabling-events,create an event rule>>,
2457 you can target tracepoints having a log level as severe as a specific
2460 The concept of LTTng-UST log levels is similar to the levels found
2461 in typical logging frameworks:
2463 * In a logging framework, the log level is given by the function
2464 or method name you use at the log statement site: `debug()`,
2465 `info()`, `warn()`, `error()`, and so on.
2466 * In LTTng-UST, you statically assign the log level to a tracepoint
2467 definition; any `tracepoint()` macro invocation which refers to
2468 this definition has this log level.
2470 You can assign a log level to a tracepoint definition with the
2471 `TRACEPOINT_LOGLEVEL()` macro. You must use this macro _after_ the
2472 <<defining-tracepoints,`TRACEPOINT_EVENT()`>> or
2473 <<using-tracepoint-classes,`TRACEPOINT_INSTANCE()`>> macro for a given
2476 The syntax of the `TRACEPOINT_LOGLEVEL()` macro is:
2479 .`TRACEPOINT_LOGLEVEL()` macro syntax.
2481 TRACEPOINT_LOGLEVEL(provider_name, tracepoint_name, log_level)
2486 * `provider_name` with the tracepoint provider name.
2487 * `tracepoint_name` with the tracepoint name.
2488 * `log_level` with the log level to assign to the tracepoint
2489 definition named `tracepoint_name` in the `provider_name`
2490 tracepoint provider.
2492 See <<liblttng-ust-tracepoint-loglevel,Tracepoint log levels>> for
2493 a list of available log level names.
2495 .Assign the `TRACE_DEBUG_UNIT` log level to a tracepoint definition.
2499 /* Tracepoint definition */
2508 ctf_integer(int, userid, userid)
2509 ctf_integer(size_t, len, len)
2513 /* Log level assignment */
2514 TRACEPOINT_LOGLEVEL(my_app, get_transaction, TRACE_DEBUG_UNIT)
2520 ===== Create a tracepoint provider package source file
2522 A _tracepoint provider package source file_ is a C source file which
2523 includes a <<tpp-header,tracepoint provider header file>> to expand its
2524 macros into event serialization and other functions.
2526 You can always use the following tracepoint provider package source
2530 .Tracepoint provider package source file template.
2532 #define TRACEPOINT_CREATE_PROBES
2537 Replace `tp.h` with the name of your <<tpp-header,tracepoint provider
2538 header file>> name. You may also include more than one tracepoint
2539 provider header file here to create a tracepoint provider package
2540 holding more than one tracepoint providers.
2543 [[probing-the-application-source-code]]
2544 ==== Add tracepoints to an application's source code
2546 Once you <<tpp-header,create a tracepoint provider header file>>, you
2547 can use the `tracepoint()` macro in your application's
2548 source code to insert the tracepoints that this header
2549 <<defining-tracepoints,defines>>.
2551 The `tracepoint()` macro takes at least two parameters: the tracepoint
2552 provider name and the tracepoint name. The corresponding tracepoint
2553 definition defines the other parameters.
2555 .`tracepoint()` usage.
2557 The following <<defining-tracepoints,tracepoint definition>> defines a
2558 tracepoint which takes two input arguments and has two output event
2562 .Tracepoint provider header file.
2564 #include "my-custom-structure.h"
2571 const char*, cmd_name
2574 ctf_string(cmd_name, cmd_name)
2575 ctf_integer(int, number_of_args, argc)
2580 You can refer to this tracepoint definition with the `tracepoint()`
2581 macro in your application's source code like this:
2584 .Application's source file.
2588 int main(int argc, char* argv[])
2590 tracepoint(my_provider, my_tracepoint, argc, argv[0]);
2596 Note how the application's source code includes
2597 the tracepoint provider header file containing the tracepoint
2598 definitions to use, path:{tp.h}.
2601 .`tracepoint()` usage with a complex tracepoint definition.
2603 Consider this complex tracepoint definition, where multiple event
2604 fields refer to the same input arguments in their argument expression
2608 .Tracepoint provider header file.
2610 /* For `struct stat` */
2611 #include <sys/types.h>
2612 #include <sys/stat.h>
2624 ctf_integer(int, my_constant_field, 23 + 17)
2625 ctf_integer(int, my_int_arg_field, my_int_arg)
2626 ctf_integer(int, my_int_arg_field2, my_int_arg * my_int_arg)
2627 ctf_integer(int, sum4_field, my_str_arg[0] + my_str_arg[1] +
2628 my_str_arg[2] + my_str_arg[3])
2629 ctf_string(my_str_arg_field, my_str_arg)
2630 ctf_integer_hex(off_t, size_field, st->st_size)
2631 ctf_float(double, size_dbl_field, (double) st->st_size)
2632 ctf_sequence_text(char, half_my_str_arg_field, my_str_arg,
2633 size_t, strlen(my_str_arg) / 2)
2638 You can refer to this tracepoint definition with the `tracepoint()`
2639 macro in your application's source code like this:
2642 .Application's source file.
2644 #define TRACEPOINT_DEFINE
2651 stat("/etc/fstab", &s);
2652 tracepoint(my_provider, my_tracepoint, 23, "Hello, World!", &s);
2658 If you look at the event record that LTTng writes when tracing this
2659 program, assuming the file size of path:{/etc/fstab} is 301{nbsp}bytes,
2660 it should look like this:
2662 .Event record fields
2664 |Field's name |Field's value
2665 |`my_constant_field` |40
2666 |`my_int_arg_field` |23
2667 |`my_int_arg_field2` |529
2669 |`my_str_arg_field` |`Hello, World!`
2670 |`size_field` |0x12d
2671 |`size_dbl_field` |301.0
2672 |`half_my_str_arg_field` |`Hello,`
2676 Sometimes, the arguments you pass to `tracepoint()` are expensive to
2677 compute--they use the call stack, for example. To avoid this
2678 computation when the tracepoint is disabled, you can use the
2679 `tracepoint_enabled()` and `do_tracepoint()` macros.
2681 The syntax of the `tracepoint_enabled()` and `do_tracepoint()` macros
2685 .`tracepoint_enabled()` and `do_tracepoint()` macros syntax.
2687 tracepoint_enabled(provider_name, tracepoint_name)
2688 do_tracepoint(provider_name, tracepoint_name, ...)
2693 * `provider_name` with the tracepoint provider name.
2694 * `tracepoint_name` with the tracepoint name.
2696 `tracepoint_enabled()` returns a non-zero value if the tracepoint named
2697 `tracepoint_name` from the provider named `provider_name` is enabled
2700 `do_tracepoint()` is like `tracepoint()`, except that it doesn't check
2701 if the tracepoint is enabled. Using `tracepoint()` with
2702 `tracepoint_enabled()` is dangerous since `tracepoint()` also contains
2703 the `tracepoint_enabled()` check, thus a race condition is
2704 possible in this situation:
2707 .Possible race condition when using `tracepoint_enabled()` with `tracepoint()`.
2709 if (tracepoint_enabled(my_provider, my_tracepoint)) {
2710 stuff = prepare_stuff();
2713 tracepoint(my_provider, my_tracepoint, stuff);
2716 If the tracepoint is enabled after the condition, then `stuff` is not
2717 prepared: the emitted event will either contain wrong data, or the whole
2718 application could crash (segmentation fault, for example).
2720 NOTE: Neither `tracepoint_enabled()` nor `do_tracepoint()` have an
2721 `STAP_PROBEV()` call. If you need it, you must emit
2725 [[building-tracepoint-providers-and-user-application]]
2726 ==== Build and link a tracepoint provider package and an application
2728 Once you have one or more <<tpp-header,tracepoint provider header
2729 files>> and a <<tpp-source,tracepoint provider package source file>>,
2730 you can create the tracepoint provider package by compiling its source
2731 file. From here, multiple build and run scenarios are possible. The
2732 following table shows common application and library configurations
2733 along with the required command lines to achieve them.
2735 In the following diagrams, we use the following file names:
2738 Executable application.
2741 Application's object file.
2744 Tracepoint provider package object file.
2747 Tracepoint provider package archive file.
2750 Tracepoint provider package shared object file.
2753 User library object file.
2756 User library shared object file.
2758 We use the following symbols in the diagrams of table below:
2761 .Symbols used in the build scenario diagrams.
2762 image::ust-sit-symbols.png[]
2764 We assume that path:{.} is part of the env:LD_LIBRARY_PATH environment
2765 variable in the following instructions.
2767 [role="growable ust-scenarios",cols="asciidoc,asciidoc"]
2768 .Common tracepoint provider package scenarios.
2770 |Scenario |Instructions
2773 The instrumented application is statically linked with
2774 the tracepoint provider package object.
2776 image::ust-sit+app-linked-with-tp-o+app-instrumented.png[]
2779 include::../common/ust-sit-step-tp-o.txt[]
2781 To build the instrumented application:
2783 . In path:{app.c}, before including path:{tpp.h}, add the following line:
2788 #define TRACEPOINT_DEFINE
2792 . Compile the application source file:
2801 . Build the application:
2806 gcc -o app app.o tpp.o -llttng-ust -ldl
2810 To run the instrumented application:
2812 * Start the application:
2822 The instrumented application is statically linked with the
2823 tracepoint provider package archive file.
2825 image::ust-sit+app-linked-with-tp-a+app-instrumented.png[]
2828 To create the tracepoint provider package archive file:
2830 . Compile the <<tpp-source,tracepoint provider package source file>>:
2839 . Create the tracepoint provider package archive file:
2848 To build the instrumented application:
2850 . In path:{app.c}, before including path:{tpp.h}, add the following line:
2855 #define TRACEPOINT_DEFINE
2859 . Compile the application source file:
2868 . Build the application:
2873 gcc -o app app.o tpp.a -llttng-ust -ldl
2877 To run the instrumented application:
2879 * Start the application:
2889 The instrumented application is linked with the tracepoint provider
2890 package shared object.
2892 image::ust-sit+app-linked-with-tp-so+app-instrumented.png[]
2895 include::../common/ust-sit-step-tp-so.txt[]
2897 To build the instrumented application:
2899 . In path:{app.c}, before including path:{tpp.h}, add the following line:
2904 #define TRACEPOINT_DEFINE
2908 . Compile the application source file:
2917 . Build the application:
2922 gcc -o app app.o -ldl -L. -ltpp
2926 To run the instrumented application:
2928 * Start the application:
2938 The tracepoint provider package shared object is preloaded before the
2939 instrumented application starts.
2941 image::ust-sit+tp-so-preloaded+app-instrumented.png[]
2944 include::../common/ust-sit-step-tp-so.txt[]
2946 To build the instrumented application:
2948 . In path:{app.c}, before including path:{tpp.h}, add the
2954 #define TRACEPOINT_DEFINE
2955 #define TRACEPOINT_PROBE_DYNAMIC_LINKAGE
2959 . Compile the application source file:
2968 . Build the application:
2973 gcc -o app app.o -ldl
2977 To run the instrumented application with tracing support:
2979 * Preload the tracepoint provider package shared object and
2980 start the application:
2985 LD_PRELOAD=./libtpp.so ./app
2989 To run the instrumented application without tracing support:
2991 * Start the application:
3001 The instrumented application dynamically loads the tracepoint provider
3002 package shared object.
3004 See the <<dlclose-warning,warning about `dlclose()`>>.
3006 image::ust-sit+app-dlopens-tp-so+app-instrumented.png[]
3009 include::../common/ust-sit-step-tp-so.txt[]
3011 To build the instrumented application:
3013 . In path:{app.c}, before including path:{tpp.h}, add the
3019 #define TRACEPOINT_DEFINE
3020 #define TRACEPOINT_PROBE_DYNAMIC_LINKAGE
3024 . Compile the application source file:
3033 . Build the application:
3038 gcc -o app app.o -ldl
3042 To run the instrumented application:
3044 * Start the application:
3054 The application is linked with the instrumented user library.
3056 The instrumented user library is statically linked with the tracepoint
3057 provider package object file.
3059 image::ust-sit+app-linked-with-lib+lib-linked-with-tp-o+lib-instrumented.png[]
3062 include::../common/ust-sit-step-tp-o-fpic.txt[]
3064 To build the instrumented user library:
3066 . In path:{emon.c}, before including path:{tpp.h}, add the
3072 #define TRACEPOINT_DEFINE
3076 . Compile the user library source file:
3081 gcc -I. -fpic -c emon.c
3085 . Build the user library shared object:
3090 gcc -shared -o libemon.so emon.o tpp.o -llttng-ust -ldl
3094 To build the application:
3096 . Compile the application source file:
3105 . Build the application:
3110 gcc -o app app.o -L. -lemon
3114 To run the application:
3116 * Start the application:
3126 The application is linked with the instrumented user library.
3128 The instrumented user library is linked with the tracepoint provider
3129 package shared object.
3131 image::ust-sit+app-linked-with-lib+lib-linked-with-tp-so+lib-instrumented.png[]
3134 include::../common/ust-sit-step-tp-so.txt[]
3136 To build the instrumented user library:
3138 . In path:{emon.c}, before including path:{tpp.h}, add the
3144 #define TRACEPOINT_DEFINE
3148 . Compile the user library source file:
3153 gcc -I. -fpic -c emon.c
3157 . Build the user library shared object:
3162 gcc -shared -o libemon.so emon.o -ldl -L. -ltpp
3166 To build the application:
3168 . Compile the application source file:
3177 . Build the application:
3182 gcc -o app app.o -L. -lemon
3186 To run the application:
3188 * Start the application:
3198 The tracepoint provider package shared object is preloaded before the
3201 The application is linked with the instrumented user library.
3203 image::ust-sit+tp-so-preloaded+app-linked-with-lib+lib-instrumented.png[]
3206 include::../common/ust-sit-step-tp-so.txt[]
3208 To build the instrumented user library:
3210 . In path:{emon.c}, before including path:{tpp.h}, add the
3216 #define TRACEPOINT_DEFINE
3217 #define TRACEPOINT_PROBE_DYNAMIC_LINKAGE
3221 . Compile the user library source file:
3226 gcc -I. -fpic -c emon.c
3230 . Build the user library shared object:
3235 gcc -shared -o libemon.so emon.o -ldl
3239 To build the application:
3241 . Compile the application source file:
3250 . Build the application:
3255 gcc -o app app.o -L. -lemon
3259 To run the application with tracing support:
3261 * Preload the tracepoint provider package shared object and
3262 start the application:
3267 LD_PRELOAD=./libtpp.so ./app
3271 To run the application without tracing support:
3273 * Start the application:
3283 The application is linked with the instrumented user library.
3285 The instrumented user library dynamically loads the tracepoint provider
3286 package shared object.
3288 See the <<dlclose-warning,warning about `dlclose()`>>.
3290 image::ust-sit+app-linked-with-lib+lib-dlopens-tp-so+lib-instrumented.png[]
3293 include::../common/ust-sit-step-tp-so.txt[]
3295 To build the instrumented user library:
3297 . In path:{emon.c}, before including path:{tpp.h}, add the
3303 #define TRACEPOINT_DEFINE
3304 #define TRACEPOINT_PROBE_DYNAMIC_LINKAGE
3308 . Compile the user library source file:
3313 gcc -I. -fpic -c emon.c
3317 . Build the user library shared object:
3322 gcc -shared -o libemon.so emon.o -ldl
3326 To build the application:
3328 . Compile the application source file:
3337 . Build the application:
3342 gcc -o app app.o -L. -lemon
3346 To run the application:
3348 * Start the application:
3358 The application dynamically loads the instrumented user library.
3360 The instrumented user library is linked with the tracepoint provider
3361 package shared object.
3363 See the <<dlclose-warning,warning about `dlclose()`>>.
3365 image::ust-sit+app-dlopens-lib+lib-linked-with-tp-so+lib-instrumented.png[]
3368 include::../common/ust-sit-step-tp-so.txt[]
3370 To build the instrumented user library:
3372 . In path:{emon.c}, before including path:{tpp.h}, add the
3378 #define TRACEPOINT_DEFINE
3382 . Compile the user library source file:
3387 gcc -I. -fpic -c emon.c
3391 . Build the user library shared object:
3396 gcc -shared -o libemon.so emon.o -ldl -L. -ltpp
3400 To build the application:
3402 . Compile the application source file:
3411 . Build the application:
3416 gcc -o app app.o -ldl -L. -lemon
3420 To run the application:
3422 * Start the application:
3432 The application dynamically loads the instrumented user library.
3434 The instrumented user library dynamically loads the tracepoint provider
3435 package shared object.
3437 See the <<dlclose-warning,warning about `dlclose()`>>.
3439 image::ust-sit+app-dlopens-lib+lib-dlopens-tp-so+lib-instrumented.png[]
3442 include::../common/ust-sit-step-tp-so.txt[]
3444 To build the instrumented user library:
3446 . In path:{emon.c}, before including path:{tpp.h}, add the
3452 #define TRACEPOINT_DEFINE
3453 #define TRACEPOINT_PROBE_DYNAMIC_LINKAGE
3457 . Compile the user library source file:
3462 gcc -I. -fpic -c emon.c
3466 . Build the user library shared object:
3471 gcc -shared -o libemon.so emon.o -ldl
3475 To build the application:
3477 . Compile the application source file:
3486 . Build the application:
3491 gcc -o app app.o -ldl -L. -lemon
3495 To run the application:
3497 * Start the application:
3507 The tracepoint provider package shared object is preloaded before the
3510 The application dynamically loads the instrumented user library.
3512 image::ust-sit+tp-so-preloaded+app-dlopens-lib+lib-instrumented.png[]
3515 include::../common/ust-sit-step-tp-so.txt[]
3517 To build the instrumented user library:
3519 . In path:{emon.c}, before including path:{tpp.h}, add the
3525 #define TRACEPOINT_DEFINE
3526 #define TRACEPOINT_PROBE_DYNAMIC_LINKAGE
3530 . Compile the user library source file:
3535 gcc -I. -fpic -c emon.c
3539 . Build the user library shared object:
3544 gcc -shared -o libemon.so emon.o -ldl
3548 To build the application:
3550 . Compile the application source file:
3559 . Build the application:
3564 gcc -o app app.o -L. -lemon
3568 To run the application with tracing support:
3570 * Preload the tracepoint provider package shared object and
3571 start the application:
3576 LD_PRELOAD=./libtpp.so ./app
3580 To run the application without tracing support:
3582 * Start the application:
3592 The application is statically linked with the tracepoint provider
3593 package object file.
3595 The application is linked with the instrumented user library.
3597 image::ust-sit+app-linked-with-tp-o+app-linked-with-lib+lib-instrumented.png[]
3600 include::../common/ust-sit-step-tp-o.txt[]
3602 To build the instrumented user library:
3604 . In path:{emon.c}, before including path:{tpp.h}, add the
3610 #define TRACEPOINT_DEFINE
3614 . Compile the user library source file:
3619 gcc -I. -fpic -c emon.c
3623 . Build the user library shared object:
3628 gcc -shared -o libemon.so emon.o
3632 To build the application:
3634 . Compile the application source file:
3643 . Build the application:
3648 gcc -o app app.o tpp.o -llttng-ust -ldl -L. -lemon
3652 To run the instrumented application:
3654 * Start the application:
3664 The application is statically linked with the tracepoint provider
3665 package object file.
3667 The application dynamically loads the instrumented user library.
3669 image::ust-sit+app-linked-with-tp-o+app-dlopens-lib+lib-instrumented.png[]
3672 include::../common/ust-sit-step-tp-o.txt[]
3674 To build the application:
3676 . In path:{app.c}, before including path:{tpp.h}, add the following line:
3681 #define TRACEPOINT_DEFINE
3685 . Compile the application source file:
3694 . Build the application:
3699 gcc -Wl,--export-dynamic -o app app.o tpp.o \
3704 The `--export-dynamic` option passed to the linker is necessary for the
3705 dynamically loaded library to ``see'' the tracepoint symbols defined in
3708 To build the instrumented user library:
3710 . Compile the user library source file:
3715 gcc -I. -fpic -c emon.c
3719 . Build the user library shared object:
3724 gcc -shared -o libemon.so emon.o
3728 To run the application:
3730 * Start the application:
3742 .Do not use man:dlclose(3) on a tracepoint provider package
3744 Never use man:dlclose(3) on any shared object which:
3746 * Is linked with, statically or dynamically, a tracepoint provider
3748 * Calls man:dlopen(3) itself to dynamically open a tracepoint provider
3749 package shared object.
3751 This is currently considered **unsafe** due to a lack of reference
3752 counting from LTTng-UST to the shared object.
3754 A known workaround (available since glibc 2.2) is to use the
3755 `RTLD_NODELETE` flag when calling man:dlopen(3) initially. This has the
3756 effect of not unloading the loaded shared object, even if man:dlclose(3)
3759 You can also preload the tracepoint provider package shared object with
3760 the env:LD_PRELOAD environment variable to overcome this limitation.
3764 [[using-lttng-ust-with-daemons]]
3765 ===== Use noch:{LTTng-UST} with daemons
3767 If your instrumented application calls man:fork(2), man:clone(2),
3768 or BSD's man:rfork(2), without a following man:exec(3)-family
3769 system call, you must preload the path:{liblttng-ust-fork.so} shared
3770 object when starting the application.
3774 LD_PRELOAD=liblttng-ust-fork.so ./my-app
3777 If your tracepoint provider package is
3778 a shared library which you also preload, you must put both
3779 shared objects in env:LD_PRELOAD:
3783 LD_PRELOAD=liblttng-ust-fork.so:/path/to/tp.so ./my-app
3787 [[lttng-ust-pkg-config]]
3788 ===== Use noch:{pkg-config}
3790 On some distributions, LTTng-UST ships with a
3791 https://www.freedesktop.org/wiki/Software/pkg-config/[pkg-config]
3792 metadata file. If this is your case, then you can use cmd:pkg-config to
3793 build an application on the command line:
3797 gcc -o my-app my-app.o tp.o $(pkg-config --cflags --libs lttng-ust)
3801 [[instrumenting-32-bit-app-on-64-bit-system]]
3802 ===== [[advanced-instrumenting-techniques]]Build a 32-bit instrumented application for a 64-bit target system
3804 In order to trace a 32-bit application running on a 64-bit system,
3805 LTTng must use a dedicated 32-bit
3806 <<lttng-consumerd,consumer daemon>>.
3808 The following steps show how to build and install a 32-bit consumer
3809 daemon, which is _not_ part of the default 64-bit LTTng build, how to
3810 build and install the 32-bit LTTng-UST libraries, and how to build and
3811 link an instrumented 32-bit application in that context.
3813 To build a 32-bit instrumented application for a 64-bit target system,
3814 assuming you have a fresh target system with no installed Userspace RCU
3817 . Download, build, and install a 32-bit version of Userspace RCU:
3823 wget http://lttng.org/files/urcu/userspace-rcu-latest-0.9.tar.bz2 &&
3824 tar -xf userspace-rcu-latest-0.9.tar.bz2 &&
3825 cd userspace-rcu-0.9.* &&
3826 ./configure --libdir=/usr/local/lib32 CFLAGS=-m32 &&
3828 sudo make install &&
3833 . Using your distribution's package manager, or from source, install
3834 the following 32-bit versions of the following dependencies of
3835 LTTng-tools and LTTng-UST:
3838 * https://sourceforge.net/projects/libuuid/[libuuid]
3839 * http://directory.fsf.org/wiki/Popt[popt]
3840 * http://www.xmlsoft.org/[libxml2]
3843 . Download, build, and install a 32-bit version of the latest
3844 LTTng-UST{nbsp}{revision}:
3850 wget http://lttng.org/files/lttng-ust/lttng-ust-latest-2.7.tar.bz2 &&
3851 tar -xf lttng-ust-latest-2.7.tar.bz2 &&
3852 cd lttng-ust-2.7.* &&
3853 ./configure --libdir=/usr/local/lib32 \
3854 CFLAGS=-m32 CXXFLAGS=-m32 \
3855 LDFLAGS='-L/usr/local/lib32 -L/usr/lib32' &&
3857 sudo make install &&
3864 Depending on your distribution,
3865 32-bit libraries could be installed at a different location than
3866 `/usr/lib32`. For example, Debian is known to install
3867 some 32-bit libraries in `/usr/lib/i386-linux-gnu`.
3869 In this case, make sure to set `LDFLAGS` to all the
3870 relevant 32-bit library paths, for example:
3874 LDFLAGS='-L/usr/lib/i386-linux-gnu -L/usr/lib32'
3878 . Download the latest LTTng-tools{nbsp}{revision}, build, and install
3879 the 32-bit consumer daemon:
3885 wget http://lttng.org/files/lttng-tools/lttng-tools-latest-2.7.tar.bz2 &&
3886 tar -xf lttng-tools-latest-2.7.tar.bz2 &&
3887 cd lttng-tools-2.7.* &&
3888 ./configure --libdir=/usr/local/lib32 CFLAGS=-m32 CXXFLAGS=-m32 \
3889 LDFLAGS='-L/usr/local/lib32 -L/usr/lib32' &&
3891 cd src/bin/lttng-consumerd &&
3892 sudo make install &&
3897 . From your distribution or from source,
3898 <<installing-lttng,install>> the 64-bit versions of
3899 LTTng-UST and Userspace RCU.
3900 . Download, build, and install the 64-bit version of the
3901 latest LTTng-tools{nbsp}{revision}:
3907 wget http://lttng.org/files/lttng-tools/lttng-tools-latest-2.7.tar.bz2 &&
3908 tar -xf lttng-tools-latest-2.7.tar.bz2 &&
3909 cd lttng-tools-2.7.* &&
3910 ./configure --with-consumerd32-libdir=/usr/local/lib32 \
3911 --with-consumerd32-bin=/usr/local/lib32/lttng/libexec/lttng-consumerd &&
3913 sudo make install &&
3918 . Pass the following options to man:gcc(1), man:g++(1), or man:clang(1)
3919 when linking your 32-bit application:
3922 -m32 -L/usr/lib32 -L/usr/local/lib32 \
3923 -Wl,-rpath,/usr/lib32,-rpath,/usr/local/lib32
3926 For example, let's rebuild the quick start example in
3927 <<tracing-your-own-user-application,Trace a user application>> as an
3928 instrumented 32-bit application:
3933 gcc -m32 -c -I. hello-tp.c
3935 gcc -m32 -o hello hello.o hello-tp.o \
3936 -L/usr/lib32 -L/usr/local/lib32 \
3937 -Wl,-rpath,/usr/lib32,-rpath,/usr/local/lib32 \
3942 No special action is required to execute the 32-bit application and
3943 to trace it: use the command-line man:lttng(1) tool as usual.
3950 `tracef()` is a small LTTng-UST API designed for quick,
3951 man:printf(3)-like instrumentation without the burden of
3952 <<tracepoint-provider,creating>> and
3953 <<building-tracepoint-providers-and-user-application,building>>
3954 a tracepoint provider package.
3956 To use `tracef()` in your application:
3958 . In the C or C++ source files where you need to use `tracef()`,
3959 include `<lttng/tracef.h>`:
3964 #include <lttng/tracef.h>
3968 . In the application's source code, use `tracef()` like you would use
3976 tracef("my message: %d (%s)", my_integer, my_string);
3982 . Link your application with `liblttng-ust`:
3987 gcc -o app app.c -llttng-ust
3991 To trace the events that `tracef()` calls emit:
3993 * <<enabling-disabling-events,Create an event rule>> which matches the
3994 `lttng_ust_tracef:*` event name:
3999 lttng enable-event --userspace 'lttng_ust_tracef:*'
4004 .Limitations of `tracef()`
4006 The `tracef()` utility function was developed to make user space tracing
4007 super simple, albeit with notable disadvantages compared to
4008 <<defining-tracepoints,user-defined tracepoints>>:
4010 * All the emitted events have the same tracepoint provider and
4011 tracepoint names, respectively `lttng_ust_tracef` and `event`.
4012 * There is no static type checking.
4013 * The only event record field you actually get, named `msg`, is a string
4014 potentially containing the values you passed to `tracef()`
4015 using your own format string. This also means that you cannot filter
4016 events with a custom expression at run time because there are no
4018 * Since `tracef()` uses the C standard library's man:vasprintf(3)
4019 function behind the scenes to format the strings at run time, its
4020 expected performance is lower than with user-defined tracepoints,
4021 which do not require a conversion to a string.
4023 Taking this into consideration, `tracef()` is useful for some quick
4024 prototyping and debugging, but you should not consider it for any
4025 permanent and serious applicative instrumentation.
4031 ==== Use `tracelog()`
4033 The `tracelog()` API is very similar to <<tracef,`tracef()`>>, with
4034 the difference that it accepts an additional log level parameter.
4036 The goal of `tracelog()` is to ease the migration from logging to
4039 To use `tracelog()` in your application:
4041 . In the C or C++ source files where you need to use `tracelog()`,
4042 include `<lttng/tracelog.h>`:
4047 #include <lttng/tracelog.h>
4051 . In the application's source code, use `tracelog()` like you would use
4052 man:printf(3), except for the first parameter which is the log
4060 tracelog(TRACE_WARNING, "my message: %d (%s)",
4061 my_integer, my_string);
4067 See <<liblttng-ust-tracepoint-loglevel,Tracepoint log levels>> for
4068 a list of available log level names.
4070 . Link your application with `liblttng-ust`:
4075 gcc -o app app.c -llttng-ust
4079 To trace the events that `tracelog()` calls emit with a log level
4080 _as severe as_ a specific log level:
4082 * <<enabling-disabling-events,Create an event rule>> which matches the
4083 `lttng_ust_tracelog:*` event name and a minimum level
4089 lttng enable-event --userspace 'lttng_ust_tracelog:*'
4090 --loglevel=TRACE_WARNING
4094 To trace the events that `tracelog()` calls emit with a
4095 _specific log level_:
4097 * Create an event rule which matches the `lttng_ust_tracelog:*`
4098 event name and a specific log level:
4103 lttng enable-event --userspace 'lttng_ust_tracelog:*'
4104 --loglevel-only=TRACE_INFO
4109 [[prebuilt-ust-helpers]]
4110 === Prebuilt user space tracing helpers
4112 The LTTng-UST package provides a few helpers in the form or preloadable
4113 shared objects which automatically instrument system functions and
4116 The helper shared objects are normally found in dir:{/usr/lib}. If you
4117 built LTTng-UST <<building-from-source,from source>>, they are probably
4118 located in dir:{/usr/local/lib}.
4120 The installed user space tracing helpers in LTTng-UST{nbsp}{revision}
4123 path:{liblttng-ust-libc-wrapper.so}::
4124 path:{liblttng-ust-pthread-wrapper.so}::
4125 <<liblttng-ust-libc-pthread-wrapper,C{nbsp}standard library
4126 memory and POSIX threads function tracing>>.
4128 path:{liblttng-ust-cyg-profile.so}::
4129 path:{liblttng-ust-cyg-profile-fast.so}::
4130 <<liblttng-ust-cyg-profile,Function entry and exit tracing>>.
4132 path:{liblttng-ust-dl.so}::
4133 <<liblttng-ust-dl,Dynamic linker tracing>>.
4135 To use a user space tracing helper with any user application:
4137 * Preload the helper shared object when you start the application:
4142 LD_PRELOAD=liblttng-ust-libc-wrapper.so my-app
4146 You can preload more than one helper:
4151 LD_PRELOAD=liblttng-ust-libc-wrapper.so:liblttng-ust-dl.so my-app
4157 [[liblttng-ust-libc-pthread-wrapper]]
4158 ==== Instrument C standard library memory and POSIX threads functions
4160 The path:{liblttng-ust-libc-wrapper.so} and
4161 path:{liblttng-ust-pthread-wrapper.so} helpers
4162 add instrumentation to some C standard library and POSIX
4166 .Functions instrumented by preloading path:{liblttng-ust-libc-wrapper.so}.
4168 |TP provider name |TP name |Instrumented function
4170 .6+|`lttng_ust_libc` |`malloc` |man:malloc(3)
4171 |`calloc` |man:calloc(3)
4172 |`realloc` |man:realloc(3)
4173 |`free` |man:free(3)
4174 |`memalign` |man:memalign(3)
4175 |`posix_memalign` |man:posix_memalign(3)
4179 .Functions instrumented by preloading path:{liblttng-ust-pthread-wrapper.so}.
4181 |TP provider name |TP name |Instrumented function
4183 .4+|`lttng_ust_pthread` |`pthread_mutex_lock_req` |man:pthread_mutex_lock(3p) (request time)
4184 |`pthread_mutex_lock_acq` |man:pthread_mutex_lock(3p) (acquire time)
4185 |`pthread_mutex_trylock` |man:pthread_mutex_trylock(3p)
4186 |`pthread_mutex_unlock` |man:pthread_mutex_unlock(3p)
4189 When you preload the shared object, it replaces the functions listed
4190 in the previous tables by wrappers which contain tracepoints and call
4191 the replaced functions.
4194 [[liblttng-ust-cyg-profile]]
4195 ==== Instrument function entry and exit
4197 The path:{liblttng-ust-cyg-profile*.so} helpers can add instrumentation
4198 to the entry and exit points of functions.
4200 man:gcc(1) and man:clang(1) have an option named
4201 https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html[`-finstrument-functions`]
4202 which generates instrumentation calls for entry and exit to functions.
4203 The LTTng-UST function tracing helpers,
4204 path:{liblttng-ust-cyg-profile.so} and
4205 path:{liblttng-ust-cyg-profile-fast.so}, take advantage of this feature
4206 to add tracepoints to the two generated functions (which contain
4207 `cyg_profile` in their names, hence the helper's name).
4209 To use the LTTng-UST function tracing helper, the source files to
4210 instrument must be built using the `-finstrument-functions` compiler
4213 There are two versions of the LTTng-UST function tracing helper:
4215 * **path:{liblttng-ust-cyg-profile-fast.so}** is a lightweight variant
4216 that you should only use when it can be _guaranteed_ that the
4217 complete event stream is recorded without any lost event record.
4218 Any kind of duplicate information is left out.
4220 This version contains the following tracepoints:
4224 .Points instrumented by preloading path:{liblttng-ust-cyg-profile-fast.so}.
4226 |TP provider name |TP name |Instrumented points
4228 .2+|`lttng_ust_cyg_profile_fast`
4234 Address of called function.
4241 Assuming no event record is lost, having only the function addresses on
4242 entry is enough to create a call graph, since an event record always
4243 contains the ID of the CPU that generated it.
4245 You can use a tool like man:addr2line(1) to convert function addresses
4246 back to source file names and line numbers.
4248 * **path:{liblttng-ust-cyg-profile.so}** is a more robust variant
4249 which also works in use cases where event records might get discarded or
4250 not recorded from application startup.
4251 In these cases, the trace analyzer needs more information to be
4252 able to reconstruct the program flow.
4254 This version contains the following tracepoints:
4258 .Points instrumented by preloading path:{liblttng-ust-cyg-profile.so}.
4260 |TP provider name |TP name |Instrumented point
4262 .2+|`lttng_ust_cyg_profile`
4268 Address of called function.
4277 Address of called function.
4284 TIP: It's sometimes a good idea to limit the number of source files that
4285 you compile with the `-finstrument-functions` option to prevent LTTng
4286 from writing an excessive amount of trace data at run time. When using
4287 man:gcc(1), you can use the
4288 `-finstrument-functions-exclude-function-list` option to avoid
4289 instrument entries and exits of specific function names.
4291 All the tracepoints that this helper contains have the
4292 <<liblttng-ust-tracepoint-loglevel,log level>> `TRACE_DEBUG_FUNCTION`.
4297 ==== Instrument the dynamic linker
4299 The path:{liblttng-ust-dl.so} helper adds instrumentation to the
4300 man:dlopen(3) and man:dlclose(3) function calls.
4303 .Functions instrumented by preloading path:{liblttng-ust-dl.so}.
4305 |TP provider name |TP name |Instrumented function
4313 Memory base address (where the dynamic linker placed the shared
4317 File system path to the loaded shared object.
4320 File size of the the loaded shared object.
4323 Last modification time (seconds since Epoch time) of the loaded shared
4330 Memory base address (where the dynamic linker placed the shared
4336 [[java-application]]
4337 === User space Java agent
4339 You can instrument a Java application which uses one of the following
4342 * The https://docs.oracle.com/javase/7/docs/api/java/util/logging/package-summary.html[**`java.util.logging`**]
4343 (JUL) core logging facilities.
4344 * http://logging.apache.org/log4j/1.2/[**Apache log4j 1.2**], since
4345 LTTng 2.6. Note that Apache Log4j{nbsp}2 is not supported.
4347 Each log statement emits an LTTng event once the
4348 application initializes the <<lttng-ust-agents,LTTng-UST Java agent>>
4352 .LTTng-UST Java agent imported by a Java application.
4353 image::java-app.png[]
4355 NOTE: We use http://openjdk.java.net/[OpenJDK] 7 for development and
4356 https://ci.lttng.org/[continuous integration], thus this version is
4357 directly supported. However, the LTTng-UST Java agent is also
4358 tested with OpenJDK 6.
4360 To use the LTTng-UST Java agent:
4362 . In the Java application's source code, import the LTTng-UST Java
4368 import org.lttng.ust.agent.LTTngAgent;
4372 . As soon as possible after the entry point of the application,
4373 initialize the LTTng-UST Java agent:
4378 LTTngAgent lttngAgent = LTTngAgent.getLTTngAgent();
4382 Any log statement that the application executes before this
4383 initialization does not emit an LTTng event.
4385 . Use `java.util.logging` and/or log4j log statements and configuration
4386 as usual. Since the LTTng-UST Java agent adds a handler to the _root_
4387 loggers, you can trace any log statement from any logger.
4389 . Before exiting the application, dispose the LTTng-UST Java agent:
4394 lttngAgent.dispose();
4398 This is not strictly necessary, but it is recommended for a clean
4399 disposal of the agent's resources.
4401 Any log statement that the application executes after this disposal does
4402 not emit an LTTng event.
4404 . Include the LTTng-UST Java agent's JAR file, path:{liblttng-ust-agent.jar},
4406 https://docs.oracle.com/javase/tutorial/essential/environment/paths.html[class path]
4407 when building the Java application.
4409 path:{liblttng-ust-agent.jar} is typically located in
4410 dir:{/usr/share/java}.
4412 IMPORTANT: The LTTng-UST Java agent must be
4413 <<installing-lttng,installed>> for the logging framework your
4416 .[[jul]]Use the LTTng-UST Java agent with `java.util.logging`.
4421 import java.util.logging.Logger;
4422 import org.lttng.ust.agent.LTTngAgent;
4426 private static final int answer = 42;
4428 public static void main(String[] argv) throws Exception
4431 Logger logger = Logger.getLogger("jello");
4433 // Call this as soon as possible (before logging)
4434 LTTngAgent lttngAgent = LTTngAgent.getLTTngAgent();
4437 logger.info("some info");
4438 logger.warning("some warning");
4440 logger.finer("finer information; the answer is " + answer);
4442 logger.severe("error!");
4444 // Not mandatory, but cleaner
4445 lttngAgent.dispose();
4450 You can build this example like this:
4454 javac -cp /usr/share/java/liblttng-ust-agent.jar Test.java
4457 You can run the compiled class like this:
4461 java -cp /usr/share/java/liblttng-ust-agent.jar:. Test
4465 .[[log4j]]Use the LTTng-UST Java agent with Apache log4j 1.2.
4470 import org.apache.log4j.Logger;
4471 import org.apache.log4j.BasicConfigurator;
4472 import org.lttng.ust.agent.LTTngAgent;
4476 private static final int answer = 42;
4478 public static void main(String[] argv) throws Exception
4480 // Create and configure a logger
4481 Logger logger = Logger.getLogger(Test.class);
4482 BasicConfigurator.configure();
4484 // Call this as soon as possible (before logging)
4485 LTTngAgent lttngAgent = LTTngAgent.getLTTngAgent();
4488 logger.info("some info");
4489 logger.warn("some warning");
4491 logger.debug("debug information; the answer is " + answer);
4493 logger.error("error!");
4494 logger.fatal("fatal error!");
4496 // Not mandatory, but cleaner
4497 lttngAgent.dispose();
4502 You can build this example like this:
4506 javac -cp /usr/share/java/liblttng-ust-agent.jar:$LOG4JCP Test.java
4509 where `$LOG4JCP` is the path to log4j's JAR file.
4511 You can run the compiled class like this:
4515 java -cp /usr/share/java/liblttng-ust-agent.jar:$LOG4JCP:. Test
4519 When you <<enabling-disabling-events,create an event rule>>, use the
4520 `--jul` (`java.util.logging`) or `--log4j` (log4j) option to target
4522 <<domain,tracing domain>>. You can also use the `--loglevel` or
4523 `--loglevel-only` option to target a range of JUL/log4j log levels or a
4524 specific JUL/log4j log level.
4528 [[python-application]]
4529 === User space Python agent
4531 You can instrument a Python 2 or Python 3 application which uses the
4532 standard https://docs.python.org/3/library/logging.html[`logging`]
4535 Each log statement emits an LTTng event once the
4536 application module imports the
4537 <<lttng-ust-agents,LTTng-UST Python agent>> package.
4540 .A Python application importing the LTTng-UST Python agent.
4541 image::python-app.png[]
4543 To use the LTTng-UST Python agent:
4545 . In the Python application's source code, import the LTTng-UST Python
4555 The LTTng-UST Python agent automatically adds its logging handler to the
4556 root logger at import time.
4558 Any log statement that the application executes before this import does
4559 not emit an LTTng event.
4561 IMPORTANT: The LTTng-UST Python agent must be
4562 <<installing-lttng,installed>>.
4564 . Use log statements and logging configuration as usual.
4565 Since the LTTng-UST Python agent adds a handler to the _root_
4566 logger, you can trace any log statement from any logger.
4568 .Use the LTTng-UST Python agent.
4578 logging.basicConfig()
4579 logger = logging.getLogger('my-logger')
4582 logger.debug('debug message')
4583 logger.info('info message')
4584 logger.warn('warn message')
4585 logger.error('error message')
4586 logger.critical('critical message')
4590 if __name__ == '__main__':
4594 NOTE: `logging.basicConfig()`, which adds to the root logger a basic
4595 logging handler which prints to the standard error stream, is not
4596 strictly required for LTTng-UST tracing to work, but in versions of
4597 Python preceding 3.2, you could see a warning message which indicates
4598 that no handler exists for the logger `my-logger`.
4601 When you <<enabling-disabling-events,create an event rule>>, use the
4602 `--python` option to target the Python
4603 <<domain,tracing domain>>. You can also use
4604 the `--loglevel` or `--loglevel-only` option to target a range of
4605 Python log levels or a specific Python log level.
4607 When an application imports the LTTng-UST Python agent, the agent tries
4608 to register to a <<lttng-sessiond,session daemon>>. Note that you must
4609 start the session daemon _before_ you start the Python application.
4610 If a session daemon is found, the agent tries to register to it
4611 during 5{nbsp}seconds, after which the application continues without
4612 LTTng tracing support. You can override this timeout value with the
4613 env:LTTNG_UST_PYTHON_REGISTER_TIMEOUT environment variable
4616 If the session daemon stops while a Python application with an imported
4617 LTTng-UST Python agent runs, the agent retries to connect and to
4618 register to a session daemon every 3{nbsp}seconds. You can override this
4619 delay with the env:LTTNG_UST_PYTHON_REGISTER_RETRY_DELAY environment
4624 [[proc-lttng-logger-abi]]
4627 The `lttng-tracer` Linux kernel module, part of
4628 <<lttng-modules,LTTng-modules>>, creates the special LTTng logger file
4629 path:{/proc/lttng-logger} when it's loaded. Any application can write
4630 text data to this file to emit an LTTng event.
4633 .An application writes to the LTTng logger file to emit an LTTng event.
4634 image::lttng-logger.png[]
4636 The LTTng logger is the quickest method--not the most efficient,
4637 however--to add instrumentation to an application. It is designed
4638 mostly to instrument shell scripts:
4642 echo "Some message, some $variable" > /proc/lttng-logger
4645 Any event that the LTTng logger emits is named `lttng_logger` and
4646 belongs to the Linux kernel <<domain,tracing domain>>. However, unlike
4647 other instrumentation points in the kernel tracing domain, **any Unix
4648 user** can <<enabling-disabling-events,create an event rule>> which
4649 matches its event name, not only the root user or users in the tracing
4652 To use the LTTng logger:
4654 * From any application, write text data to the path:{/proc/lttng-logger}
4657 The `msg` field of `lttng_logger` event records contains the
4660 NOTE: The maximum message length of an LTTng logger event is
4661 1024{nbsp}bytes. Writing more than this makes the LTTng logger emit more
4662 than one event to contain the remaining data.
4664 You should not use the LTTng logger to trace a user application which
4665 can be instrumented in a more efficient way, namely:
4667 * <<c-application,C and $$C++$$ applications>>.
4668 * <<java-application,Java applications>>.
4669 * <<python-application,Python applications>>.
4672 [[instrumenting-linux-kernel]]
4673 === LTTng kernel tracepoints
4675 NOTE: This section shows how to _add_ instrumentation points to the
4676 Linux kernel. The kernel's subsystems are already thoroughly
4677 instrumented at strategic places for LTTng when you
4678 <<installing-lttng,install>> the <<lttng-modules,LTTng-modules>>
4682 There are two methods to instrument the Linux kernel:
4684 . <<linux-add-lttng-layer,Add an LTTng layer>> over an existing ftrace
4685 tracepoint which uses the `TRACE_EVENT()` API.
4687 Choose this if you want to instrumentation a Linux kernel tree with an
4688 instrumentation point compatible with ftrace, perf, and SystemTap.
4690 . Use an <<linux-lttng-tracepoint-event,LTTng-only approach>> to
4691 instrument an out-of-tree kernel module.
4693 Choose this if you don't need ftrace, perf, or SystemTap support.
4697 [[linux-add-lttng-layer]]
4698 ==== [[instrumenting-linux-kernel-itself]][[mainline-trace-event]][[lttng-adaptation-layer]]Add an LTTng layer to an existing ftrace tracepoint
4700 This section shows how to add an LTTng layer to existing ftrace
4701 instrumentation using the `TRACE_EVENT()` API.
4703 This section does not document the `TRACE_EVENT()` macro. You can
4704 read the following articles to learn more about this API:
4706 * http://lwn.net/Articles/379903/[Using the TRACE_EVENT() macro (Part 1)]
4707 * http://lwn.net/Articles/381064/[Using the TRACE_EVENT() macro (Part 2)]
4708 * http://lwn.net/Articles/383362/[Using the TRACE_EVENT() macro (Part 3)]
4710 The following procedure assumes that your ftrace tracepoints are
4711 correctly defined in their own header and that they are created in
4712 one source file using the `CREATE_TRACE_POINTS` definition.
4714 To add an LTTng layer over an existing ftrace tracepoint:
4716 . Make sure the following kernel configuration options are
4722 * `CONFIG_HIGH_RES_TIMERS`
4723 * `CONFIG_TRACEPOINTS`
4726 . Build the Linux source tree with your custom ftrace tracepoints.
4727 . Boot the resulting Linux image on your target system.
4729 Confirm that the tracepoints exist by looking for their names in the
4730 dir:{/sys/kernel/debug/tracing/events/subsys} directory, where `subsys`
4731 is your subsystem's name.
4733 . Get a copy of the latest LTTng-modules{nbsp}{revision}:
4739 wget http://lttng.org/files/lttng-modules/lttng-modules-latest-2.8.tar.bz2 &&
4740 tar -xf lttng-modules-latest-2.8.tar.bz2 &&
4741 cd lttng-modules-2.8.*
4745 . In dir:{instrumentation/events/lttng-module}, relative to the root
4746 of the LTTng-modules source tree, create a header file named
4747 +__subsys__.h+ for your custom subsystem +__subsys__+ and write your
4748 LTTng-modules tracepoint definitions using the LTTng-modules
4751 Start with this template:
4755 .path:{instrumentation/events/lttng-module/my_subsys.h}
4758 #define TRACE_SYSTEM my_subsys
4760 #if !defined(_LTTNG_MY_SUBSYS_H) || defined(TRACE_HEADER_MULTI_READ)
4761 #define _LTTNG_MY_SUBSYS_H
4763 #include "../../../probes/lttng-tracepoint-event.h"
4764 #include <linux/tracepoint.h>
4766 LTTNG_TRACEPOINT_EVENT(
4768 * Format is identical to TRACE_EVENT()'s version for the three
4769 * following macro parameters:
4772 TP_PROTO(int my_int, const char *my_string),
4773 TP_ARGS(my_int, my_string),
4775 /* LTTng-modules specific macros */
4777 ctf_integer(int, my_int_field, my_int)
4778 ctf_string(my_bar_field, my_bar)
4782 #endif /* !defined(_LTTNG_MY_SUBSYS_H) || defined(TRACE_HEADER_MULTI_READ) */
4784 #include "../../../probes/define_trace.h"
4788 The entries in the `TP_FIELDS()` section are the list of fields for the
4789 LTTng tracepoint. This is similar to the `TP_STRUCT__entry()` part of
4790 ftrace's `TRACE_EVENT()` macro.
4792 See <<lttng-modules-tp-fields,Tracepoint fields macros>> for a
4793 complete description of the available `ctf_*()` macros.
4795 . Create the LTTng-modules probe's kernel module C source file,
4796 +probes/lttng-probe-__subsys__.c+, where +__subsys__+ is your
4801 .path:{probes/lttng-probe-my-subsys.c}
4803 #include <linux/module.h>
4804 #include "../lttng-tracer.h"
4807 * Build-time verification of mismatch between mainline
4808 * TRACE_EVENT() arguments and the LTTng-modules adaptation
4809 * layer LTTNG_TRACEPOINT_EVENT() arguments.
4811 #include <trace/events/my_subsys.h>
4813 /* Create LTTng tracepoint probes */
4814 #define LTTNG_PACKAGE_BUILD
4815 #define CREATE_TRACE_POINTS
4816 #define TRACE_INCLUDE_PATH ../instrumentation/events/lttng-module
4818 #include "../instrumentation/events/lttng-module/my_subsys.h"
4820 MODULE_LICENSE("GPL and additional rights");
4821 MODULE_AUTHOR("Your name <your-email>");
4822 MODULE_DESCRIPTION("LTTng my_subsys probes");
4823 MODULE_VERSION(__stringify(LTTNG_MODULES_MAJOR_VERSION) "."
4824 __stringify(LTTNG_MODULES_MINOR_VERSION) "."
4825 __stringify(LTTNG_MODULES_PATCHLEVEL_VERSION)
4826 LTTNG_MODULES_EXTRAVERSION);
4830 . Edit path:{probes/Makefile} and add your new kernel module object
4831 next to the existing ones:
4835 .path:{probes/Makefile}
4839 obj-m += lttng-probe-module.o
4840 obj-m += lttng-probe-power.o
4842 obj-m += lttng-probe-my-subsys.o
4848 . Build and install the LTTng kernel modules:
4853 make KERNELDIR=/path/to/linux
4854 sudo make modules_install
4858 Replace `/path/to/linux` with the path to the Linux source tree where
4859 you defined and used tracepoints with ftrace's `TRACE_EVENT()` macro.
4861 Note that you can also use the
4862 <<lttng-tracepoint-event-code,`LTTNG_TRACEPOINT_EVENT_CODE()` macro>>
4863 instead of `LTTNG_TRACEPOINT_EVENT()` to use custom local variables and
4864 C code that need to be executed before the event fields are recorded.
4866 The best way to learn how to use the previous LTTng-modules macros is to
4867 inspect the existing LTTng-modules tracepoint definitions in the
4868 dir:{instrumentation/events/lttng-module} header files. Compare them
4869 with the Linux kernel mainline versions in the
4870 dir:{include/trace/events} directory of the Linux source tree.
4874 [[lttng-tracepoint-event-code]]
4875 ===== Use custom C code to access the data for tracepoint fields
4877 Although we recommended to always use the
4878 <<lttng-adaptation-layer,`LTTNG_TRACEPOINT_EVENT()`>> macro to describe
4879 the arguments and fields of an LTTng-modules tracepoint when possible,
4880 sometimes you need a more complex process to access the data that the
4881 tracer records as event record fields. In other words, you need local
4882 variables and multiple C{nbsp}statements instead of simple
4883 argument-based expressions that you pass to the
4884 <<lttng-modules-tp-fields,`ctf_*()` macros of `TP_FIELDS()`>>.
4886 You can use the `LTTNG_TRACEPOINT_EVENT_CODE()` macro instead of
4887 `LTTNG_TRACEPOINT_EVENT()` to declare custom local variables and define
4888 a block of C{nbsp}code to be executed before LTTng records the fields.
4889 The structure of this macro is:
4892 .`LTTNG_TRACEPOINT_EVENT_CODE()` macro syntax.
4894 LTTNG_TRACEPOINT_EVENT_CODE(
4896 * Format identical to the LTTNG_TRACEPOINT_EVENT()
4897 * version for the following three macro parameters:
4900 TP_PROTO(int my_int, const char *my_string),
4901 TP_ARGS(my_int, my_string),
4903 /* Declarations of custom local variables */
4906 unsigned long b = 0;
4907 const char *name = "(undefined)";
4908 struct my_struct *my_struct;
4912 * Custom code which uses both tracepoint arguments
4913 * (in TP_ARGS()) and local variables (in TP_locvar()).
4915 * Local variables are actually members of a structure pointed
4916 * to by the special variable tp_locvar.
4920 tp_locvar->a = my_int + 17;
4921 tp_locvar->my_struct = get_my_struct_at(tp_locvar->a);
4922 tp_locvar->b = my_struct_compute_b(tp_locvar->my_struct);
4923 tp_locvar->name = my_struct_get_name(tp_locvar->my_struct);
4924 put_my_struct(tp_locvar->my_struct);
4933 * Format identical to the LTTNG_TRACEPOINT_EVENT()
4934 * version for this, except that tp_locvar members can be
4935 * used in the argument expression parameters of
4936 * the ctf_*() macros.
4939 ctf_integer(unsigned long, my_struct_b, tp_locvar->b)
4940 ctf_integer(int, my_struct_a, tp_locvar->a)
4941 ctf_string(my_string_field, my_string)
4942 ctf_string(my_struct_name, tp_locvar->name)
4947 IMPORTANT: The C code defined in `TP_code()` must not have any side
4948 effects when executed. In particular, the code must not allocate
4949 memory or get resources without deallocating this memory or putting
4950 those resources afterwards.
4953 [[instrumenting-linux-kernel-tracing]]
4954 ==== Load and unload a custom probe kernel module
4956 You must load a <<lttng-adaptation-layer,created LTTng-modules probe
4957 kernel module>> in the kernel before it can emit LTTng events.
4959 To load the default probe kernel modules and a custom probe kernel
4962 * Use the `--extra-kmod-probes` option to give extra probe modules
4963 to load when starting a root <<lttng-sessiond,session daemon>>:
4966 .Load the `my_subsys`, `usb`, and the default probe modules.
4970 sudo lttng-sessiond --extra-kmod-probes=my_subsys,usb
4975 You only need to pass the subsystem name, not the whole kernel module
4978 To load _only_ a given custom probe kernel module:
4980 * Use the `--kmod-probes` option to give the probe modules
4981 to load when starting a root session daemon:
4984 .Load only the `my_subsys` and `usb` probe modules.
4988 sudo lttng-sessiond --kmod-probes=my_subsys,usb
4993 To confirm that a probe module is loaded:
5000 lsmod | grep lttng_probe_usb
5004 To unload the loaded probe modules:
5006 * Kill the session daemon with `SIGTERM`:
5011 sudo pkill lttng-sessiond
5015 You can also use man:modprobe(8)'s `--remove` option if the session
5016 daemon terminates abnormally.
5019 [[controlling-tracing]]
5022 Once an application or a Linux kernel is
5023 <<instrumenting,instrumented>> for LTTng tracing,
5026 This section is divided in topics on how to use the various
5027 <<plumbing,components of LTTng>>, in particular the <<lttng-cli,cmd:lttng
5028 command-line tool>>, to _control_ the LTTng daemons and tracers.
5030 Note that the <<online-lttng-manpages,Online LTTng man pages>> are
5031 more comprehensive than the guides of this section. Refer to them if
5032 your use case is not included in this section.
5036 === Start a session daemon
5038 In some situations, you need to run a <<lttng-sessiond,session daemon>>
5039 _before_ you can use the cmd:lttng command-line tool.
5041 You will see the following error when you run a command while no session
5045 Error: No session daemon is available
5048 The only command that automatically runs a session daemon is `create`,
5049 which you use to <<creating-destroying-tracing-sessions,create a tracing
5050 session>>. While this is most of the time the first operation that you
5051 do, sometimes it's not. Some examples are:
5053 * <<list-instrumentation-points,List the available instrumentation points>>.
5054 * <<saving-loading-tracing-session,Load a tracing session configuration>>.
5056 [[tracing-group]] Each Unix user must have its own running session
5057 daemon to trace user applications. The session daemon that the root user
5058 starts is the only one allowed to control the LTTng kernel tracer. Users
5059 that are part of the _tracing group_ can control the root session
5060 daemon. The default tracing group name is `tracing`; you can set it to
5061 something else with the `--group` option when you start the root session
5064 To start a user session daemon:
5066 * Run cmd:lttng-sessiond:
5071 lttng-sessiond --daemonize
5075 To start the root session daemon:
5077 * Run cmd:lttng-sessiond as the root user:
5082 sudo lttng-sessiond --daemonize
5086 In both cases, remove the `--daemonize` option to start the session
5087 daemon in foreground.
5089 To stop a session daemon, use cmd:kill on its process ID (standard
5092 Note that some Linux distributions could manage the LTTng session daemon
5093 as a service. In this case, you should use the service manager to
5094 start, restart, and stop session daemons.
5097 [[creating-destroying-tracing-sessions]]
5098 === Create and destroy a tracing session
5100 Almost all the LTTng control operations happen in the scope of
5101 a <<tracing-session,tracing session>>, which is the dialogue between the
5102 <<lttng-sessiond,session daemon>> and you.
5104 To create a tracing session with a generated name:
5106 * Use the `create` command:
5115 The created tracing session's name is `auto` followed by the
5118 To create a tracing session with a specific name:
5120 * Use the optional argument of the `create` command:
5125 lttng create my-session
5129 Replace `my-session` with the specific tracing session name.
5131 LTTng appends the creation date to the created tracing session's name.
5133 LTTng writes the traces of a tracing session in
5134 +$LTTNG_HOME/lttng-trace/__name__+ by default, where +__name__+ is the
5135 name of the tracing session. Note that the env:LTTNG_HOME environment
5136 variable defaults to `$HOME` if not set.
5138 To output LTTng traces to a non-default location:
5140 * Use the `--output` option of the `create` command:
5145 lttng create --output=/tmp/some-directory my-session
5149 You may create as many tracing sessions as you wish.
5151 To list all the existing tracing sessions for your Unix user:
5153 * Use the `list` command:
5162 When you create a tracing session, it is set as the _current tracing
5163 session_. The following man:lttng(1) commands operate on the current
5164 tracing session when you don't specify one:
5166 [role="list-3-cols"]
5182 To change the current tracing session:
5184 * Use the `set-session` command:
5189 lttng set-session new-session
5193 Replace `new-session` by the name of the new current tracing session.
5195 When you are done tracing in a given tracing session, you can destroy
5196 it. This operation frees the resources taken by the tracing session
5197 to destroy; it does not destroy the trace data that LTTng wrote for
5198 this tracing session.
5200 To destroy the current tracing session:
5202 * Use the `destroy` command:
5212 [[list-instrumentation-points]]
5213 === List the available instrumentation points
5215 The <<lttng-sessiond,session daemon>> can query the running instrumented
5216 user applications and the Linux kernel to get a list of available
5217 instrumentation points. For the Linux kernel <<domain,tracing domain>>,
5218 they are tracepoints and system calls. For the user space tracing
5219 domain, they are tracepoints. For the other tracing domains, they are
5222 To list the available instrumentation points:
5224 * Use the `list` command with the requested tracing domain's option
5228 * `--kernel`: Linux kernel tracepoints (your Unix user must be a root
5229 user, or it must be a member of the tracing group).
5230 * `--kernel --syscall`: Linux kernel system calls (your Unix user must
5231 be a root user, or it must be a member of the tracing group).
5232 * `--userspace`: user space tracepoints.
5233 * `--jul`: `java.util.logging` loggers.
5234 * `--log4j`: Apache log4j loggers.
5235 * `--python`: Python loggers.
5238 .List the available user space tracepoints.
5242 lttng list --userspace
5246 .List the available Linux kernel system call tracepoints.
5250 lttng list --kernel --syscall
5255 [[enabling-disabling-events]]
5256 === Create and enable an event rule
5258 Once you <<creating-destroying-tracing-sessions,create a tracing
5259 session>>, you can create <<event,event rules>> with the
5260 `enable-event` command.
5262 You specify each condition with a command-line option. The available
5263 condition options are shown in the following table.
5265 [role="growable",cols="asciidoc,asciidoc,default"]
5266 .Condition command-line options for the `enable-event` command.
5268 |Option |Description |Applicable tracing domains
5274 . +--probe=__ADDR__+
5275 . +--function=__ADDR__+
5278 Instead of using the default _tracepoint_ instrumentation type, use:
5280 . A Linux system call.
5281 . A Linux https://lwn.net/Articles/132196/[KProbe] (symbol or address).
5282 . The entry and return points of a Linux function (symbol or address).
5286 |First positional argument.
5289 Tracepoint or system call name. In the case of a Linux KProbe or
5290 function, this is a custom name given to the event rule. With the
5291 JUL, log4j, and Python domains, this is a logger name.
5293 With a tracepoint, logger, or system call name, the last character
5294 can be `*` to match anything that remains.
5301 . +--loglevel=__LEVEL__+
5302 . +--loglevel-only=__LEVEL__+
5305 . Match only tracepoints or log statements with a logging level at
5306 least as severe as +__LEVEL__+.
5307 . Match only tracepoints or log statements with a logging level
5308 equal to +__LEVEL__+.
5310 You can get the list of available logging level names with
5311 `lttng enable-event --help`.
5313 |User space, JUL, log4j, and Python.
5315 |+--exclude=__EXCLUSIONS__+
5318 When you use a `*` character at the end of the tracepoint or logger
5319 name (first positional argument), exclude the specific names in the
5320 comma-delimited list +__EXCLUSIONS__+.
5323 User space, JUL, log4j, and Python.
5325 |+--filter=__EXPR__+
5328 Match only events which satisfy the expression +__EXPR__+.
5330 +__EXPR__+ is a C-like logical expression where identifiers are event
5331 fields (preceded with `$ctx.` for context fields). Nested expressions
5332 with `(` and `)`, and all the logical and comparison operators of the C
5333 language are supported. The precedence rules of those operators are the
5334 same as in the C language.
5336 When a comparison includes a non-existent event field, the whole filter
5337 expression evaluates to false.
5339 C integer and floating point number constants are supported, as well as
5340 literal strings between double quotes (`"`). Literal strings can
5341 contain a wildcard character (`*`) at the end to match anything that
5342 remains. This wildcard can be escaped using `\*`.
5344 Note that, although it is possible to use this option with the JUL,
5345 log4j, and Python tracing domains, the tracer evalutes the expression
5346 against the equivalent user space event.
5353 for more details about those command-line options.
5355 You attach an event rule to a <<channel,channel>> on creation. If you
5356 do not specify the channel with the `--channel` option, and if the event
5357 rule to create is the first in its <<domain,tracing domain>> for a given
5358 tracing session, then LTTng creates a _default channel_ for you. This
5359 default channel is reused in subsequent invocations of the
5360 `enable-event` command for the same tracing domain.
5362 An event rule is always enabled at creation time.
5364 The following examples show how you can combine the previous
5365 command-line options to create simple to more complex event rules.
5367 .Create an event rule targetting a Linux kernel tracepoint (default channel).
5371 lttng enable-event --kernel sched_switch
5375 .Create an event rule matching four Linux kernel system calls (default channel).
5379 lttng enable-event --kernel --syscall open,write,read,close
5383 .Create an event rule matching a Linux kernel tracepoint with a filter expression (default channel).
5387 lttng enable-event --kernel sched_switch --filter='prev_comm == "bash"'
5390 IMPORTANT: Make sure to always quote the filter string when you
5391 use man:lttng(1) from a shell.
5394 .Create an event rule matching any user space tracepoint of a given tracepoint provider with a log level range (default channel).
5398 lttng enable-event --userspace my_app:'*' --loglevel=TRACE_INFO
5401 IMPORTANT: Make sure to always quote the wildcard character when you
5402 use man:lttng(1) from a shell.
5405 .Create an event rule matching multiple Python loggers with a wildcard and with exclusions (default channel).
5409 lttng enable-event --python my-app.'*' \
5410 --exclude='my-app.module,my-app.hello'
5414 .Create an event rule matching any Apache log4j logger with a specific log level (default channel).
5418 lttng enable-event --log4j --all --loglevel-only=LOG4J_WARN
5422 .Create an event rule attached to a specific channel matching a specific user space tracepoint provider and tracepoint.
5426 lttng enable-event --userspace my_app:my_tracepoint --channel=my-channel
5430 The event rules of a given channel form a whitelist: as soon as an
5431 emitted event passes one of them, LTTng can record the event. For
5432 example, an event named `my_app:my_tracepoint` emitted from a user space
5433 tracepoint with a `TRACE_ERROR` log level passes both of the following
5438 lttng enable-event --userspace my_app:my_tracepoint
5439 lttng enable-event --userspace my_app:my_tracepoint \
5440 --loglevel=TRACE_INFO
5443 The second event rule is redundant: the first one includes
5447 [[disable-event-rule]]
5448 === Disable an event rule
5450 To disable an event rule that you <<enabling-disabling-events,created>>
5451 previously, use the `disable-event` command. This command disables _all_
5452 the event rules (of a given tracing domain and channel) which match an
5453 instrumentation point. The other conditions are not supported as of
5454 LTTng{nbsp}{revision}.
5456 The LTTng tracer does not record an emitted event which passes
5457 a _disabled_ event rule.
5459 .Disable an event rule matching a Python logger (default channel).
5463 lttng disable-event --python my-logger
5467 .Disable an event rule matching all `java.util.logging` loggers (default channel).
5471 lttng disable-event --jul '*'
5475 .Disable _all_ the event rules of the default channel.
5477 The `--all-events` option is not, like the `--all` option of
5478 `enable-event`, the equivalent of the event name `*` (wildcard): it
5479 disables _all_ the event rules of a given channel.
5483 lttng disable-event --jul --all-events
5487 NOTE: You cannot delete an event rule once you create it.
5491 === Get the status of a tracing session
5493 To get the status of a tracing session, that is, its channels, event
5494 rules, and their attributes:
5496 * Use the `list` command with the tracing session's name:
5501 lttng list my-session
5505 Replace `my-session` with your tracing session's name.
5508 [[basic-tracing-session-control]]
5509 === Start and stop a tracing session
5511 Once you <<creating-destroying-tracing-sessions,create a tracing
5513 <<enabling-disabling-events,create one or more event rules>>,
5514 you can start and stop the tracers for this tracing session.
5516 To start tracing in the current tracing session:
5518 * Use the `start` command:
5527 To stop tracing in the current tracing session:
5529 * Use the `stop` command:
5538 LTTng is very flexible: you can launch user applications before
5539 or after the you start the tracers. The tracers only record the events
5540 if they pass enabled event rules and if they occur while the tracers are
5544 [[enabling-disabling-channels]]
5545 === Create a channel
5547 Once you create a tracing session, you can create a <<channel,channel>>
5548 with the `enable-channel` command.
5550 Note that LTTng automatically creates a default channel when, for a
5551 given <<domain,tracing domain>>, no channels exist and you
5552 <<enabling-disabling-events,create>> the first event rule. This default
5553 channel is named `channel0` and its attributes are set to reasonable
5554 values. Therefore, you only need to create a channel when you need
5555 non-default attributes.
5557 You specify each non-default channel attribute with a command-line
5558 option when you use the `enable-channel` command. The available
5559 command-line options are:
5561 [role="growable",cols="asciidoc,asciidoc"]
5562 .Command-line options for the `enable-channel` command.
5564 |Option |Description
5570 <<channel-overwrite-mode-vs-discard-mode,event loss mode>> instead of
5571 the default _discard_ mode.
5573 |`--buffers-pid` (user space tracing domain only)
5576 Use the per-process <<channel-buffering-schemes,buffering scheme>>
5577 instead of the default per-user buffering scheme.
5579 |+--subbuf-size=__SIZE__+
5582 Allocate sub-buffers of +__SIZE__+ bytes (power of two), for each CPU,
5583 either for each Unix user (default), or for each instrumented process.
5585 See <<channel-subbuf-size-vs-subbuf-count,Sub-buffer count and size>>.
5587 |+--num-subbuf=__COUNT__+
5590 Allocate +__COUNT__+ sub-buffers (power of two), for each CPU, either
5591 for each Unix user (default), or for each instrumented process.
5593 See <<channel-subbuf-size-vs-subbuf-count,Sub-buffer count and size>>.
5595 |+--tracefile-size=__SIZE__+
5598 Set the maximum size of each trace file that this channel writes within
5599 a stream to +__SIZE__+ bytes instead of no maximum.
5601 See <<tracefile-rotation,Trace file count and size>>.
5603 |+--tracefile-count=__COUNT__+
5606 Limit the number of trace files that this channel creates to
5607 +__COUNT__+ channels instead of no limit.
5609 See <<tracefile-rotation,Trace file count and size>>.
5611 |+--switch-timer=__PERIODUS__+
5614 Set the <<channel-switch-timer,switch timer period>>
5615 to +__PERIODUS__+{nbsp}µs.
5617 |+--read-timer=__PERIODUS__+
5620 Set the <<channel-read-timer,read timer period>>
5621 to +__PERIODUS__+{nbsp}µs.
5623 |+--output=__TYPE__+ (Linux kernel tracing domain only)
5626 Set the channel's output type to +__TYPE__+, either `mmap` or `splice`.
5631 for more details about those command-line options.
5633 You can only create a channel in the Linux kernel and user space
5634 <<domain,tracing domains>>: other tracing domains have their own
5635 channel created on the fly when
5636 <<enabling-disabling-events,creating event rules>>.
5640 Because of a current LTTng limitation, you must create all channels
5641 _before_ you <<basic-tracing-session-control,start tracing>> in a given
5642 tracing session, that is, before the first time you run `lttng start`.
5644 Since LTTng automatically creates a default channel when you use the
5645 `enable-event` command with a specific tracing domain, you cannot, for
5646 example, create a Linux kernel event rule, start tracing, and then
5647 create a user space event rule, because no user space channel exists yet
5648 and it's too late to create one.
5650 For this reason, make sure to configure your channels properly
5651 before starting the tracers for the first time!
5654 The following examples show how you can combine the previous
5655 command-line options to create simple to more complex channels.
5657 .Create a Linux kernel channel with default attributes.
5661 lttng enable-channel --kernel my-channel
5665 .Create a user space channel with 4 sub-buffers or 1{nbsp}MiB each, per CPU, per instrumented process.
5669 lttng enable-channel --userspace --num-subbuf=4 --subbuf-size=1M \
5670 --buffers-pid my-channel
5674 .Create a Linux kernel channel which rotates 8 trace files of 4{nbsp}MiB each for each stream
5678 lttng enable-channel --kernel --tracefile-count=8 \
5679 --tracefile-size=4194304 my-channel
5683 .Create a user space channel in overwrite (or _flight recorder_) mode.
5687 lttng enable-channel --userspace --overwrite my-channel
5691 You can <<enabling-disabling-events,create>> the same event rule in
5692 two different channels:
5696 lttng enable-event --userspace --channel=my-channel app:tp
5697 lttng enable-event --userspace --channel=other-channel app:tp
5700 If both channels are enabled, when a tracepoint named `app:tp` is
5701 reached, LTTng records two events, one for each channel.
5705 === Disable a channel
5707 To disable a specific channel that you <<enabling-disabling-channels,created>>
5708 previously, use the `disable-channel` command.
5710 .Disable a specific Linux kernel channel.
5714 lttng disable-channel --kernel my-channel
5718 The state of a channel precedes the individual states of event rules
5719 attached to it: event rules which belong to a disabled channel, even if
5720 they are enabled, are also considered disabled.
5724 === Add context fields to a channel
5726 Event record fields in trace files provide important information about
5727 events that occured previously, but sometimes some external context may
5728 help you solve a problem faster. Examples of context fields are:
5730 * The **process ID**, **thread ID**, **process name**, and
5731 **process priority** of the thread in which the event occurs.
5732 * The **hostname** of the system on which the event occurs.
5733 * The current values of many possible **performance counters** using
5735 ** CPU cycles, stalled cycles, idle cycles, and the other cycle types.
5737 ** Branch instructions, misses, and loads.
5740 To get the full list of available context fields, see
5741 `lttng add-context --help`. Some context fields are reserved for a
5742 specific <<domain,tracing domain>> (Linux kernel or user space).
5744 You add context fields to <<channel,channels>>. All the events
5745 that a channel with added context fields records contain those fields.
5747 To add context fields to one or all the channels of a given tracing
5748 session, use the `add-context` command.
5750 .Add context fields to all the channels of the current tracing session.
5752 The following command line adds the virtual process identifier and
5753 the per-thread CPU cycles count fields to all the user space channels
5754 of the current tracing session.
5758 lttng add-context --userspace --type=vpid --type=perf:thread:cpu-cycles
5762 .Add a context field to a specific channel.
5764 The following command line adds the thread identifier context field
5765 to the Linux kernel channel named `my-channel` in the current
5770 lttng add-context --kernel --channel=my-channel --type=tid
5774 NOTE: You cannot remove context fields from a channel once you add it.
5779 === Track process IDs
5781 It's often useful to allow only specific process IDs (PIDs) to emit
5782 events. For example, you may wish to record all the system calls made by
5783 a given process (Ă la http://linux.die.net/man/1/strace[strace]).
5785 The `track` and `untrack` commands serve this purpose. Both commands
5786 operate on a whitelist of process IDs. You _add_ entries to this
5787 whitelist with the `track` command and remove entries with the `untrack`
5788 command. Any process which has one of the PIDs in the whitelist is
5789 allowed to emit LTTng events which pass an enabled <<event,event rule>>.
5791 NOTE: The PID tracker tracks the _numeric process IDs_. Should a
5792 process with a given tracked ID exit and another process be given this
5793 ID, then the latter would also be allowed to emit events.
5795 .Track and untrack process IDs.
5797 For the sake of the following example, assume the target system has 16
5801 <<creating-destroying-tracing-sessions,create a tracing session>>,
5802 the whitelist contains all the possible PIDs:
5805 .All PIDs are tracked.
5806 image::track-all.png[]
5808 When the whitelist is full and you use the `track` command to specify
5809 some PIDs to track, LTTng first clears the whitelist, then it tracks
5810 the specific PIDs. After:
5814 lttng track --pid=3,4,7,10,13
5820 .PIDs 3, 4, 7, 10, and 13 are tracked.
5821 image::track-3-4-7-10-13.png[]
5823 You can add more PIDs to the whitelist afterwards:
5827 lttng track --pid=1,15,16
5833 .PIDs 1, 15, and 16 are added to the whitelist.
5834 image::track-1-3-4-7-10-13-15-16.png[]
5836 The `untrack` command removes entries from the PID tracker's whitelist.
5837 Given the previous example, the following command:
5841 lttng untrack --pid=3,7,10,13
5844 leads to this whitelist:
5847 .PIDs 3, 7, 10, and 13 are removed from the whitelist.
5848 image::track-1-4-15-16.png[]
5850 LTTng can track all possible PIDs again using the `--all` option:
5854 lttng track --pid --all
5857 The result is, again:
5860 .All PIDs are tracked.
5861 image::track-all.png[]
5864 .Track only specific PIDs
5866 A very typical use case with PID tracking is to start with an empty
5867 whitelist, then <<basic-tracing-session-control,start the tracers>>,
5868 and then add PIDs manually while tracers are active. You can accomplish
5869 this by using the `--all` option of the `untrack` command to clear the
5870 whitelist after you create a tracing session:
5874 lttng untrack --pid --all
5880 .No PIDs are tracked.
5881 image::untrack-all.png[]
5883 If you trace with this whitelist configuration, the tracer records no
5884 events for this <<domain,tracing domain>> because no processes are
5885 tracked. You can use the `track` command as usual to track specific
5890 lttng track --pid=6,11
5896 .PIDs 6 and 11 are tracked.
5897 image::track-6-11.png[]
5902 [[saving-loading-tracing-session]]
5903 === Save and load tracing session configurations
5905 Configuring a <<tracing-session,tracing session>> can be long. Some of
5906 the tasks involved are:
5908 * <<enabling-disabling-channels,Create channels>> with
5909 specific attributes.
5910 * <<adding-context,Add context fields>> to specific channels.
5911 * <<enabling-disabling-events,Create event rules>> with specific log
5912 level and filter conditions.
5914 If you use LTTng to solve real world problems, chances are you have to
5915 record events using the same tracing session setup over and over,
5916 modifying a few variables each time in your instrumented program
5917 or environment. To avoid constant tracing session reconfiguration,
5918 the cmd:lttng command-line tool can save and load tracing session
5919 configurations to/from XML files.
5921 To save a given tracing session configuration:
5923 * Use the `save` command:
5928 lttng save my-session
5932 Replace `my-session` with the name of the tracing session to save.
5934 LTTng saves tracing session configurations to
5935 dir:{$LTTNG_HOME/.lttng/sessions} by default. Note that the
5936 env:LTTNG_HOME environment variable defaults to `$HOME` if not set. Use
5937 the `--output-path` option to change this destination directory.
5939 LTTng saves all configuration parameters, for example:
5941 * The tracing session name.
5942 * The trace data output path.
5943 * The channels with their state and all their attributes.
5944 * The context fields you added to channels.
5945 * The event rules with their state, log level and filter conditions.
5947 To load a tracing session:
5949 * Use the `load` command:
5954 lttng load my-session
5958 Replace `my-session` with the name of the tracing session to load.
5960 When LTTng loads a configuration, it restores your saved tracing session
5961 as if you just configured it manually.
5963 See man:lttng(1) for the complete list of command-line options. You
5964 can also save and load all many sessions at a time, and decide in which
5965 directory to output the XML files.
5968 [[sending-trace-data-over-the-network]]
5969 === Send trace data over the network
5971 LTTng can send the recorded trace data to a remote system over the
5972 network instead of writing it to the local file system.
5974 To send the trace data over the network:
5976 . On the _remote_ system (which can also be the target system),
5977 start an LTTng <<lttng-relayd,relay daemon>>:
5986 . On the _target_ system, create a tracing session configured to
5987 send trace data over the network:
5992 lttng create my-session --set-url=net://remote-system
5996 Replace `remote-system` by the host name or IP address of the
5997 remote system. See `lttng create --help` for the exact URL format.
5999 . On the target system, use the cmd:lttng command-line tool as usual.
6000 When tracing is active, the target's consumer daemon sends sub-buffers
6001 to the relay daemon running on the remote system intead of flushing
6002 them to the local file system. The relay daemon writes the received
6003 packets to the local file system.
6005 The relay daemon writes trace files to
6006 +$LTTNG_HOME/lttng-traces/__hostname__/__session__+ by default, where
6007 +__hostname__+ is the host name of the target system and +__session__+
6008 is the tracing session name. Note that the env:LTTNG_HOME environment
6009 variable defaults to `$HOME` if not set. Use the `--output` option of
6010 cmd:lttng-relayd to write trace files to another base directory.
6015 === View events as LTTng emits them (noch:{LTTng} live)
6017 LTTng live is a network protocol implemented by the
6018 <<lttng-relayd,relay daemon>> to allow compatible trace viewers to
6019 display events as LTTng emits them on the target system while tracing
6022 The relay daemon creates a _tee_: it forwards the trace data to both
6023 the local file system and to connected live viewers:
6026 .The relay daemon creates a _tee_, forwarding the trace data to both trace files and a connected live viewer.
6031 . On the _target system_, create a <<tracing-session,tracing session>>
6037 lttng create --live my-session
6041 This spawns a local relay daemon.
6043 . Start the live viewer and configure it to connect to the relay
6044 daemon. For example, with http://diamon.org/babeltrace[Babeltrace]:
6049 babeltrace --input-format=lttng-live net://localhost/host/hostname/my-session
6056 * `hostname` with the host name of the target system.
6057 * `my-session` with the name of the tracing session to view.
6060 . Configure the tracing session as usual with the cmd:lttng
6061 command-line tool, and <<basic-tracing-session-control,start tracing>>.
6063 You can list the available live tracing sessions with Babeltrace:
6067 babeltrace --input-format=lttng-live net://localhost
6070 You can start the relay daemon on another system. In this case, you need
6071 to specify the relay daemon's URL when you create the tracing session
6072 with the `--set-url` option. You also need to replace `localhost`
6073 in the procedure above with the host name of the system on which the
6074 relay daemon is running.
6076 See man:lttng(1) and man:lttng-relayd(8) for the complete list of
6077 command-line options.
6081 [[taking-a-snapshot]]
6082 === Take a snapshot of the current sub-buffers of a tracing session
6084 The normal behavior of LTTng is to append full sub-buffers to growing
6085 trace data files. This is ideal to keep a full history of the events
6086 that occurred on the target system, but it can
6087 represent too much data in some situations. For example, you may wish
6088 to trace your application continuously until some critical situation
6089 happens, in which case you only need the latest few recorded
6090 events to perform the desired analysis, not multi-gigabyte trace files.
6092 With the `snapshot` command, you can take a snapshot of the current
6093 sub-buffers of a given <<tracing-session,tracing session>>. LTTng can
6094 write the snapshot to the local file system or send it over the network.
6098 . Create a tracing session in _snapshot mode_:
6103 lttng create --snapshot my-session
6107 The <<channel-overwrite-mode-vs-discard-mode,event loss mode>> of
6108 <<channel,channels>> created in this mode is automatically set to
6109 _overwrite_ (flight recorder mode).
6111 . Configure the tracing session as usual with the cmd:lttng
6112 command-line tool, and <<basic-tracing-session-control,start tracing>>.
6114 . **Optional**: When you need to take a snapshot, stop tracing.
6116 You can take a snapshot when the tracers are active, but if you stop
6117 them first, you are sure that the data in the sub-buffers does not
6118 change before you actually take the snapshot.
6125 lttng snapshot record --name=my-first-snapshot
6129 LTTng writes the current sub-buffers of all the current tracing
6130 session's channels to trace files on the local file system. Those trace
6131 files have `my-first-snapshot` in their name.
6133 There is no difference between the format of a normal trace file and the
6134 format of a snapshot: viewers of LTTng traces also support LTTng
6137 By default, LTTng writes snapshot files to the path shown by
6138 `lttng snapshot list-output`. You can change this path or decide to send
6139 snapshots over the network using either:
6141 . An output path or URL that you specify when you create the
6143 . An snapshot output path or URL that you add using
6144 `lttng snapshot add-output`
6145 . An output path or URL that you provide directly to the
6146 `lttng snapshot record` command.
6148 Method 3 overrides method 2, which overrides method 1. When you
6149 specify a URL, a relay daemon must listen on a remote system (see
6150 <<sending-trace-data-over-the-network,Send trace data over the network>>).
6155 === Use the machine interface
6157 With any command of the cmd:lttng command-line tool, you can use the
6158 `--mi=xml` argument (before the command name) to get an XML machine
6159 interface output, for example:
6163 lttng --mi=xml enable-event --kernel --syscall open
6166 A schema definition (XSD) is
6167 https://github.com/lttng/lttng-tools/blob/stable-{revision}/src/common/mi_lttng.xsd[available]
6168 to ease the integration with external tools as much as possible.
6172 [[persistent-memory-file-systems]]
6173 === Record trace data on persistent memory file systems
6175 https://en.wikipedia.org/wiki/Non-volatile_random-access_memory[Non-volatile random-access memory]
6176 (NVRAM) is random-access memory that retains its information when power
6177 is turned off (non-volatile). Systems with such memory can store data
6178 structures in RAM and retrieve them after a reboot, without flushing
6179 to typical _storage_.
6181 Linux supports NVRAM file systems thanks to either
6182 http://pramfs.sourceforge.net/[PRAMFS] or
6183 https://www.kernel.org/doc/Documentation/filesystems/dax.txt[DAX]{nbsp}+{nbsp}http://lkml.iu.edu/hypermail/linux/kernel/1504.1/03463.html[pmem]
6184 (requires Linux 4.1+).
6186 This section does not describe how to operate such file systems;
6187 we assume that you have a working persistent memory file system.
6189 When you create a <<tracing-session,tracing session>>, you can specify
6190 the path of the shared memory holding the sub-buffers. If you specify a
6191 location on an NVRAM file system, then you can retrieve the latest
6192 recorded trace data when the system reboots after a crash.
6194 To record trace data on a persistent memory file system and retrieve the
6195 trace data after a system crash:
6197 . Create a tracing session with a sub-buffer shared memory path located
6198 on an NVRAM file system:
6203 lttng create --shm-path=/path/to/shm
6207 . Configure the tracing session as usual with the cmd:lttng
6208 command-line tool, and <<basic-tracing-session-control,start tracing>>.
6210 . After a system crash, use the cmd:lttng-crash command-line tool to
6211 view the trace data recorded on the NVRAM file system:
6216 lttng-crash /path/to/shm
6220 The binary layout of the ring buffer files is not exactly the same as
6221 the trace files layout. This is why you need to use the cmd:lttng-crash
6222 utility instead of your preferred trace viewer directly.
6224 To convert the ring buffer files to LTTng trace files:
6226 * Use the `--extract` option of cmd:lttng-crash:
6231 lttng-crash --extract=/path/to/trace /path/to/shm
6235 See man:lttng-crash(1) for the complete list of command-line options.
6241 This section presents various references for LTTng packages such as
6242 links to online manpages, tables that the rest of the text needs,
6243 descriptions of library functions, and more.
6246 [[online-lttng-manpages]]
6247 === Online noch:{LTTng} manpages
6249 LTTng packages currently install the following link:/man[man pages],
6250 available online using the links below:
6254 ** man:lttng-crash(1)
6255 ** man:lttng-sessiond(8)
6256 ** man:lttng-relayd(8)
6258 ** man:lttng-gen-tp(1)
6260 ** man:lttng-ust-cyg-profile(3)
6261 ** man:lttng-ust-dl(3)
6265 === noch:{LTTng-UST}
6267 This section presents references of the LTTng-UST package.
6271 ==== noch:{LTTng-UST} library (+liblttng‑ust+)
6273 The LTTng-UST library, or `liblttng-ust`, is the main shared object
6274 against which user applications are linked to make LTTng user space
6277 The <<c-application,C application>> guide shows the complete
6278 process to instrument, build and run a C/$$C++$$ application using
6279 LTTng-UST, while this section contains a few important tables.
6282 [[liblttng-ust-tp-fields]]
6283 ===== Tracepoint fields macros (for `TP_FIELDS()`)
6285 The available macros to define tracepoint fields, which you must use
6286 within `TP_FIELDS()` in `TRACEPOINT_EVENT()`, are:
6288 [role="func-desc growable",cols="asciidoc,asciidoc"]
6289 .Available macros to define LTTng-UST tracepoint fields
6291 |Macro |Description and parameters
6294 +ctf_integer(__t__, __n__, __e__)+
6296 +ctf_integer_nowrite(__t__, __n__, __e__)+
6298 Standard integer, displayed in base 10.
6301 Integer C type (`int`, `long`, `size_t`, ...).
6307 Argument expression.
6309 |+ctf_integer_hex(__t__, __n__, __e__)+
6311 Standard integer, displayed in base 16.
6320 Argument expression.
6322 |+ctf_integer_network(__t__, __n__, __e__)+
6324 Integer in network byte order (big-endian), displayed in base 10.
6333 Argument expression.
6335 |+ctf_integer_network_hex(__t__, __n__, __e__)+
6337 Integer in network byte order, displayed in base 16.
6346 Argument expression.
6349 +ctf_float(__t__, __n__, __e__)+
6351 +ctf_float_nowrite(__t__, __n__, __e__)+
6353 Floating point number.
6356 Floating point number C type (`float` or `double`).
6362 Argument expression.
6365 +ctf_string(__n__, __e__)+
6367 +ctf_string_nowrite(__n__, __e__)+
6369 Null-terminated string; undefined behavior if +__e__+ is `NULL`.
6375 Argument expression.
6378 +ctf_array(__t__, __n__, __e__, __s__)+
6380 +ctf_array_nowrite(__t__, __n__, __e__, __s__)+
6382 Statically-sized array of integers
6385 Array element C type.
6391 Argument expression.
6397 +ctf_array_text(__t__, __n__, __e__, __s__)+
6399 +ctf_array_text_nowrite(__t__, __n__, __e__, __s__)+
6401 Statically-sized array, printed as text.
6403 The string does not need to be null-terminated.
6406 Array element C type (always `char`).
6412 Argument expression.
6418 +ctf_sequence(__t__, __n__, __e__, __T__, __E__)+
6420 +ctf_sequence_nowrite(__t__, __n__, __e__, __T__, __E__)+
6422 Dynamically-sized array of integers.
6424 The type of +__E__+ must be unsigned.
6427 Array element C type.
6433 Argument expression.
6436 Length expression C type.
6442 +ctf_sequence_text(__t__, __n__, __e__, __T__, __E__)+
6444 +ctf_sequence_text_nowrite(__t__, __n__, __e__, __T__, __E__)+
6446 Dynamically-sized array, displayed as text.
6448 The string does not need to be null-terminated.
6450 The type of +__E__+ must be unsigned.
6452 The behaviour is undefined if +__e__+ is `NULL`.
6455 Sequence element C type (always `char`).
6461 Argument expression.
6464 Length expression C type.
6470 The `_nowrite` versions omit themselves from the session trace, but are
6471 otherwise identical. This means the tracer does not write the `_nowrite`
6472 fields to the trace. Their primary purpose is to make some of the event
6473 context available to the <<enabling-disabling-events,event filters>>
6474 without having to commit the data to sub-buffers.
6477 [[liblttng-ust-tracepoint-loglevel]]
6478 ===== Tracepoint log levels (for `TRACEPOINT_LOGLEVEL()`)
6480 The following table shows the available log level values for the
6481 `TRACEPOINT_LOGLEVEL()` macro:
6487 Action must be taken immediately.
6490 Critical conditions.
6499 Normal, but significant, condition.
6502 Informational message.
6504 `TRACE_DEBUG_SYSTEM`::
6505 Debug information with system-level scope (set of programs).
6507 `TRACE_DEBUG_PROGRAM`::
6508 Debug information with program-level scope (set of processes).
6510 `TRACE_DEBUG_PROCESS`::
6511 Debug information with process-level scope (set of modules).
6513 `TRACE_DEBUG_MODULE`::
6514 Debug information with module (executable/library) scope (set of units).
6516 `TRACE_DEBUG_UNIT`::
6517 Debug information with compilation unit scope (set of functions).
6519 `TRACE_DEBUG_FUNCTION`::
6520 Debug information with function-level scope.
6522 `TRACE_DEBUG_LINE`::
6523 Debug information with line-level scope (TRACEPOINT_EVENT default).
6526 Debug-level message.
6528 Log levels `TRACE_EMERG` through `TRACE_INFO` and `TRACE_DEBUG` match
6529 http://man7.org/linux/man-pages/man3/syslog.3.html[syslog]
6530 level semantics. Log levels `TRACE_DEBUG_SYSTEM` through `TRACE_DEBUG`
6531 offer more fine-grained selection of debug information.
6534 [[lttng-modules-ref]]
6535 === noch:{LTTng-modules}
6537 This section presents references of the LTTng-modules package.
6541 [[lttng-modules-tp-fields]]
6542 ==== Tracepoint fields macros (for `TP_FIELDS()`)
6544 [[tp-fast-assign]][[tp-struct-entry]]The available macros to define
6545 tracepoint fields, which must be listed within `TP_FIELDS()` in
6546 `LTTNG_TRACEPOINT_EVENT()`, are:
6548 [role="func-desc growable",cols="asciidoc,asciidoc"]
6549 .Available macros to define LTTng-modules tracepoint fields
6551 |Macro |Description and parameters
6554 +ctf_integer(__t__, __n__, __e__)+
6556 +ctf_integer_nowrite(__t__, __n__, __e__)+
6558 +ctf_user_integer(__t__, __n__, __e__)+
6560 +ctf_user_integer_nowrite(__t__, __n__, __e__)+
6562 Standard integer, displayed in base 10.
6565 Integer C type (`int`, `long`, `size_t`, ...).
6571 Argument expression.
6574 +ctf_integer_hex(__t__, __n__, __e__)+
6576 +ctf_user_integer_hex(__t__, __n__, __e__)+
6578 Standard integer, displayed in base 16.
6587 Argument expression.
6589 |+ctf_integer_oct(__t__, __n__, __e__)+
6591 Standard integer, displayed in base 8.
6600 Argument expression.
6603 +ctf_integer_network(__t__, __n__, __e__)+
6605 +ctf_user_integer_network(__t__, __n__, __e__)+
6607 Integer in network byte order (big-endian), displayed in base 10.
6616 Argument expression.
6619 +ctf_integer_network_hex(__t__, __n__, __e__)+
6621 +ctf_user_integer_network_hex(__t__, __n__, __e__)+
6623 Integer in network byte order, displayed in base 16.
6632 Argument expression.
6635 +ctf_string(__n__, __e__)+
6637 +ctf_string_nowrite(__n__, __e__)+
6639 +ctf_user_string(__n__, __e__)+
6641 +ctf_user_string_nowrite(__n__, __e__)+
6643 Null-terminated string; undefined behavior if +__e__+ is `NULL`.
6649 Argument expression.
6652 +ctf_array(__t__, __n__, __e__, __s__)+
6654 +ctf_array_nowrite(__t__, __n__, __e__, __s__)+
6656 +ctf_user_array(__t__, __n__, __e__, __s__)+
6658 +ctf_user_array_nowrite(__t__, __n__, __e__, __s__)+
6660 Statically-sized array of integers
6663 Array element C type.
6669 Argument expression.
6675 +ctf_array_text(__t__, __n__, __e__, __s__)+
6677 +ctf_array_text_nowrite(__t__, __n__, __e__, __s__)+
6679 +ctf_user_array_text(__t__, __n__, __e__, __s__)+
6681 +ctf_user_array_text_nowrite(__t__, __n__, __e__, __s__)+
6683 Statically-sized array, printed as text.
6685 The string does not need to be null-terminated.
6688 Array element C type (always `char`).
6694 Argument expression.
6700 +ctf_sequence(__t__, __n__, __e__, __T__, __E__)+
6702 +ctf_sequence_nowrite(__t__, __n__, __e__, __T__, __E__)+
6704 +ctf_user_sequence(__t__, __n__, __e__, __T__, __E__)+
6706 +ctf_user_sequence_nowrite(__t__, __n__, __e__, __T__, __E__)+
6708 Dynamically-sized array of integers.
6710 The type of +__E__+ must be unsigned.
6713 Array element C type.
6719 Argument expression.
6722 Length expression C type.
6727 |+ctf_sequence_hex(__t__, __n__, __e__, __T__, __E__)+
6729 Dynamically-sized array of integers, displayed in base 16.
6731 The type of +__E__+ must be unsigned.
6734 Array element C type.
6740 Argument expression.
6743 Length expression C type.
6748 |+ctf_sequence_network(__t__, __n__, __e__, __T__, __E__)+
6750 Dynamically-sized array of integers in network byte order (big-endian),
6751 displayed in base 10.
6753 The type of +__E__+ must be unsigned.
6756 Array element C type.
6762 Argument expression.
6765 Length expression C type.
6771 +ctf_sequence_text(__t__, __n__, __e__, __T__, __E__)+
6773 +ctf_sequence_text_nowrite(__t__, __n__, __e__, __T__, __E__)+
6775 +ctf_user_sequence_text(__t__, __n__, __e__, __T__, __E__)+
6777 +ctf_user_sequence_text_nowrite(__t__, __n__, __e__, __T__, __E__)+
6779 Dynamically-sized array, displayed as text.
6781 The string does not need to be null-terminated.
6783 The type of +__E__+ must be unsigned.
6785 The behaviour is undefined if +__e__+ is `NULL`.
6788 Sequence element C type (always `char`).
6794 Argument expression.
6797 Length expression C type.
6803 Use the `_user` versions when the argument expression, `e`, is
6804 a user space address. In the cases of `ctf_user_integer*()` and
6805 `ctf_user_float*()`, `&e` must be a user space address, thus `e` must
6808 The `_nowrite` versions omit themselves from the session trace, but are
6809 otherwise identical. This means the `_nowrite` fields won't be written
6810 in the recorded trace. Their primary purpose is to make some
6811 of the event context available to the
6812 <<enabling-disabling-events,event filters>> without having to
6813 commit the data to sub-buffers.
6819 Terms related to LTTng and to tracing in general:
6822 The http://diamon.org/babeltrace[Babeltrace] project, which includes
6823 the cmd:babeltrace command, some libraries, and Python bindings.
6825 <<channel-buffering-schemes,buffering scheme>>::
6826 A layout of sub-buffers applied to a given channel.
6828 <<channel,channel>>::
6829 An entity which is responsible for a set of ring buffers.
6831 <<event,Event rules>> are always attached to a specific channel.
6834 A reference of time for a tracer.
6836 <<lttng-consumerd,consumer daemon>>::
6837 A process which is responsible for consuming the full sub-buffers
6838 and write them to a file system or send them over the network.
6840 <<channel-overwrite-mode-vs-discard-mode,discard mode>>:: The event loss
6841 mode in which the tracer _discards_ new event records when there's no
6842 sub-buffer space left to store them.
6845 The consequence of the execution of an instrumentation
6846 point, like a tracepoint that you manually place in some source code,
6847 or a Linux kernel KProbe.
6849 An event is said to _occur_ at a specific time. Different actions can
6850 be taken upon the occurance of an event, like record the event's payload
6853 <<channel-overwrite-mode-vs-discard-mode,event loss mode>>::
6854 The mechanism by which event records of a given channel are lost
6855 (not recorded) when there is no sub-buffer space left to store them.
6857 [[def-event-name]]event name::
6858 The name of an event, which is also the name of the event record.
6859 This is also called the _instrumentation point name_.
6862 A record, in a trace, of the payload of an event which occured.
6864 <<event,event rule>>::
6865 Set of conditions which must be satisfied for one or more occuring
6866 events to be recorded.
6868 `java.util.logging`::
6870 https://docs.oracle.com/javase/7/docs/api/java/util/logging/package-summary.html[core logging facilities].
6872 <<instrumenting,instrumentation>>::
6873 The use of LTTng probes to make a piece of software traceable.
6875 instrumentation point::
6876 A point in the execution path of a piece of software that, when
6877 reached by this execution, can emit an event.
6879 instrumentation point name::
6880 See _<<def-event-name,event name>>_.
6883 A http://logging.apache.org/log4j/1.2/[logging library] for Java
6884 developed by the Apache Software Foundation.
6887 Level of severity of a log statement or user space
6888 instrumentation point.
6891 The _Linux Trace Toolkit: next generation_ project.
6893 <<lttng-cli,cmd:lttng>>::
6894 A command-line tool provided by the LTTng-tools project which you
6895 can use to send and receive control messages to and from a
6899 The https://github.com/lttng/lttng-analyses[LTTng analyses] project,
6900 which is a set of analyzing programs that are used to obtain a
6901 higher level view of an LTTng trace.
6903 cmd:lttng-consumerd::
6904 The name of the consumer daemon program.
6907 A utility provided by the LTTng-tools project which can convert
6908 ring buffer files (usually
6909 <<persistent-memory-file-systems,saved on a persistent memory file system>>)
6912 LTTng Documentation::
6915 <<lttng-live,LTTng live>>::
6916 A communication protocol between the relay daemon and live viewers
6917 which makes it possible to see events "live", as they are received by
6920 <<lttng-modules,LTTng-modules>>::
6921 The https://github.com/lttng/lttng-modules[LTTng-modules] project,
6922 which contains the Linux kernel modules to make the Linux kernel
6923 instrumentation points available for LTTng tracing.
6926 The name of the relay daemon program.
6928 cmd:lttng-sessiond::
6929 The name of the session daemon program.
6932 The https://github.com/lttng/lttng-tools[LTTng-tools] project, which
6933 contains the various programs and libraries used to
6934 <<controlling-tracing,control tracing>>.
6936 <<lttng-ust,LTTng-UST>>::
6937 The https://github.com/lttng/lttng-ust[LTTng-UST] project, which
6938 contains libraries to instrument user applications.
6940 <<lttng-ust-agents,LTTng-UST Java agent>>::
6941 A Java package provided by the LTTng-UST project to allow the
6942 LTTng instrumentation of `java.util.logging` and Apache log4j 1.2
6945 <<lttng-ust-agents,LTTng-UST Python agent>>::
6946 A Python package provided by the LTTng-UST project to allow the
6947 LTTng instrumentation of Python logging statements.
6949 <<channel-overwrite-mode-vs-discard-mode,overwrite mode>>::
6950 The event loss mode in which new event records overwrite older
6951 event records when there's no sub-buffer space left to store them.
6953 <<channel-buffering-schemes,per-process buffering>>::
6954 A buffering scheme in which each instrumented process has its own
6955 sub-buffers for a given user space channel.
6957 <<channel-buffering-schemes,per-user buffering>>::
6958 A buffering scheme in which all the processes of a Unix user share the
6959 same sub-buffer for a given user space channel.
6961 <<lttng-relayd,relay daemon>>::
6962 A process which is responsible for receiving the trace data sent by
6963 a distant consumer daemon.
6966 A set of sub-buffers.
6968 <<lttng-sessiond,session daemon>>::
6969 A process which receives control commands from you and orchestrates
6970 the tracers and various LTTng daemons.
6972 <<taking-a-snapshot,snapshot>>::
6973 A copy of the current data of all the sub-buffers of a given tracing
6974 session, saved as trace files.
6977 One part of an LTTng ring buffer which contains event records.
6980 The time information attached to an event when it is emitted.
6983 A set of files which are the concatenations of one or more
6984 flushed sub-buffers.
6987 The action of recording the events emitted by an application
6988 or by a system, or to initiate such recording by controlling
6992 The http://tracecompass.org[Trace Compass] project and application.
6995 An instrumentation point using the tracepoint mechanism of the Linux
6996 kernel or of LTTng-UST.
6998 tracepoint definition::
6999 The definition of a single tracepoint.
7002 The name of a tracepoint.
7004 tracepoint provider::
7005 A set of functions providing tracepoints to an instrumented user
7008 Not to be confused with a _tracepoint provider package_: many tracepoint
7009 providers can exist within a tracepoint provider package.
7011 tracepoint provider package::
7012 One or more tracepoint providers compiled as an object file or as
7016 A software which records emitted events.
7018 <<domain,tracing domain>>::
7019 A namespace for event sources.
7022 The Unix group in which a Unix user can be to be allowed to trace the
7025 <<tracing-session,tracing session>>::
7026 A stateful dialogue between you and a <<lttng-sessiond,session
7030 An application running in user space, as opposed to a Linux kernel
7031 module, for example.