LLVM-SYMBOLIZER(1)
π
LLVM-SYMBOLIZER(1) π
okay so welcome to the LLVM-SYMBOLIZER(1) manual page, bestie β this is the LLVM one, and it's genuinely such a useful little icon. β¨
π NAME π
llvm-symbolizer β convert addresses into source code locations. That's the whole main-character job: you hand it addresses, it tells you where in the source they live. π
β¨ SYNOPSIS β¨
llvm-symbolizer [options] [addressesβ¦]
π¦ DESCRIPTION π¦
llvm-symbolizer reads object file names and addresses from the command-line and prints corresponding source code locations to standard output. lowkey iconic. π
If no address is specified on the command-line, it reads the addresses from standard input. If no object file 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.
If an input value isnβt recognized, it just gets echoed straight back to the output. No extra drama, just mirror vibes. πͺ
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.
Object files can be specified together with the addresses either on standard input or as positional arguments on the command-line, following any DATA or CODE prefix.
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.
π EXAMPLES π
All 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" "inlined.elf 0x400480"
baz()
/tmp/test.cpp:11:0
foo()
/tmp/test.cpp:8:10
$ cat addr2.txt
test.elf 0x4004a0
inlined.elf 0x400480
$ llvm-symbolizer < addr2.txt
main
/tmp/test.cpp:15:0
foo()
/tmp/test.cpp:8:10
π Example 4 - CODE and DATA prefixes
$ llvm-symbolizer --obj=test.elf "CODE 0x400490" "DATA 0x601028"
baz()
/tmp/test.cpp:11:0
bar
6295592 4
$ cat addr3.txt
CODE test.elf 0x4004a0
DATA inlined.elf 0x601028
$ llvm-symbolizer < addr3.txt
main
/tmp/test.cpp:15:0
bar
6295592 4
π§ Example 5 - 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 π
Okay bestie, this is the part where we get into every single flag. Buckle up, because there are a lot of them and theyβre all kind of iconic in their own way.
--adjust-vma <offset>β adds the offset you give it to object file addresses when itβs doing lookups. Basically you can do lookups as if the object had been relocated by that offset. lowkey useful, no cap.--basenames,-sβ prints just the fileβs name with no directories, instead of the absolute path. just the lil filename, periodt.--demangle,-Cβ prints demangled function names if the names are mangled. For example, the mangled name_Z3bazvbecomesbaz(), whilst the non-mangled namefozis printed as is. This defaults totrue. slay.--dwp <path>β use the specified DWP file at<path>for any CUs that have split DWARF debug data.--fallback-debug-path <path>β when a separate file contains debug data and is referenced by a GNU debug link section, use the specified path as a basis for locating the debug data if it canβt be found relative to the object.--functions [=<none|short|linkage>],-fβ specify the way function names are printed: omit the function name, print the short function name, or print the full linkage name, respectively. Defaults tolinkage. choose your fighter π--help,-hβ show help and usage for this command. the βhelp me bestieβ button.--inlining,--inlines,-iβ if a source code location is in an inlined function, prints all the inlined frames. This is the default. very demure, very mindful.--no-inlinesβ donβt print inlined frames. sometimes you just want the main character only.--no-demangleβ donβt print demangled function names. raw name energy.--obj <path>,--exe,-eβ path to the object file to be symbolized. If-is specified, read the object directly from the standard input stream. stdin girlies rise.--output-style <LLVM|GNU|JSON>β specify the preferred output style. Defaults toLLVM. When the output style is set toGNU, the tool follows the style of GNUβsaddr2line. The differences from the LLVM style are:- Does not print the column of a source code location.
- Does not add an empty line after the report for an address.
- Does not replace the name of an inlined function with the name of the topmost caller when inlined frames are not shown.
- Prints an addressβs debug-data discriminator when it is non-zero. One way to produce discriminators is to compile with clangβs
-fdebug-info-for-profiling.
JSON style provides a machine readable output in JSON. If addresses are supplied via stdin, the output JSON will be a series of individual objects. Otherwise, all results will be contained in a single array.
$ 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,
"Source": "",
"StartFileName": "/tmp/test.cpp",
"StartLine": 9
},
{
"Column": 0,
"Discriminator": 0,
"FileName": "/tmp/test.cpp",
"FunctionName": "main",
"Line": 15,
"Source": "",
"StartFileName": "/tmp/test.cpp",
"StartLine": 14
}
]
},
{
"Address": "0x400486",
"ModuleName": "inlined.elf",
"Symbol": [
{
"Column": 3,
"Discriminator": 0,
"FileName": "/tmp/test.cpp",
"FunctionName": "foo()",
"Line": 6,
"Source": "",
"StartFileName": "/tmp/test.cpp",
"StartLine": 5
}
]
}
]
--pretty-print,-pβ print human readable output. If--inliningis specified, the enclosing scope is prefixed by(inlined by). For JSON output, the option will cause JSON to be indented and split over new lines. Otherwise, the JSON output will be printed in a compact form. itβs giving readable π
$ 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
--print-address,--addresses,-aβ print the address before the source code location. Defaults tofalse.
$ 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
--print-source-context-lines <N>β printNlines of source context for each symbolized address. context queen π
$ 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 : }
--relativenamesβ print the fileβs path relative to the compilation directory, instead of the absolute path. If the command-line to the compiler included the full path, this will be the same as the default.--verboseβ print verbose address, line and column information. spill the details, bestie.
$ 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
--version,-vβ print version information for the tool. the βwho am iβ flag π@<FILE>β read command-line options from response file<FILE>.
πͺ WINDOWS/PDB SPECIFIC OPTIONS πͺ
--diaβ use the Windows DIA SDK for symbolization. If the DIA SDK is not found,llvm-symbolizerwill fall back to the native implementation.
π MACH-O SPECIFIC OPTIONS π
--default-arch <arch>β if a binary contains object files for multiple architectures (e.g. it is a Mach-O universal binary), symbolize the object file for a given architecture. You can also specify the architecture by writingbinary_name:arch_namein the input (see example below). If the architecture is not specified in either way, the address will not be symbolized. Defaults to empty string.
$ 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
--dsym-hint <path/to/file.dSYM>β if the debug info for a binary isnβt present in the default location, look for the debug info at the.dSYMpath provided via this option. This flag can be used multiple times. yes, multiple times. we love a repeatable icon.
πͺ EXIT STATUS πͺ
llvm-symbolizer returns 0. Other exit codes imply an internal program error. so if you see anything else, something is lowkey wrong internally π
π SEE ALSO π
βοΈ AUTHOR βοΈ
Maintained by the LLVM Team (https://llvm.org/).
Β©οΈ COPYRIGHT Β©οΈ
2003-2023, LLVM Project
π thatβs a wrap on LLVM-SYMBOLIZER(1) β version 13, dated 2023-07-14. go forth and symbolize something iconic, bestie π
β¨
π¦ where this page comes from
- ubuntu jammy: llvm-13 1:13.0.1-2ubuntu2.2 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms