valgrind简介以及在ARM上交叉编译运行【转】

时间:2022-12-30 08:39:50

转自:https://blog.csdn.net/dengcanjun6/article/details/54958359

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/dengcanjun6/article/details/54958359
Valgrind是一款用于内存调试、内存泄漏检测以及性能分析的软件开发工具。
Valgrind的最初作者是Julian Seward,他于2006年由于在开发Valgrind上的工作获得了第二届Google-O’Reilly开源代码奖。
Valgrind遵守GNU通用公共许可证条款,是一款*软件。

关于valgrind的具体使用网上有很多。这里记录一下在ARM上的交叉编译及使用过程中的一些问题。

1、下载及编译准备

wget http://valgrind.org/downloads/valgrind-3.12.0.tar.bz2

tar xvf valgrind-3.12.0.tar.bz2

cd valgrind-3.12.0

apt-get install automake

./autogen.s

2、交叉编译
修改configure: armv7*) 改成 armv7*|arm)

./configure --host=arm-linux CC=arm-none-linux-gnueabi-gcc CPP=arm-none-linux-gnueabi-cpp CXX=arm-none-linux-gnueabi-g++ --prefix=/home/dcj/valgrind

make

make install

/home/dcj/valgrind目录下生成好的valgrind,包括4个文件夹:bin,include,lib,share

–prefix=/home/dcj/valgrind指定的目录要与开发板上放置的目录一致,不然运行valgrind时可能会出现“valgrind: failed to start tool ‘memcheck’ for platform ‘arm-linux’: No such file or directory”错误。

3、运行
把安装目录下的文件valgrind目录通过winscp复制到目标板上的/home/dcj/目录下,修改bin目录下的执行权限。

chrom -R +x /home/dcj/valgrind/bin/

此时运行bin目录下的valgrind会出现如下错误提示:

valgrind: failed to start tool 'memcheck' for platform 'arm-linux': Permission denied

解决方法:

export VALGRIND_LIB="/home/dcj/valgrind/lib/valgrind"
chmod -R +x /home/dcj/valgrind/lib/valgrind/

就可以对ARM上的代码进行内存泄露等检查。
---------------------
作者:dengcanjun6
来源:CSDN
原文:https://blog.csdn.net/dengcanjun6/article/details/54958359
版权声明:本文为博主原创文章,转载请附上博文链接!