addr2line(1)
Convert program addresses to source file names and line numbers.
Synopsis
addr2line [OPTION]... ADDRESSESDescription
addr2line translates addresses within program code into the corresponding source file names and line numbers. It reads hexadecimal addresses from standard input or command-line arguments and uses debugging symbols from a compiled binary to map those addresses back to their original locations in source code.
This tool is essential for debugging stripped binaries, analyzing core dumps, and interpreting stack traces. It requires that the binary was compiled with debugging symbols (typically using the -g flag with gcc/clang).
Common options
| Flag | What it does |
|---|---|
-e EXECUTABLE | Specify the executable file to extract symbol information from |
-f | Display the function name containing the address |
-s | Display only the file name and line number, not the full path |
-C | Demangle C++ symbol names for readability |
-a | Display the absolute address being translated |
-i | Display all inlined functions for the given address |
-p | Make output more readable with file:line format |
-j NAME | Read addresses from the specified section of the binary |
Examples
Convert a single address from the myapp binary to source location
addr2line -e /usr/bin/myapp 0x4005d0Show the function name along with file and line number for an address in bash
addr2line -e /bin/bash -f 0x41a5c0Convert multiple addresses piped from standard input
echo -e '0x400500\n0x400600' | addr2line -e ./programDemangle C++ symbols and display function names for a C++ binary
addr2line -e /usr/bin/myapp -C -f 0x123abcExtract addresses from a GDB backtrace and resolve them to source locations
gdb ./program -batch -ex 'run' -ex 'bt' 2>&1 | grep '0x' | awk '{print $1}' | addr2line -e ./program -fFind the line number in libc.so.6, showing short paths only
addr2line -e /lib/libc.so.6 -s 0x12345