oprofile 使用之一(build)

 最近公司作新项目,在老的板子上跑着感觉异常的沉重,arm1176运行我们的程序有点不堪重负,于是产生了强烈的优化想法。

    老大给机会让我研究一下gprof && oprofile 一开始搞gprof的过程稍候会补上。

    后来参加了一次hello gcc 的活动,那里那些作编译器的推荐使用oprofile,因为gprof只是针对应用层的分析,而oprofile是通过硬件(CPU)本身支持的性能计数器进行的性能分析,贯穿内核到用户应用程序,很有参考价值。

    开始了漫长的编译过程

    1.下载oprofile-0.9.7进行交叉编译

       ./configure --host=arm-linux --prefix=/opt/oprofile.test/ --with-kernel-support

       提示

       checking for poptGetContext in -lpopt... no
       configure: error: popt library not found

       popt 库找不到

       

     2.下载popt-1.7进行交叉编译

      ./configure --prefix=/opt/linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/usr/ --host=arm-linux --disable-nls && make && make install

       继续编译oprofile-0.9.7

        ./configure --host=arm-linux --prefix=/opt/oprofile.test/ --with-kernel-support

       提示

       checking for bfd_fdopenr in -lbfd... no
       configure: error: bfd library not found

        bfd库找不到

     3.下载binutils-2.19.1进行编译

      ./configure --host=arm-linux --prefix=/opt/binutils.test/ --enable-install-libbfd --enable-shared && make && make install

      继续编译oprofile-0.9.7

      ./configure --host=arm-linux --prefix=/opt/oprofile.test/ --with-kernel-support  --with-binutils=/opt/binutils.test/

      4. 会出现如下警告

Warning: QT version 3 was requested but not found. No GUI will be built.
Warning: The user account 'oprofile:oprofile' does not exist on the system.
         To profile JITed code, this special user account must exist.
         Please add the following user and group:
             user name : 'oprofile'
             group name: 'oprofile'
         The 'oprofile' group must be the default group for the 'oprofile' user.

        执行 useradd oprofile

                 groupadd oprofile

       5. 继续编译oprofile-0.9.7

      ./configure --host=arm-linux --prefix=/opt/oprofile.test/ --with-kernel-support  --with-binutils=/opt/binutils.test/ && make && make install

        编译成功

       6.确保内核选项中有oprofile的支持,要弄成模块,方便以后的加载驱动参数更改

       7.确保你本地的nfs server 已经导出

        /opt/oprofile.test/ 

        /opt/binutils.test/

       8.配置开发板运行环境

        mkdir -p /opt/binutils.test/ /opt/oprofile.test/ /opt/gtk/
        mount -o nolock 192.168.50.54:/opt/binutils.test/ /opt/binutils.test/
        mount -o nolock 192.168.50.54:/opt/oprofile.test/ /opt/oprofile.test/
        mount -o nolock 192.168.50.54:/opt/gtk /opt/gtk
        export PATH=/opt/oprofile.test/bin/:$PATH
        export LD_LIBRARY_PATH=/opt/binutils/lib:/opt/oprofile/lib/oprofile.test/:$LD_LIBRARY_PATH

       9.拷贝POPT动态库到/opt/binutils.test/lib/下

          cp -fra /opt/linux/x86-arm/gcc-3.4.3-uClibc-0.9.28/usr/lib/libpopt.* /opt/binutils.test/lib/

          因为我为了编译方便把libpopt直接放到编译器目录下面了,但是这样会导致LD_LIBRARY_PATH无法找到改库提示如下错误

         /opt/oprofile.test/bin/ophelp: can't load library 'libpopt.so.0' 

        10.牛刀小试

         opcontrol --init
         Kernel support not available, missing opcontrol --init as root ?

        出现上述错误,没关系,删除以前的/etc/mtab执行如下命令

         ln -s /proc/mounts /etc/mtab

          opcontrol --init  这次执行成功

        说明我们环境已经配置完毕。

         交叉编译OK。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值