|
NAMEllvm-symbolizer - convert addresses into source code locationsSYNOPSISllvm-symbolizer [options] [addresses...]DESCRIPTIONllvm-symbolizer reads input names and addresses from the command-line and prints corresponding source code locations to standard output.If no address is specified on the command-line, it reads the addresses from standard input. If no input name is specified on the command-line, but addresses are, or if at any time an input value is not recognized, the input is simply echoed to the output. Input names can be specified together with the addresses either on standard input or as positional arguments on the command-line. By default, input names are interpreted as object file paths. However, prefixing a name with BUILDID: states that it is a hex build ID rather than a path. This will look up the corresponding debug binary. For consistency, prefixing a name with FILE: explicitly states that it is an object file path (the default). A positional argument or standard input value can be preceded by "DATA" or "CODE" to indicate that the address should be symbolized as data or executable code respectively. If neither is specified, "CODE" is assumed. DATA is symbolized as address and symbol size rather than line number. llvm-symbolizer parses options from the environment variable LLVM_SYMBOLIZER_OPTS after parsing options from the command line. LLVM_SYMBOLIZER_OPTS is primarily useful for supplementing the command-line options when llvm-symbolizer is invoked by another program or runtime. EXAMPLESAll of the following examples use the following two source files as input. They use a mixture of C-style and C++-style linkage to illustrate how these names are printed differently (see --demangle).// test.h extern "C" inline int foz() { return 1234; } // test.cpp #include "test.h" int bar=42; int foo() { return bar; } int baz() { volatile int k = 42; return foz() + k; } int main() { return foo() + baz(); } These files are built as follows: $ clang -g test.cpp -o test.elf $ clang -g -O2 test.cpp -o inlined.elf Example 1 - addresses and object on command-line: $ llvm-symbolizer --obj=test.elf 0x4004d0 0x400490 foz /tmp/test.h:1:0 baz() /tmp/test.cpp:11:0 Example 2 - addresses on standard input: $ cat addr.txt 0x4004a0 0x400490 0x4004d0 $ llvm-symbolizer --obj=test.elf < addr.txt main /tmp/test.cpp:15:0 baz() /tmp/test.cpp:11:0 foz /tmp/./test.h:1:0 Example 3 - object specified with address: $ llvm-symbolizer "test.elf 0x400490" "FILE:inlined.elf 0x400480" baz() /tmp/test.cpp:11:0 foo() /tmp/test.cpp:8:10 $ cat addr2.txt FILE:test.elf 0x4004a0 inlined.elf 0x400480 $ llvm-symbolizer < addr2.txt main /tmp/test.cpp:15:0 foo() /tmp/test.cpp:8:10 Example 4 - BUILDID and FILE prefixes: $ llvm-symbolizer "FILE:test.elf 0x400490" "DATA BUILDID:123456789abcdef 0x601028" baz() /tmp/test.cpp:11:0 bar 6295592 4 $ cat addr3.txt FILE:test.elf 0x400490 DATA BUILDID:123456789abcdef 0x601028 $ llvm-symbolizer < addr3.txt baz() /tmp/test.cpp:11:0 bar 6295592 4 Example 5 - CODE and DATA prefixes: $ llvm-symbolizer --obj=test.elf "CODE 0x400490" "DATA 0x601028" baz() /tmp/test.cpp:11:0 bar 6295592 4 $ cat addr4.txt CODE test.elf 0x4004a0 DATA inlined.elf 0x601028 $ llvm-symbolizer < addr4.txt main /tmp/test.cpp:15:0 bar 6295592 4 Example 6 - path-style options: This example uses the same source file as above, but the source file's full path is /tmp/foo/test.cpp and is compiled as follows. The first case shows the default absolute path, the second --basenames, and the third shows --relativenames. $ pwd /tmp $ clang -g foo/test.cpp -o test.elf $ llvm-symbolizer --obj=test.elf 0x4004a0 main /tmp/foo/test.cpp:15:0 $ llvm-symbolizer --obj=test.elf 0x4004a0 --basenames main test.cpp:15:0 $ llvm-symbolizer --obj=test.elf 0x4004a0 --relativenames main foo/test.cpp:15:0 OPTIONS
$ llvm-symbolizer --obj=inlined.elf 0x4004be 0x400486 -p baz() at /tmp/test.cpp:11:18 (inlined by) main at /tmp/test.cpp:15:0 foo() at /tmp/test.cpp:6:3 $ llvm-symbolizer --output-style=LLVM --obj=inlined.elf 0x4004be 0x400486 -p --no-inlines main at /tmp/test.cpp:11:18 foo() at /tmp/test.cpp:6:3 $ llvm-symbolizer --output-style=GNU --obj=inlined.elf 0x4004be 0x400486 -p --no-inlines baz() at /tmp/test.cpp:11 foo() at /tmp/test.cpp:6 $ clang -g -fdebug-info-for-profiling test.cpp -o profiling.elf $ llvm-symbolizer --output-style=GNU --obj=profiling.elf 0x401167 -p --no-inlines main at /tmp/test.cpp:15 (discriminator 2) $ llvm-symbolizer --output-style=JSON --obj=inlined.elf 0x4004be 0x400486 -p [ { "Address": "0x4004be", "ModuleName": "inlined.elf", "Symbol": [ { "Column": 18, "Discriminator": 0, "FileName": "/tmp/test.cpp", "FunctionName": "baz()", "Line": 11, "StartAddress": "0x4004be", "StartFileName": "/tmp/test.cpp", "StartLine": 9 }, { "Column": 0, "Discriminator": 0, "FileName": "/tmp/test.cpp", "FunctionName": "main", "Line": 15, "StartAddress": "0x4004be", "StartFileName": "/tmp/test.cpp", "StartLine": 14 } ] }, { "Address": "0x400486", "ModuleName": "inlined.elf", "Symbol": [ { "Column": 3, "Discriminator": 0, "FileName": "/tmp/test.cpp", "FunctionName": "foo()", "Line": 6, "StartAddress": "0x400486", "StartFileName": "/tmp/test.cpp", "StartLine": 5 } ] } ]
$ llvm-symbolizer --obj=inlined.elf 0x4004be --inlining --pretty-print baz() at /tmp/test.cpp:11:18 (inlined by) main at /tmp/test.cpp:15:0
$ llvm-symbolizer --obj=inlined.elf --print-address 0x4004be 0x4004be baz() /tmp/test.cpp:11:18 main /tmp/test.cpp:15:0 $ llvm-symbolizer --obj=inlined.elf 0x4004be --pretty-print --print-address 0x4004be: baz() at /tmp/test.cpp:11:18 (inlined by) main at /tmp/test.cpp:15:0
$ llvm-symbolizer --obj=test.elf 0x400490 --print-source-context-lines=3 baz() /tmp/test.cpp:11:0 10 : volatile int k = 42; 11 >: return foz() + k; 12 : }
$ llvm-symbolizer --obj=inlined.elf --verbose 0x4004be baz() Filename: /tmp/test.cpp Function start filename: /tmp/test.cpp Function start line: 9 Function start address: 0x4004b6 Line: 11 Column: 18 main Filename: /tmp/test.cpp Function start filename: /tmp/test.cpp Function start line: 14 Function start address: 0x4004b0 Line: 15 Column: 18
WINDOWS/PDB SPECIFIC OPTIONS
MACH-O SPECIFIC OPTIONS
$ cat addr.txt /tmp/mach_universal_binary:i386 0x1f84 /tmp/mach_universal_binary:x86_64 0x100000f24 $ llvm-symbolizer < addr.txt _main /tmp/source_i386.cc:8 _main /tmp/source_x86_64.cc:8
EXIT STATUSllvm-symbolizer returns 0. Other exit codes imply an internal program error.SEE ALSOllvm-addr2line(1)AUTHORMaintained by the LLVM Team (https://llvm.org/).COPYRIGHT2003-2022, LLVM Project
Visit the GSP FreeBSD Man Page Interface. |