addr2line command search path for debug symbols
Asked Answered
D

0

7

I cannot make addr2line to work. It does look for symbols at three (unexisting) paths:

/usr/bin/*.debug
/usr/bin/.debug/*.debug
/usr/lib/debug/usr/bin/*.debug

But it just seems to ignore the path where all debugging symbols are actually installed by default:

/usr/lib/debug/.build-id/

I run *addr2line** like this:

addr2line -f -C -e <PathToExecFile> <Addr>

Am I missing some configuration switch, system option, or anything similar?


That was the question statement, now some proofs for what I'm saying. Here, I'll be using the program screen as an example:

$ sudo apt-get install screen screen-dbg
$ file /usr/bin/screen
> /usr/bin/screen: setgid ELF 64-bit LSB executable, x86-64, version 1 (SYSV),
  dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32,
  BuildID[sha1]=e9d3cd5073daa6b7365b3787673143edeec589d3, stripped
$ dpkg -L screen-dbg
> /usr/lib/debug/.build-id/e9/d3cd5073daa6b7365b3787673143edeec589d3.debug

Here we empirically found out where the debug symbols for screen are:

/usr/lib/debug/.build-id/e9/d3cd5073daa6b7365b3787673143edeec589d3.debug

Now we run strace addr2line to see where it tries to access...

# Get any valid object address
$ objdump -T /usr/bin/screen
> 00000000006697e0

# Use the object address in addr2line
$ strace -f addr2line -f -C \
    -e /usr/bin/screen 0x00000000006697e0 2>&1 | grep debug
> open("/usr/bin/d3cd5073daa6b7365b3787673143edeec589d3.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
  open("/usr/bin/.debug/d3cd5073daa6b7365b3787673143edeec589d3.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
  open("/usr/lib/debug/usr/bin/d3cd5073daa6b7365b3787673143edeec589d3.debug", O_RDONLY) = -1 ENOENT (No such file or directory)

Here we see the 3 paths I mentioned earlier, but no signs of the desired one.

Dutiable answered 26/3, 2018 at 20:0 Comment(2)
Added bug report in Ubuntu: bugs.launchpad.net/ubuntu/+source/binutils/+bug/1759248Dutiable
Old question and not quite an answer, but in case anyone gets stuck like I did, you can just directly pass the .debug file as the parameter to -e e.g. addr2line -e /usr/bin/.debug/xxx.debug 0x1d234, it worked in my case at least.Victoriavictorian

© 2022 - 2024 — McMap. All rights reserved.