12

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.

Community
  • 1
  • 1
Matthew Mitchell
  • 5,293
  • 14
  • 70
  • 122

1 Answers1

8

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

Community
  • 1
  • 1
Alex Bitek
  • 6,529
  • 5
  • 47
  • 77
  • and what happens in the cases that we want to run it on an application that does not belong to us? anyway to workaround the 31 chars limitation – Paschalis Feb 24 '16 at 16:34
  • On my machine it produces another error: `usage: setprop ` I guess this is because token `"logwrapper /data/local/valgrind"`. But when I escape this space character, it still does not work. – Aleksei Petrenko Jul 11 '16 at 18:25