how to cross compile valgrind on android platform
2017-02-08 17:33
435 查看
The article is mainly introduce how to crossing compile valgrind and using valgrind to check memory leak for app file and executable file
References:
http://www.itdadao.com/articles/c15a376180p0.html
http://blog.csdn.net/roland_sun/article/details/46049485
https://gist.github.com/mnemonicflow/131eb830a4d74911bf5a
https://sergiolima.wordpress.com/2015/07/07/vallgrind-and-android-working-together/
https://wiki.linaro.org/Platform/Android/UseValgrindOnAndroid
The following cmd must be execute in one line, and there is no “/n”, or there will be make error.
for check app, export $APP=”org.droidtv.helloworld”
for check exe, exprot $BIN=”helloworld”
And then run the start_vgl.sh
setprop wrap.app “logwrapper /data/logcal/valgrind/start_vgl.sh”
kill the app process pid, and then it will generate memory-leak info to /sdcard/valgrind.log.%p.
maybe you can download the valgrind tool for checking memory-leak, but i am not sure it can run on your platform.
https://code.csdn.net/gonghuixue/philips_tv_apps/tree/master/valgrind.tar
References:
http://www.itdadao.com/articles/c15a376180p0.html
http://blog.csdn.net/roland_sun/article/details/46049485
https://gist.github.com/mnemonicflow/131eb830a4d74911bf5a
https://sergiolima.wordpress.com/2015/07/07/vallgrind-and-android-working-together/
https://wiki.linaro.org/Platform/Android/UseValgrindOnAndroid
1: valgrind tool introduce
http://valgrind.org, and we can get lots of valgrind infomation from the website2: set env val according to your arm-linux-gcc
Before compile valgrind file, we can reference the README.android, which is mainly introduce how to compile valgrind step by step.2.1: download valgrind
valgrind-3.12.0.tar.bz2.2: download android ndk
2.3: set val
export NDKROOT=/home/huixue.gong/tools/arm-linux/android-ndk-r6 export HWKIND=generic 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
The following cmd must be execute in one line, and there is no “/n”, or there will be make error.
CPPFLAGS="--sysroot=$NDKROOT/platforms/android-9/arch-arm" CFLAGS="--sysroot=$NDKROOT/platforms/android-9/arch-arm" ./configure --prefix=/data/local/valgrind --host=armv7-unknown-linux --target=armv7-unknown-linux --with-tmpdir=/sdcard
make -j4 make -j4 install DESTDIR='pwd'/valgrind
2.4: copy the output folder valgrind to your platform.
cp valgrind /data/local/3: using valgrind to check memory-leak check
before check memory-leak, you can use the following start_vgl.sh, and set export VALGRIND_LIB=/data/local/valgrind/lib/valgrind.if [ "$APP" ]; then echo "check $APP memory leak" VGPARAMS='-v --error-limit=no --trace-children=yes --log-file=/sdcard/valgrind.log.%p --tool=memcheck --leak-check=full --show-reachable=yes' export TMPDIR=/data/data/$APP exec /data/local/valgrind/bin/valgrind $VGPARAMS $* # am force-stop app # setprop wrap.app "logwrapper /data/logcal/valgrind/start_vgl.sh" else echo "APP is null, check BIN file" # check bin memory leak if [ "$BIN" ]; then echo "check $BIN memory leak" BIN_CHECK='--tool=memcheck --leak-check=yes --show-reachable=yes' exec /data/local/valgrind/bin/valgrind $BIN_CHECK $BIN /data/local/valgrind/bin_leak.txt 2>&1 echo "store the output file to app_leak.txt" else echo "BIN is null, please input bin file" fi fi
for check app, export $APP=”org.droidtv.helloworld”
for check exe, exprot $BIN=”helloworld”
And then run the start_vgl.sh
3.1: check app memory leak
stop your checking app: am force-stop appsetprop wrap.app “logwrapper /data/logcal/valgrind/start_vgl.sh”
kill the app process pid, and then it will generate memory-leak info to /sdcard/valgrind.log.%p.
if [ "$APP" ]; then echo "check $APP memory leak" VGPARAMS='-v --error-limit=no --trace-children=yes --log-file=/sdcard/valgrind.log.%p --tool=memcheck --leak-check=full --show-reachable=yes' export TMPDIR=/data/data/$APP exec /data/local/valgrind/bin/valgrind $VGPARAMS $* else echo "APP is null, check BIN file" fi
3.2: check executable file
if [ "$BIN" ]; then echo "check $BIN memory leak" BIN_CHECK='--tool=memcheck --leak-check=yes --show-reachable=yes' exec /data/local/valgrind/bin/valgrind $BIN_CHECK $BIN /data/local/valgrind/bin_leak.txt 2>&1 echo "store the output file to app_leak.txt" else echo "BIN is null, please input bin file" fi
maybe you can download the valgrind tool for checking memory-leak, but i am not sure it can run on your platform.
https://code.csdn.net/gonghuixue/philips_tv_apps/tree/master/valgrind.tar
相关文章推荐
- How to compile Android 2.3 on Ubuntu 10.04 32bit
- How to Cross Compile the Bash shell for Android 1.5
- How to Compile Android on Ubuntu (12.04)
- How To Use RMAN CONVERT DATABASE on Source Host for Cross Platform Migration
- How to compile Android 2.3 on Ubuntu 10.04 32bit
- How to generate unique key on Android platform
- How to Cross Compile the Bash shell for Android 1.5 (为Android平台编译Bash shell)
- how to compile android2.3 on ubuntu14
- How to compile Android 2.3 on Ubuntu 10.04 32bit
- How to Compile Android on Ubuntu (12.04)
- How to Compile Android on Ubuntu (12.04)
- How to Compile Android on Ubuntu (12.04)
- How to compile Android 2.3 on Ubuntu 10.04 32bit
- How to support scroll bar in webkit of android platform
- Android 4.4.3 bionic can't compile c code on LFS 6.6 platform
- How to cross-compile OpenSSL for ARM
- How to run test cases on android-ndk
- How to add buttons (Home, Back, Menu) on Android statusBar
- 关于mplayer on Windows how to compile 资料
- In Android how to display one view as overlay on top of another view?