ADDR2LINE(1)
π ADDR2LINE(1) β GNU Development Tools π
okay bestie, gather round, because this little icon of the binutils world is about to change your whole debugging life. it's addr2line, and it does exactly what the name says (rare W for naming conventions): it turns addresses or symbol+offset into file names and line numbers. no cap. β¨
πΈ NAME πΈ
addr2line β convert 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 π¦
so basically, addr2line takes addresses or symbol+offset and translates them into file names and line numbers. like, you hand it an address or a symbol+offset from an executable, or an offset inside a section of a relocatable object, and it goes digging through the debugging information to figure out which file name and line number are associated with it. it's giving detective energy fr fr π
the executable or relocatable object you want it to use? that's the -e option's whole job. and if you don't say anything, the default is the file a.out. (yes, a.out, the classic. iconic behavior.) the section inside the relocatable object is chosen with the -j option.
now, addr2line has two modes of operation, and both are lowkey great:
- in the first mode, you pass hexadecimal addresses or symbol+offset right there on the command line, and
addr2lineshows you the file name and line number for each one. - in the second mode,
addr2linereads hexadecimal addresses or symbol+offset from standard input, and prints the file name and line number for each address to standard output. this is the pipe girlie mode β perfect for converting dynamically chosen addresses on the fly. π«Ά
the format of the output is FILENAME:LINENO. by default, each input address generates exactly one line of output. one address, one line, clean, minimal, slay.
two options can generate 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 theFUNCTIONNAMEβ that's the name of the function containing the address.
one option can generate extra lines after the FILENAME:LINENO line:
- if you use
-iand the code at the given address is present there because of inlining by the compiler, then extra lines get displayed afterwards. you get one or two extra lines (two if you're also using-f) for each inlined function. the way that nesting just keeps going π
alternatively, if you use -p, then each input address generates a single, long, gorgeous output line containing the address, the function name, the file name and the line number. and if you also used -i, any inlined functions get displayed the same way but on separate lines, prefixed by the text (inlined by). cute!
if the file name or function name can't be determined, addr2line prints two question marks in their place. mysterious. cryptic. ??. and if the line number can't be determined, it prints 0.
when you're using symbol+offset, the +offset part is optional β except when the symbol is ambiguous with a hex number. also: the resolved symbols can be mangled or unmangled, but heads up, unmangled symbols with + are not allowed. π
β¨ OPTIONS β¨
the long and short forms of options are shown here as alternatives, and bestie, they are equivalent. pick your fave.
-a,--addressesβ displays the address before the function name, file and line number info. the address gets printed with a0xprefix so you can spot it easily. π-bbfdname,--target=bfdname β specify that the object-code format for the object files is bfdname.-C,--demangle[=style]β decode (demangle) low-level symbol names into user-level names. besides removing any initial underscore prepended by the system, this makes C++ function names readable. different compilers have different mangling styles, and the optional demangling style argument lets you pick the appropriate one for your compiler. it's giving translation services for your compiler's drama π-efilename,--exe=filename β specify the name of the executable for which addresses should be translated. the default file isa.out.-f,--functionsβ display function names as well as file and line number information.-s,--basenamesβ display only the base of each file name.-i,--inlinesβ if the address belongs to a function that was inlined, the source information for all enclosing scopes back to the first non-inlined function will also be printed. for example, ifmaininlinescallee1which inlinescallee2, and the address is fromcallee2, the source information forcallee1andmainwill also be printed. it's the family tree reveal of stack frames π-j,--sectionβ read offsets relative to the specified section instead of absolute addresses.-p,--pretty-printβ make the output more human friendly: each location is printed on one line. if option-iis specified, lines for all enclosing scopes are prefixed with(inlined by).-r,-R,--recurse-limit,--no-recurse-limit,--recursion-limit,--no-recursion-limitβ enables or disables a limit on the amount of recursion performed whilst demangling strings. here's the tea: since the name mangling formats allow for an infinite level of recursion, it is possible to create strings whose decoding will exhaust the amount of stack space available on the host machine, triggering a memory fault. π³ the limit tries to prevent this from happening by restricting recursion to 2048 levels of nesting.
the default is for this limit to be enabled, but disabling it may be necessary in order to demangle truly complicated names. note however that if the recursion limit is disabled then stack exhaustion is possible, and any bug reports about such an event will be rejected. periodt. don't come crying to the maintainers.
the -r option is a synonym for the --no-recurse-limit option. the -R option is a synonym for the --recurse-limit option.
heads up bestie: this option is only effective if the-Cor--demangleoption has been enabled. no demangle, no drama.
@file β read command-line options from file. the options read are inserted in place of the original@file option. if file does not exist, or cannot be read, then the option will be treated literally, and not removed. (so it just sits there, awkwardly. we've all been there. π)
options in file are separated by whitespace. a whitespace character may be included in an option by surrounding the entire option in either single or double quotes. any character (including a backslash) may be included by prefixing the character to be included with a backslash. the file may itself contain additional @file options; any such options will be processed recursively. it's giving inception π
π₯ SEE ALSO π₯
info entries for binutils.
π COPYRIGHT π
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, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".
and that's the whole vibe, bestie β this page came to you straight from binutils-2.45.50, dated 2025-12-09. go forth and demangle your stack traces, you absolute main character. π β¨π¦π
π¦ where this page comes from
- ubuntu resolute: binutils-xtensa-lx106 2.45.50.20251209-1ubuntu1+6build1
- ubuntu stonking: binutils-xtensa-lx106 2.45.50.20251209-1ubuntu1+6build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms