[PATCH v2] [PR gdb/27614] gdb-add-index fails on symlinks.

Lancelot SIX lsix@lancelotsix.com
Fri Mar 26 19:44:28 GMT 2021


Le Fri, Mar 26, 2021 at 02:53:12PM -0400, Simon Marchi a écrit :
> BSDs' readlink doesn't have the -e option, so it would probably derail
> from here (should we also check the exit status of readlink to make sure
> it worked?  did you try with a symlink pointing to a non-existent file /
> with a non-existent component?).
> 
> Would it work with just `readlink <file>`?

This would fail if $file is a symlink to a symlink.  This is what
ldconfig usually does (libfoo.so -> libfoo.so.x -> libfoo.so.x.y).

I guess the most robust approach will be something like:

${GDB} --batch -nx -iex 'set auto-load no' \
       -iex "file '$file'" -iex 'maint info bfds' | \
    awk -F/ '{ fname=$NF } END { print fname }'

This rely on how 'maint info bfds' formats its output and I am not
sure how stable shit will be in time, but hopefully the new test case
will catch any breackage.

This will require few more tweaks along the way but nothing too fanncy.
I’ll do that unless there is a simpler and as portable approach
available.

Lancelot.

> 
> Simon
> 


More information about the Gdb-patches mailing list