$linuxjunkies
>

addr2line(1)

Convert program addresses to source file names and line numbers.

UbuntuDebianFedoraArch

Synopsis

addr2line [OPTION]... ADDRESSES

Description

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

FlagWhat it does
-e EXECUTABLESpecify the executable file to extract symbol information from
-fDisplay the function name containing the address
-sDisplay only the file name and line number, not the full path
-CDemangle C++ symbol names for readability
-aDisplay the absolute address being translated
-iDisplay all inlined functions for the given address
-pMake output more readable with file:line format
-j NAMERead 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 0x4005d0

Show the function name along with file and line number for an address in bash

addr2line -e /bin/bash -f 0x41a5c0

Convert multiple addresses piped from standard input

echo -e '0x400500\n0x400600' | addr2line -e ./program

Demangle C++ symbols and display function names for a C++ binary

addr2line -e /usr/bin/myapp -C -f 0x123abc

Extract 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 -f

Find the line number in libc.so.6, showing short paths only

addr2line -e /lib/libc.so.6 -s 0x12345

Related commands