Alexey Samsonov | 2bc1012 | 2013-03-01 07:58:27 +0000 | [diff] [blame] | 1 | llvm-symbolizer - convert addresses into source code locations |
| 2 | ============================================================== |
| 3 | |
| 4 | SYNOPSIS |
| 5 | -------- |
| 6 | |
| 7 | :program:`llvm-symbolizer` [options] |
| 8 | |
| 9 | DESCRIPTION |
| 10 | ----------- |
| 11 | |
| 12 | :program:`llvm-symbolizer` reads object file names and addresses from standard |
Alexey Samsonov | 60e59e2 | 2013-12-24 19:33:22 +0000 | [diff] [blame] | 13 | input and prints corresponding source code locations to standard output. |
Mike Aizatsky | 54a7c69 | 2016-01-07 23:57:41 +0000 | [diff] [blame] | 14 | If object file is specified in command line, :program:`llvm-symbolizer` |
| 15 | processes only addresses from standard input, the rest is output verbatim. |
| 16 | This program uses debug info sections and symbol table in the object files. |
Alexey Samsonov | 2bc1012 | 2013-03-01 07:58:27 +0000 | [diff] [blame] | 17 | |
| 18 | EXAMPLE |
| 19 | -------- |
| 20 | |
| 21 | .. code-block:: console |
| 22 | |
| 23 | $ cat addr.txt |
| 24 | a.out 0x4004f4 |
| 25 | /tmp/b.out 0x400528 |
| 26 | /tmp/c.so 0x710 |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 27 | /tmp/mach_universal_binary:i386 0x1f84 |
| 28 | /tmp/mach_universal_binary:x86_64 0x100000f24 |
Alexey Samsonov | 2bc1012 | 2013-03-01 07:58:27 +0000 | [diff] [blame] | 29 | $ llvm-symbolizer < addr.txt |
| 30 | main |
| 31 | /tmp/a.cc:4 |
| 32 | |
| 33 | f(int, int) |
| 34 | /tmp/b.cc:11 |
| 35 | |
| 36 | h_inlined_into_g |
| 37 | /tmp/header.h:2 |
| 38 | g_inlined_into_f |
| 39 | /tmp/header.h:7 |
| 40 | f_inlined_into_main |
| 41 | /tmp/source.cc:3 |
| 42 | main |
| 43 | /tmp/source.cc:8 |
| 44 | |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 45 | _main |
| 46 | /tmp/source_i386.cc:8 |
| 47 | |
| 48 | _main |
| 49 | /tmp/source_x86_64.cc:8 |
Alexey Samsonov | 60e59e2 | 2013-12-24 19:33:22 +0000 | [diff] [blame] | 50 | $ cat addr2.txt |
| 51 | 0x4004f4 |
| 52 | 0x401000 |
| 53 | $ llvm-symbolizer -obj=a.out < addr2.txt |
| 54 | main |
| 55 | /tmp/a.cc:4 |
| 56 | |
| 57 | foo(int) |
| 58 | /tmp/a.cc:12 |
Hemant Kulkarni | bdce12a | 2015-11-11 20:41:43 +0000 | [diff] [blame] | 59 | $cat addr.txt |
| 60 | 0x40054d |
| 61 | $llvm-symbolizer -inlining -print-address -pretty-print -obj=addr.exe < addr.txt |
| 62 | 0x40054d: inc at /tmp/x.c:3:3 |
| 63 | (inlined by) main at /tmp/x.c:9:0 |
| 64 | $llvm-symbolizer -inlining -pretty-print -obj=addr.exe < addr.txt |
| 65 | inc at /tmp/x.c:3:3 |
| 66 | (inlined by) main at /tmp/x.c:9:0 |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 67 | |
Alexey Samsonov | 2bc1012 | 2013-03-01 07:58:27 +0000 | [diff] [blame] | 68 | OPTIONS |
| 69 | ------- |
| 70 | |
Dmitry Venikov | 37c1e2e | 2019-01-11 11:51:52 +0000 | [diff] [blame] | 71 | .. option:: -obj, -exe, -e |
Alexey Samsonov | cd01472 | 2014-05-17 00:07:48 +0000 | [diff] [blame] | 72 | |
Alexey Samsonov | 60e59e2 | 2013-12-24 19:33:22 +0000 | [diff] [blame] | 73 | Path to object file to be symbolized. |
| 74 | |
Igor Kudrin | 99f641c | 2019-04-19 10:17:52 +0000 | [diff] [blame^] | 75 | .. _llvm-symbolizer-opt-f: |
| 76 | |
James Henderson | 25ce596 | 2019-01-23 17:27:48 +0000 | [diff] [blame] | 77 | .. option:: -functions[=<none|short|linkage>], -f |
Alexey Samsonov | 2bc1012 | 2013-03-01 07:58:27 +0000 | [diff] [blame] | 78 | |
Alexey Samsonov | cd01472 | 2014-05-17 00:07:48 +0000 | [diff] [blame] | 79 | Specify the way function names are printed (omit function name, |
| 80 | print short function name, or print full linkage name, respectively). |
| 81 | Defaults to ``linkage``. |
Alexey Samsonov | 2bc1012 | 2013-03-01 07:58:27 +0000 | [diff] [blame] | 82 | |
Igor Kudrin | 99f641c | 2019-04-19 10:17:52 +0000 | [diff] [blame^] | 83 | .. _llvm-symbolizer-opt-use-symbol-table: |
| 84 | |
Alexey Samsonov | 2bc1012 | 2013-03-01 07:58:27 +0000 | [diff] [blame] | 85 | .. option:: -use-symbol-table |
| 86 | |
| 87 | Prefer function names stored in symbol table to function names |
| 88 | in debug info sections. Defaults to true. |
| 89 | |
Igor Kudrin | 99f641c | 2019-04-19 10:17:52 +0000 | [diff] [blame^] | 90 | .. _llvm-symbolizer-opt-C: |
| 91 | |
Dmitry Venikov | d3f21d3 | 2019-01-16 07:05:58 +0000 | [diff] [blame] | 92 | .. option:: -demangle, -C |
Alexey Samsonov | 2bc1012 | 2013-03-01 07:58:27 +0000 | [diff] [blame] | 93 | |
| 94 | Print demangled function names. Defaults to true. |
| 95 | |
Dmitry Venikov | 119cf66 | 2019-01-21 10:00:57 +0000 | [diff] [blame] | 96 | .. option:: -no-demangle |
| 97 | |
| 98 | Don't print demangled function names. |
| 99 | |
Igor Kudrin | 99f641c | 2019-04-19 10:17:52 +0000 | [diff] [blame^] | 100 | .. _llvm-symbolizer-opt-i: |
| 101 | |
Douglas Yung | 7876c0e | 2019-01-24 00:34:09 +0000 | [diff] [blame] | 102 | .. option:: -inlining, -inlines, -i |
Alexey Samsonov | 2bc1012 | 2013-03-01 07:58:27 +0000 | [diff] [blame] | 103 | |
| 104 | If a source code location is in an inlined function, prints all the |
| 105 | inlnied frames. Defaults to true. |
| 106 | |
Alexey Samsonov | 2ca6536 | 2013-06-28 08:15:40 +0000 | [diff] [blame] | 107 | .. option:: -default-arch |
| 108 | |
| 109 | If a binary contains object files for multiple architectures (e.g. it is a |
| 110 | Mach-O universal binary), symbolize the object file for a given architecture. |
| 111 | You can also specify architecture by writing ``binary_name:arch_name`` in the |
| 112 | input (see example above). If architecture is not specified in either way, |
| 113 | address will not be symbolized. Defaults to empty string. |
| 114 | |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 115 | .. option:: -dsym-hint=<path/to/file.dSYM> |
| 116 | |
| 117 | (Darwin-only flag). If the debug info for a binary isn't present in the default |
| 118 | location, look for the debug info at the .dSYM path provided via the |
| 119 | ``-dsym-hint`` flag. This flag can be used multiple times. |
| 120 | |
Dmitry Venikov | 5c1768f | 2019-01-14 10:10:51 +0000 | [diff] [blame] | 121 | .. option:: -print-address, -addresses, -a |
Hemant Kulkarni | b3d4f21 | 2015-11-11 22:14:58 +0000 | [diff] [blame] | 122 | |
Hemant Kulkarni | 80f82fb | 2015-10-12 19:26:44 +0000 | [diff] [blame] | 123 | Print address before the source code location. Defaults to false. |
Alexander Potapenko | 7aaf514 | 2014-10-17 00:50:19 +0000 | [diff] [blame] | 124 | |
Dmitry Venikov | 60d71e4 | 2019-01-10 15:33:35 +0000 | [diff] [blame] | 125 | .. option:: -pretty-print, -p |
Hemant Kulkarni | b3d4f21 | 2015-11-11 22:14:58 +0000 | [diff] [blame] | 126 | |
Hemant Kulkarni | bdce12a | 2015-11-11 20:41:43 +0000 | [diff] [blame] | 127 | Print human readable output. If ``-inlining`` is specified, enclosing scope is |
| 128 | prefixed by (inlined by). Refer to listed examples. |
| 129 | |
James Henderson | 33c16a3 | 2019-01-22 10:24:32 +0000 | [diff] [blame] | 130 | .. option:: -basenames, -s |
| 131 | |
| 132 | Strip directories when printing the file path. |
| 133 | |
James Henderson | 759d5e6 | 2019-01-25 11:49:21 +0000 | [diff] [blame] | 134 | .. option:: -adjust-vma=<offset> |
| 135 | |
| 136 | Add the specified offset to object file addresses when performing lookups. This |
James Henderson | 6f39f6a | 2019-01-29 10:43:48 +0000 | [diff] [blame] | 137 | can be used to perform lookups as if the object were relocated by the offset. |
James Henderson | 759d5e6 | 2019-01-25 11:49:21 +0000 | [diff] [blame] | 138 | |
Igor Kudrin | 99f641c | 2019-04-19 10:17:52 +0000 | [diff] [blame^] | 139 | .. _llvm-symbolizer-opt-output-style: |
| 140 | |
Igor Kudrin | 1b71b7f | 2019-04-19 10:14:18 +0000 | [diff] [blame] | 141 | .. option:: -output-style=<LLVM|GNU> |
| 142 | |
| 143 | Specify the preferred output style. Defaults to ``LLVM``. When the output |
| 144 | style is set to ``GNU``, the tool follows the style of GNU's **addr2line**. |
| 145 | The differences from the ``LLVM`` style are: |
| 146 | |
| 147 | * Does not print column of a source code location. |
| 148 | |
| 149 | * Does not add an empty line after the report for an address. |
| 150 | |
| 151 | * Does not replace the name of an inlined function with the name of the |
| 152 | topmost caller when inlined frames are not shown and ``-use-symbol-table`` |
| 153 | is on. |
| 154 | |
| 155 | .. code-block:: console |
| 156 | |
| 157 | $ llvm-symbolizer -p -e=addr.exe 0x40054d 0x400568 |
| 158 | inc at /tmp/x.c:3:3 |
| 159 | (inlined by) main at /tmp/x.c:14:0 |
| 160 | |
| 161 | main at /tmp/x.c:14:3 |
| 162 | |
| 163 | $ llvm-symbolizer --output-style=LLVM -p -i=0 -e=addr.exe 0x40054d 0x400568 |
| 164 | main at /tmp/x.c:3:3 |
| 165 | |
| 166 | main at /tmp/x.c:14:3 |
| 167 | |
| 168 | $ llvm-symbolizer --output-style=GNU -p -i=0 -e=addr.exe 0x40054d 0x400568 |
| 169 | inc at /tmp/x.c:3 |
| 170 | main at /tmp/x.c:14 |
| 171 | |
Alexey Samsonov | 2bc1012 | 2013-03-01 07:58:27 +0000 | [diff] [blame] | 172 | EXIT STATUS |
| 173 | ----------- |
| 174 | |
| 175 | :program:`llvm-symbolizer` returns 0. Other exit codes imply internal program error. |