How do I run valgrind with an Android app?

社会主义新天地 提交于 2019-12-20 18:34:13

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/19011887/how-do-i-run-valgrind-with-an-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!