如何使用 valgrind 启动一个安卓应用程序 [英] How to start an android app with valgrind

查看:26
本文介绍了如何使用 valgrind 启动一个安卓应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上周我一直在寻找这个问题的答案.

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 代码的应用,我需要检查它是否存在可疑的内存错误.

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?

哦,上面的setprop"命令指示了 shell 脚本.所以

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

这篇关于如何使用 valgrind 启动一个安卓应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆