【Linux】linux性能分析工具oprofile移植

一、内核编译选项

make menuconfig

[html]  view plain  copy
  1. <span style="font-size:18px">General setup--->  
  2. [*] Profiling support  
  3. <*> OProfile system profiling</span>  


二、popt移植

       下载源码:http://rpm5.org/files/popt/    popt-1.16.tar.gz

 

       解压缩后,在popt-1.16当前目录下,新建build.sh,编辑内容如下:

---------------------------------------分割线----------------------------------------------------

[html]  view plain  copy
  1. <span style="font-size:18px">#!/bin/sh   
  2. ./configure  --host=arm-linux \   
  3.                  --prefix=/home/eastmoon/rootfs \  
  4. --target=arm-linux  
  5.  </span>  

---------------------------------------分割线----------------------------------------------------

设置下build.sh的权限后,

./build.sh 配置好以后,

make下,

再make install就ok了。

然后可以看到在/home/eastmoon/rootfs中就会有相关的.so等库了。


二、binutils移植

下载源码:http://ftp.gnu.org/gnu/binutils/   binutils-2.22.tar.gz

 

解压缩后,在binutils-2.22当前目录下,新建build.sh,编辑内容如下:

---------------------------------------分割线----------------------------------------------------

[html]  view plain  copy
  1. <span style="font-size:18px">#!/bin/sh   
  2. ./configure  --host=arm-linux \   
  3.                  --with-kernel-support \  
  4.                  --prefix=/home/eastmoon/rootfs \  
  5. --target=arm-linux \  
  6. --disable-nls</span>  


---------------------------------------分割线----------------------------------------------------

设置下build.sh的权限后,

./build.sh 配置好以后,

修改gas/Makefile,WARN_CFLAGS中去掉-Werror

因为有些机器是64位的,编译的.a在oprofile中链接会有问题。所以,这时候

vim config.status

修改$[“CFLAGS”]=”-g–O2” 为 $[“CFLAGS”]=”-g–O2  -fPIC”.

 

接着

make下,

再make install就ok了。

然后可以看到在/home/eastmoon/rootfs中就会有相关的.so等库了。

 


三、oprofile移植

下载源码:http://oprofile.sourceforge.net/download/    oprofile-0.9.9.tar.gz

 

解压缩后,在oprofile-0.9.9当前目录下,新建build.sh,编辑内容如下:

---------------------------------------分割线----------------------------------------------------

[html]  view plain  copy
  1. <span style="font-size:18px">#!/bin/sh   
  2. CFLGAS+=-I//home/eastmoon/rootfs/include \  
  3. CXXFLGAS+=-I//home/eastmoon/rootfs/include\  
  4. LDFLGAS+=-L//home/eastmoon/rootfs/lib \  
  5. ./configure  --host=arm-linux \   
  6.                  --with-kernel-support \  
  7.                  --prefix=/home/eastmoon/rootfs \  
  8. --target=arm-linux \  
  9.  </span>  

---------------------------------------分割线----------------------------------------------------

设置下build.sh的权限后,

./build.sh 配置好以后,

接着

make下,

再make install就ok了。

然后可以看到在/home/eastmoon/rootfs中就会有相关的应用程序了。

 

四、应用

编译的时候有指定的OPROFILE_EVENTS_DIR的路径。所以,在使用的时候

export  OPROFILE_EVENTS_DIR=’/home/oprofile’

 

       把/home/eastmoon/rootfs/share/oprofile下的文件,拷贝到/home/oprofile下。

 

最后,就可以使用oprofile了

opcontrol –setup–no-vmlinux

        opcontrol –init

        opcontrol –start  //启动

        opcontrol –dump  //采集

    opcontrol –stop   //停止

    opreport     //查看

    opreport –l   //查看,包括函数

具体的其他功能可以百度查看,这里只是移植和简单的应用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值