Created
July 29, 2016 09:59
-
-
Save handong1587/9312ae0f4e69a4a3f47b66ddb71c7661 to your computer and use it in GitHub Desktop.
Some scripts to run valgrind. Forked from https://gist.github.com/frals/7775c413a52763d80de3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## step 4 | |
export NDKROOT=D:/Software/AndroidDev/android-ndk-r10e | |
export SDKROOT=D:/Software/AndroidDev/android-sdk-windows/platform-tools | |
## step 5 | |
export HWKIND=generic | |
## 32bit | |
export TOOLCHAIN=$NDKROOT/toolchains/arm-linux-androideabi-4.9/prebuilt/windows/bin/arm-linux-androideabi | |
export AR=$TOOLCHAIN-ar.exe | |
export LD=$TOOLCHAIN-ld.exe | |
export CC=$TOOLCHAIN-gcc.exe | |
echo $NDKROOT | |
echo $TOOLCHAIN | |
echo $CC | |
## 32bit | |
CPPFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm" \ | |
CFLAGS="--sysroot=$NDKROOT/platforms/android-3/arch-arm" \ | |
./configure --prefix=/data/local/Inst \ | |
--host=armv7-unknown-linux \ | |
--target=armv7-unknown-linux \ | |
--with-tmpdir=/sdcard | |
echo $TOOLCHAIN | |
make -j4 | |
make -j4 install DESTDIR=`pwd`/Inst | |
## step 6 | |
$SDKROOT/adb.exe root | |
$SDKROOT/adb.exe remount | |
## step 7 | |
$SDKROOT/adb.exe shell "mkdir /data/local/Inst" | |
## could be optimised... probably | |
$SDKROOT/adb.exe push Inst / | |
$SDKROOT/adb.exe shell "chmod 777 /data/local/Inst" | |
$SDKROOT/adb.exe shell "chmod 777 /data/local/Inst/bin/valgrind" | |
$SDKROOT/adb.exe shell "chmod -R 777 /data/local/Inst/lib/valgrind" | |
$SDKROOT/adb.exe shell "export VALGRIND_LIB=/data/local/Inst/lib/valgrind" | |
$SDKROOT/adb.exe shell "echo $VALGRIND_LIB" | |
$SDKROOT/adb.exe shell "/data/local/Inst/bin/valgrind --version" | |
## step 8 | |
export VALGRAIND_RUN_HOME=D:/Git/run_valgrind | |
chmod 777 $VALGRAIND_RUN_HOME/run_valgrind.sh | |
$VALGRAIND_RUN_HOME/run_valgrind.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## step 4 | |
export NDKROOT=D:/Software/AndroidDev/android-ndk-r10e | |
export SDKROOT=D:/Software/AndroidDev/android-sdk-windows/platform-tools | |
## step 5 | |
export HWKIND=generic | |
## 64bit | |
export TOOLCHAIN=$NDKROOT/toolchains/aarch64-linux-android-4.9/prebuilt/windows/bin/aarch64-linux-android | |
export AR=$TOOLCHAIN-ar.exe | |
export LD=$TOOLCHAIN-ld.exe | |
export CC=$TOOLCHAIN-gcc.exe | |
echo $NDKROOT | |
echo $TOOLCHAIN | |
echo $CC | |
## 64bit | |
CPPFLAGS="--sysroot=$NDKROOT/platforms/android-21/arch-arm64" \ | |
CFLAGS="--sysroot=$NDKROOT/platforms/android-21/arch-arm64" \ | |
LIBS="-L$NDKROOT/platforms/android-21/arch-arm64/usr/lib" \ | |
./configure --prefix=/data/local/Inst \ | |
--host=aarch64-unknown-linux \ | |
--target=aarch64-unknown-linux \ | |
--with-tmpdir=/sdcard | |
echo $TOOLCHAIN | |
make -j4 | |
make -j4 install DESTDIR=`pwd`/Inst | |
## step 6 | |
$SDKROOT/adb.exe root | |
$SDKROOT/adb.exe remount | |
## step 7 | |
$SDKROOT/adb.exe shell "mkdir /data/local/Inst" | |
## could be optimised... probably | |
$SDKROOT/adb.exe push Inst / | |
$SDKROOT/adb.exe shell "chmod 777 /data/local/Inst" | |
$SDKROOT/adb.exe shell "chmod 777 /data/local/Inst/bin/valgrind" | |
$SDKROOT/adb.exe shell "chmod -R 777 /data/local/Inst/lib/valgrind" | |
$SDKROOT/adb.exe shell "export VALGRIND_LIB=/data/local/Inst/lib/valgrind" | |
$SDKROOT/adb.exe shell "echo $VALGRIND_LIB" | |
$SDKROOT/adb.exe shell "/data/local/Inst/bin/valgrind --version" | |
## step 8 | |
export VALGRAIND_RUN_HOME=D:/Git/run_valgrind | |
chmod 777 $VALGRAIND_RUN_HOME/run_valgrind.sh | |
$VALGRAIND_RUN_HOME/run_valgrind.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
export SDKROOT=D:/Software/AndroidDev/android-sdk-windows/platform-tools | |
export VALGRAIND_RUN_HOME=D:/Git/run_valgrind | |
PACKAGE="com.example.MyApp" | |
$SDKROOT/adb.exe push $VALGRAIND_RUN_HOME/start_valgrind.sh /data/local/ | |
$SDKROOT/adb.exe push $VALGRAIND_RUN_HOME/valgrind.supp /data/local/ | |
$SDKROOT/adb.exe shell chmod 777 /data/local/start_valgrind.sh | |
$SDKROOT/adb.exe root | |
$SDKROOT/adb.exe shell setprop wrap.$PACKAGE "logwrapper /data/local/start_valgrind.sh" | |
# use this to disable valgrind for this pkg | |
# adb shell setprop wrap.se.frals.example "" | |
echo "wrap.$PACKAGE: $($SDKROOT/adb.exe shell getprop wrap.$PACKAGE)" | |
$SDKROOT/adb.exe shell am force-stop $PACKAGE | |
$SDKROOT/adb.exe shell am start -a android.intent.action.MAIN -n com.example.MyApp/.MyAppMain | |
$SDKROOT/adb.exe logcat -> D:/valgrind_log.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/system/bin/sh | |
PACKAGE="com.example.MyApp" | |
VGPARAMS='--error-limit=no --trace-children=yes --tool=memcheck --sigill-diagnostics=no --extra-debuginfo-path=/sdcard/system/symbols/ --suppressions=/data/local/valgrind.supp' | |
export TMPDIR=/data/data/$PACKAGE | |
echo "Executing through valgrind: $VGPARAMS $*" | |
exec /data/local/Inst/bin/valgrind $VGPARAMS $* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
ignore-ashmem | |
Memcheck:Value4 | |
obj:/dev/ashmem | |
} | |
{ | |
ignore-ashmem-cond | |
Memcheck:Cond | |
obj:/dev/ashmem | |
} | |
{ | |
ignore-libcrypto | |
Memcheck:Value4 | |
obj:/system/lib/libcrypto.so | |
} | |
### default generated by valgrind | |
# Suppressions for Android's libc (bionic) and probably other | |
# stuff too. | |
# this is a real bug in the Android stack -- this routine really does read and write below sp. | |
{ | |
sha1_block_data_order-reads-below-sp | |
Memcheck:Addr4 | |
fun:sha1_block_data_order | |
} | |
# This is a false error, and it's reported in the wrong place. Memcheck misinterprets | |
# a restore path in dvmPlatformInvoke: "ldmdb r4, {r4, r5, r6, r7, r8, r9, sp, pc}" | |
# because it breaks this up into non-atomic IR. This non atomic IR restores PC | |
# first, then SP, and then r4-r9; the latter of which happen after (from Memcheck's | |
# point of view) the assignment to SP, hence constitute a read below SP (depends | |
# which way SP moved, I guess). Worse, because these happen after the restore to SP, | |
# the errors are reported in the callers of this function, not here :-( | |
# General bogusness all round, but I don't see how to handle it any better. Hence | |
# hide all the callers; fortunately there appear to be not many. | |
# | |
{ | |
dvmPlatformInvoke-misinterpretation-1 | |
Memcheck:Addr4 | |
fun:dvmCallJNIMethod_virtualNoRef | |
} | |
{ | |
dvmPlatformInvoke-misinterpretation-2 | |
Memcheck:Addr4 | |
fun:dvmCallJNIMethod_staticNoRef | |
} | |
{ | |
dvmPlatformInvoke-misinterpretation-3 | |
Memcheck:Addr4 | |
fun:dvmCallJNIMethod_general | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment