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
34 All of the following examples use the following two source files as input. They
35 use a mixture of C-style and C++-style linkage to illustrate how these names are
36 printed differently (see :option:`--demangle`).
41 extern "C" inline int foz() {
64 These files are built as follows:
66 .. code-block:: console
68 $ clang -g test.cpp -o test.elf
69 $ clang -g -O2 test.cpp -o inlined.elf
71 Example 1 - addresses and object on command-line:
73 .. code-block:: console
75 $ llvm-symbolizer --obj=test.elf 0x4004d0 0x400490
82 Example 2 - addresses on standard input:
84 .. code-block:: console
90 $ llvm-symbolizer --obj=test.elf < addr.txt
100 Example 3 - object specified with address:
102 .. code-block:: console
104 $ llvm-symbolizer "test.elf 0x400490" "inlined.elf 0x400480"
115 $ llvm-symbolizer < addr2.txt
122 Example 4 - CODE and DATA prefixes:
124 .. code-block:: console
126 $ llvm-symbolizer --obj=test.elf "CODE 0x400490" "DATA 0x601028"
134 CODE test.elf 0x4004a0
135 DATA inlined.elf 0x601028
137 $ llvm-symbolizer < addr3.txt
147 .. option:: --adjust-vma <offset>
149 Add the specified offset to object file addresses when performing lookups.
150 This can be used to perform lookups as if the object were relocated by the
153 .. option:: --basenames, -s
155 Strip directories when printing the file path.
157 .. _llvm-symbolizer-opt-C:
159 .. option:: --demangle, -C
161 Print demangled function names, if the names are mangled (e.g. the mangled
162 name `_Z3bazv` becomes `baz()`, whilst the non-mangled name `foz` is printed
163 as is). Defaults to true.
165 .. option:: --dwp <path>
167 Use the specified DWP file at ``<path>`` for any CUs that have split DWARF
170 .. option:: --fallback-debug-path <path>
172 When a separate file contains debug data, and is referenced by a GNU debug
173 link section, use the specified path as a basis for locating the debug data if
174 it cannot be found relative to the object.
176 .. _llvm-symbolizer-opt-f:
178 .. option:: --functions [<none|short|linkage>], -f
180 Specify the way function names are printed (omit function name, print short
181 function name, or print full linkage name, respectively). Defaults to
184 .. option:: --help, -h
186 Show help and usage for this command.
188 .. option:: --help-list
190 Show help and usage for this command without grouping the options into categories.
192 .. _llvm-symbolizer-opt-i:
194 .. option:: --inlining, --inlines, -i
196 If a source code location is in an inlined function, prints all the inlined
197 frames. Defaults to true.
199 .. option:: --no-demangle
201 Don't print demangled function names.
203 .. option:: --obj <path>, --exe, -e
205 Path to object file to be symbolized. If ``-`` is specified, read the object
206 directly from the standard input stream.
208 .. _llvm-symbolizer-opt-output-style:
210 .. option:: --output-style <LLVM|GNU>
212 Specify the preferred output style. Defaults to ``LLVM``. When the output
213 style is set to ``GNU``, the tool follows the style of GNU's **addr2line**.
214 The differences from the ``LLVM`` style are:
216 * Does not print the column of a source code location.
218 * Does not add an empty line after the report for an address.
220 * Does not replace the name of an inlined function with the name of the
221 topmost caller when inlined frames are not shown and :option:`--use-symbol-table`
224 .. code-block:: console
226 $ llvm-symbolizer --obj=inlined.elf 0x4004be 0x400486 -p
227 baz() at /tmp/test.cpp:11:18
228 (inlined by) main at /tmp/test.cpp:15:0
230 foo() at /tmp/test.cpp:6:3
232 $ llvm-symbolizer --output-style=LLVM --obj=inlined.elf 0x4004be 0x400486 -p -i=0
233 main at /tmp/test.cpp:11:18
235 foo() at /tmp/test.cpp:6:3
237 $ llvm-symbolizer --output-style=GNU --obj=inlined.elf 0x4004be 0x400486 -p -i=0
238 baz() at /tmp/test.cpp:11
239 foo() at /tmp/test.cpp:6
241 .. option:: --pretty-print, -p
243 Print human readable output. If :option:`--inlining` is specified, the
244 enclosing scope is prefixed by (inlined by).
246 .. code-block:: console
248 $ llvm-symbolizer --obj=inlined.elf 0x4004be --inlining --pretty-print
249 baz() at /tmp/test.cpp:11:18
250 (inlined by) main at /tmp/test.cpp:15:0
252 .. option:: --print-address, --addresses, -a
254 Print address before the source code location. Defaults to false.
256 .. code-block:: console
258 $ llvm-symbolizer --obj=inlined.elf --print-address 0x4004be
265 $ llvm-symbolizer --obj=inlined.elf 0x4004be --pretty-print --print-address
266 0x4004be: baz() at /tmp/test.cpp:11:18
267 (inlined by) main at /tmp/test.cpp:15:0
269 .. option:: --print-source-context-lines <N>
271 Print ``N`` lines of source context for each symbolized address.
273 .. code-block:: console
275 $ llvm-symbolizer --obj=test.elf 0x400490 --print-source-context-lines=2
278 10 : volatile int k = 42;
279 11 >: return foz() + k;
282 .. _llvm-symbolizer-opt-use-symbol-table:
284 .. option:: --use-symbol-table
286 Prefer function names stored in symbol table to function names in debug info
287 sections. Defaults to true.
289 .. option:: --verbose
291 Print verbose line and column information.
293 .. code-block:: console
295 $ llvm-symbolizer --obj=inlined.elf --verbose 0x4004be
297 Filename: /tmp/test.cpp
298 Function start line: 9
302 Filename: /tmp/test.cpp
303 Function start line: 14
307 .. option:: --version
309 Print version information for the tool.
313 Read command-line options from response file `<FILE>`.
315 MACH-O SPECIFIC OPTIONS
316 -----------------------
318 .. option:: --default-arch <arch>
320 If a binary contains object files for multiple architectures (e.g. it is a
321 Mach-O universal binary), symbolize the object file for a given architecture.
322 You can also specify the architecture by writing ``binary_name:arch_name`` in
323 the input (see example below). If the architecture is not specified in either
324 way, the address will not be symbolized. Defaults to empty string.
326 .. code-block:: console
329 /tmp/mach_universal_binary:i386 0x1f84
330 /tmp/mach_universal_binary:x86_64 0x100000f24
332 $ llvm-symbolizer < addr.txt
334 /tmp/source_i386.cc:8
337 /tmp/source_x86_64.cc:8
339 .. option:: --dsym-hint <path/to/file.dSYM>
341 If the debug info for a binary isn't present in the default location, look for
342 the debug info at the .dSYM path provided via this option. This flag can be
348 :program:`llvm-symbolizer` returns 0. Other exit codes imply an internal program
354 :manpage:`llvm-addr2line(1)`