omap移植systemtap

参考网站:

http://omappedia.org/wiki/Systemtap

http://blog.csdn.net/lzuzhp06/article/details/7778189

http://blog.csdn.net/sunnybeike/article/details/7794183

http://pastebin.com/Fka5h427

http://fosiao.com/node/19#comment-13

步骤一:编译host端和omap端的systemtap
host端的systemtap通过交叉编译将stp脚本生成ko文件,而omap端的systemtap将来要拷贝到pandaboard中,用来执行上面这个ko脚本。
你需要下载的东西:
1.  systemtap 1.5
2.  elfutils0.143
3.  arm-linux-4.4.3(搭建arm linux的交叉编译环境)
我开始的时候用gcc4.6,但是有错,用gcc4.5就不会出现相同的错误了。
编译:
(1)生成host端的systemtap

[html]  view plain copy
  1. ./configure --exec-prefix=/home/sun/zhp/systemtap/hostSystemtap --prefix=/home/sun/zhp/systemtap/hostSystemtap --with-elfutils=/home/sun/zhp/systemtap/elfutils-0.143  
  2. make install  



(20)生成arm target端的systemtap
[html]  view plain copy
  1. ac_cv_file__usr_include_avahi_common=no ac_cv_file__usr_include_avahi_client=no ac_cv_file__usr_include_nspr=no ac_cv_file__usr_include_nspr4=no ac_cv_file__usr_include_nss=no ac_cv_file__usr_include_nss3=no ac_cv_func_malloc_0_nonnull=yes ./configure --exec-prefix=/home/sun/zhp/systemtap/omapSystemtap --prefix=/home/sun/zhp/systemtap/omapSystemtap --host=arm-none-linux-gnueabi CXXFLAGS=-static CFLAGS=-static --with-elfutils=/home/sun/zhp/systemtap/elfutils-0.143 --disable-translator --disable-docs --disable-refdocs --disable-grapher --without-rpm  
  2.   
  3.   
  4. make install  



步骤二:重新编译android内核,并代替原来的内核
主要是包含进去调试信息。
(1)下载内核
[html]  view plain copy
  1. #in case you need kernel source(normally you don't need this)  
  2. $git clone https://android.googlesource.com/kernel/omap.git  
  3. $cd omap  
  4. $git checkout origin/android-omap-panda-3.0  





(2)编译内核

[html]  view plain copy
  1. #修改Makefile文件  
  2. ARCH        ?= arm    #将体系结构指定为ARM    
  3. CROSS_COMPILE   ?= /home/sun/zhp/android/WORKING_DIRECTORY/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-    

#这个交叉编译工具应该是和你编译android用的编译器一样的,这个编译器包含在你下载的android原码中
(3)生成配置文件

[html]  view plain copy
  1. $make panda_defconfig    
  2. $make menuconfig   

修改menuconfig:
[html]  view plain copy
  1. CONFIG_KPROBES: General Setup -> Kprobes    
  2. CONFIG_RELAY: General Setup -> user spacerelay support    
  3. CONFIG_PROFILING: General Setup -> Profilingsupport (EXPERIMENTAL) + General Setup -> Oprofile system profiling(EXPERIMENTAL)    

(4)修改kernel/arch/arm/include/asm/ptrace.h文件如下:
[html]  view plain copy
  1. #defineinterrupts_enabled(regs) \    
  2.     (!((regs)->ARM_cpsr & PSR_I_BIT))    
  3. #definefast_interrupts_enabled(regs) \    
  4.     (!((regs)->ARM_cpsr & PSR_F_BIT))    
  5.     
  6. ++  #define condition_codes(regs) \    
  7. ++          ((regs)->ARM_cpsr &(PSR_V_BIT|PSR_C_BIT|PSR_Z_BIT|PSR_N_BIT))    


(5)编译
$make


(6)用新生成的arch/arm/boot/zImage替换原来android中的device/ti/panda/kernel
(7)重新编译android原码
步骤三:将新生成的android可执行文件拷贝到pandaboard中:
[html]  view plain copy
  1. #do not insert SD card, reboot the board  
  2. $sudo device/ti/panda/usbboot device/ti/panda/bootloader.bin  
  3. #now insert the SD card  
  4. $sudo out/host/linux-x86/bin/fastboot oem format  
  5. $sudo out/host/linux-x86/bin/fastboot flash xloader device/ti/panda/xloader.bin  
  6. $sudo out/host/linux-x86/bin/fastboot flash bootloader device/ti/panda/bootloader.bin  
  7. #reboot the board to fastboot mode again(hold user button, then toggle power button)  
  8. $sudo out/host/linux-x86/bin/fastboot erase cache  
  9. $sudo out/host/linux-x86/bin/fastboot -p panda flash userdata  
  10. $sudo out/host/linux-x86/bin/fastboot -p panda flashall  
  11. #pandaboard will autoreboot  
  12. $adb shell date $(date +%s)  
  13. $adb shell dhcpcd eth0  
  14. #now have fun :)  

步骤四:向pandaboard中拷贝systemtap的omap端的文件
(1)
[html]  view plain copy
  1. $adp push /home/sun/zhp/systemtap/omapSystemtap /data/omapSystemtap  

(2)设置执行环境
[html]  view plain copy
  1. $adb shell  #进入到android的文件系统中  
  2. $mount  -o remount,rw rootfs / #重新挂在文件系统,使其为可读写的  
  3. $mkdir -p /home/sun/zhp/systemtap #注意这个文件夹的路径要和你在主机上保存omapSystemtap的路径相同  
  4. $ln -s /data/omapSystemtap /home/sun/zhp/systemtap/omapSystemtap   

最后一步可能出现link failed File exists的错误,解决方法:
退出到主机环境,然后:
[html]  view plain copy
  1. $ adb shell sync  
  2. $ adb reboot  
  3. $ adb wait-for-device shell  

如果还是不行,则考虑重新烧写pandaboard,然后重新执行上面的命令。
这里有个问题,为什么要建立上面的软链接?
我猜想,在主机上编译systemtap的时候,肯能将systemtap的绝对路径写到了某个可执行文件中,然而这个路径在pandaboard中的android中是没有的,因此
可以通过建立软链接的方式,解决这个问题,否则会出现找不到某个文件的错误。
步骤五:在主机上交叉编译生成ko文件
[html]  view plain copy
  1. $./home/sun/zhp/systemtap/hostSystemtap/stap -gv -a arm -BCROSS_COMPILE=arm-none-linux-gnueabi- -r /home/sun/zhp/android/omap -m syscall_all.ko syscall_all.stp  

其中/home/sun/zhp/systemtap/hostSystemtap/stap是你在第一步编译生成的host端的stap,/home/sun/zhp/android/omap是你下载的,编译过后用来替换android的kernel的内核原码,syscall_all.stp是你自己写的测试脚本,如下:

[html]  view plain copy
  1. probe kernel.function("sys_*") {  
  2.     printf("%s(%d) %s\n",execname(),pid(),probefunc());  
  3. }  



最终生成syscall_all.ko文件。
步骤六:在panaboard中执行syscall_all.ko文件
(1)将ko文件拷贝到panaboard中:

[html]  view plain copy
  1. $adb push /home/sun/zhp/systemtap/hostSystemtap/bin/syscall_all.ko /data/local  



(2)执行
[html]  view plain copy
  1. #cd /data/omapSystemtap/bin/  
  2. #./staprun /data/local/syscall_all.ko  



JUST ENJOY IT!
完工!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值