Oprofile在Android中的应用(一)

2014-11-24 09:19:53 · 作者: · 浏览: 0

Oprofile 是用于 Linux 的若干种评测和性能监控工具中的一种。它可以工作在不同的体系结构上,包括 IA32 IA64 AMD Athlon 系列。它的开销小,将被包含在( Linux 2.6 版的内核中。


Oprofile 可以帮助用户识别诸如循环的展开、高速缓存的使用率低、低效的类型转换和冗余操作、错误预测转移等问题。它收集有关处理器事件的信息,其中包括 TLB 的故障、停机、存储器访问、位于 DCU (数据高速缓存单元)中的总线路数、一个 DCU 故障的周期数 以及不可高速缓存的和可高速缓存的指令的获取数量。 Oprofile 是一种细粒度的工具,可以为指令集或者为函数、系统调用或中断处理例程收集采样。 Oprofile 通过取样来工作。使用收集到的评测数据,用户可以很容易地找出性能问题。


Oprofile 工具概述:


op_help: 列出可用的事件,并带有简短的描述


opcontrol: 控制 Oprofile 的数据收集


oprofpp: 检索有用的评测数据


op_time: 为系统上的所有映像列出相关的评测值


op_to_source: 产生带注解的源文件、汇编文件或源文件和汇编文件的混合


op_merge: 合并属于同一个应用程序的采样文件


op_import: 将采样数据库文件从外部格式( abi )转换为本地格式


opreport: 显示分析结果




2 oprofile 的移植




2.1 相关资源


源码包 :


Oprofile-0.9.4.tar.gz


gettext-0.18.1.1.tar.bz2


buildroot-2010.02.tar.bz2


Popt-1.7.tar.gz


Binutils-2.19.51.0.3.tar.bz2


busybox-1.8.1.tar.bz2


编译工具:


arm-2008q3-72-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2





2.2 详细步骤




1. 在交叉编译之前需要做的一些工作 :


1 打开内核的 Oprofile 选项


通过 make menuconfig=>general setup=>


[*] Profiling support (EXPERIMENTAL)


[ ]Activate markers


[*] OProfile system profiling (EXPERIMENTAL)


2 )选择安装交叉编译链


修改 ~/.bashrc 添加 arm-none-linux-gnueabi 的路径。


PATH=$PATH: /home/cuiyan/work/arm-2008q3/bin/


3 )配置编译、链接参数


$:export CC=arm-none-linux-gnueabi-gcc


$:export CXX=arm-none-linux-gnueabi-g++


$:export CFLAGS=-static


$:export CXXFLAGS=-static


$:export CPPFLAGS=-staitc




2 交叉编译 popt


$:cd /home/cuiyan/work/oprofile/popt/


$:tar xfz gettext-0.18.1.1.tar.bz2


$:cd gettext-0.18.1.1


$:./configure –prefix=/usr


$:make


$:make install


$:cd ../




$:tar xfz popt-1.7.tar.gz


$:cd popt-1.7


$:./configure --with-kernel-support --host=arm-none-linux-gnueabi


--prefix=/home/cuiyan/work/oprofile/popt/poptinstall/


$:make


$:make install


$: cp /home/cuiyan/work/oprofile/popt/poptinstall/lib/* /home/cuiyan/work/arm-2008q3/arm-none-linux-gnueabi/lib


$: cp /home/cuiyan/work/oprofile/popt/poptinstall/include/* /home/cuiyan/work/arm-2008q3/arm-none-linux-gnueabi/include




3 静态交叉编译 binutils


$:cd /home/cuiyan/work/oprofile/binutils/


$:sudo apt-get install makeinfo




$:tar jxf binutils-2.19.51.0.3.tar.bz2


$:cd binutils-2.19.51.0.3


$:./configure --with-kernel-support --host= arm-none-linux-gnueabi


--prefix=/home/cuiyan/work/oprofile/binutils/binutils-install/


$:make


$:make install


$:c p /home/cuiyan/work/oprofile/binutils/binutils-install/lib/* /home/cuiyan/work/arm-2008q3/arm-none-linux-gnueabi/lib


$:c p /home/cuiyan/work/oprofile/binutils/binutils-install/include/* /home/cuiyan/work/arm-2008q3/arm-none-linux-gnueabi/include




4 静态交叉编译 oprofile


$:cd /home/cuiyan/work/oprofile/oprofile/


$: tar zxf oprofile-0.9.4.tar.gz


$:cd oprofile-0.9.4


$:/configure --with-linux=/home/cuiyan/mid/gongban/ --with-kernel-support


--host= arm-none-linux-gnueabi


--prefix=/home/cuiyan/work/oprofile/oprofile/oprofile-install


$:make


$:make install


通过 1-4 操作,可在 oprofile-install/bin 目录下查看到一些 oprofile 的工具。


$:bin$ file ophelp


ophelp: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.14, not stripped



5 转换动态链接为静