2013-03-01 07:58:27 +00:00
|
|
|
llvm-symbolizer - convert addresses into source code locations
|
|
|
|
==============================================================
|
|
|
|
|
[docs][tools] Add missing "program" tags to rst files
Sphinx allows for definitions of command-line options using
`.. option <name>` and references to those options via `:option:<name>`.
However, it looks like there is no scoping of these options by default,
meaning that links can end up pointing to incorrect documents. See for
example the llvm-mca document, which contains references to -o that,
prior to this patch, pointed to a different document. What's worse is
that these links appear to be non-deterministic in which one is picked
(on my machine, some references end up pointing to opt, whereas on the
live docs, they point to llvm-dwarfdump, for example).
The fix is to add the .. program <name> tag. This essentially namespaces
the options (definitions and references) to the named program, ensuring
that the links are kept correct.
Reviwed by: andreadb
Differential Revision: https://reviews.llvm.org/D63873
llvm-svn: 364538
2019-06-27 13:24:46 +00:00
|
|
|
.. program:: llvm-symbolizer
|
|
|
|
|
2013-03-01 07:58:27 +00:00
|
|
|
SYNOPSIS
|
|
|
|
--------
|
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
:program:`llvm-symbolizer` [*options*] [*addresses...*]
|
2013-03-01 07:58:27 +00:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
|
|
|
|
2022-02-15 22:21:14 +00:00
|
|
|
:program:`llvm-symbolizer` reads input names and addresses from the command-line
|
2022-05-04 22:47:42 +00:00
|
|
|
and prints corresponding source code locations to standard output. It can also
|
|
|
|
symbolize logs containing :doc:`Symbolizer Markup </SymbolizerMarkupFormat>` via
|
2023-04-03 23:28:50 +07:00
|
|
|
:option:`--filter-markup`. Addresses may be specified as numbers or symbol names.
|
2013-03-01 07:58:27 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
If no address is specified on the command-line, it reads the addresses from
|
2022-02-15 22:21:14 +00:00
|
|
|
standard input. If no input name is specified on the command-line, but addresses
|
2023-08-30 15:30:35 +07:00
|
|
|
are, the first address value is treated as an input name. If an input value is not
|
|
|
|
recognized, it reports that source information is not found.
|
2022-02-15 22:21:14 +00:00
|
|
|
|
|
|
|
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).
|
2019-06-26 11:42:03 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2019-12-18 10:19:47 -08:00
|
|
|
:program:`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 :program:`llvm-symbolizer` is invoked by another program or
|
|
|
|
runtime.
|
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
EXAMPLES
|
2013-03-01 07:58:27 +00:00
|
|
|
--------
|
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
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 :option:`--demangle`).
|
|
|
|
|
|
|
|
.. code-block:: c
|
|
|
|
|
|
|
|
// test.h
|
|
|
|
extern "C" inline int foz() {
|
|
|
|
return 1234;
|
|
|
|
}
|
|
|
|
|
|
|
|
.. code-block:: c
|
|
|
|
|
|
|
|
// 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:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ clang -g test.cpp -o test.elf
|
|
|
|
$ clang -g -O2 test.cpp -o inlined.elf
|
|
|
|
|
|
|
|
Example 1 - addresses and object on command-line:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ 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:
|
|
|
|
|
2013-03-01 07:58:27 +00:00
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ cat addr.txt
|
2019-06-26 11:42:03 +00:00
|
|
|
0x4004a0
|
|
|
|
0x400490
|
|
|
|
0x4004d0
|
|
|
|
$ llvm-symbolizer --obj=test.elf < addr.txt
|
2013-03-01 07:58:27 +00:00
|
|
|
main
|
2019-06-26 11:42:03 +00:00
|
|
|
/tmp/test.cpp:15:0
|
2013-03-01 07:58:27 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
baz()
|
|
|
|
/tmp/test.cpp:11:0
|
|
|
|
|
|
|
|
foz
|
|
|
|
/tmp/./test.h:1:0
|
|
|
|
|
|
|
|
Example 3 - object specified with address:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
2022-02-15 22:21:14 +00:00
|
|
|
$ llvm-symbolizer "test.elf 0x400490" "FILE:inlined.elf 0x400480"
|
2019-06-26 11:42:03 +00:00
|
|
|
baz()
|
|
|
|
/tmp/test.cpp:11:0
|
|
|
|
|
|
|
|
foo()
|
|
|
|
/tmp/test.cpp:8:10
|
2013-06-28 08:15:40 +00:00
|
|
|
|
2013-12-24 19:33:22 +00:00
|
|
|
$ cat addr2.txt
|
2022-02-15 22:21:14 +00:00
|
|
|
FILE:test.elf 0x4004a0
|
2019-06-26 11:42:03 +00:00
|
|
|
inlined.elf 0x400480
|
|
|
|
|
|
|
|
$ llvm-symbolizer < addr2.txt
|
2013-12-24 19:33:22 +00:00
|
|
|
main
|
2019-06-26 11:42:03 +00:00
|
|
|
/tmp/test.cpp:15:0
|
2013-06-28 08:15:40 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
foo()
|
|
|
|
/tmp/test.cpp:8:10
|
2013-03-01 07:58:27 +00:00
|
|
|
|
2022-02-15 22:21:14 +00:00
|
|
|
Example 4 - BUILDID and FILE prefixes:
|
2014-05-17 00:07:48 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
.. code-block:: console
|
2013-12-24 19:33:22 +00:00
|
|
|
|
2022-02-15 22:21:14 +00:00
|
|
|
$ llvm-symbolizer "FILE:test.elf 0x400490" "DATA BUILDID:123456789abcdef 0x601028"
|
2019-06-26 11:42:03 +00:00
|
|
|
baz()
|
|
|
|
/tmp/test.cpp:11:0
|
2019-04-19 10:17:52 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
bar
|
|
|
|
6295592 4
|
2013-03-01 07:58:27 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
$ cat addr3.txt
|
2022-02-15 22:21:14 +00:00
|
|
|
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:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ llvm-symbolizer --obj=test.elf "CODE 0x400490" "DATA 0x601028"
|
|
|
|
baz()
|
|
|
|
/tmp/test.cpp:11:0
|
|
|
|
|
|
|
|
bar
|
|
|
|
6295592 4
|
|
|
|
|
|
|
|
$ cat addr4.txt
|
2019-06-26 11:42:03 +00:00
|
|
|
CODE test.elf 0x4004a0
|
|
|
|
DATA inlined.elf 0x601028
|
2013-03-01 07:58:27 +00:00
|
|
|
|
2022-02-15 22:21:14 +00:00
|
|
|
$ llvm-symbolizer < addr4.txt
|
2019-06-26 11:42:03 +00:00
|
|
|
main
|
|
|
|
/tmp/test.cpp:15:0
|
2019-04-19 10:17:52 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
bar
|
|
|
|
6295592 4
|
|
|
|
|
2022-02-15 22:21:14 +00:00
|
|
|
Example 6 - path-style options:
|
2020-03-20 13:28:50 -07:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
.. code-block:: console
|
2020-04-13 14:39:25 +02:00
|
|
|
|
2020-03-20 13:28:50 -07:00
|
|
|
$ pwd
|
|
|
|
/tmp
|
|
|
|
$ clang -g foo/test.cpp -o test.elf
|
2020-04-13 14:39:25 +02:00
|
|
|
$ llvm-symbolizer --obj=test.elf 0x4004a0
|
2020-03-20 13:28:50 -07:00
|
|
|
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
|
2020-04-13 14:39:25 +02:00
|
|
|
|
2023-04-03 23:28:50 +07:00
|
|
|
Example 7 - Addresses as symbol names:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ llvm-symbolizer --obj=test.elf main
|
|
|
|
main
|
|
|
|
/tmp/test.cpp:14:0
|
|
|
|
$ llvm-symbolizer --obj=test.elf "CODE foz"
|
|
|
|
foz
|
|
|
|
/tmp/test.h:1:0
|
|
|
|
|
2024-08-05 13:38:34 +05:30
|
|
|
Example 8 - :option:`--skip-line-zero` output for an address with no line correspondence (an address associated with line zero):
|
|
|
|
|
|
|
|
.. code-block:: c
|
|
|
|
|
|
|
|
// test.c
|
|
|
|
int foo = 0;
|
|
|
|
int x = 1234;
|
|
|
|
int main() {
|
|
|
|
if (x)
|
|
|
|
return foo;
|
|
|
|
else
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
These files are built as follows:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ clang -g -O2 -S test.c -o test.s
|
|
|
|
$ llvm-mc -filetype=obj -triple=x86_64-unknown-linux test.s -o test.o
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ llvm-symbolizer --obj=test.o --skip-line-zero 0xa
|
|
|
|
main
|
|
|
|
/tmp/test.c:5:7 (approximate)
|
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
OPTIONS
|
|
|
|
-------
|
2013-03-01 07:58:27 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
.. option:: --adjust-vma <offset>
|
|
|
|
|
|
|
|
Add the specified offset to object file addresses when performing lookups.
|
|
|
|
This can be used to perform lookups as if the object were relocated by the
|
|
|
|
offset.
|
|
|
|
|
2024-08-05 13:38:34 +05:30
|
|
|
.. option:: --skip-line-zero
|
|
|
|
|
|
|
|
If an address does not have an associated line number, use the last line
|
|
|
|
number from the current sequence in the line-table. Such lines are labeled
|
|
|
|
as "approximate" in the output as they may be misleading.
|
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
.. option:: --basenames, -s
|
|
|
|
|
2020-03-20 13:28:50 -07:00
|
|
|
Print just the file's name without any directories, instead of the
|
|
|
|
absolute path.
|
2021-11-15 09:17:08 +08:00
|
|
|
|
2022-01-21 00:13:52 +00:00
|
|
|
.. option:: --build-id
|
|
|
|
|
|
|
|
Look up the object using the given build ID, specified as a hexadecimal
|
|
|
|
string. Mutually exclusive with :option:`--obj`.
|
|
|
|
|
2022-05-04 22:47:42 +00:00
|
|
|
.. option:: --color [=<always|auto|never>]
|
|
|
|
|
|
|
|
Specify whether to use color in :option:`--filter-markup` mode. Defaults to
|
|
|
|
``auto``, which detects whether standard output supports color. Specifying
|
|
|
|
``--color`` alone is equivalent to ``--color=always``.
|
|
|
|
|
2022-08-23 13:44:30 -07:00
|
|
|
.. option:: --debug-file-directory <path>
|
|
|
|
|
|
|
|
Provide a path to a directory with a `.build-id` subdirectory to search for
|
|
|
|
debug information for stripped binaries. Multiple instances of this argument
|
|
|
|
are searched in the order given.
|
|
|
|
|
2022-01-31 22:22:22 +00:00
|
|
|
.. option:: --debuginfod, --no-debuginfod
|
|
|
|
|
|
|
|
Whether or not to try debuginfod lookups for debug binaries. Unless specified,
|
|
|
|
debuginfod is only enabled if libcurl was compiled in (``LLVM_ENABLE_CURL``)
|
|
|
|
and at least one server URL was provided by the environment variable
|
|
|
|
``DEBUGINFOD_URLS``.
|
|
|
|
|
2019-04-19 10:17:52 +00:00
|
|
|
.. _llvm-symbolizer-opt-C:
|
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
.. option:: --demangle, -C
|
2013-03-01 07:58:27 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
Print demangled function names, if the names are mangled (e.g. the mangled
|
|
|
|
name `_Z3bazv` becomes `baz()`, whilst the non-mangled name `foz` is printed
|
|
|
|
as is). Defaults to true.
|
2013-03-01 07:58:27 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
.. option:: --dwp <path>
|
2019-01-21 10:00:57 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
Use the specified DWP file at ``<path>`` for any CUs that have split DWARF
|
|
|
|
debug data.
|
2019-01-21 10:00:57 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
.. option:: --fallback-debug-path <path>
|
2019-04-19 10:17:52 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
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 cannot be found relative to the object.
|
2013-03-01 07:58:27 +00:00
|
|
|
|
2022-05-04 22:47:42 +00:00
|
|
|
.. option:: --filter-markup
|
|
|
|
|
|
|
|
Reads from standard input, converts contained
|
|
|
|
:doc:`Symbolizer Markup </SymbolizerMarkupFormat>` into human-readable form,
|
2022-07-19 14:20:12 -07:00
|
|
|
and prints the results to standard output. The following markup elements are
|
|
|
|
not yet supported:
|
2022-05-04 22:47:42 +00:00
|
|
|
|
2022-08-05 14:58:44 -07:00
|
|
|
* ``{{{hexdict}}}``
|
|
|
|
* ``{{{dumpfile}}}``
|
|
|
|
|
|
|
|
The ``{{{bt}}}`` backtrace element reports frames using the following syntax:
|
|
|
|
|
|
|
|
``#<number>[.<inline>] <address> <function> <file>:<line>:<col> (<module>+<relative address>)``
|
|
|
|
|
|
|
|
``<inline>`` provides frame numbers for calls inlined into the caller
|
2023-08-13 23:46:44 -07:00
|
|
|
corresponding to ``<number>``. The inlined call numbers start at 1 and increase
|
2022-08-05 14:58:44 -07:00
|
|
|
from callee to caller.
|
|
|
|
|
|
|
|
``<address>`` is an address inside the call instruction to the function. The
|
|
|
|
address may not be the start of the instruction. ``<relative address>`` is
|
|
|
|
the corresponding virtual offset in the ``<module>`` loaded at that address.
|
|
|
|
|
2022-05-04 22:47:42 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
.. _llvm-symbolizer-opt-f:
|
2013-03-01 07:58:27 +00:00
|
|
|
|
2020-02-26 10:24:50 +00:00
|
|
|
.. option:: --functions [=<none|short|linkage>], -f
|
2013-06-28 08:15:40 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
Specify the way function names are printed (omit function name, print short
|
|
|
|
function name, or print full linkage name, respectively). Defaults to
|
|
|
|
``linkage``.
|
2013-06-28 08:15:40 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
.. option:: --help, -h
|
2014-10-17 00:50:19 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
Show help and usage for this command.
|
2014-10-17 00:50:19 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
.. _llvm-symbolizer-opt-i:
|
2015-11-11 22:14:58 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
.. option:: --inlining, --inlines, -i
|
2015-11-11 20:41:43 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
If a source code location is in an inlined function, prints all the inlined
|
2020-08-04 08:51:24 -07:00
|
|
|
frames. This is the default.
|
|
|
|
|
|
|
|
.. option:: --no-inlines
|
|
|
|
|
|
|
|
Don't print inlined frames.
|
2019-01-22 10:24:32 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
.. option:: --no-demangle
|
2019-01-22 10:24:32 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
Don't print demangled function names.
|
2019-01-25 11:49:21 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
.. option:: --obj <path>, --exe, -e
|
|
|
|
|
|
|
|
Path to object file to be symbolized. If ``-`` is specified, read the object
|
2022-01-21 00:13:52 +00:00
|
|
|
directly from the standard input stream. Mutually exclusive with
|
|
|
|
:option:`--build-id`.
|
2019-01-25 11:49:21 +00:00
|
|
|
|
2019-04-19 10:17:52 +00:00
|
|
|
.. _llvm-symbolizer-opt-output-style:
|
|
|
|
|
2021-05-11 13:10:54 +04:00
|
|
|
.. option:: --output-style <LLVM|GNU|JSON>
|
2019-04-19 10:14:18 +00:00
|
|
|
|
|
|
|
Specify the preferred output style. Defaults to ``LLVM``. When the output
|
|
|
|
style is set to ``GNU``, the tool follows the style of GNU's **addr2line**.
|
|
|
|
The differences from the ``LLVM`` style are:
|
2021-11-15 09:17:08 +08:00
|
|
|
|
2019-07-10 13:40:45 +00:00
|
|
|
* Does not print the column of a source code location.
|
2019-04-19 10:14:18 +00:00
|
|
|
|
|
|
|
* 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
|
2021-05-10 17:19:05 +01:00
|
|
|
topmost caller when inlined frames are not shown.
|
2019-04-19 10:14:18 +00:00
|
|
|
|
2020-01-23 17:51:33 -08:00
|
|
|
* 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.
|
|
|
|
|
2021-05-11 13:10:54 +04:00
|
|
|
``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.
|
|
|
|
|
2019-04-19 10:14:18 +00:00
|
|
|
.. code-block:: console
|
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
$ 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
|
|
|
|
|
2020-08-04 08:51:24 -07:00
|
|
|
$ llvm-symbolizer --output-style=LLVM --obj=inlined.elf 0x4004be 0x400486 -p --no-inlines
|
2019-06-26 11:42:03 +00:00
|
|
|
main at /tmp/test.cpp:11:18
|
|
|
|
|
|
|
|
foo() at /tmp/test.cpp:6:3
|
|
|
|
|
2020-08-04 08:51:24 -07:00
|
|
|
$ llvm-symbolizer --output-style=GNU --obj=inlined.elf 0x4004be 0x400486 -p --no-inlines
|
2019-06-26 11:42:03 +00:00
|
|
|
baz() at /tmp/test.cpp:11
|
|
|
|
foo() at /tmp/test.cpp:6
|
|
|
|
|
2020-01-23 17:51:33 -08:00
|
|
|
$ clang -g -fdebug-info-for-profiling test.cpp -o profiling.elf
|
2020-08-04 08:51:24 -07:00
|
|
|
$ llvm-symbolizer --output-style=GNU --obj=profiling.elf 0x401167 -p --no-inlines
|
2020-01-23 17:51:33 -08:00
|
|
|
main at /tmp/test.cpp:15 (discriminator 2)
|
|
|
|
|
2021-05-11 13:10:54 +04:00
|
|
|
$ 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,
|
2021-12-07 14:18:42 +00:00
|
|
|
"StartAddress": "0x4004be",
|
2021-05-11 13:10:54 +04:00
|
|
|
"StartFileName": "/tmp/test.cpp",
|
|
|
|
"StartLine": 9
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Column": 0,
|
|
|
|
"Discriminator": 0,
|
|
|
|
"FileName": "/tmp/test.cpp",
|
|
|
|
"FunctionName": "main",
|
|
|
|
"Line": 15,
|
2021-12-07 14:18:42 +00:00
|
|
|
"StartAddress": "0x4004be",
|
2021-05-11 13:10:54 +04:00
|
|
|
"StartFileName": "/tmp/test.cpp",
|
|
|
|
"StartLine": 14
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Address": "0x400486",
|
|
|
|
"ModuleName": "inlined.elf",
|
|
|
|
"Symbol": [
|
|
|
|
{
|
|
|
|
"Column": 3,
|
|
|
|
"Discriminator": 0,
|
|
|
|
"FileName": "/tmp/test.cpp",
|
|
|
|
"FunctionName": "foo()",
|
|
|
|
"Line": 6,
|
2021-12-07 14:18:42 +00:00
|
|
|
"StartAddress": "0x400486",
|
2021-05-11 13:10:54 +04:00
|
|
|
"StartFileName": "/tmp/test.cpp",
|
|
|
|
"StartLine": 5
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
.. option:: --pretty-print, -p
|
|
|
|
|
|
|
|
Print human readable output. If :option:`--inlining` is specified, the
|
|
|
|
enclosing scope is prefixed by (inlined by).
|
2021-05-11 13:10:54 +04:00
|
|
|
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.
|
2019-06-26 11:42:03 +00:00
|
|
|
|
2020-02-26 10:29:47 +00:00
|
|
|
.. code-block:: console
|
2019-06-26 11:42:03 +00:00
|
|
|
|
2020-02-26 10:29:47 +00:00
|
|
|
$ 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
|
2019-06-26 11:42:03 +00:00
|
|
|
|
|
|
|
.. option:: --print-address, --addresses, -a
|
|
|
|
|
|
|
|
Print address before the source code location. Defaults to false.
|
|
|
|
|
2020-02-26 10:29:47 +00:00
|
|
|
.. code-block:: console
|
2019-06-26 11:42:03 +00:00
|
|
|
|
2020-02-26 10:29:47 +00:00
|
|
|
$ llvm-symbolizer --obj=inlined.elf --print-address 0x4004be
|
|
|
|
0x4004be
|
|
|
|
baz()
|
|
|
|
/tmp/test.cpp:11:18
|
|
|
|
main
|
|
|
|
/tmp/test.cpp:15:0
|
2019-04-19 10:14:18 +00:00
|
|
|
|
2020-02-26 10:29:47 +00:00
|
|
|
$ 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
|
2019-04-19 10:14:18 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
.. option:: --print-source-context-lines <N>
|
2019-04-19 10:14:18 +00:00
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
Print ``N`` lines of source context for each symbolized address.
|
2019-04-19 10:14:18 +00:00
|
|
|
|
2020-02-26 10:29:47 +00:00
|
|
|
.. code-block:: console
|
2019-06-26 11:42:03 +00:00
|
|
|
|
2021-06-11 13:35:04 +01:00
|
|
|
$ llvm-symbolizer --obj=test.elf 0x400490 --print-source-context-lines=3
|
2020-02-26 10:29:47 +00:00
|
|
|
baz()
|
|
|
|
/tmp/test.cpp:11:0
|
|
|
|
10 : volatile int k = 42;
|
|
|
|
11 >: return foz() + k;
|
|
|
|
12 : }
|
2019-06-26 11:42:03 +00:00
|
|
|
|
2021-01-12 10:11:49 +00:00
|
|
|
.. option:: --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.
|
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
.. option:: --verbose
|
|
|
|
|
2021-05-19 02:38:13 +04:00
|
|
|
Print verbose address, line and column information.
|
2019-06-26 11:42:03 +00:00
|
|
|
|
2020-02-26 10:29:47 +00:00
|
|
|
.. code-block:: console
|
2019-06-26 11:42:03 +00:00
|
|
|
|
2020-02-26 10:29:47 +00:00
|
|
|
$ llvm-symbolizer --obj=inlined.elf --verbose 0x4004be
|
|
|
|
baz()
|
|
|
|
Filename: /tmp/test.cpp
|
2021-06-11 16:58:00 +01:00
|
|
|
Function start filename: /tmp/test.cpp
|
2021-05-19 02:38:13 +04:00
|
|
|
Function start line: 9
|
2021-06-11 16:58:00 +01:00
|
|
|
Function start address: 0x4004b6
|
2020-02-26 10:29:47 +00:00
|
|
|
Line: 11
|
|
|
|
Column: 18
|
|
|
|
main
|
|
|
|
Filename: /tmp/test.cpp
|
2021-06-11 16:58:00 +01:00
|
|
|
Function start filename: /tmp/test.cpp
|
2021-05-19 02:38:13 +04:00
|
|
|
Function start line: 14
|
|
|
|
Function start address: 0x4004b0
|
2020-02-26 10:29:47 +00:00
|
|
|
Line: 15
|
2021-06-11 16:58:00 +01:00
|
|
|
Column: 18
|
2019-06-26 11:42:03 +00:00
|
|
|
|
2020-08-10 08:15:33 -07:00
|
|
|
.. option:: --version, -v
|
2019-06-26 11:42:03 +00:00
|
|
|
|
|
|
|
Print version information for the tool.
|
2019-04-19 10:14:18 +00:00
|
|
|
|
2019-06-21 11:49:20 +00:00
|
|
|
.. option:: @<FILE>
|
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
Read command-line options from response file `<FILE>`.
|
|
|
|
|
2020-11-30 14:35:15 -08:00
|
|
|
WINDOWS/PDB SPECIFIC OPTIONS
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
.. option:: --dia
|
|
|
|
|
|
|
|
Use the Windows DIA SDK for symbolization. If the DIA SDK is not found,
|
|
|
|
llvm-symbolizer will fall back to the native implementation.
|
|
|
|
|
2019-06-26 11:42:03 +00:00
|
|
|
MACH-O SPECIFIC OPTIONS
|
|
|
|
-----------------------
|
|
|
|
|
|
|
|
.. option:: --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 writing ``binary_name:arch_name`` in
|
|
|
|
the input (see example below). If the architecture is not specified in either
|
|
|
|
way, the address will not be symbolized. Defaults to empty string.
|
|
|
|
|
2020-02-26 10:29:47 +00:00
|
|
|
.. code-block:: console
|
2019-06-26 11:42:03 +00:00
|
|
|
|
2020-02-26 10:29:47 +00:00
|
|
|
$ cat addr.txt
|
|
|
|
/tmp/mach_universal_binary:i386 0x1f84
|
|
|
|
/tmp/mach_universal_binary:x86_64 0x100000f24
|
2019-06-26 11:42:03 +00:00
|
|
|
|
2020-02-26 10:29:47 +00:00
|
|
|
$ llvm-symbolizer < addr.txt
|
|
|
|
_main
|
|
|
|
/tmp/source_i386.cc:8
|
2019-06-26 11:42:03 +00:00
|
|
|
|
2020-02-26 10:29:47 +00:00
|
|
|
_main
|
|
|
|
/tmp/source_x86_64.cc:8
|
2019-06-26 11:42:03 +00:00
|
|
|
|
|
|
|
.. option:: --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 .dSYM path provided via this option. This flag can be
|
|
|
|
used multiple times.
|
2019-06-21 11:49:20 +00:00
|
|
|
|
2013-03-01 07:58:27 +00:00
|
|
|
EXIT STATUS
|
|
|
|
-----------
|
|
|
|
|
2019-06-12 11:41:43 +00:00
|
|
|
:program:`llvm-symbolizer` returns 0. Other exit codes imply an internal program
|
|
|
|
error.
|
2019-06-26 11:42:03 +00:00
|
|
|
|
|
|
|
SEE ALSO
|
|
|
|
--------
|
|
|
|
|
|
|
|
:manpage:`llvm-addr2line(1)`
|