和菜鸟一起学linux之linux性能分析工具oprofile移植

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6



一、内核编译选项

make menuconfig

General setup--->
[*] Profiling support
<*> OProfile system profiling





二、popt移植

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

 

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

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

#!/bin/sh 
./configure --host=arm-linux \
--prefix=/home/eastmoon/rootfs \
--target=arm-linux




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

设置下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,编辑内容如下:

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

#!/bin/sh 
./configure --host=arm-linux \
--with-kernel-support \
--prefix=/home/eastmoon/rootfs \
--target=arm-linux \
--disable-nls


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

设置下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,编辑内容如下:

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

#!/bin/sh 
CFLGAS+=-I//home/eastmoon/rootfs/include \
CXXFLGAS+=-I//home/eastmoon/rootfs/include\
LDFLGAS+=-L//home/eastmoon/rootfs/lib \
./configure --host=arm-linux \
--with-kernel-support \
--prefix=/home/eastmoon/rootfs \
--target=arm-linux \




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

设置下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   //查看,包括函数

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

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
标签: linux

“和菜鸟一起学linux之linux性能分析工具oprofile移植” 的相关文章