fix: trailing backslash in include/Makefile.am
[lttng-ust.git] / README.md
CommitLineData
28ed9628
PP
1LTTng-UST
2=========
3
4The LTTng User Space Tracing (LTTng-UST) library allows any C/C++
5application to be instrumented for and traced by
6[LTTng](http://lttng.org/). LTTng-UST also includes a logging
7back-end for Java applications and various dynamically loadable
8user space tracing helpers for any application.
9
10
11Prerequisites
12-------------
13
090b0701 14LTTng-UST depends on **[liburcu](http://liburcu.org/) >= 0.12** at build and
915faa3d 15run times. It also optionally depends on libnuma.
28ed9628
PP
16
17
18Building
19--------
20
21### Prerequisites
22
23This source tree is based on the Autotools suite from GNU to simplify
24portability. Here are some things you should have on your system in order to
25compile the Git repository tree:
26
6f9466c5 27 - [GNU Autotools](http://www.gnu.org/software/autoconf/)
90e5d8e4
MJ
28 (**Automake >= 1.12**, **Autoconf >= 2.69**,
29 **Autoheader >= 2.69**;
28ed9628 30 make sure your system-wide `automake` points to a recent version!)
6f9466c5 31 - **[GNU Libtool](https://www.gnu.org/software/libtool/) >= 2.2**
ff1ee9bc 32 - **[pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/)**
c5123a13
PP
33
34
35### Optional dependencies
28ed9628 36
b49b04f4 37Optional packages to build LTTng-ust man pages:
4ddbd0b7
PP
38
39 - **[AsciiDoc](http://www.methods.co.nz/asciidoc/) >= 8.4.5**
40 (previous versions may work, but were not tested)
41 - **[xmlto](https://fedorahosted.org/xmlto/) >= 0.0.21** (previous
42 versions may work, but were not tested)
43
44Note that the man pages are already built in a distribution tarball.
45In this case, you only need AsciiDoc and xmlto if you indend to modify
46the AsciiDoc man page sources.
47
c5123a13
PP
48Needed for `make check` and tests:
49
50 - **[Perl](https://www.perl.org/)**
51
52
53### Building steps
54
28ed9628
PP
55If you get the tree from the Git repository, you will need to run
56
57 ./bootstrap
58
59in its root. It calls all the GNU tools needed to prepare the tree
60configuration.
61
62To build LTTng-UST, do:
63
64 ./configure
65 make
66 sudo make install
67 sudo ldconfig
68
69**Note:** the `configure` script sets `/usr/local` as the default prefix for
70files it installs. However, this path is not part of most distributions'
71default library path, which will cause builds depending on `liblttng-ust`
72to fail unless `-L/usr/local/lib` is added to `LDFLAGS`. You may provide a
73custom prefix to `configure` by using the `--prefix` switch
74(e.g., `--prefix=/usr`). LTTng-UST needs to be a shared library, _even if_
75the tracepoint probe provider is statically linked into the application.
76
77
78Using
79-----
80
81First of all, create an instrumentation header following the
82[tracepoint examples](doc/examples).
83
84There are two ways to compile the tracepoint provider and link it with
85your application: statically or dynamically. Please follow carefully one
86or the other method.
87
88
89### Static linking
90
91This method links the tracepoint provider with the application,
92either directly or through a static library (`.a`):
93
94 1. Into exactly one unit (C/C++ source file) of your _application_,
95 define `TRACEPOINT_DEFINE` and include the tracepoint provider
96 header.
97 2. Include the tracepoint provider header into all C/C++ files using
98 the provider and insert tracepoints using the `tracepoint()` macro.
99 3. Use `-I.` when compiling the unit defining `TRACEPOINT_DEFINE`
100 (e.g., `tp.c`).
101 4. Link the application with `-ldl` on Linux, or with `-lc` on BSD,
102 and with `-llttng-ust`.
103
104Example:
105
106 gcc -c -I. tp.c
107 gcc -c some-source.c
108 gcc -c other-source.c
109 gcc -o my-app tp.o some-source.o other-source.o -ldl -llttng-ust
110
111Run the application directly:
112
113 ./my-app
114
115Other relevant examples:
116
117 - [`doc/examples/easy-ust`](doc/examples/easy-ust)
118 - [`doc/examples/hello-static-lib`](doc/examples/hello-static-lib)
119
120
121### Dynamic loading
122
123This method decouples the tracepoint provider from the application,
124making it dynamically loadable.
125
126 1. Into exactly one unit of your _application_, define
127 `TRACEPOINT_DEFINE` _and_ `TRACEPOINT_PROBE_DYNAMIC_LINKAGE`,
128 then include the tracepoint provider header.
129 2. Include the tracepoint provider header into all C/C++ files using
130 the provider and insert tracepoints using the `tracepoint()` macro.
131 3. Use `-I.` and `-fpic` when compiling the tracepoint provider
132 (e.g., `tp.c`).
133 4. Link the tracepoint provider with `-llttng-ust` and make it a
134 shared object with `-shared`.
135 5. Link the application with `-ldl` on Linux, or with `-lc` on BSD.
136
137Example:
138
139 gcc -c -I. -fpic tp.c
140 gcc -o tp.so -shared tp.o -llttng-ust
141 gcc -o my-app some-source.c other-source.c -ldl
142
143To run _without_ LTTng-UST support:
144
145 ./my-app
146
147To run with LTTng-UST support (register your tracepoint provider,
148`tp.so`):
149
150 LD_PRELOAD=./tp.so ./my-app
151
152You could also use `libdl` directly in your application and `dlopen()`
153your tracepoint provider shared object (`tp.so`) to make LTTng-UST
154tracing possible.
155
156Other relevant examples:
157
158 - [`doc/examples/demo`](doc/examples/demo)
159
160
161### Controlling tracing and viewing traces
162
163Use [LTTng-tools](https://lttng.org/download) to control the tracer.
164Use [Babeltrace](https://lttng.org/babeltrace) to print traces as a
165human-readable text log.
166
167
168### Environment variables and compile flags
169
170 - `liblttng-ust` debug can be activated by setting the environment
171 variable `LTTNG_UST_DEBUG` when launching the user application. It
172 can also be enabled at build time by compiling LTTng-UST with
173 `-DLTTNG_UST_DEBUG`.
174 - The environment variable `LTTNG_UST_REGISTER_TIMEOUT` can be used to
175 specify how long the applications should wait for the session
176 daemon _registration done_ command before proceeding to execute the
177 main program. The default is 3000 ms (3 seconds). The timeout value
178 is specified in milliseconds. The value 0 means _don't wait_. The
179 value -1 means _wait forever_. Setting this environment variable to 0
180 is recommended for applications with time constraints on the process
181 startup time.
182 - The compilation flag `-DLTTNG_UST_DEBUG_VALGRIND` should be enabled
183 at build time to allow `liblttng-ust` to be used with Valgrind
184 (side-effect: disables per-CPU buffering).
185
186
187### Notes
188
189#### C++ support
190
191Since LTTng-UST 2.3, both tracepoints and tracepoint providers can be
192compiled in C++. To compile tracepoint probes in C++, you need
15b385c8 193G++ >= 4.7 or Clang. The C++ compilers need to support C++11.
28ed9628
PP
194
195
196Contact
197-------
198
199Maintainer: [Mathieu Desnoyers](mailto:mathieu.desnoyers@efficios.com)
200
201Mailing list: [`lttng-dev@lists.lttng.org`](https://lttng.org/cgi-bin/mailman/listinfo/lttng-dev)
202
203
204Package contents
205----------------
206
207This package contains the following elements:
208
209 - `doc`: LTTng-UST documentation and examples.
210 - `include`: the public header files that will be installed on the
211 system.
212 - `liblttng-ust`: the actual userspace tracing library that must be
213 linked to the instrumented programs.
214 - `liblttng-ust-comm`: a static library shared between `liblttng-ust`
215 and LTTng-tools, that provides functions that allow these components
216 to communicate together.
217 - `liblttng-ust-ctl`: a library to control tracing in other processes;
218 used by LTTng-tools.
219 - `liblttng-ust-cyg-profile`: a library that can be preloaded (using
220 `LD_PRELOAD`) to instrument function entries and exits when the target
221 application is built with the GCC flag `-finstrument-functions`.
222 - `liblttng-ust-dl`: a library that can be preloaded to instrument
223 calls to `dlopen()` and `dlclose()`.
224 - `liblttng-ust-fork`: a library that is preloaded and that hijacks
225 calls to several system calls in order to trace across these calls.
226 It _has_ to be preloaded in order to hijack calls. In contrast,
227 `liblttng-ust` may be linked at build time.
228 - `liblttng-ust-java`: a simple library that uses JNI to allow tracing
380a81f4 229 in Java programs. (Configure with `--enable-jni-interface`).
b49b04f4
MJ
230 - `liblttng-ust-java-agent`: a package that includes a JNI library and a
231 JAR library to provide an LTTng-UST logging back-end for Java
380a81f4
GB
232 applications using Java Util Logging or Log4j. (Configure with
233 `--enable-java-agent-jul` or `--enable-java-agent-log4j` or
234 `--enable-java-agent-all`).
28ed9628
PP
235 - `liblttng-ust-libc-wrapper`: an example library that can be
236 preloaded to instrument some calls to libc (currently `malloc()` and
237 `free()`) and to POSIX threads (mutexes currently instrumented) in
238 any program without need to recompile it.
b49b04f4 239 - `liblttng-ust-python-agent`: a library used by python-lttngust to allow
380a81f4 240 tracing in Python applications. (Configure with `--enable-python-agent`)
28ed9628 241 - `libringbuffer`: the ring buffer implementation used within LTTng-UST.
b49b04f4
MJ
242 - `python-lttngust`: a package to provide an LTTng-UST logging back-end
243 for Python applications using the standard logging framework.
28ed9628
PP
244 - `snprintf`: an asynchronous signal-safe version of `snprintf()`.
245 - `tests`: various test programs.
246 - `tools`: home of `lttng-gen-tp`.
This page took 0.03335 seconds and 4 git commands to generate.