• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

addr2line Command Examples in Linux

by admin

addr2line is a command-line utility in Linux that is used to convert addresses in an executable or shared object file into line numbers and file names. It is commonly used in combination with tools like gdb (the GNU debugger) and objdump to translate addresses of functions or variables in a program’s binary into their corresponding source code locations.

Here is an example of how addr2line might be used:

$ $ addr2line -e myprogram 0x4005e6
/path/to/myprogram.c:23

In this example, addr2line is used to translate the address 0x4005e6 in the executable file myprogram into a file name and line number. The output indicates that the address corresponds to line 23 in the file /path/to/myprogram.c.

addr2line can be used to translate addresses from both code and data sections of an executable or shared object file. It can also be used to translate addresses from core dumps or other types of memory dumps.

addr2line Command Examples

1. Display the filename and line number of the source code from an instruction address of an executable:

# addr2line --exe={{path/to/executable}} {{address}}

2. Display the function name, filename and line number:

# addr2line --exe={{path/to/executable}} --functions {{address}}

3. Demangle the function name for C++ code:

# addr2line --exe={{path/to/executable}} --functions --demangle {{address}}

Filed Under: Linux

Some more articles you might also be interested in …

  1. How to enable the automatic extension for a thin LVM volume
  2. lslogins Command Examples in Linux
  3. module Command Examples in Linux
  4. Log watching using tail or less
  5. CentOS / RHEL : anacron basics (What is anacron and how to configure it)
  6. How to create and mount filesystems in Linux
  7. chcon: command not found
  8. CentOS / RHEL : How to view the commands executed in yum history command output
  9. tuned-adm and Oracle
  10. CentOS / RHEL 7 : How to configure kdump

You May Also Like

Primary Sidebar

Recent Posts

  • nixos-rebuild Command Examples in Linux
  • nixos-option: Command Examples in Linux
  • nixos-container : Command Examples in Linux
  • nitrogen Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright