获取Android的一个Valgrind的。用`valgrind`的问题寻找`MEMCHECK臂,linux` [英] Getting a valgrind for android. Problems with `valgrind`'s looking for `memcheck-arm-linux`

查看:260
本文介绍了获取Android的一个Valgrind的。用`valgrind`的问题寻找`MEMCHECK臂,linux`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文正在开发通过 SH 系统调用使用几个静态可执行二进制代码的Andr​​oid应用程序。其中一个二进制文件的使用时,三星Galaxy S4手机(但不使用仿真器或索尼Xperia手机TIPO时),所以下面的 http://embetek.blogspot.com.es/2011/10/valgrind-for-arm.html 几个自定义修改(CFLAGS =' - 静态-march =的ARMv7-A),最终得到一个

Context is developing an android app that uses several static executable binaries through sh syscall. One of the binaries eventually segfaults when using a samsung galaxy s4 cellphone (but not when using emulator or a Sony Xperia tipo cellphone), so following http://embetek.blogspot.com.es/2011/10/valgrind-for-arm.html with several custom modifications (CFLAGS='-static -march=armv7-a') end up getting a

$ ldd valgrind
not a dynamic executable
$ file valgrind
valgrind: ELF 32-bit LSB executable, ARM, version 1 (SYSV),
statically linked, for GNU/Linux 3.2.0, not stripped.

加载的目标手机(Android的版本4.2.2内核3.4 ...),(context.getFilesDir()+文件分割符+的valgrind)。canExecute() $ C>返回false。

Loaded on the target phone (versioned android 4.2.2 kernel 3.4...), (context.getFilesDir() + File.separator + "valgrind").canExecute() returns false.

运行上海-c PATH ...的valgrind 告诉的valgrind:不能执行:权限被拒绝和状态126上的退出。

Running sh -c PATH...valgrind tells valgrind: can't execute: Permission denied and status 126 on exit.

模拟器似乎运​​行2.6内核...所以有亚行外壳并执行的valgrind 有告诉相似的东西,但更多装饰讲述内核版本不匹配:从字面上

Emulator seems to run kernel 2.6... so there adb shell and executing valgrind there told something similar but more decorated telling about a kernel version mismatch: literally

llostatic/files/valgrind                                                       <
FATAL: kernel too old
Segmentation fault

(context.getFilesDir()+文件分割符+的valgrind)。setExecute() <击>是由不明原因已失败,因为失败它并不是在所有的完成(在做类似 dumpAssetToFile(Valgrind的){/ *许多事情燮$ p $这里pssed。* / argument.setExecute()/ *如果做错了没有文件目录路径问* /}

(context.getFilesDir() + File.separator + "valgrind").setExecute() is failing by unknown reason was failing because it wasn't being done at all (was doing something like dumpAssetToFile("valgrind"){/* Many things suppressed here. */ argument.setExecute() /* Done wrong without a files dir path ask */}.

现在的valgrind 似乎是正确的,要求一个 MEMCHECK臂Linux的,但我并没有使得它承认它。

Now valgrind seems to be correctly calling for a memcheck-arm-linux, but I didn't yet made it recognize it.

即使SH -c \\PATH = $ PATH的执行:+ getFilesDir()+文件分割符++ getFilesDir()+文件分割符+busybox的的valgrind strace的 - v+ BINARY ++ ARGS ++2 - ;&放大器; 1 \\并没有做什么,我的期望。这不正是这算什么得到执行,但我这个输出到标准错误。

Even a execution of "sh -c \"PATH=$PATH:" + getFilesDir() + File.separator + " " + getFilesDir() + File.separator + "busybox strace valgrind -v " + BINARY + " " + ARGS + " " + "2>&1\"" does not do what I expect. It is not exactly this what gets executed, but am outputting this to stderr.

W/System.err(6918): commandStrArr[0]: sh
W/System.err(6918): commandStrArr[1]: -c
W/System.err(6918): commandStrArr[2]: PATH=$PATH:/data/data/NAMESPACE/files/ busy
box strace valgrind -v /data/data/NAMESPACE/files/BINARY ARGS 2>&1
W/System.err(6918): strace: applet not found
W/System.err(6918): valgrind: failed to start tool 'memcheck' for platform 'arm-l
inux': No such file or directory
W/System.err(6918): Error: BINARY exited with status nonzero (1).

我这个读是 busybox的无法模拟 strace的,但作为一个命令和args无论如何都会执行从它认为是的 ARGS [2] 的到的参数视图的结尾。 的valgrind 加载良好,但无法找到 MEMCHECK 。这里的一个背景是 MEMCHECK臂Linux的是资产'的 ED 的静态二进制与合作的valgrind busybox的。我能不能够确保 MEMCHECK臂Linux的的到底是什么要求,如果我不能得到一个系统调用跟踪。恕我直言的这将是一个疑难杂症的不是 MEMCHECK臂Linux的什么的valgrind 呼吁这里'MEMCHECK'的平台臂Linux的。

My read of this is that busybox can not emulate strace, but is anyway executing as a command and args from what it thinks as args[2] to the end of its view of arguments. valgrind is loading well but can not find memcheck. A context here is memcheck-arm-linux is an asset' ed static binary dumped to the files directory together with those working valgrind and busybox. I can not be able to be sure memcheck-arm-linux is exactly what is asking for, if I can't get a system calls trace. IMHO It would be a gotcha not being memcheck-arm-linux what valgrind is calling here "'memcheck' for platform 'arm-linux'".

其他信息(抽象cwds讨好):

Additional info (abstract the cwds please):

$ file busybox
busybox: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for
 GNU/Linux 3.2.0, stripped
[...]
$ file coregrind/valgrind
coregrind/valgrind: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically 
linked, for GNU/Linux 3.2.0, not stripped
[...]
$ file memcheck/memcheck-arm-linux
memcheck/memcheck-arm-linux: ELF 32-bit LSB executable, ARM, version 1 (SYSV), st
atically linked, not stripped

有谁知道为什么的valgrind 似乎没有被接受 MEMCHECK臂Linux的为有效 MEMCHECK 工具?

Does anybody see why valgrind seems no to be accepting memcheck-arm-linux as a valid memcheck tool?

推荐答案

最后 strace的给解决了这个问题。

Finally strace gave solution to this problem.

不要还是有痕迹,但 strace的说的很清楚,的valgrind 打电话 MEMCHECK臂Linux的带错了路。期待从主机编译器的机器,显然没有在目标机器上存在的一些路径。

Don't still have the trace, but strace told very clearly that valgrind was calling memcheck-arm-linux with a wrong path. Was looking some path from the host compiler machine that obviously don't exist in the target machine.

这暗示了的valgrind 打造命令应该从

That hinted the valgrind build command should be changed from

$ export CROSS_COMPILE=arm-unknown-linux-gnueabi- && export CC=${CROSS_COMPILE}gc
c && export CPP=${CROSS_COMPILE}cpp && export CXX=${CROSS_COMPILE}g++ && export L
D=${CROSS_COMPILE}ld && export AR=${CROSS_COMPILE}ar && ./configure --target=arm-
unknown-linux-gnueabi --host=armv7a-none-linux-gnueabi --prefix=$HOME/valgrind-3.
6.1/construct CFLAGS='-static -march=armv7-a' -verbose 2>&1 && make clean && make
 -j4 && make

$ export CROSS_COMPILE=arm-unknown-linux-gnueabi- && export CC=${CROSS_COMPILE}gc
c && export CPP=${CROSS_COMPILE}cpp && export CXX=${CROSS_COMPILE}g++ && export L
D=${CROSS_COMPILE}ld && export AR=${CROSS_COMPILE}ar && ./configure --target=arm-
unknown-linux-gnueabi --host=armv7a-none-linux-gnueabi --prefix=/data/data/$APK_P
ACKAGE_NAMESPACE/files CFLAGS='-static -march=armv7-a' -verbose 2>&1 && make clea
n && make -j4 && make

您可以看到 - preFIX 现在正确设置为存在于目标设备,而且是有效的路径。硬codeD。脏。丑陋。但是,现在正在工作。

You can see --prefix is now correctly set to a path that exists in the target device, and is valid. Hardcoded. Dirty. Ugly. But is working now.

这篇关于获取Android的一个Valgrind的。用`valgrind`的问题寻找`MEMCHECK臂,linux`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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