linux下的进程堆栈查看工具pstack

本文发布时间: 2019-Mar-22
pstack在linux上是一个非常有用的工具,可以查看进程内部调用函数的信息。可惜的是在ubuntu10.10版本中没有找到这个工具。无奈,只能下载尝试编译了。首先安装编译环境,使用如下命令:apt-get install build-essential #编译所需环境apt-get install dpkg-dev #dpkg编译所需环境apt-get build-dep pstack #解决源码编译的依赖问题接着下载pstack的源码,可见是蛮老的了。apt-get source pstack #生成如下信息=======================下载 16.5kB,耗时 0秒 (189kB/s)gpgv: 于 2004年10月09日 星期六 02时00分15秒 CST 创建的签名,使用 DSA,钥匙号 AB474598gpgv: 无法检查签名:找不到公钥dpkg-source: 警告: 对 ./pstack_1.2-1.dsc 校验签名失败dpkg-source: info: extracting pstack in pstack-1.2dpkg-source: info: unpacking pstack_1.2.orig.tar.gzdpkg-source: info: applying pstack_1.2-1.diff.gzdpkg-source: info: upstream files that have been modified: pstack-1.2/pstack.c编译安装报错:makepstack.c:544: error: ‘EIP’ undeclared (first use in this function)pstack.c:544: error: (Each undeclared identifier is reported only oncepstack.c:544: error: for each function it appears in.)pstack.c:546: error: ‘EBP’ undeclared (first use in this function)网上有不少解决这个办法的文章,但是我发现没有用。于是乎,自己找到了 EIP 和 EBP 的宏定义,直接将数值写了进去。再次编译,通过。接着安装,同样的报错:root@test:/home/leon/project/pstack/pstack-1.2# make installmkdir -p mkdir: 缺少操作数请尝试执行"mkdir --help"来获取更多信息。make: *** [install] 错误 1打开Makefile一看,BINDIR 和 MANDIR 根本就没有定义。这是有多不靠谱啊。。。。自己定义一下:BINDIR = /usr/binMANDIR = /usr/share/man再次安装,通过。使用man pstack也可以看到信息。但是悲催的又来了,当我调试一个进程的时候,发现报错信息:only 32 bit objects supported.打开源代码一看,人家明白的写着只支持32位系统。 27 /* RESTRICTIONS: 28 29 pstack currently works only on Linux, only on an x86 machine running 30 32 bit ELF binaries (64 bit not supported). Also, for symbolic 31 information, you need to use a GNU compiler to generate your 32 program, and you can't strip symbols from the binaries. For thread 33 information to be dumped, you have to use the debug-aware version 34 of libpthread.so. (To check, run 'nm' on your libpthread.so, and 35 make sure that the symbol "__pthread_threads_debug" is defined.) 36 */算了,我不折腾了。各位看官若有pstack的最新代码,烦请通知博主一声。谢过!


(以上内容不代表本站观点。)
---------------------------------
本网站以及域名有仲裁协议。
本網站以及域名有仲裁協議。

2024-Mar-04 02:11pm
栏目列表