This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: eu-addr2line only searches by build-id?


> $ gcc tst.c -o tst

Since this has no .gnu_debuglink, the default is to append .debug to its
basename and look for that in the debuginfo-path.  The first place to look
is the containing directory (leading : in ":.debug:/usr/lib/debug").
Hence:

> Now I get:
> open("tst", O_RDONLY)                   = 3
> open("/usr/lib/debug/.build-id/db/983b5986bc45464df0546768402dcad201e5b9.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
> open("tst.debug", O_RDONLY)             = -1 ENOENT (No such file or directory)

the first by-name try here is "tst.debug" in the place where "tst" was found.
(If you specify it as -e $PWD/tst or -e ./././tst or whatnot, you'll see
that the containing directory is what it's trying.)

> $ cp tst tst1
> $ objcopy --add-gnu-debuglink=tst1 tst1

Since this does have a .gnu_debuglink, the name to look for is taken from that.
You've made that name the same as the original name.  Hence:

> Now I get:
> open("tst1", O_RDONLY)                  = 3
> open("/usr/lib/debug/.build-id/db/983b5986bc45464df0546768402dcad201e5b9.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
> open("tst1", O_RDONLY)                  = 3

Again, it tried the file name in the containing directory (i.e. cwd here).
But this time it found it, so it stopped looking further.

> While I was expecting something like:
> tst1
> /usr/lib/debug/.build-id/db/983b5986bc45464df0546768402dcad201e5b9.debug
> .debug/tst1

That list skips the first element of the debuginfo-path, which is the empty
element implied by the leading :, meaning the directory containing the
original file in question.  

> $ cp tst tst2
> $ cp tst tst2.debug
> $ objcopy --add-gnu-debuglink=tst2.debug tst2
> 
> Now I get:
> open("tst2", O_RDONLY)                  = 3
> open("/usr/lib/debug/.build-id/db/983b5986bc45464df0546768402dcad201e5b9.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
> open("tst2.debug", O_RDONLY)            = 3

The same rule is being applied here, but since the debuglink name is
"tst2.debug", that's the one being tried for the first debuginfo-path
element.

I wasn't aware that anyone ever set the debuglink name to the original name
without .debug appended.  Obviously, that leads to finding the main file
again.  It only ever uses the first existing file in the debuginfo-path.
Perhaps you were expecting that it would open each such file and then
ignore it when it has no DWARF in it.  But that's never how it's been.
I'm not inclined to change that.

I suppose we could make it explicitly check for the debuglink-derived name
matching the original name and skip it when they match.  But IMHO it really
seems like you are getting what you asked for now.


Thanks,
Roland

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]