Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run valgrind with an Android app?

I've installed valgrind for android and I can confirm it is working as I tried running ls with it, and it works fine.

But how do I execute an android app with a native component I would like to debug? I looked at this question: How to start an android app with valgrind but I have no idea how to follow it. How do you wrap an app in a shell script? What is "wrap." followed by the package name supposed to be?

I tried doing this with com.matthewmitchell.wakeifyplus being my application package:

setprop wrap.com.matthewmitchell.wakeifyplus "logwrapper /data/local/valgrind" 

but it says "could not set property". What am I supposed to do? I can't find any step by step guide that works. I did try this (I don't even know what setprop does):

setprop com.matthewmitchell.wakeifyplus "logwrapper /data/local/valgrind" 

With /data/local/valgrind being a shell script with execute permissions which is:

#!/system/bin/sh
VGPARAMS='--error-limit=no'
export TMPDIR=/data/data/com.matthewmitchell.wakeifyplus
exec /data/local/Inst/bin/valgrind $VGPARAMS $*

But when I run the app with:

am start -a android.intent.action.MAIN -n com.matthewmitchell.wakeifyplus/.MainActivity 

valgrind does not show up in logcat, even after clearing it.

like image 415
Matthew Mitchell Avatar asked Sep 25 '13 17:09

Matthew Mitchell


1 Answers

You get the error "could not set property" because you CANNOT set a property name with a length greater than 31, which is the number maximum allowed characters in the property name: https://stackoverflow.com/a/5068818/313113

Try to reduce the package name length to less than or equal 31 characters when you set the property with adb shell setprop.
And use a bash script to simply things.
For further details see my answer here: https://stackoverflow.com/a/19235439/313113

like image 165
Alex Bitek Avatar answered Nov 04 '22 01:11

Alex Bitek