gdb searches first for libraries in sysroot
(with an absolute path), and then only if it fails to find them it searches into solib-search-path
(with a relative path).
For that reason, when using gdb server / remote debugging you probably want to use ONLY gdb's sysroot
option. On a Linux system using solib-search-path
will NOT work unless you change the value of sysroot
, because the default value of sysroot is target
, meaning that gdb is loading the so-file found on the filesystem you are debugging. This is also what is indicated in gdb's documentation:
set solib-search-path path
colon-separated list of directories to search for shared libraries.
‘solib-search-path’ is used after ‘sysroot’ fails to locate the
library, or if the path to the library is relative instead of
absolute. If you want to use ‘solib-search-path’ instead of ‘sysroot’,
be sure to set ‘sysroot’ to a nonexistent directory to prevent GDB
from finding your host’s libraries. ‘sysroot’ is preferred; setting it
to a nonexistent directory may interfere with automatic loading of
shared library symbols.
As indicated in this thread, the use-case for solib-search-path
is rather:
solib-search-path is there mostly to help targets like Windows that
don't report to the debugger the full path to the shared library.
GNU/Linux always works with full patchs, such as
"/usr/lib/libjpeg.so.8"