如何开始的valgrind一个Android应用程序应用程序、valgrind、Android

2023-09-12 04:08:13 作者:梦里梦着梦不醒的梦、

我一直在寻找的最后一个星期试图找到这个问题的答案。

I've been searching for the last week trying to find an answer to this question.

我如何开始的valgrind一个Android应用程序?我知道我可以开始用AM命令的应用程序,但它启动的应用程序,并退出。

How do I start an Android app with valgrind? I know I can start an app with the 'am' command, but it starts the app and exits.

我在写一个使用NDK的本机C code的应用程序,我需要检查其可疑的内存错误。

I'm writing an app that uses the NDK for native C code, and I need to check it for suspected memory errors.

编辑:

我学到多一点。你可以包装的应用程序,一个shell脚本。

I've learned a little more. You can "wrap" an app with a shell script.

下面的shell脚本我使用:

Here's the shell script I'm using:

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

而这里的setprop:

And here's setprop:

adb shell setprop wrap.com.starlon.froyvisuals "logwrapper valgrind"

这就是我如何启动应用程序:

And here's how I start the app:

adb shell am start -n com.starlon.froyvisuals/.FroyVisuals

我不认为这是正确的,因为我不知道在哪里,在shell脚本适合,我没有看到在logcat中任何东西。任何提示?

I don't think this is right, because I'm not sure where the shell script fits in and I'm not seeing anything in logcat. Any hints?

EDIT2: 呵呵shell脚本显示为setprop命令上面。因此,

Oh the shell script is indicated with "setprop" command above. So

adb shell setprop wrap.com.starlon.froyvisuals "logwrapper /data/local/val.sh"

我还没有看到任何的logcat中。

I'm still not seeing anything in logcat.

推荐答案

您可以尝试先清除logcat的

You can try to clear the logcat first

prompt# adb logcat -c
prompt# adb logcat

您应该可以看到日志进来,一旦你触发了您的应用程序。

You should be able to see the logs coming in once you triggered your application.

am start -a android.intent.action.MAIN -n com.example.hellojni/.HelloJni

我有问题,我的shell脚本,我用这个来代替。

I had problems with my shell script and i used this instead.

adb shell setprop wrap.com.example.hellojni "logwrapper /data/local/Inst/bin/valgrind"

您应该可以的valgrind后右路传中,在参数

You should be able to pass in the parameter right after valgrind