Chinaunix首页 | 论坛 | 博客
  • 博客访问: 485787
  • 博文数量: 135
  • 博客积分: 3010
  • 博客等级: 中校
  • 技术积分: 905
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-24 19:31
文章分类

全部博文(135)

文章存档

2010年(135)

我的朋友

分类: LINUX

2010-02-07 10:42:20

2、Oprofile内核模块的编译

修改内核配置如下:

General setup --->

[*] Profiling support (EXPERIMENTAL)

[ ] Activate markers

OProfile system profiling (EXPERIMENTAL)

编译完成后在arc/mips/oprofile/ 文件夹下生成Oprofile.ko内核模块。也可以直接把Oprofile编译进内核。

的交叉编译(以mips为例)

编译前准备

1、              编译Oprofile需要如下软件包:

popt-1.7.tar.gz

binutils-2.19.tar.bz2

oprofile-0.9.5.tar.gz

2、              安装嵌入式编译工具链

编译popt

tar xfz popt-1.7.tar.gz

cd popt-1.7/

export CC=mipsel-linux-gnu-gcc

export CXX=mipsel-linux-gnu-g++

export CFLAGS=-static

export CXXFLAGS=-static

export CPPFLAGS=-static

./configure --with-kernel-support --host=mipsel-linux-gnu --prefix=/tmp/poptimg (popt安装目录)

make

make install

(拷贝库文件到编译器目录下)

编译binutils

tar jxf binutils-2.19.tar.bz2

cd binutils-2.19/

export CC=mipsel-linux-gnu-gcc

export CXX=mipsel-linux-gnu-g++

export CFLAGS=-static

export CXXFLAGS=-static

export CPPFLAGS=-static

./configure --host=mipsel-linux-gnu --prefix=/tmp/binutilsimg (设置安装目录)

make

make install

编译Oprofile

tar zxf oprofile-0.9.5.tar.gz

cd oprofile-0.9.5/

export CC=mipsel-linux-gnu-gcc

export CXX=mipsel-linux-gnu-g++

export CFLAGS=-static

export CXXFLAGS=-static

export CPPFLAGS=-static

./configure --with-kernel-support --host=mipsel-linux-gnu --build=i686-pc-linux-gnu --with-binutils=/tmp/binutilsimg --prefix=/mnt/oprofile/(此安装路径必须和嵌入式平台上的安装路径一致)

make

make install

安装Oprofile

修改文件系统

1、在文件系统中加入Oprofile内核模块,复制arch/mips/oprofile/oprofile.ko 至文件系统 /lib\modules/2.6.27.28/ 文件夹下,同时修改modules.dep(若没有请创建),增加一行oprofile.ko: (直接编译进内核的不需这一步)

2、在文件系统\etc下创建符号链接 ln –sf /proc/mounts mtab 。同时确保文件系统中存在如下共享库:libdl.so.2libstdc++.so.6libm.so.6libgcc_s.so.1libc.so.6

3、由于在分析内核时使用到objdump,复制binutilsimg/bin/objdump 至文件系统的/bin文件下。(objdump在符号分析时用到

配置

1、如使用busybox,由于busybox不支持wc –m 选项,修改opcontrol 1242行的 wc –m  wc –c

2、由于Oprofile编译时采用的是绝对路径,在编译时设置的安装路径必须与嵌入式平台上运行时的路径一致。可以复制/mnt/oprofile/文件夹至SD卡或者nfs文件夹内,然后挂载到嵌入式设备的/mnt目录下。

3、增加PATH路径 PATH=$ PATH:/mnt/oprofile/bin

阅读(2840) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~