下载最新源码
1、配置configure脚本,由于是在linux服务器上编译的,/目录下没有权限,因此将prefix指定为自己目录下安装,
这样的话,一定要记得valgrind在手机放置的目录,必须和prefix指定的目录一致。
配置脚本build.sh见下,路径记得要改成自己的。
export NDKROOT=~/android-ndk-r8b export HWKIND=generic #export VALGRIND_LIB=/data/local/valgrind/lib/valgrind/ # Set up toolchain paths. # # For ARM export AR=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ar export LD=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-ld export CC=$NDKROOT/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc # for ARM CPPFLAGS="--sysroot=$NDKROOT/platforms/android-14/arch-arm -DANDROID_HARDWARE_$HWKIND" \ CFLAGS="--sysroot=$NDKROOT/platforms/android-14/arch-arm" \ ./configure --prefix=/home/myname/valgrind-3.9.0/valgrind-3.9.0/Inst \ --host=armv7-unknown-linux --target=armv7-linux-androideabi \ --with-tmpdir=/sdcard # note: on android emulator, android-14 platform was also tested and works. # It is not clear what this platform nr really is.
2、配置、编译、安装
./build.sh
make
make install
3、在prefix指定的目录下可以看到安装好的Inst,将其拷贝到手机侧,切记:一定要和prefix定义的路径一致,对应我现在定义的prefix,需要将Inst拷贝到
/home/myname/valgrind-3.9.0/valgrind-3.9.0/。
4、测试valgrind。进入手机侧/home/myname/valgrind-3.9.0/valgrind-3.9.0/Inst/bin,执行./valgrind ls,提示没有权限,ls -l可以看出根组其他用户都没有执行权限,chmod 777 valgrind;进入/home/myname/valgrind-3.9.0/valgrind-3.9.0/Inst/lib/valgrind,chmod 777 *,将所有文件权限修改。再执行./valgrind ls,出现如下画面。一切OK,开始使用valgrind吧。
==7624== Memcheck, a memory error detector ==7624== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. ==7624== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info ==7624== Command: ls ==7624== valgrind ==7624== ==7624== HEAP SUMMARY: ==7624== in use at exit: 0 bytes in 0 blocks ==7624== total heap usage: 5 allocs, 5 frees, 6,289 bytes allocated ==7624== ==7624== All heap blocks were freed -- no leaks are possible ==7624== ==7624== For counts of detected and suppressed errors, rerun with: -v ==7624== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
注意事项:
1、手机侧放置valgrind的路径一定要和prefix定义一致,否则会出现如下错误
failed to start tool 'memcheck' for platform 'arm-linux': No such file or directory"。参见参考1。
2、如果使用cygwin模拟linux环境编译,configure中的kernel=`uname -r`检测内核时返回的是cgywin的版本号,
需要参考2进行修改。
参考:
1、http://blog.csdn.net/foruok/article/details/20701991
2、https://webcache.googleusercontent.com/search?q=cache:6hb5lNVRBDcJ:eatmyrandom.blogspot.com/2010/10/valgrind-and-failed-to-start-tool.html+&cd=1&hl=en&ct=clnk&gl=hk