2 id: liblttng‑ust‑cyg‑profile
5 Function tracing is the recording of which functions are entered and
6 left during the execution of an application. Like with any LTTng event,
7 the precise time at which this happens is also kept.
9 GCC and clang have an option named
10 <a href="https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/Code-Gen-Options.html" class="ext"><code>-finstrument-functions</code></a>
11 which generates instrumentation calls for entry and exit to functions.
12 The LTTng-UST function tracing helpers, `liblttng-ust-cyg-profile.so`
13 and `liblttng-ust-cyg-profile-fast.so`, take advantage of this feature
14 to add instrumentation to the two generated functions (which contain
15 `cyg_profile` in their names, hence the shared object's name).
17 In order to use LTTng-UST function tracing, the translation units to
18 instrument must be built using the `-finstrument-functions` compiler
21 LTTng-UST function tracing comes in two flavors, each providing
22 different trade-offs: `liblttng-ust-cyg-profile-fast.so` and
23 `liblttng-ust-cyg-profile.so`.
25 **`liblttng-ust-cyg-profile-fast.so`** is a lightweight variant that
26 should only be used where it can be _guaranteed_ that the complete event
27 stream is recorded without any missing events. Any kind of duplicate
28 information is left out. This version registers the following
31 <table class="func-desc">
34 <th><abbr title="Tracepoint">TP</abbr> provider name</th>
35 <th><abbr title="Tracepoint">TP</abbr> name</th>
36 <th>Description/fields</th>
42 <code class="no-bg">lttng_ust_cyg_profile_fast</code>
45 <code class="no-bg">func_entry</code>
52 <code class="arg">addr</code> address of the
60 <code class="no-bg">func_exit</code>
69 Assuming no event is lost, having only the function addresses on entry
70 is enough for creating a call graph (remember that a recorded event
71 always contains the ID of the CPU that generated it). A tool like
72 <a href="https://sourceware.org/binutils/docs/binutils/addr2line.html" class="ext"><code>addr2line</code></a>
73 may be used to convert function addresses back to source files names
77 **`liblttng-ust-cyg-profile.so`**,
78 is a more robust variant which also works for use cases where
79 events might get discarded or not recorded from application startup.
80 In these cases, the trace analyzer needs extra information to be
81 able to reconstruct the program flow. This version registers the
82 following tracepoints:
84 <table class="func-desc">
87 <th><abbr title="Tracepoint">TP</abbr> provider name</th>
88 <th><abbr title="Tracepoint">TP</abbr> name</th>
89 <th>Description/fields</th>
95 <code class="no-bg">lttng_ust_cyg_profile</code>
98 <code class="no-bg">func_entry</code>
101 <p>Function entry</p>
105 <code class="arg">addr</code> address of the
109 <code class="arg">call_site</code> call site
117 <code class="no-bg">func_exit</code>
124 <code class="arg">addr</code> address of the
128 <code class="arg">call_site</code> call site
137 To use one or the other variant with any user application, assuming at
138 least one translation unit of the latter is compiled with the
139 `-finstrument-functions` option, do:
142 LD_PRELOAD=liblttng-ust-cyg-profile-fast.so my-app
148 LD_PRELOAD=liblttng-ust-cyg-profile.so my-app
151 It might be necessary to limit the number of source files where
152 `-finstrument-functions` is used to prevent excessive amount of trace
153 data to be generated at runtime.
157 <span class="t">Tip:</span> When using GCC, at least, you may use
159 <code>-finstrument-functions-exclude-function-list</code>
160 option to avoid instrumenting entries and exits of specific
165 All events generated from LTTng-UST function tracing are provided on
166 log level `TRACE_DEBUG_FUNCTION`, which is useful to easily enable
167 function tracing events in your tracing session using the
168 `--loglevel-only` option of `lttng enable-event`
169 (see [Controlling tracing](#doc-controlling-tracing)).