1 llvm-symbolizer - convert addresses into source code locations
2 ==============================================================
4 .. program:: llvm-symbolizer
9 :program:`llvm-symbolizer` [*options*] [*addresses...*]
14 :program:`llvm-symbolizer` reads object file names and addresses from the
15 command-line and prints corresponding source code locations to standard output.
17 If no address is specified on the command-line, it reads the addresses from
18 standard input. If no object file is specified on the command-line, but
19 addresses are, or if at any time an input value is not recognized, the input is
20 simply echoed to the output.
22 A positional argument or standard input value can be preceded by "DATA" or
23 "CODE" to indicate that the address should be symbolized as data or executable
24 code respectively. If neither is specified, "CODE" is assumed. DATA is
25 symbolized as address and symbol size rather than line number.
27 Object files can be specified together with the addresses either on standard
28 input or as positional arguments on the command-line, following any "DATA" or
31 :program:`llvm-symbolizer` parses options from the environment variable
32 ``LLVM_SYMBOLIZER_OPTS`` after parsing options from the command line.
33 ``LLVM_SYMBOLIZER_OPTS`` is primarily useful for supplementing the command-line
34 options when :program:`llvm-symbolizer` is invoked by another program or
40 All of the following examples use the following two source files as input. They
41 use a mixture of C-style and C++-style linkage to illustrate how these names are
42 printed differently (see :option:`--demangle`).
47 extern "C" inline int foz() {
70 These files are built as follows:
72 .. code-block:: console
74 $ clang -g test.cpp -o test.elf
75 $ clang -g -O2 test.cpp -o inlined.elf
77 Example 1 - addresses and object on command-line:
79 .. code-block:: console
81 $ llvm-symbolizer --obj=test.elf 0x4004d0 0x400490
88 Example 2 - addresses on standard input:
90 .. code-block:: console
96 $ llvm-symbolizer --obj=test.elf < addr.txt
106 Example 3 - object specified with address:
108 .. code-block:: console
110 $ llvm-symbolizer "test.elf 0x400490" "inlined.elf 0x400480"
121 $ llvm-symbolizer < addr2.txt
128 Example 4 - CODE and DATA prefixes:
130 .. code-block:: console
132 $ llvm-symbolizer --obj=test.elf "CODE 0x400490" "DATA 0x601028"
140 CODE test.elf 0x4004a0
141 DATA inlined.elf 0x601028
143 $ llvm-symbolizer < addr3.txt
153 .. option:: --adjust-vma <offset>
155 Add the specified offset to object file addresses when performing lookups.
156 This can be used to perform lookups as if the object were relocated by the
159 .. option:: --basenames, -s
161 Strip directories when printing the file path.
163 .. _llvm-symbolizer-opt-C:
165 .. option:: --demangle, -C
167 Print demangled function names, if the names are mangled (e.g. the mangled
168 name `_Z3bazv` becomes `baz()`, whilst the non-mangled name `foz` is printed
169 as is). Defaults to true.
171 .. option:: --dwp <path>
173 Use the specified DWP file at ``<path>`` for any CUs that have split DWARF
176 .. option:: --fallback-debug-path <path>
178 When a separate file contains debug data, and is referenced by a GNU debug
179 link section, use the specified path as a basis for locating the debug data if
180 it cannot be found relative to the object.
182 .. _llvm-symbolizer-opt-f:
184 .. option:: --functions [<none|short|linkage>], -f
186 Specify the way function names are printed (omit function name, print short
187 function name, or print full linkage name, respectively). Defaults to
190 .. option:: --help, -h
192 Show help and usage for this command.
194 .. option:: --help-list
196 Show help and usage for this command without grouping the options into categories.
198 .. _llvm-symbolizer-opt-i:
200 .. option:: --inlining, --inlines, -i
202 If a source code location is in an inlined function, prints all the inlined
203 frames. Defaults to true.
205 .. option:: --no-demangle
207 Don't print demangled function names.
209 .. option:: --obj <path>, --exe, -e
211 Path to object file to be symbolized. If ``-`` is specified, read the object
212 directly from the standard input stream.
214 .. _llvm-symbolizer-opt-output-style:
216 .. option:: --output-style <LLVM|GNU>
218 Specify the preferred output style. Defaults to ``LLVM``. When the output
219 style is set to ``GNU``, the tool follows the style of GNU's **addr2line**.
220 The differences from the ``LLVM`` style are:
222 * Does not print the column of a source code location.
224 * Does not add an empty line after the report for an address.
226 * Does not replace the name of an inlined function with the name of the
227 topmost caller when inlined frames are not shown and :option:`--use-symbol-table`
230 .. code-block:: console
232 $ llvm-symbolizer --obj=inlined.elf 0x4004be 0x400486 -p
233 baz() at /tmp/test.cpp:11:18
234 (inlined by) main at /tmp/test.cpp:15:0
236 foo() at /tmp/test.cpp:6:3
238 $ llvm-symbolizer --output-style=LLVM --obj=inlined.elf 0x4004be 0x400486 -p -i=0
239 main at /tmp/test.cpp:11:18
241 foo() at /tmp/test.cpp:6:3
243 $ llvm-symbolizer --output-style=GNU --obj=inlined.elf 0x4004be 0x400486 -p -i=0
244 baz() at /tmp/test.cpp:11
245 foo() at /tmp/test.cpp:6
247 .. option:: --pretty-print, -p
249 Print human readable output. If :option:`--inlining` is specified, the
250 enclosing scope is prefixed by (inlined by).
252 .. code-block:: console
254 $ llvm-symbolizer --obj=inlined.elf 0x4004be --inlining --pretty-print
255 baz() at /tmp/test.cpp:11:18
256 (inlined by) main at /tmp/test.cpp:15:0
258 .. option:: --print-address, --addresses, -a
260 Print address before the source code location. Defaults to false.
262 .. code-block:: console
264 $ llvm-symbolizer --obj=inlined.elf --print-address 0x4004be
271 $ llvm-symbolizer --obj=inlined.elf 0x4004be --pretty-print --print-address
272 0x4004be: baz() at /tmp/test.cpp:11:18
273 (inlined by) main at /tmp/test.cpp:15:0
275 .. option:: --print-source-context-lines <N>
277 Print ``N`` lines of source context for each symbolized address.
279 .. code-block:: console
281 $ llvm-symbolizer --obj=test.elf 0x400490 --print-source-context-lines=2
284 10 : volatile int k = 42;
285 11 >: return foz() + k;
288 .. _llvm-symbolizer-opt-use-symbol-table:
290 .. option:: --use-symbol-table
292 Prefer function names stored in symbol table to function names in debug info
293 sections. Defaults to true.
295 .. option:: --verbose
297 Print verbose line and column information.
299 .. code-block:: console
301 $ llvm-symbolizer --obj=inlined.elf --verbose 0x4004be
303 Filename: /tmp/test.cpp
304 Function start line: 9
308 Filename: /tmp/test.cpp
309 Function start line: 14
313 .. option:: --version
315 Print version information for the tool.
319 Read command-line options from response file `<FILE>`.
321 MACH-O SPECIFIC OPTIONS
322 -----------------------
324 .. option:: --default-arch <arch>
326 If a binary contains object files for multiple architectures (e.g. it is a
327 Mach-O universal binary), symbolize the object file for a given architecture.
328 You can also specify the architecture by writing ``binary_name:arch_name`` in
329 the input (see example below). If the architecture is not specified in either
330 way, the address will not be symbolized. Defaults to empty string.
332 .. code-block:: console
335 /tmp/mach_universal_binary:i386 0x1f84
336 /tmp/mach_universal_binary:x86_64 0x100000f24
338 $ llvm-symbolizer < addr.txt
340 /tmp/source_i386.cc:8
343 /tmp/source_x86_64.cc:8
345 .. option:: --dsym-hint <path/to/file.dSYM>
347 If the debug info for a binary isn't present in the default location, look for
348 the debug info at the .dSYM path provided via this option. This flag can be
354 :program:`llvm-symbolizer` returns 0. Other exit codes imply an internal program
360 :manpage:`llvm-addr2line(1)`