Skip to content

Instantly share code, notes, and snippets.

@frals
Created July 2, 2014 18:19
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save frals/7775c413a52763d80de3 to your computer and use it in GitHub Desktop.
Save frals/7775c413a52763d80de3 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
adb push start_valgrind.sh /data/local/
adb push valgrind.supp /data/local/
adb shell chmod 777 /data/local/start_valgrind.sh
adb shell setprop wrap.se.frals.example "logwrapper /data/local/start_valgrind.sh"
# use this to disable valgrind for this pkg
# adb shell setprop wrap.se.frals.example ""
adb shell am force-stop se.frals.example
adb shell am start -a android.intent.action.MAIN -n se.frals.example/.activities.MainActivity
adb logcat -c
#!/system/bin/sh
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/se.frals.example
echo "Executing through valgrind: $VGPARAMS $*"
exec /data/local/Inst/bin/valgrind $VGPARAMS $*
{
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