Building and running valgrind on Android

Note to self post for when the next time I need it, or: how to build and run your application under valgrind on Android (tested on 4.4).

Preqres: Patience, Android NDK, rooted device, linux host (VM, or whatever).

Step 1:
Make sure you are running dalvik as your runtime. art might be new and flashy, but it does not play well with valgrind in my experience.

Step 2:
Get valgrind sources from valgrind.org or do

Unpack it if you downloaded the source tarball, obviously.

Step 3:

in the svn checkout (skip it if you downloaded the tarball)

Step 4:

or where ever you have your Android NDK setup.

Step 5:
Configuring and building, replace arm-linux-androideabi-4.6 with your toolchain and linux-x86 with your platform.

Step 6:
Installing on your device:
If you have an engineering build or install adbd insecure, just do:

and then jump to the next step!

Otherwise, just remount /system read-write:

Step 7:
Putting it on your device

If you built your own Android image to get symbols for everything, put them in place as well:

Step 8:
Get these two shell scripts and optionally the suppression file for valgrind. Make sure your apps package name is less than 26 chars long, because setprop fails to set properties longer than 31 chars (26 + ‘wrap.’).

Done! Now just watch adb logcat and marvel at the wonders of valgrind. :)

Credits: building and running

Comments are closed.