gperftools交叉编译运行

1,下载gperftools

2,编译gperftools

./autogen.sh

./configure --with-sysroot=/opt/xxx/sysroots --build=x86_64-xxx-linux --host=aarch64-xxx-linux --prefix=/opt/xxx/sysroots/x86_64-xxx-linux/usr/

make

make install

3,编译代码

官方文档:

If you want the CPU profiler, heap profiler, and heap leak-checker to
all be available for your application, you can do:
   gcc -o myapp ... -lprofiler -ltcmalloc

However, if you have a reason to use the static versions of the
library, this two-library linking won't work:
   gcc -o myapp ... /usr/lib/libprofiler.a /usr/lib/libtcmalloc.a  # errors!

Instead, use the special libtcmalloc_and_profiler library, which we
make for just this purpose:
   gcc -o myapp ... /usr/lib/libtcmalloc_and_profiler.a

另外,heap profiler和heap leak-checker可以不用重新编译代码,按照如下官方文档说明操作即可:

You can also use LD_PRELOAD to heap-check an executable that you
didn't compile.

4,把gperftools的.so以及.a(位置/opt/xxx/sysroots/x86_64-xxx-linux/usr/)拷贝到盒子上/usr/lib中

5,把编译好的程序放入盒子中

6,执行程序

CPU PROFILER

CPUPROFILE=/tmp/prof.out <path/to/binary> [binary args]

HEAP CHECKER

HEAPCHECK=1 <path/to/binary> [binary args]

7,使用pprof解析生成的文件

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值