参考网站:
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
./configure --exec-prefix=/home/sun/zhp/systemtap/hostSystemtap --prefix=/home/sun/zhp/systemtap/hostSystemtap --with-elfutils=/home/sun/zhp/systemtap/elfutils-0.143 make install
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 make install
#in case you need kernel source(normally you don't need this) $git clone https://android.googlesource.com/kernel/omap.git $cd omap $git checkout origin/android-omap-panda-3.0
#修改Makefile文件 ARCH ?= arm #将体系结构指定为ARM CROSS_COMPILE ?= /home/sun/zhp/android/WORKING_DIRECTORY/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
#这个交叉编译工具应该是和你编译android用的编译器一样的,这个编译器包含在你下载的android原码中
(3)生成配置文件
$make panda_defconfig $make menuconfig
CONFIG_KPROBES: General Setup -> Kprobes CONFIG_RELAY: General Setup -> user spacerelay support CONFIG_PROFILING: General Setup -> Profilingsupport (EXPERIMENTAL) + General Setup -> Oprofile system profiling(EXPERIMENTAL)
#defineinterrupts_enabled(regs) \ (!((regs)->ARM_cpsr & PSR_I_BIT)) #definefast_interrupts_enabled(regs) \ (!((regs)->ARM_cpsr & PSR_F_BIT)) ++ #define condition_codes(regs) \ ++ ((regs)->ARM_cpsr &(PSR_V_BIT|PSR_C_BIT|PSR_Z_BIT|PSR_N_BIT))
#do not insert SD card, reboot the board $sudo device/ti/panda/usbboot device/ti/panda/bootloader.bin #now insert the SD card $sudo out/host/linux-x86/bin/fastboot oem format $sudo out/host/linux-x86/bin/fastboot flash xloader device/ti/panda/xloader.bin $sudo out/host/linux-x86/bin/fastboot flash bootloader device/ti/panda/bootloader.bin #reboot the board to fastboot mode again(hold user button, then toggle power button) $sudo out/host/linux-x86/bin/fastboot erase cache $sudo out/host/linux-x86/bin/fastboot -p panda flash userdata $sudo out/host/linux-x86/bin/fastboot -p panda flashall #pandaboard will autoreboot $adb shell date $(date +%s) $adb shell dhcpcd eth0 #now have fun :)
$adp push /home/sun/zhp/systemtap/omapSystemtap /data/omapSystemtap
$adb shell #进入到android的文件系统中 $mount -o remount,rw rootfs / #重新挂在文件系统,使其为可读写的 $mkdir -p /home/sun/zhp/systemtap #注意这个文件夹的路径要和你在主机上保存omapSystemtap的路径相同 $ln -s /data/omapSystemtap /home/sun/zhp/systemtap/omapSystemtap
$ adb shell sync $ adb reboot $ adb wait-for-device shell
$./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
probe kernel.function("sys_*") { printf("%s(%d) %s\n",execname(),pid(),probefunc()); }
最终生成syscall_all.ko文件。
步骤六:在panaboard中执行syscall_all.ko文件
(1)将ko文件拷贝到panaboard中:
$adb push /home/sun/zhp/systemtap/hostSystemtap/bin/syscall_all.ko /data/local
#cd /data/omapSystemtap/bin/ #./staprun /data/local/syscall_all.ko