$ pwd /home/gdb (gdb) info sharedlibrary From To Syms Read Shared Object Library 0x00007fba2c572570 0x00007fba2c57267b No ../libadd.so 0x00007fba2c370570 0x00007fba2c37066b No ../../var/libsub.so (gdb) bt #0 0x00007fba2c57266b in ?? () #1 0x00007ffc6f703ff0 in ?? ()
解决方法
设置gdb的solib-search-path选项, 指定加载失败的so的搜索路径即可。
solib-search-path可以指定多个路径。在linux上,路径之间用冒号分隔,命令如下:
1 2 3 4 5 6 7 8 9 10 11 12
(gdb) set solib-search-path /var:/home Reading symbols from ../libadd.so...done. Loaded symbols for ../libadd.so Reading symbols from ../../var/libsub.so...done. Loaded symbols for ../../var/libsub.so (gdb) info sharedlibrary From To Syms Read Shared Object Library 0x00007fba2c572570 0x00007fba2c57267b Yes ../libadd.so 0x00007fba2c370570 0x00007fba2c37066b Yes ../../var/libsub.so (gdb) bt #0 0x00007fba2c57266b in add (a=1, b=2) at add.c:5 #1 0x0000000000400600 in ?? ()