pstack 安装linux_linux下的进程堆栈查看工具pstack

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,钥匙号 AB474598

gpgv: 无法检查签名:找不到公钥

dpkg-source: 警告: 对 ./pstack_1.2-1.dsc 校验签名失败

dpkg-source: info: extracting pstack in pstack-1.2

dpkg-source: info: unpacking pstack_1.2.orig.tar.gz

dpkg-source: info: applying pstack_1.2-1.diff.gz

dpkg-source: info: upstream files that have been modified:

pstack-1.2/pstack.c

编译安装报错:

make

pstack.c:544: error: ‘EIP’ undeclared (first use in this function)

pstack.c:544: error: (Each undeclared identifier is reported only once

pstack.c:544: error: for each function it appears in.)

pstack.c:546: error: ‘EBP’ undeclared (first use in this function)

网上有不少解决这个办法的文章,但是我发现没有用。于是乎,自己找到了 EIP 和 EBP 的宏定义,直接将数值写了进去。再次编译,通过。接着安装,同样的报错:www.it165.net

root@test:/home/leon/project/pstack/pstack-1.2# make install

mkdir -p

mkdir: 缺少操作数

请尝试执行"mkdir --help"来获取更多信息。

make: *** [install] 错误 1

打开Makefile一看,BINDIR 和 MANDIR 根本就没有定义。这是有多不靠谱啊。。。。自己定义一下:

BINDIR = /usr/bin

MANDIR = /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的最新代码,烦请通知博主一声。谢过!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值