1LLVM-SYMBOLIZER(1) LLVM LLVM-SYMBOLIZER(1)
2
3
4
6 llvm-symbolizer - convert addresses into source code locations
7
9 llvm-symbolizer [options] [addresses...]
10
12 llvm-symbolizer reads object file names and addresses from the com‐
13 mand-line and prints corresponding source code locations to standard
14 output.
15
16 If no address is specified on the command-line, it reads the addresses
17 from standard input. If no object file is specified on the com‐
18 mand-line, but addresses are, or if at any time an input value is not
19 recognized, the input is simply echoed to the output.
20
21 A positional argument or standard input value can be preceded by "DATA"
22 or "CODE" to indicate that the address should be symbolized as data or
23 executable code respectively. If neither is specified, "CODE" is
24 assumed. DATA is symbolized as address and symbol size rather than line
25 number.
26
27 Object files can be specified together with the addresses either on
28 standard input or as positional arguments on the command-line, follow‐
29 ing any "DATA" or "CODE" prefix.
30
31 llvm-symbolizer parses options from the environment variable LLVM_SYM‐
32 BOLIZER_OPTS after parsing options from the command line. LLVM_SYMBOL‐
33 IZER_OPTS is primarily useful for supplementing the command-line
34 options when llvm-symbolizer is invoked by another program or runtime.
35
37 All of the following examples use the following two source files as
38 input. They use a mixture of C-style and C++-style linkage to illus‐
39 trate how these names are printed differently (see --demangle).
40
41 // test.h
42 extern "C" inline int foz() {
43 return 1234;
44 }
45
46 // test.cpp
47 #include "test.h"
48 int bar=42;
49
50 int foo() {
51 return bar;
52 }
53
54 int baz() {
55 volatile int k = 42;
56 return foz() + k;
57 }
58
59 int main() {
60 return foo() + baz();
61 }
62
63 These files are built as follows:
64
65 $ clang -g test.cpp -o test.elf
66 $ clang -g -O2 test.cpp -o inlined.elf
67
68 Example 1 - addresses and object on command-line:
69
70 $ llvm-symbolizer --obj=test.elf 0x4004d0 0x400490
71 foz
72 /tmp/test.h:1:0
73
74 baz()
75 /tmp/test.cpp:11:0
76
77 Example 2 - addresses on standard input:
78
79 $ cat addr.txt
80 0x4004a0
81 0x400490
82 0x4004d0
83 $ llvm-symbolizer --obj=test.elf < addr.txt
84 main
85 /tmp/test.cpp:15:0
86
87 baz()
88 /tmp/test.cpp:11:0
89
90 foz
91 /tmp/./test.h:1:0
92
93 Example 3 - object specified with address:
94
95 $ llvm-symbolizer "test.elf 0x400490" "inlined.elf 0x400480"
96 baz()
97 /tmp/test.cpp:11:0
98
99 foo()
100 /tmp/test.cpp:8:10
101
102 $ cat addr2.txt
103 test.elf 0x4004a0
104 inlined.elf 0x400480
105
106 $ llvm-symbolizer < addr2.txt
107 main
108 /tmp/test.cpp:15:0
109
110 foo()
111 /tmp/test.cpp:8:10
112
113 Example 4 - CODE and DATA prefixes:
114
115 $ llvm-symbolizer --obj=test.elf "CODE 0x400490" "DATA 0x601028"
116 baz()
117 /tmp/test.cpp:11:0
118
119 bar
120 6295592 4
121
122 $ cat addr3.txt
123 CODE test.elf 0x4004a0
124 DATA inlined.elf 0x601028
125
126 $ llvm-symbolizer < addr3.txt
127 main
128 /tmp/test.cpp:15:0
129
130 bar
131 6295592 4
132
133 Example 5 - path-style options:
134
135 This example uses the same source file as above, but the source file's
136 full path is /tmp/foo/test.cpp and is compiled as follows. The first
137 case shows the default absolute path, the second --basenames, and the
138 third shows --relativenames.
139
140 $ pwd
141 /tmp
142 $ clang -g foo/test.cpp -o test.elf
143 $ llvm-symbolizer --obj=test.elf 0x4004a0
144 main
145 /tmp/foo/test.cpp:15:0
146 $ llvm-symbolizer --obj=test.elf 0x4004a0 --basenames
147 main
148 test.cpp:15:0
149 $ llvm-symbolizer --obj=test.elf 0x4004a0 --relativenames
150 main
151 foo/test.cpp:15:0
152
154 --adjust-vma <offset>
155 Add the specified offset to object file addresses when perform‐
156 ing lookups. This can be used to perform lookups as if the
157 object were relocated by the offset.
158
159 --basenames, -s
160 Print just the file's name without any directories, instead of
161 the absolute path.
162
163 --relativenames
164 Print the file's path relative to the compilation directory,
165 instead of the absolute path. If the command-line to the com‐
166 piler included the full path, this will be the same as the
167 default.
168
169 --demangle, -C
170 Print demangled function names, if the names are mangled (e.g.
171 the mangled name _Z3bazv becomes baz(), whilst the non-mangled
172 name foz is printed as is). Defaults to true.
173
174 --dwp <path>
175 Use the specified DWP file at <path> for any CUs that have split
176 DWARF debug data.
177
178 --fallback-debug-path <path>
179 When a separate file contains debug data, and is referenced by a
180 GNU debug link section, use the specified path as a basis for
181 locating the debug data if it cannot be found relative to the
182 object.
183
184 --functions [=<none|short|linkage>], -f
185 Specify the way function names are printed (omit function name,
186 print short function name, or print full linkage name, respec‐
187 tively). Defaults to linkage.
188
189 --help, -h
190 Show help and usage for this command.
191
192 --help-list
193 Show help and usage for this command without grouping the
194 options into categories.
195
196 --inlining, --inlines, -i
197 If a source code location is in an inlined function, prints all
198 the inlined frames. Defaults to true.
199
200 --no-demangle
201 Don't print demangled function names.
202
203 --obj <path>, --exe, -e
204 Path to object file to be symbolized. If - is specified, read
205 the object directly from the standard input stream.
206
207 --output-style <LLVM|GNU>
208 Specify the preferred output style. Defaults to LLVM. When the
209 output style is set to GNU, the tool follows the style of GNU's
210 addr2line. The differences from the LLVM style are:
211
212 · Does not print the column of a source code location.
213
214 · Does not add an empty line after the report for an address.
215
216 · Does not replace the name of an inlined function with the name
217 of the topmost caller when inlined frames are not shown and
218 --use-symbol-table is on.
219
220 · Prints an address's debug-data discriminator when it is
221 non-zero. One way to produce discriminators is to compile with
222 clang's -fdebug-info-for-profiling.
223
224 $ llvm-symbolizer --obj=inlined.elf 0x4004be 0x400486 -p
225 baz() at /tmp/test.cpp:11:18
226 (inlined by) main at /tmp/test.cpp:15:0
227
228 foo() at /tmp/test.cpp:6:3
229
230 $ llvm-symbolizer --output-style=LLVM --obj=inlined.elf 0x4004be 0x400486 -p -i=0
231 main at /tmp/test.cpp:11:18
232
233 foo() at /tmp/test.cpp:6:3
234
235 $ llvm-symbolizer --output-style=GNU --obj=inlined.elf 0x4004be 0x400486 -p -i=0
236 baz() at /tmp/test.cpp:11
237 foo() at /tmp/test.cpp:6
238
239 $ clang -g -fdebug-info-for-profiling test.cpp -o profiling.elf
240 $ llvm-symbolizer --output-style=GNU --obj=profiling.elf 0x401167 -p -i=0
241 main at /tmp/test.cpp:15 (discriminator 2)
242
243 --pretty-print, -p
244 Print human readable output. If --inlining is specified, the
245 enclosing scope is prefixed by (inlined by).
246
247 $ llvm-symbolizer --obj=inlined.elf 0x4004be --inlining --pretty-print
248 baz() at /tmp/test.cpp:11:18
249 (inlined by) main at /tmp/test.cpp:15:0
250
251 --print-address, --addresses, -a
252 Print address before the source code location. Defaults to
253 false.
254
255 $ llvm-symbolizer --obj=inlined.elf --print-address 0x4004be
256 0x4004be
257 baz()
258 /tmp/test.cpp:11:18
259 main
260 /tmp/test.cpp:15:0
261
262 $ llvm-symbolizer --obj=inlined.elf 0x4004be --pretty-print --print-address
263 0x4004be: baz() at /tmp/test.cpp:11:18
264 (inlined by) main at /tmp/test.cpp:15:0
265
266 --print-source-context-lines <N>
267 Print N lines of source context for each symbolized address.
268
269 $ llvm-symbolizer --obj=test.elf 0x400490 --print-source-context-lines=2
270 baz()
271 /tmp/test.cpp:11:0
272 10 : volatile int k = 42;
273 11 >: return foz() + k;
274 12 : }
275
276 --use-symbol-table
277 Prefer function names stored in symbol table to function names
278 in debug info sections. Defaults to true.
279
280 --verbose
281 Print verbose line and column information.
282
283 $ llvm-symbolizer --obj=inlined.elf --verbose 0x4004be
284 baz()
285 Filename: /tmp/test.cpp
286 Function start line: 9
287 Line: 11
288 Column: 18
289 main
290 Filename: /tmp/test.cpp
291 Function start line: 14
292 Line: 15
293 Column: 0
294
295 --version
296 Print version information for the tool.
297
298 @<FILE>
299 Read command-line options from response file <FILE>.
300
302 --default-arch <arch>
303 If a binary contains object files for multiple architectures
304 (e.g. it is a Mach-O universal binary), symbolize the object
305 file for a given architecture. You can also specify the archi‐
306 tecture by writing binary_name:arch_name in the input (see exam‐
307 ple below). If the architecture is not specified in either way,
308 the address will not be symbolized. Defaults to empty string.
309
310 $ cat addr.txt
311 /tmp/mach_universal_binary:i386 0x1f84
312 /tmp/mach_universal_binary:x86_64 0x100000f24
313
314 $ llvm-symbolizer < addr.txt
315 _main
316 /tmp/source_i386.cc:8
317
318 _main
319 /tmp/source_x86_64.cc:8
320
321 --dsym-hint <path/to/file.dSYM>
322 If the debug info for a binary isn't present in the default
323 location, look for the debug info at the .dSYM path provided via
324 this option. This flag can be used multiple times.
325
327 llvm-symbolizer returns 0. Other exit codes imply an internal program
328 error.
329
331 llvm-addr2line(1)
332
334 Maintained by the LLVM Team (https://llvm.org/).
335
337 2003-2020, LLVM Project
338
339
340
341
34211 2020-10-15 LLVM-SYMBOLIZER(1)