babeltrace-filter.lttng-utils.debug-info(7): fix LTTng prerequisites
[babeltrace.git] / doc / man / babeltrace-filter.lttng-utils.debug-info.7.txt
CommitLineData
0659f3af
PP
1babeltrace-filter.lttng-utils.debug-info(7)
2===========================================
3:manpagetype: component class
4:revdate: 5 October 2017
5:comp: compcls:filter.lttng-utils.debug-info
6:defdebuginfoname: `debug_info`
7
8
9NAME
10----
11babeltrace-filter.lttng-utils.debug-info - Babeltrace's debugging
12information filter component class for LTTng traces
13
14
15DESCRIPTION
16-----------
17The Babeltrace {comp} component class, provided by the the
18man:babeltrace-plugin-lttng-utils(7) plugin, once instantiated, receives
19events from http://lttng.org/[LTTng] traces and creates new ones
20which are copies of the original ones with extra debugging information
21when it's available and possible.
22
23A {comp} component uses the LTTng state dump events as well as the event
24context's `ip` (instruction pointer) field to locate and read the
25corresponding debugging information. The component can find the extra
26debugging information in an executable file or in a directory containing
27debugging information created by the compiler.
28
29The new events contain the exact same fields as the original ones and,
30when possible, a new event context's structure field (besides the `ip`
31field) named {defdebuginfoname} by default. This structure field
32contains the following fields:
33
34`bin` (string field)::
35 Executable path or name followed by `@ADDR` or `+ADDR`, where
36 `ADDR` is the address where it was loaded while being traced.
37 `@ADDR` means `ADDR` is an absolute address, and `+ADDR` means
38 `ADDR` is a relative address.
39+
40Example: `my-program@0x401040`.
41
42[[field-func]]`func` (string field)::
43 Function name followed by `+OFFSET`, where `OFFSET` is the
44 offset from the beginning of the function symbol in the executable
45 file.
46+
47Example: `load_user_config+0x194`.
48
49[[field-src]]`src` (string field)::
50 Source file path or name followed by `:LINE`, where `LINE` is the
51 line number in this source file at which the event occured.
52+
53Example: `user-config.c:1025`.
54
55Any of those the previous fields can be an empty string if the
56debugging information was not available for the analyzed original
57LTTng event.
58
59When a filter component creates a new event with debugging
60information, it discards the original event. If the component receives a
61non-LTTng event, the component moves the event to its output port
62without alteration.
63
64
65Compile an executable for debugging information analysis
66~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
67With GCC or Clang, you should compile the program or library source
68files in debug mode with the nlopt:-g option. This option makes the
69compiler generate debugging information in the operating system's native
70format. This format is recognized by a {comp} component: it can
71translate the instruction pointer field of an event's context to a
72source file and line number, along with the name of the surrounding
73function.
74
75NOTE: This component class only supports the debugging information in
76DWARF format, version{nbsp}2 or later. Use the nlopt:-gdwarf or
77nlopt:-gdwarf-VERSION (where `VERSION` is the DWARF version) compiler
78options to explicitly generate DWARF debugging information.
79
80If you don't compile the executable's source files with the nlopt:-g
81option or with an equivalent option, no DWARF information is available:
82the component uses ELF symbols from the executable file instead. In this
83case, the events that the component creates do not contain the source
84file and line number (<<field-src,`src` field>>), but only the name of
85the nearest function symbol with an offset in bytes to the location in
86the executable from which the LTTng event occured (<<field-func,`func`
87field>>).
88
89If the executable file has neither ELF symbols nor DWARF information,
90the {comp} component cannot map the event to
91its source location: it emits the original LTTng event which has no
92special {defdebuginfoname} context field.
93
94
95LTTng prerequisites
96~~~~~~~~~~~~~~~~~~~
97A {comp} component can only analyze user space events generated by
98http://lttng.org[LTTng]{nbsp}2.8.0 or later.
99
a4c4205a
PP
100To get debugging information for LTTng-UST events which occur in
101executables and libraries which the system's loader loads (what
102you can see with man:ldd(1)):
0659f3af 103
a4c4205a
PP
104. Add the `ip` and `vpid` context fields to user space event records:
105+
106--
0659f3af
PP
107[role="term"]
108----
109$ lttng add-context --userspace --type=ip --type=vpid
110----
a4c4205a
PP
111--
112+
113See man:lttng-add-context(1) for more details.
0659f3af 114
a4c4205a
PP
115. Enable the LTTng-UST state dump events:
116+
117--
118[role="term"]
119----
120$ lttng enable-event --userspace 'lttng_ust_statedump:*'
121----
122--
123+
124See man:lttng-enable-event(1) and man:lttng-ust(3) for more details.
0659f3af
PP
125
126To get debugging information for LTTng-UST events which occur in
a4c4205a 127dynamically loaded objects, for example plugins:
0659f3af 128
a4c4205a
PP
129. Do the previous steps (add context fields and enable
130 the LTTng-UST state dump events).
131
132. Enable the LTTng-UST dynamic linker tracing helper events:
133+
134--
0659f3af
PP
135[role="term"]
136----
a4c4205a 137$ lttng enable-event --userspace 'lttng_ust_dl:*'
0659f3af 138----
a4c4205a
PP
139--
140+
141See man:lttng-ust-dl(3) for more details.
0659f3af 142
a4c4205a
PP
143. When you are ready to trace, start your application with the
144 `LD_PRELOAD` environment variable set to `liblttng-ust-dl.so`:
145+
146--
147[role="term"]
148----
149$ LD_PRELOAD=liblttng-ust-dl.so my-app
150----
151--
0659f3af
PP
152
153
154Separate debugging information
155~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
156It is possible to store DWARF debugging information outside the
157executable itself, whether it is to reduce the executable's file size,
158or simply to facilitate the sharing of the debugging information.
159
160This is usually achieved via one of two mechanisms, namely _build ID_
161and _debug link_. Their use and operation is described in the
162https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html[Debugging
163Information in Separate Files] section of GDB's documentation.
164
165A {comp} component can find separate debugging information files
166automatically, as long as they meet the requirements stated in this man
167page.
168
169The debugging information lookup order is the same as GDB's, namely:
170
171. Within the executable file itself.
172
173. Through the build ID method in the `/usr/lib/debug/.build-id`
174 directory.
175
176. In the various possible debug link locations.
177
178The component uses the first debugging information file that it finds.
179
180You can use the param:deubg-info-dir initialization parameter to
181override the default `/usr/lib/debug` directory used in the build ID and
182debug link methods.
183
184NOTE: It is currently not possible to make this component search for
185debugging information in multiple directories.
186
187
188Target prefix
189~~~~~~~~~~~~~
190The debugging information analysis that a {comp} component performs uses
191the paths to the executables as collected during tracing as the default
192mechanism to resolve DWARF and ELF information.
193
194If the trace was recorded on a separate machine, however, you can use
195the param:target-prefix parameter to specify a prefix directory, that
196is, the root of the target file system.
197
198For example, if an instrumented executable's path is `/usr/bin/foo` on
199the target system, you can place this file at
200`/home/user/target/usr/bin/foo` on the system on which you use the
201component. In this case, the target prefix to use is
202`/home/user/target`.
203
204
205INITIALIZATION PARAMETERS
206-------------------------
207The following parameters are optional.
208
209param:debug-info-dir='DIR' (string)::
210 Use 'DIR' as the directory from which to load debugging information
211 with the build ID and debug link methods instead of
212 `/usr/lib/debug`.
213
214param:debug-info-field-name='NAME' (string)::
215 Name the debugging information structure field in the context of
216 the created events 'NAME' instead of the default {defdebuginfoname}.
217
218param:full-path=`yes` (boolean)::
219 Use the full path when writing the executable name (`bin`) and
220 source file name (`src`) fields in the {defdebuginfoname} context
221 field of the created events.
222
223param:target-prefix='DIR' (string)::
224 Use 'DIR' as the root directory of the target file system instead of
225 `/`.
226
227
228PORTS
229-----
230Input
231~~~~~
232`in`::
233 Single input port from which the component receives the
234 notifications to augment with debugging information.
235
236
237Output
238~~~~~~
239`out`::
240 Single output port to which the component sends the augmented
241 or unaltered notifications.
242
243
244QUERY OBJECTS
245-------------
246This component class has no objects to query.
247
248
249ENVIRONMENT VARIABLES
250---------------------
251include::common-common-compat-env.txt[]
252
253`BABELTRACE_FLT_LTTNG_UTILS_DEBUG_INFO_LOG_LEVEL`::
254 Component class's log level. The available values are the
255 same as for the manopt:babeltrace(1):--log-level option of
256 man:babeltrace(1).
257
258
259include::common-footer.txt[]
260
261
262SEE ALSO
263--------
264man:babeltrace-plugin-lttng-utils(7),
265man:lttng(1),
266man:lttng-add-context(1),
267man:babeltrace-intro(7)
This page took 0.032169 seconds and 4 git commands to generate.