File: README.md

package info (click to toggle)
ust 2.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,444 kB
  • sloc: xml: 78,798; ansic: 48,233; sh: 5,806; java: 2,202; makefile: 1,832; python: 727; cpp: 384
file content (275 lines) | stat: -rw-r--r-- 10,026 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<!--
SPDX-FileCopyrightText: 2023 EfficiOS, Inc.

SPDX-License-Identifier: CC-BY-4.0
-->

LTTng-UST
=========

The LTTng User Space Tracing (LTTng-UST) library allows any C/C++
application to be instrumented for and traced by
[LTTng](http://lttng.org/). LTTng-UST also includes a logging
back-end for Java applications and various dynamically loadable
user space tracing helpers for any application.


Prerequisites
-------------

LTTng-UST depends on **[liburcu](http://liburcu.org/) >= 0.15** at build
time. It also optionally depends on libnuma.


Building
--------

### Prerequisites

This source tree is based on the Autotools suite from GNU to simplify
portability. Here are some things you should have on your system in order to
compile the Git repository tree:

  - [GNU Autotools](http://www.gnu.org/software/autoconf/)
    (**Automake >= 1.12**, **Autoconf >= 2.69**,
    **Autoheader >= 2.69**;
    make sure your system-wide `automake` points to a recent version!)
  - **[GNU Libtool](https://www.gnu.org/software/libtool/) >= 2.2**
  - **[GNU Make](https://www.gnu.org/software/make/)**
  - **[pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/)**


### Optional dependencies

Optional packages to build LTTng-ust man pages:

  - **[AsciiDoc](http://www.methods.co.nz/asciidoc/) >= 8.4.5**
    (previous versions may work, but were not tested)
  - **[xmlto](https://fedorahosted.org/xmlto/) >= 0.0.21** (previous
    versions may work, but were not tested)

Note that the man pages are already built in a distribution tarball.
In this case, you only need AsciiDoc and xmlto if you indend to modify
the AsciiDoc man page sources.

Needed for `make check` and tests:

  - **[Perl](https://www.perl.org/)**


### Building steps

If you get the tree from the Git repository, you will need to run

    ./bootstrap

in its root. It calls all the GNU tools needed to prepare the tree
configuration.

To build LTTng-UST, do:

    ./configure
    make
    sudo make install
    sudo ldconfig

**Note:** the `configure` script sets `/usr/local` as the default prefix for
files it installs. However, this path is not part of most distributions'
default library path, which will cause builds depending on `liblttng-ust`
to fail unless `-L/usr/local/lib` is added to `LDFLAGS`. You may provide a
custom prefix to `configure` by using the `--prefix` switch
(e.g., `--prefix=/usr`). LTTng-UST needs to be a shared library, _even if_
the tracepoint probe provider is statically linked into the application.


Using
-----

First of all, create an instrumentation header following the
[tracepoint examples](doc/examples).

There are two ways to compile the tracepoint provider and link it with
your application: statically or dynamically. Please follow carefully one
or the other method.


### Static linking

This method links the tracepoint provider with the application,
either directly or through a static library (`.a`):

  1. Into exactly one unit (C/C++ source file) of your _application_,
     define `LTTNG_UST_TRACEPOINT_DEFINE` and include the tracepoint provider
     header.
  2. Include the tracepoint provider header into all C/C++ files using
     the provider and insert tracepoints using the `tracepoint()` macro.
  3. Use `-I.` when compiling the unit defining `LTTNG_UST_TRACEPOINT_DEFINE`
     (e.g., `tp.c`).
  4. Link the application with `-ldl` on Linux, or with `-lc` on BSD,
     and with `-llttng-ust`.

Example:

    gcc -c -I. tp.c
    gcc -c some-source.c
    gcc -c other-source.c
    gcc -o my-app tp.o some-source.o other-source.o -ldl -llttng-ust

Run the application directly:

    ./my-app

Other relevant examples:

  - [`doc/examples/easy-ust`](doc/examples/easy-ust)
  - [`doc/examples/hello-static-lib`](doc/examples/hello-static-lib)


### Dynamic loading

This method decouples the tracepoint provider from the application,
making it dynamically loadable.

  1. Into exactly one unit of your _application_, define
     `LTTNG_UST_TRACEPOINT_DEFINE` _and_ `LTTNG_UST_TRACEPOINT_PROBE_DYNAMIC_LINKAGE`,
     then include the tracepoint provider header.
  2. Include the tracepoint provider header into all C/C++ files using
     the provider and insert tracepoints using the `tracepoint()` macro.
  3. Use `-I.` and `-fpic` when compiling the tracepoint provider
     (e.g., `tp.c`).
  4. Link the tracepoint provider with `-llttng-ust` and make it a
     shared object with `-shared`.
  5. Link the application with `-ldl` on Linux, or with `-lc` on BSD.

Example:

    gcc -c -I. -fpic tp.c
    gcc -o tp.so -shared tp.o -llttng-ust
    gcc -o my-app some-source.c other-source.c -ldl

To run _without_ LTTng-UST support:

    ./my-app

To run with LTTng-UST support (register your tracepoint provider,
`tp.so`):

    LD_PRELOAD=./tp.so ./my-app

You could also use `libdl` directly in your application and `dlopen()`
your tracepoint provider shared object (`tp.so`) to make LTTng-UST
tracing possible.

Other relevant examples:

  - [`doc/examples/demo`](doc/examples/demo)


### Controlling tracing and viewing traces

Use [LTTng-tools](https://lttng.org/download) to control the tracer.
Use [Babeltrace](https://lttng.org/babeltrace) to print traces as a
human-readable text log.


### Environment variables and compile flags

  - `liblttng-ust` debug can be activated by setting the environment
    variable `LTTNG_UST_DEBUG` when launching the user application. It
    can also be enabled at build time by compiling LTTng-UST with
    `-DLTTNG_UST_DEBUG`.
  - `liblttng-ust` abort on critical can be activated by setting the
    environment variable `LTTNG_UST_ABORT_ON_CRITICAL` when launching the user
    application. It can also be enabled at build time by compiling LTTng-UST with
    `-DLTTNG_UST_ABORT_ON_CRITICAL`.
  - The environment variable `LTTNG_UST_REGISTER_TIMEOUT` can be used to
    specify how long the applications should wait for the session
    daemon  _registration done_ command before proceeding to execute the
    main program. The default is 3000 ms (3 seconds). The timeout value
    is specified in milliseconds. The value 0 means _don't wait_. The
    value -1 means _wait forever_. Setting this environment variable to 0
    is recommended for applications with time constraints on the process
    startup time.
  - The compilation flag `-DLTTNG_UST_DEBUG_VALGRIND` should be enabled
    at build time to allow `liblttng-ust` to be used with Valgrind
    (side-effect: disables per-CPU buffering).


### Notes

#### C++ support

Since LTTng-UST 2.3, both tracepoints and tracepoint providers can be
compiled in C++. To compile tracepoint probes in C++, you need
G++ >= 4.7 or Clang >= 4.0. The C++ compilers need to support C++11.


Supported versions
------------------

The LTTng project supports the last two released stable versions
(e.g. stable-2.13 and stable-2.12).

Fixes are backported from the master branch to the last stable version
unless those fixes would break the ABI or API. Those fixes may be backported
to the second-last stable version, depending on complexity and ABI/API
compatibility.

Security fixes are backported from the master branch to both of the last stable
version and the the second-last stable version.

New features are integrated into the master branch and not backported to the
last stable branch.

Contact
-------

Maintainer: [Mathieu Desnoyers](mailto:mathieu.desnoyers@efficios.com)

Mailing list: [`lttng-dev@lists.lttng.org`](https://lttng.org/cgi-bin/mailman/listinfo/lttng-dev)

Code review: [_lttng-ust_ project](https://review.lttng.org/q/project:lttng-ust) on LTTng Review

Package contents
----------------

This package contains the following elements:

  - `doc`: LTTng-UST documentation and examples.
  - `include`: the public header files that will be installed on the
    system.
  - `liblttng-ust`: the actual userspace tracing library that must be
    linked to the instrumented programs.
  - `liblttng-ust-comm`: a static library shared between `liblttng-ust`
    and LTTng-tools, that provides functions that allow these components
    to communicate together.
  - `liblttng-ust-ctl`: a library to control tracing in other processes;
     used by LTTng-tools.
  - `liblttng-ust-cyg-profile`: a library that can be preloaded (using
    `LD_PRELOAD`) to instrument function entries and exits when the target
    application is built with the GCC flag `-finstrument-functions`.
  - `liblttng-ust-dl`: a library that can be preloaded to instrument
    calls to `dlopen()` and `dlclose()`.
  - `liblttng-ust-fork`: a library that is preloaded and that hijacks
    calls to several system calls in order to trace across these calls.
    It _has_ to be preloaded in order to hijack calls. In contrast,
    `liblttng-ust` may be linked at build time.
  - `liblttng-ust-java`: a simple library that uses JNI to allow tracing
    in Java programs. (Configure with `--enable-jni-interface`).
  - `liblttng-ust-java-agent`: a package that includes a JNI library and a
    JAR library to provide an LTTng-UST logging back-end for Java
    applications using Java Util Logging or Log4j. (Configure with
    `--enable-java-agent-jul` or `--enable-java-agent-log4j` or
    `--enable-java-agent-log4j2` or `--enable-java-agent-all`).
  - `liblttng-ust-libc-wrapper`: an example library that can be
    preloaded to instrument some calls to libc (currently `malloc()` and
    `free()`) and to POSIX threads (mutexes currently instrumented) in
    any program without need to recompile it.
  - `liblttng-ust-python-agent`: a library used by python-lttngust to allow
    tracing in Python applications. (Configure with `--enable-python-agent`)
  - `libringbuffer`: the ring buffer implementation used within LTTng-UST.
  - `python-lttngust`: a package to provide an LTTng-UST logging back-end
    for Python applications using the standard logging framework.
  - `snprintf`: an asynchronous signal-safe version of `snprintf()`.
  - `tests`: various test programs.
  - `tools`: home of `lttng-gen-tp`.