Forrest logo
back to the addr2line tool

addr2line:tldr:27dd0

addr2line: Demangle the function name for C++ code.
$ addr2line --exe=${path-to-executable} --functions --demangle ${address}
try on your machine

The command addr2line is a utility in Linux for converting memory addresses into source code file names and line numbers. It is primarily used for debugging purposes.

The provided command addr2line --exe=${path-to-executable} --functions --demangle ${address} has the following components:

  • addr2line: The command itself, used to invoke the addr2line utility.
  • --exe=${path-to-executable}: This option specifies the path to the executable file for which you want to retrieve source code information.
  • --functions: This option tells addr2line to output the names of the function(s) associated with the given address(es).
  • --demangle: This option instructs addr2line to demangle function names if they are mangled (e.g., from C++ names).
  • ${address}: This parameter represents the memory address(es) for which you want to obtain the corresponding source code information.

When you run this command, addr2line will analyze the given executable file (${path-to-executable}) and map the provided memory address(es) (${address}) to the corresponding function names and source code file locations. The output will show the source code file names and line numbers associated with the given address(es), as well as the demangled function names if applicable. This can help you determine the source code location that corresponds to a particular memory address, aiding in the debugging process.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the addr2line tool