]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/clang/llvm-symbolizer/llvm-symbolizer.1
Merge llvm-project main llvmorg-13-init-16847-g88e66fa60ae5
[FreeBSD/FreeBSD.git] / usr.bin / clang / llvm-symbolizer / llvm-symbolizer.1
1 .\" $FreeBSD$
2 .\" Man page generated from reStructuredText.
3 .
4 .
5 .nr rst2man-indent-level 0
6 .
7 .de1 rstReportMargin
8 \\$1 \\n[an-margin]
9 level \\n[rst2man-indent-level]
10 level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
11 -
12 \\n[rst2man-indent0]
13 \\n[rst2man-indent1]
14 \\n[rst2man-indent2]
15 ..
16 .de1 INDENT
17 .\" .rstReportMargin pre:
18 . RS \\$1
19 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
20 . nr rst2man-indent-level +1
21 .\" .rstReportMargin post:
22 ..
23 .de UNINDENT
24 . RE
25 .\" indent \\n[an-margin]
26 .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
27 .nr rst2man-indent-level -1
28 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
29 .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
30 ..
31 .TH "LLVM-SYMBOLIZER" "1" "2021-06-07" "12" "LLVM"
32 .SH NAME
33 llvm-symbolizer \- convert addresses into source code locations
34 .SH SYNOPSIS
35 .sp
36 \fBllvm\-symbolizer\fP [\fIoptions\fP] [\fIaddresses...\fP]
37 .SH DESCRIPTION
38 .sp
39 \fBllvm\-symbolizer\fP reads object file names and addresses from the
40 command\-line and prints corresponding source code locations to standard output.
41 .sp
42 If no address is specified on the command\-line, it reads the addresses from
43 standard input. If no object file is specified on the command\-line, but
44 addresses are, or if at any time an input value is not recognized, the input is
45 simply echoed to the output.
46 .sp
47 A positional argument or standard input value can be preceded by "DATA" or
48 "CODE" to indicate that the address should be symbolized as data or executable
49 code respectively. If neither is specified, "CODE" is assumed. DATA is
50 symbolized as address and symbol size rather than line number.
51 .sp
52 Object files can be specified together with the addresses either on standard
53 input or as positional arguments on the command\-line, following any "DATA" or
54 "CODE" prefix.
55 .sp
56 \fBllvm\-symbolizer\fP parses options from the environment variable
57 \fBLLVM_SYMBOLIZER_OPTS\fP after parsing options from the command line.
58 \fBLLVM_SYMBOLIZER_OPTS\fP is primarily useful for supplementing the command\-line
59 options when \fBllvm\-symbolizer\fP is invoked by another program or
60 runtime.
61 .SH EXAMPLES
62 .sp
63 All of the following examples use the following two source files as input. They
64 use a mixture of C\-style and C++\-style linkage to illustrate how these names are
65 printed differently (see \fI\%\-\-demangle\fP).
66 .INDENT 0.0
67 .INDENT 3.5
68 .sp
69 .nf
70 .ft C
71 // test.h
72 extern "C" inline int foz() {
73   return 1234;
74 }
75 .ft P
76 .fi
77 .UNINDENT
78 .UNINDENT
79 .INDENT 0.0
80 .INDENT 3.5
81 .sp
82 .nf
83 .ft C
84 // test.cpp
85 #include "test.h"
86 int bar=42;
87
88 int foo() {
89   return bar;
90 }
91
92 int baz() {
93   volatile int k = 42;
94   return foz() + k;
95 }
96
97 int main() {
98   return foo() + baz();
99 }
100 .ft P
101 .fi
102 .UNINDENT
103 .UNINDENT
104 .sp
105 These files are built as follows:
106 .INDENT 0.0
107 .INDENT 3.5
108 .sp
109 .nf
110 .ft C
111 $ clang \-g test.cpp \-o test.elf
112 $ clang \-g \-O2 test.cpp \-o inlined.elf
113 .ft P
114 .fi
115 .UNINDENT
116 .UNINDENT
117 .sp
118 Example 1 \- addresses and object on command\-line:
119 .INDENT 0.0
120 .INDENT 3.5
121 .sp
122 .nf
123 .ft C
124 $ llvm\-symbolizer \-\-obj=test.elf 0x4004d0 0x400490
125 foz
126 /tmp/test.h:1:0
127
128 baz()
129 /tmp/test.cpp:11:0
130 .ft P
131 .fi
132 .UNINDENT
133 .UNINDENT
134 .sp
135 Example 2 \- addresses on standard input:
136 .INDENT 0.0
137 .INDENT 3.5
138 .sp
139 .nf
140 .ft C
141 $ cat addr.txt
142 0x4004a0
143 0x400490
144 0x4004d0
145 $ llvm\-symbolizer \-\-obj=test.elf < addr.txt
146 main
147 /tmp/test.cpp:15:0
148
149 baz()
150 /tmp/test.cpp:11:0
151
152 foz
153 /tmp/./test.h:1:0
154 .ft P
155 .fi
156 .UNINDENT
157 .UNINDENT
158 .sp
159 Example 3 \- object specified with address:
160 .INDENT 0.0
161 .INDENT 3.5
162 .sp
163 .nf
164 .ft C
165 $ llvm\-symbolizer "test.elf 0x400490" "inlined.elf 0x400480"
166 baz()
167 /tmp/test.cpp:11:0
168
169 foo()
170 /tmp/test.cpp:8:10
171
172 $ cat addr2.txt
173 test.elf 0x4004a0
174 inlined.elf 0x400480
175
176 $ llvm\-symbolizer < addr2.txt
177 main
178 /tmp/test.cpp:15:0
179
180 foo()
181 /tmp/test.cpp:8:10
182 .ft P
183 .fi
184 .UNINDENT
185 .UNINDENT
186 .sp
187 Example 4 \- CODE and DATA prefixes:
188 .INDENT 0.0
189 .INDENT 3.5
190 .sp
191 .nf
192 .ft C
193 $ llvm\-symbolizer \-\-obj=test.elf "CODE 0x400490" "DATA 0x601028"
194 baz()
195 /tmp/test.cpp:11:0
196
197 bar
198 6295592 4
199
200 $ cat addr3.txt
201 CODE test.elf 0x4004a0
202 DATA inlined.elf 0x601028
203
204 $ llvm\-symbolizer < addr3.txt
205 main
206 /tmp/test.cpp:15:0
207
208 bar
209 6295592 4
210 .ft P
211 .fi
212 .UNINDENT
213 .UNINDENT
214 .sp
215 Example 5 \- path\-style options:
216 .sp
217 This example uses the same source file as above, but the source file\(aqs
218 full path is /tmp/foo/test.cpp and is compiled as follows. The first case
219 shows the default absolute path, the second \-\-basenames, and the third
220 shows \-\-relativenames.
221 .INDENT 0.0
222 .INDENT 3.5
223 .sp
224 .nf
225 .ft C
226 $ pwd
227 /tmp
228 $ clang \-g foo/test.cpp \-o test.elf
229 $ llvm\-symbolizer \-\-obj=test.elf 0x4004a0
230 main
231 /tmp/foo/test.cpp:15:0
232 $ llvm\-symbolizer \-\-obj=test.elf 0x4004a0 \-\-basenames
233 main
234 test.cpp:15:0
235 $ llvm\-symbolizer \-\-obj=test.elf 0x4004a0 \-\-relativenames
236 main
237 foo/test.cpp:15:0
238 .ft P
239 .fi
240 .UNINDENT
241 .UNINDENT
242 .SH OPTIONS
243 .INDENT 0.0
244 .TP
245 .B \-\-adjust\-vma <offset>
246 Add the specified offset to object file addresses when performing lookups.
247 This can be used to perform lookups as if the object were relocated by the
248 offset.
249 .UNINDENT
250 .INDENT 0.0
251 .TP
252 .B \-\-basenames, \-s
253 Print just the file\(aqs name without any directories, instead of the
254 absolute path.
255 .UNINDENT
256 .INDENT 0.0
257 .TP
258 .B \-\-demangle, \-C
259 Print demangled function names, if the names are mangled (e.g. the mangled
260 name \fI_Z3bazv\fP becomes \fIbaz()\fP, whilst the non\-mangled name \fIfoz\fP is printed
261 as is). Defaults to true.
262 .UNINDENT
263 .INDENT 0.0
264 .TP
265 .B \-\-dwp <path>
266 Use the specified DWP file at \fB<path>\fP for any CUs that have split DWARF
267 debug data.
268 .UNINDENT
269 .INDENT 0.0
270 .TP
271 .B \-\-fallback\-debug\-path <path>
272 When a separate file contains debug data, and is referenced by a GNU debug
273 link section, use the specified path as a basis for locating the debug data if
274 it cannot be found relative to the object.
275 .UNINDENT
276 .INDENT 0.0
277 .TP
278 .B \-\-functions [=<none|short|linkage>], \-f
279 Specify the way function names are printed (omit function name, print short
280 function name, or print full linkage name, respectively). Defaults to
281 \fBlinkage\fP\&.
282 .UNINDENT
283 .INDENT 0.0
284 .TP
285 .B \-\-help, \-h
286 Show help and usage for this command.
287 .UNINDENT
288 .INDENT 0.0
289 .TP
290 .B \-\-inlining, \-\-inlines, \-i
291 If a source code location is in an inlined function, prints all the inlined
292 frames. This is the default.
293 .UNINDENT
294 .INDENT 0.0
295 .TP
296 .B \-\-no\-inlines
297 Don\(aqt print inlined frames.
298 .UNINDENT
299 .INDENT 0.0
300 .TP
301 .B \-\-no\-demangle
302 Don\(aqt print demangled function names.
303 .UNINDENT
304 .INDENT 0.0
305 .TP
306 .B \-\-obj <path>, \-\-exe, \-e
307 Path to object file to be symbolized. If \fB\-\fP is specified, read the object
308 directly from the standard input stream.
309 .UNINDENT
310 .INDENT 0.0
311 .TP
312 .B \-\-output\-style <LLVM|GNU>
313 Specify the preferred output style. Defaults to \fBLLVM\fP\&. When the output
314 style is set to \fBGNU\fP, the tool follows the style of GNU\(aqs \fBaddr2line\fP\&.
315 The differences from the \fBLLVM\fP style are:
316 .INDENT 7.0
317 .IP \(bu 2
318 Does not print the column of a source code location.
319 .IP \(bu 2
320 Does not add an empty line after the report for an address.
321 .IP \(bu 2
322 Does not replace the name of an inlined function with the name of the
323 topmost caller when inlined frames are not shown and \fI\%\-\-use\-symbol\-table\fP
324 is on.
325 .IP \(bu 2
326 Prints an address\(aqs debug\-data discriminator when it is non\-zero. One way to
327 produce discriminators is to compile with clang\(aqs \-fdebug\-info\-for\-profiling.
328 .UNINDENT
329 .INDENT 7.0
330 .INDENT 3.5
331 .sp
332 .nf
333 .ft C
334 $ llvm\-symbolizer \-\-obj=inlined.elf 0x4004be 0x400486 \-p
335 baz() at /tmp/test.cpp:11:18
336  (inlined by) main at /tmp/test.cpp:15:0
337
338 foo() at /tmp/test.cpp:6:3
339
340 $ llvm\-symbolizer \-\-output\-style=LLVM \-\-obj=inlined.elf 0x4004be 0x400486 \-p \-\-no\-inlines
341 main at /tmp/test.cpp:11:18
342
343 foo() at /tmp/test.cpp:6:3
344
345 $ llvm\-symbolizer \-\-output\-style=GNU \-\-obj=inlined.elf 0x4004be 0x400486 \-p \-\-no\-inlines
346 baz() at /tmp/test.cpp:11
347 foo() at /tmp/test.cpp:6
348
349 $ clang \-g \-fdebug\-info\-for\-profiling test.cpp \-o profiling.elf
350 $ llvm\-symbolizer \-\-output\-style=GNU \-\-obj=profiling.elf 0x401167 \-p \-\-no\-inlines
351 main at /tmp/test.cpp:15 (discriminator 2)
352 .ft P
353 .fi
354 .UNINDENT
355 .UNINDENT
356 .UNINDENT
357 .INDENT 0.0
358 .TP
359 .B \-\-pretty\-print, \-p
360 Print human readable output. If \fI\%\-\-inlining\fP is specified, the
361 enclosing scope is prefixed by (inlined by).
362 .INDENT 7.0
363 .INDENT 3.5
364 .sp
365 .nf
366 .ft C
367 $ llvm\-symbolizer \-\-obj=inlined.elf 0x4004be \-\-inlining \-\-pretty\-print
368 baz() at /tmp/test.cpp:11:18
369  (inlined by) main at /tmp/test.cpp:15:0
370 .ft P
371 .fi
372 .UNINDENT
373 .UNINDENT
374 .UNINDENT
375 .INDENT 0.0
376 .TP
377 .B \-\-print\-address, \-\-addresses, \-a
378 Print address before the source code location. Defaults to false.
379 .INDENT 7.0
380 .INDENT 3.5
381 .sp
382 .nf
383 .ft C
384 $ llvm\-symbolizer \-\-obj=inlined.elf \-\-print\-address 0x4004be
385 0x4004be
386 baz()
387 /tmp/test.cpp:11:18
388 main
389 /tmp/test.cpp:15:0
390
391 $ llvm\-symbolizer \-\-obj=inlined.elf 0x4004be \-\-pretty\-print \-\-print\-address
392 0x4004be: baz() at /tmp/test.cpp:11:18
393  (inlined by) main at /tmp/test.cpp:15:0
394 .ft P
395 .fi
396 .UNINDENT
397 .UNINDENT
398 .UNINDENT
399 .INDENT 0.0
400 .TP
401 .B \-\-print\-source\-context\-lines <N>
402 Print \fBN\fP lines of source context for each symbolized address.
403 .INDENT 7.0
404 .INDENT 3.5
405 .sp
406 .nf
407 .ft C
408 $ llvm\-symbolizer \-\-obj=test.elf 0x400490 \-\-print\-source\-context\-lines=2
409 baz()
410 /tmp/test.cpp:11:0
411 10  :   volatile int k = 42;
412 11 >:   return foz() + k;
413 12  : }
414 .ft P
415 .fi
416 .UNINDENT
417 .UNINDENT
418 .UNINDENT
419 .INDENT 0.0
420 .TP
421 .B \-\-relativenames
422 Print the file\(aqs path relative to the compilation directory, instead
423 of the absolute path. If the command\-line to the compiler included
424 the full path, this will be the same as the default.
425 .UNINDENT
426 .INDENT 0.0
427 .TP
428 .B \-\-use\-symbol\-table
429 Prefer function names stored in symbol table to function names in debug info
430 sections. Defaults to true.
431 .UNINDENT
432 .INDENT 0.0
433 .TP
434 .B \-\-verbose
435 Print verbose line and column information.
436 .INDENT 7.0
437 .INDENT 3.5
438 .sp
439 .nf
440 .ft C
441 $ llvm\-symbolizer \-\-obj=inlined.elf \-\-verbose 0x4004be
442 baz()
443   Filename: /tmp/test.cpp
444 Function start line: 9
445   Line: 11
446   Column: 18
447 main
448   Filename: /tmp/test.cpp
449 Function start line: 14
450   Line: 15
451   Column: 0
452 .ft P
453 .fi
454 .UNINDENT
455 .UNINDENT
456 .UNINDENT
457 .INDENT 0.0
458 .TP
459 .B \-\-version, \-v
460 Print version information for the tool.
461 .UNINDENT
462 .INDENT 0.0
463 .TP
464 .B @<FILE>
465 Read command\-line options from response file \fI<FILE>\fP\&.
466 .UNINDENT
467 .SH WINDOWS/PDB SPECIFIC OPTIONS
468 .INDENT 0.0
469 .TP
470 .B \-\-dia
471 Use the Windows DIA SDK for symbolization. If the DIA SDK is not found,
472 llvm\-symbolizer will fall back to the native implementation.
473 .UNINDENT
474 .SH MACH-O SPECIFIC OPTIONS
475 .INDENT 0.0
476 .TP
477 .B \-\-default\-arch <arch>
478 If a binary contains object files for multiple architectures (e.g. it is a
479 Mach\-O universal binary), symbolize the object file for a given architecture.
480 You can also specify the architecture by writing \fBbinary_name:arch_name\fP in
481 the input (see example below). If the architecture is not specified in either
482 way, the address will not be symbolized. Defaults to empty string.
483 .INDENT 7.0
484 .INDENT 3.5
485 .sp
486 .nf
487 .ft C
488 $ cat addr.txt
489 /tmp/mach_universal_binary:i386 0x1f84
490 /tmp/mach_universal_binary:x86_64 0x100000f24
491
492 $ llvm\-symbolizer < addr.txt
493 _main
494 /tmp/source_i386.cc:8
495
496 _main
497 /tmp/source_x86_64.cc:8
498 .ft P
499 .fi
500 .UNINDENT
501 .UNINDENT
502 .UNINDENT
503 .INDENT 0.0
504 .TP
505 .B \-\-dsym\-hint <path/to/file.dSYM>
506 If the debug info for a binary isn\(aqt present in the default location, look for
507 the debug info at the .dSYM path provided via this option. This flag can be
508 used multiple times.
509 .UNINDENT
510 .SH EXIT STATUS
511 .sp
512 \fBllvm\-symbolizer\fP returns 0. Other exit codes imply an internal program
513 error.
514 .SH SEE ALSO
515 .sp
516 \fBllvm\-addr2line(1)\fP
517 .SH AUTHOR
518 Maintained by the LLVM Team (https://llvm.org/).
519 .SH COPYRIGHT
520 2003-2021, LLVM Project
521 .\" Generated by docutils manpage writer.
522 .