Make gdb load shared library from specific path

I have a kernel when running the application, and I saved the executable, the main file, and the shared library that the application uses in /tmpto check them later. Then I modified the library, rebuilt it, and ran the executable again. Now when I try to debug the kernel, gdb loads the shared library from the source path, not from the directory /tmpwhere I saved the source library.

For example, the original path was /opt/mydir/lib/libmylib.so.0. gdb is loading this shared library, and I want it to load /tmp/libmylib.so.0. The application also uses some standard libraries that are in directories /usr/liband /libtherefore I do not want these paths to change. Just want to change /opt/mydir/lib//tmp. How can i do this?

+4
source share
1 answer

The simplest solution is to temporarily restore the /opt/mydir/lib/libmylib.so.0copy that was used during the crash (i.e., now in /tmp), analyze the kernel, and then restore the new version.

If you do not want to do this, set solib-search-pathand set sysroot your friends .

, core. :

(gdb) set sysroot /no/such/file
(gdb) set solib-search-path /tmp:/usr/lib:/lib
(gdb) core /tmp/core
+1

Source: https://habr.com/ru/post/1617181/


All Articles