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