1. strace是一款非常强大的调试用户程序的工具,如在嵌入式平台使用,则需要对其进行交叉编译;
2. 以ARM及PPC平台为例,编译strace-4.5.18;
- ARM平台(arm-linux-gcc)
- CC=arm-linux-gcc LD=arm-linux-ld RANLIB=arm-linux-ranlib ./configure --host=arm-linux --target=arm-linux
- PPC平台(ppc-linux-)
- CC=ppc_82xx-gcc LD=ppc_82xx-ld RANLIB=ppc_82xx-ranlib ./configure --host=powerpc-linux --target=powerpc-linux
- DaVinCi平台(arm_v5t_le-gcc)
- CC=arm_v5t_le-gcc LD=arm_v5t_le-ld RANLIB=arm_v5t_le-ranlib ./configure --host=arm-linux --target=arm-linux
3. 编译
make && make check
4. 如果希望安装到指定目录,则在配置时指定 --prefix=/yourdir,编译之后执行make install即可。
=================================================================================================================
strace工具是一个非常强大的工具,是调试程序的好工具。要移植到arm平台,就需要使用交叉编译工具编译生成静态链接的可执行文件。具体步骤如下:
1.下载 strace-4.5.16.tar.bz2,不要下载最新的strace-4.5.18.tar.bz2,因为后者编译会出错。下载网址是:http:///project/showfiles.php?group_id=2861&package_id=2819;
2.解压。对于ARM平台,必须打上一个补丁,补丁在文章的最后面;
3.配置。./configure --host=arm-linux CC=arm_v5t_le-gcc LD=arm_v5t_le-ld;
4.编译。make CFLAGS+="-static",生成strace静态可执行文件,2M多;
5.strip。arm_v5t_le-stip strace,这样可执行文件就减小到600多K。
以上采用的是达芬奇平台的arm工具,也可以直接使用通用的arm-linux-gcc工具,版本3.4.1的我试过,可以编译通过,其他版本的不清楚。
strace的使用介绍可以参考以下两篇文章:
1.http://www.ibm.com/developerworks/cn/aix/library/au-unix-strace.html。
2.http://blog./u1/38279/showart_367248.html
--- strace-4.5.16-orig/syscall.c 2005-06-08 21:45:28.000000000 +0100
+++ strace-4.5.16/syscall.c 2005-10-25 19:26:39.000000000 +0100
@@ -1045,6 +1045,15 @@ struct tcb *tcp;
/*
* Note: we only deal with only 32-bit CPUs here.
*/
+
+ if (!(tcp->flags & TCB_INSYSCALL) &&
+ (tcp->flags & TCB_WAITEXECVE)) {
+ /* caught a fake syscall from the execve's exit */
+ tcp->flags &= ~TCB_WAITEXECVE;
+ return 0;
+ }
+
+
if (regs.ARM_cpsr & 0x20) {
/*
* Get the Thumb-mode system call number
|
|