solib-absolute-prefix 和solib-search-path是 gdb比较常用的选项,用来设置符号文件的位置。
那么,它们有什么区别呢?
solib-absolute-prefix设置的是被搜索文件路径的前缀,solib-search-path设置的是被搜索文件的路径。
solib-search-path可以有多个路径,中间按用:隔开, solib-absolute-prefix的值只能有一个。
假设库的绝对路径如下:
/images/rootfs_tmp/opt/ah/lib/libah_event.so
在GDB下显示的名称如下:
(gdb) info sharedlib
No /opt/ah/lib/libah_event.so
那么GDB要索引它,可以通过以下方式:
1.set solib-absolute-prefix /images/rootfs_tmp
2.set solib-search-path /images/rootfs_tmp/opt/ah/lib/
GDB 默认的solib-absolute-prefix : 交叉编译器库路径
默认的solib-search-path:为空
可以通过show solib-absolute-prefix和show solib-search-path来查看对应的设置信息:
-
gwwu@hz-dev2.aerohive.com:~/codes/cfd_896/build_AH-APPLIANCE-1>x86_64-aerohive-linux-gnu-gdb
-
GNU gdb 6.8
-
Copyright (C) 2008 Free Software Foundation, Inc.
-
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
-
This is free software: you are free to change and redistribute it.
-
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
-
and "show warranty" for details.
-
This GDB was configured as "--host=x86_64-build_unknown-linux-gnu --target=x86_64-aerohive-linux-gnu".
-
(gdb) show solib-absolute-prefix
-
The current system root is "/eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot".
-
(gdb) show solib-search-path
-
The search path for loading non-absolute shared library symbol files is .
-
(gdb)
举例说明:
1.修改solib-search-path
-
gwwu@hz-dev2.aerohive.com:~/codes/cfd_896/build_AH-APPLIANCE-1>x86_64-aerohive-linux-gnu-gdb -----------调用GDB
-
GNU gdb 6.8
-
Copyright (C) 2008 Free Software Foundation, Inc.
-
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
-
This is free software: you are free to change and redistribute it.
-
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
-
and "show warranty" for details.
-
This GDB was configured as "--host=x86_64-build_unknown-linux-gnu --target=x86_64-aerohive-linux-gnu".
-
(gdb) info sharedlib ---查看共享lib,此时没有任何lib
-
No shared libraries loaded at this time.
-
(gdb) file ./images/rootfs_tmp/opt/ah/bin/dhcpd ---通过file命令载入可执行命令
-
Reading symbols from /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/bin/dhcpd...done.
-
(gdb) core-file ../dhcpd_pid1082_sig6_time1412177643.core -----通过core-file命令导入core文件
-
warning: exec file is newer than core file.
-
warning: Can't read pathname for load map: Input/output error.
-
Error while mapping shared library sections:
-
/opt/ah/lib/libah_event.so: No such file or directory.
-
Error while mapping shared library sections:
-
/opt/ah/lib/libah_mpi.so: No such file or directory.
-
Error while mapping shared library sections:
-
/opt/ah/lib/libah_sys.so: No such file or directory.
-
Error while mapping shared library sections:
-
/opt/ah/lib/libah.so: No such file or directory.
-
Error while mapping shared library sections:
-
/opt/ah/lib/libah_tpa.so: No such file or directory.
-
Error while mapping shared library sections:
-
/opt/ah/lib/libah_dhcp.so: No such file or directory.
-
Error while mapping shared library sections:
-
/opt/ah/lib/libah_dhcp_db.so: No such file or directory.
-
Error while mapping shared library sections:
-
/opt/ah/lib/libah_top.so: No such file or directory.
-
Error while mapping shared library sections:
-
/opt/ah/lib/libgdbm.so.3: No such file or directory.
-
Error while mapping shared library sections:
-
/opt/ah/lib/libah_db.so: No such file or directory.
-
Error while mapping shared library sections:
-
/opt/ah/lib/libah_dcd.so: No such file or directory.
-
Error while mapping shared library sections:
-
/opt/ah/lib/libah_cli.so: No such file or directory.
-
Symbol file not found for /opt/ah/lib/libah_event.so
-
Symbol file not found for /opt/ah/lib/libah_mpi.so
-
Symbol file not found for /opt/ah/lib/libah_sys.so
-
Symbol file not found for /opt/ah/lib/libah.so
-
Reading symbols from /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libpthread.so.0...done.
-
Loaded symbols for /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libpthread.so.0
-
Symbol file not found for /opt/ah/lib/libah_tpa.so
-
Symbol file not found for /opt/ah/lib/libah_dhcp.so
-
Symbol file not found for /opt/ah/lib/libah_dhcp_db.so
-
Symbol file not found for /opt/ah/lib/libah_top.so
-
Symbol file not found for /opt/ah/lib/libgdbm.so.3
-
Symbol file not found for /opt/ah/lib/libah_db.so
-
Symbol file not found for /opt/ah/lib/libah_dcd.so
-
Symbol file not found for /opt/ah/lib/libah_cli.so
-
Reading symbols from /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libc.so.6...done.
-
Loaded symbols for /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libc.so.6
-
Reading symbols from /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/ld-linux-x86-64.so.2...done.
-
Loaded symbols for /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib64/ld-linux-x86-64.so.2
-
Core was generated by `/opt/ah/bin/dhcpd'.
-
Program terminated with signal 6, Aborted.
-
[New process 1082]
-
[New process 1155]
-
[New process 1158]
-
[New process 1157]
-
[New process 1156]
-
#0 0x00007ffa01b7a062 in select () from /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libc.so.6
-
(gdb) bt ---------使用bt查看堆栈信息,发现很多??,这个表明符号表没有正确导入
-
#0 0x00007ffa01b7a062 in select () from /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libc.so.6
-
#1 0x00007ffa030d6226 in ?? ()
-
#2 0x000000000060c280 in ?? ()
-
#3 0x00007fff31dce5a0 in ?? ()
-
#4 0x000000000060c230 in ?? ()
-
#5 0x05088c0a04088c0a in ?? ()
-
#6 0x0000100000000010 in ?? ()
-
#7 0x00000000542c1eeb in ?? ()
-
#8 0x00000000000062d5 in ?? ()
-
#9 0x00000000000ba44f in ?? ()
-
#10 0x0000000000080000 in ?? ()
-
#11 0x0000000000000000 in ?? ()
-
(gdb) info sharedlib -------使用info sharedlib查看共享库的导入情况,发现很多共享库都不存在。
-
From To Syms Read Shared Object Library
-
No /opt/ah/lib/libah_event.so
-
No /opt/ah/lib/libah_mpi.so
-
No /opt/ah/lib/libah_sys.so
-
No /opt/ah/lib/libah.so
-
0x00007ffa02eb2270 0x00007ffa02ebcb08 Yes /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libpthread.so.0
-
No /opt/ah/lib/libah_tpa.so
-
No /opt/ah/lib/libah_dhcp.so
-
No /opt/ah/lib/libah_dhcp_db.so
-
No /opt/ah/lib/libah_top.so
-
No /opt/ah/lib/libgdbm.so.3
-
No /opt/ah/lib/libah_db.so
-
No /opt/ah/lib/libah_dcd.so
-
No /opt/ah/lib/libah_cli.so
-
0x00007ffa01ad61b0 0x00007ffa01bb4c6c Yes /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libc.so.6
-
0x00007ffa03904ac0 0x00007ffa0391a8a4 Yes /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib64/ld-linux-x86-64.so.2
-
(gdb) set solib-search-path ./images/rootfs_tmp/opt/ah/lib/ ----------通过设置solib-search-path导入共享库
-
warning: Can't read pathname for load map: Input/output error.
-
Error while mapping shared library sections:
-
/opt/ah/lib/libgdbm.so.3: No such file or directory.
-
Reading symbols from /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_event.so...done.
-
Loaded symbols for /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_event.so
-
Reading symbols from /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_mpi.so...done.
-
Loaded symbols for /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_mpi.so
-
Reading symbols from /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_sys.so...done.
-
Loaded symbols for /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_sys.so
-
Reading symbols from /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah.so...done.
-
Loaded symbols for /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah.so
-
Reading symbols from /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libpthread.so.0...done.
-
Loaded symbols for /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libpthread.so.0
-
Reading symbols from /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_tpa.so...done.
-
Loaded symbols for /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_tpa.so
-
Reading symbols from /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_dhcp.so...done.
-
Loaded symbols for /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_dhcp.so
-
Reading symbols from /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_dhcp_db.so...done.
-
Loaded symbols for /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_dhcp_db.so
-
Reading symbols from /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_top.so...done.
-
Loaded symbols for /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_top.so
-
Symbol file not found for /opt/ah/lib/libgdbm.so.3
-
Reading symbols from /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_db.so...done.
-
Loaded symbols for /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_db.so
-
Reading symbols from /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_dcd.so...done.
-
Loaded symbols for /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_dcd.so
-
Reading symbols from /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_cli.so...done.
-
Loaded symbols for /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_cli.so
-
Reading symbols from /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libc.so.6...done.
-
Loaded symbols for /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libc.so.6
-
Reading symbols from /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/ld-linux-x86-64.so.2...done.
-
Loaded symbols for /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib64/ld-linux-x86-64.so.2
-
(gdb) info sharedlib -----------再次查看共享库信息,此时基本上的共享库都已经存在了
-
warning: Can't read pathname for load map: Input/output error.
-
From To Syms Read Shared Object Library
-
0x00007ffa036f2e70 0x00007ffa036fe674 Yes /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_event.so
-
0x00007ffa034e7180 0x00007ffa034ee7fc Yes /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_mpi.so
-
0x00007ffa032dfa20 0x00007ffa032e39e8 Yes /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_sys.so
-
0x00007ffa030cc020 0x00007ffa030d8228 Yes /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah.so
-
0x00007ffa02eb2270 0x00007ffa02ebcb08 Yes /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libpthread.so.0
-
0x00007ffa02c90fe0 0x00007ffa02ca4fd0 Yes /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_tpa.so
-
0x00007ffa02a80d90 0x00007ffa02a867f4 Yes /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_dhcp.so
-
0x00007ffa0287b040 0x00007ffa0287bff0 Yes /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_dhcp_db.so
-
0x00007ffa02677058 0x00007ffa026785c4 Yes /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_top.so
-
No /opt/ah/lib/libgdbm.so.3
-
0x00007ffa0226bd28 0x00007ffa0226c788 Yes /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_db.so
-
0x00007ffa0201b2f8 0x00007ffa02058b9c Yes /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_dcd.so
-
0x00007ffa01e048a0 0x00007ffa01e0ab68 Yes /home/gwwu/codes/cfd_896/build_AH-APPLIANCE-1/images/rootfs_tmp/opt/ah/lib/libah_cli.so
-
0x00007ffa01ad61b0 0x00007ffa01bb4c6c Yes /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libc.so.6
-
0x00007ffa03904ac0 0x00007ffa0391a8a4 Yes /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib64/ld-linux-x86-64.so.2
-
(gdb) bt ------再次调用bt获取堆栈信息
-
#0 0x00007ffa01b7a062 in select () from /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libc.so.6
-
#1 0x00007ffa030d6226 in ah_arpping (yiaddr=0, ip=1412177643, smac=0x100000000010 <Address 0x100000000010 out of bounds>,
-
dmac=0x5088c0a04088c0a <Address 0x5088c0a04088c0a out of bounds>, interface=0x60c230 "郳034A鏒?) at ah_arpping.c:119
-
#2 0x0000000000406bcb in check_ip (addr=84446218) at leases.c:255
-
#3 0x0000000000406d7e in find_address (check_expired=0) at leases.c:307
-
#4 0x0000000000407882 in sendOffer (oldpacket=0x7fff31dcebd0) at serverpacket.c:211
-
#5 0x00000000004056cd in deal_packet (fd=6) at dhcpd.c:313
-
#6 0x0000000000406245 in main (argc=1, argv=0x7fff31dcf2b8) at dhcpd.c:614
-
(gdb) info threads -----查看线程数
-
5 process 1156 0x00007ffa01b7a062 in select ()
-
from /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libc.so.6
-
4 process 1157 0x00007ffa01b7a062 in select ()
-
from /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libc.so.6
-
3 process 1158 0x00007ffa02eb9d8c in __lll_lock_wait ()
-
from /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libpthread.so.0
-
2 process 1155 0x00007ffa01b7a062 in select ()
-
from /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libc.so.6
-
* 1 process 1082 0x00007ffa01b7a062 in select ()
-
from /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libc.so.6
-
(gdb) thread 3 -----切换到线程3
-
[Switching to thread 3 (process 1158)]#0 0x00007ffa02eb9d8c in __lll_lock_wait ()
-
from /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libpthread.so.0
-
(gdb) bt -----查看线程3的堆栈信息
-
#0 0x00007ffa02eb9d8c in __lll_lock_wait ()
-
from /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libpthread.so.0
-
#1 0x00007ffa02eb58dd in _L_lock_52 () from /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libpthread.so.0
-
#2 0x00007ffa02eb520c in pthread_mutex_lock ()
-
from /eng/crosstool/x86_64-aerohive-linux-gnu/x86_64-aerohive-linux-gnu/sysroot/lib/libpthread.so.0
-
#3 0x0000000000404009 in ah_dhcps_proc_event (event_id=AH_EVENT_DHCPS_CFG_CHG, size=2400, data=0x62ec68) at ah_dhcps_event.c:661
-
#4 0x00007ffa036fdc9c in ah_event_process_msg (buf=0x62ec60 "\226
1.修改solib-absolute-prefix
当然也可以通过修改solib-absolute-prefix来解决,但是由于原来的lib可能会对absolute-prefix有依赖,所以修改solib-absolute-prefix时候还是要慎重。
阅读(3972) | 评论(0) | 转发(0) |