addr2line [-a|--addresses] [-b bfdname|--target=bfdname] [-C|--demangle[=style]] [-e filename|--exe=filename] [-f|--functions] [-s|--basename] [-i|--inlines] [-p|--pretty-print] [-j|--section=name] [-H|--help] [-V|--version] [addr addr …]
addr2line
translates addresses into file names and line numbers.
Given an address in an executable or an offset in a section of a relocatable
object, it uses the debugging information to figure out which file name and
line number are associated with it.
The executable or relocatable object to use is specified with the -e option. The default is the file a.out. The section in the relocatable object to use is specified with the -j option.
addr2line
has two modes of operation.
In the first, hexadecimal addresses are specified on the command line,
and addr2line
displays the file name and line number for each
address.
In the second, addr2line
reads hexadecimal addresses from
standard input, and prints the file name and line number for each
address on standard output. In this mode, addr2line
may be used
in a pipe to convert dynamically chosen addresses.
The format of the output is ‘FILENAME:LINENO’. The file name and line number for each input address is printed on separate lines.
If the -f option is used, then each ‘FILENAME:LINENO’ line is preceded by ‘FUNCTIONNAME’ which is the name of the function containing the address.
If the -i option is used and the code at the given address is present there because of inlining by the compiler then the ‘{FUNCTIONNAME} FILENAME:LINENO’ information for the inlining function will be displayed afterwards. This continues recursively until there is no more inlining to report.
If the -a option is used then the output is prefixed by the input address.
If the -p option is used then the output for each input address is displayed on one, possibly quite long, line. If -p is not used then the output is broken up into multiple lines, based on the paragraphs above.
If the file name or function name can not be determined,
addr2line
will print two question marks in their place. If the
line number can not be determined, addr2line
will print 0.
The long and short forms of options, shown here as alternatives, are equivalent.
-a
--addresses
Display the address before the function name, file and line number information. The address is printed with a ‘0x’ prefix to easily identify it.
-b bfdname
--target=bfdname
Specify that the object-code format for the object files is bfdname.
-C
--demangle[=style]
Decode (demangle) low-level symbol names into user-level names. Besides removing any initial underscore prepended by the system, this makes C++ function names readable. Different compilers have different mangling styles. The optional demangling style argument can be used to choose an appropriate demangling style for your compiler. See c++filt, for more information on demangling.
-e filename
--exe=filename
Specify the name of the executable for which addresses should be translated. The default file is a.out.
-f
--functions
Display function names as well as file and line number information.
-s
--basenames
Display only the base of each file name.
-i
--inlines
If the address belongs to a function that was inlined, the source
information for all enclosing scopes back to the first non-inlined
function will also be printed. For example, if main
inlines
callee1
which inlines callee2
, and address is from
callee2
, the source information for callee1
and main
will also be printed.
-j
--section
Read offsets relative to the specified section instead of absolute addresses.
-p
--pretty-print
Make the output more human friendly: each location are printed on one line. If option -i is specified, lines for all enclosing scopes are prefixed with ‘(inlined by)’.