addr2line: Usage, Options & Common CI Errors
addr2line turns a hex address in a binary into a source file and line number.
addr2line is how you decode a bare-address crash backtrace from CI into real file:line locations. It needs the unstripped binary (or its .debug file) built with -g, which is why release symbolication depends on the split-debug workflow.
What it does
addr2line translates program addresses into source file names and line numbers using the DWARF debug information in a binary. Given a crash address from a backtrace, it tells you which line of which file that address corresponds to.
Common usage
addr2line -e app 0x401136
addr2line -f -C -e app 0x401136 # also print the function
addr2line -e app.debug 0x401136 # use the split debug file
addr2line -p -f -e app 0x401136 0x4011a0 # multiple addresses
nm app | grep main # find an address to testOptions
| Flag | What it does |
|---|---|
| -e <file> | The executable/object to look up in |
| -f | Also show the function name |
| -C | Demangle C++ names |
| -p | Pretty, one line per address |
| -i | Show inlined frames too |
Common errors in CI
addr2line printing "??:0" or "??:?" means there is no debug info for that address - the binary was stripped or built without -g; point -e at the .debug file instead. The addresses must match the same binary that crashed; an address from a PIE/ASLR run is a runtime address, so subtract the load base first (or use addresses relative to the binary). Cross-arch binaries need the target-prefixed addr2line.