简体   繁体   English

如何检查正在运行的进程以查看它正在使用的共享库?

[英]How can I check a running process to see what shared libraries it is using?

On Linux, I have a C++ application that is using dlopen() to load some shared libraries, but I'm suspicious that the version of the shared library being loaded is not the one I expect because my debugging trace code does not appear to be executed. 在Linux上,我有一个使用dlopen()来加载一些共享库的C ++应用程序,但是我怀疑正在加载的共享库的版本不是我期望的版本,因为我的调试跟踪代码似乎不是执行。

Is there a way to check a running process to query all the shared libraries it currently has open and the path to each of those libraries? 有没有办法检查正在运行的进程来查询它当前打开的所有共享库以及每个库的路径? In other words, something akin to ldd but that works on a running executable and lists runtime loaded libraries as well. 换句话说,类似于ldd但它适用于正在运行的可执行文件,并列出了运行时加载的库。

If you want to know the library files a program have opened, you can try pmap. 如果您想知道程序已打开的库文件,可以尝试pmap。 For example, if we want to know the libraries that bash process 3860 have opened, the result could be: 例如,如果我们想知道bash进程3860打开的库,结果可能是:

3860:   bash
08048000    880K r-x--  /bin/bash
08124000      4K r----  /bin/bash
08125000     20K rw---  /bin/bash
0812a000     20K rw---    [ anon ]
099ae000    348K rw---    [ anon ]
b715c000     44K r-x--  /lib/i386-linux-gnu/libnss_files-2.15.so
b7167000      4K r----  /lib/i386-linux-gnu/libnss_files-2.15.so
b7168000      4K rw---  /lib/i386-linux-gnu/libnss_files-2.15.so
b7169000     88K r-x--  /lib/i386-linux-gnu/libnsl-2.15.so
b717f000      4K r----  /lib/i386-linux-gnu/libnsl-2.15.so
b7180000      4K rw---  /lib/i386-linux-gnu/libnsl-2.15.so
b7181000      8K rw---    [ anon ]
b7183000     28K r-x--  /lib/i386-linux-gnu/libnss_compat-2.15.so
b718a000      4K r----  /lib/i386-linux-gnu/libnss_compat-2.15.so
b718b000      4K rw---  /lib/i386-linux-gnu/libnss_compat-2.15.so
b71a1000      4K r----  /usr/lib/locale/locale-archive
b71a2000   1428K r----  /usr/lib/locale/locale-archive
b7307000   2048K r----  /usr/lib/locale/locale-archive
b7507000      4K rw---    [ anon ]
b7508000   1676K r-x--  /lib/i386-linux-gnu/libc-2.15.so
b76ab000      8K r----  /lib/i386-linux-gnu/libc-2.15.so
b76ad000      4K rw---  /lib/i386-linux-gnu/libc-2.15.so
b76ae000     16K rw---    [ anon ]
b76b2000     12K r-x--  /lib/i386-linux-gnu/libdl-2.15.so
b76b5000      4K r----  /lib/i386-linux-gnu/libdl-2.15.so
b76b6000      4K rw---  /lib/i386-linux-gnu/libdl-2.15.so
b76b7000    112K r-x--  /lib/i386-linux-gnu/libtinfo.so.5.9
b76d3000      8K r----  /lib/i386-linux-gnu/libtinfo.so.5.9
b76d5000      4K rw---  /lib/i386-linux-gnu/libtinfo.so.5.9
b76d8000     28K r--s-  /usr/lib/i386-linux-gnu/gconv/gconv-modules.cache
b76df000     40K r-x--  /lib/i386-linux-gnu/libnss_nis-2.15.so
b76e9000      4K r----  /lib/i386-linux-gnu/libnss_nis-2.15.so
b76ea000      4K rw---  /lib/i386-linux-gnu/libnss_nis-2.15.so
b76eb000      8K rw---    [ anon ]
b76ed000      4K r-x--    [ anon ]
b76ee000    128K r-x--  /lib/i386-linux-gnu/ld-2.15.so
b770e000      4K r----  /lib/i386-linux-gnu/ld-2.15.so
b770f000      4K rw---  /lib/i386-linux-gnu/ld-2.15.so
bfbbf000    132K rw---    [ stack ]
 total     7152K

Wish it would be of help for you. 希望它对你有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM