ADDR2LINE(1)

πŸ“¦ version 2.45, in ubuntu questing

πŸ’– ADDR2LINE(1) πŸ’–

okay bestie, this is the GNU Development Tools manual page for addr2line 🧚 It's a tool that takes memory addresses (or symbol+offset) and tells you which file and line number they belong to. Lowkey the most underrated debugging tool πŸ’…

✨ NAME ✨

addr2line converts addresses or symbol+offset into file names and line numbers. πŸ¦‹

πŸŽ€ SYNOPSIS πŸŽ€

addr2line [-a|--addresses]
          [-b bfdname|--target=bfdname]
          [-C|--demangle[=style]]
          [-r|--no-recurse-limit]
          [-R|--recurse-limit]
          [-e filename|--exe=filename]
          [-f|--functions] [-s|--basename]
          [-i|--inlines]
          [-p|--pretty-print]
          [-j|--section=name]
          [-H|--help] [-V|--version]
          [addr addr ...]

🌸 DESCRIPTION 🌸

okay so addr2line translates addresses or symbol+offset into file names and line numbers. πŸ”₯ You give it an address (or symbol+offset) from an executable, or an offset inside a section of a relocatable object, and it digs through the debugging info to figure out which file name and line number go with it. Iconic behavior, honestly 😭

The executable or relocatable object you want to use gets picked with the -e option. The default is the file a.out. The section in the relocatable object gets picked with the -j option. πŸ’œ

addr2line has two modes, and both slay ✨

In the first mode, you put hexadecimal addresses or symbol+offset right on the command line, and addr2line shows the file name and line number for each one. πŸ“

In the second mode, addr2line reads hexadecimal addresses or symbol+offset from standard input and prints the file name and line number for each one on standard output. This is the mode to use when you're piping stuff in, because it can convert addresses you only figure out dynamically 🧚

The output looks like FILENAME:LINENO. By default, each input address gets exactly one line of output. Simple, clean, no notes πŸ’…

Two options can add extra lines before each FILENAME:LINENO line, and they show up in this order:

  • If you use -a, you get a line with the input address. πŸ¦‹
  • If you use -f, you get a line with the FUNCTIONNAME, which is the name of the function containing the address. πŸ‘‘

One option can add extra lines after the FILENAME:LINENO line. πŸ™ˆ

If you use -i and the code at that address is only there because the compiler inlined something, extra lines get printed after. You get one or two extra lines (two if you also use -f) for each inlined function. The vibe is very layered 🌈

Or, if you use -p, each input address spits out one single long line with the address, the function name, the file name and the line number. If you also used -i, any inlined functions show up the same way but on their own lines, and they get prefixed with the text (inlined by). πŸ’–

If the file name or function name can't be figured out, addr2line prints two question marks in its place. If the line number can't be figured out, it prints 0. ⭐

When you use symbol+offset, the +offset part is optional, except when the symbol is ambiguous with a hex number. Resolved symbols can be mangled or unmangled, except unmangled symbols with + are not allowed. 🚫

⚠️ Heads up: unmangled symbols containing + are not allowed, so don't even try it. πŸ’€

πŸŽ€ OPTIONS πŸŽ€

The long and short forms of each option are equivalent, so pick whichever one you vibe with 🫢

  • -a, --addresses β€” Shows the address before the function name, file and line number info. The address gets a 0x prefix so it's easy to spot. πŸ¦‹
  • -b bfdname, --target=bfdname β€” Tells addr2line that the object-code format of the object files is bfdname. 🧚
  • -C, --demangle[=style] β€” Decodes (demangles) low-level symbol names into user-level names. It removes any initial underscore the system tacked on, and it makes C++ function names readable, which is honestly a glow-up πŸ’… Different compilers mangle names in different ways, so the optional style argument lets you pick the demangling style that fits your compiler. ✨
  • -e filename, --exe=filename β€” Picks the executable whose addresses should be translated. The default is a.out. 🌸
  • -f, --functions β€” Shows function names along with the file and line number info. πŸ‘‘
  • -s, --basenames β€” Shows only the base name of each file name. πŸ“
  • -i, --inlines β€” If the address belongs to an inlined function, the source info for every enclosing scope, all the way back to the first non-inlined function, also gets printed. For example, if "main" inlines "callee1", which inlines "callee2", and the address is from "callee2", then the source info for "callee1" and "main" gets printed too. Main character energy 🌈
  • -j, --section β€” Reads offsets relative to the specified section instead of absolute addresses. πŸ’œ
  • -p, --pretty-print β€” Makes the output more human friendly: each location gets printed on one line. If you also use -i, the lines for all enclosing scopes get prefixed with (inlined by). πŸŽ€
  • -r, -R, --recurse-limit, --no-recurse-limit, --recursion-limit, --no-recursion-limit β€” Turns a limit on how much recursion happens while demangling strings on or off. The mangling formats technically allow infinite recursion, so you can build strings that eat up all the stack space on the host machine and cause a memory fault. The limit stops that by capping recursion at 2048 levels of nesting. πŸ›‘

The limit is on by default, but you might need to turn it off to demangle truly complicated names. Heads up though: if you disable the limit, stack exhaustion is possible, and any bug reports about that will be rejected πŸ’€

-r is a synonym for --no-recurse-limit, and -R is a synonym for --recurse-limit.

Note that this option only matters if -C or --demangle is enabled. πŸ™ˆ

  • @file β€” Reads command-line options from file. The options read get inserted in place of the original @file option. If file doesn't exist or can't be read, the option gets treated literally and doesn't get removed. 🧚

Options inside file are separated by whitespace. If you need a whitespace character inside an option, wrap the entire option in single or double quotes. Any character (including a backslash) can be included by putting a backslash in front of it. The file can also contain more @file options, and those get processed recursively. It's giving Russian nesting doll πŸͺ†

πŸ¦‹ SEE ALSO πŸ¦‹

Info entries for binutils. πŸ“–

Copyright (c) 1991-2025 Free Software Foundation, Inc. 🌈

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation, with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". πŸ“œ


That's the whole thing, bestie! ✨ This page came from binutils-2.45, dated 2025-12-03. Go debug something iconic πŸ’–πŸ«Ά

πŸ“¦ where this page comes from