现在的位置: 首页 > 综合 > 正文

strace工具移植到ARM(davinci)平台

2013年10月09日 ⁄ 综合 ⁄ 共 1204字 ⁄ 字号 评论关闭

strace工具是一个非常强大的工具,是调试程序的好工具。要移植到arm平台,就需要使用交叉编译工具编译生成静态链接的可执行文件。具体步骤如下:

1.下载 strace-4.5.16.tar.bz2,不要下载最新的strace-4.5.18.tar.bz2,因为后者编译会出错。下载网址是:http://sourceforge.net/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.chinaunix.net/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    

 

转载请注明原文出处:http://zhiqiang0071.cublog.cn

抱歉!评论已关闭.