Valgrind cannot execute memcheck tool on Android O

2019-06-26 06:52发布

I've compiled Valgrind for ARM using this with minor alterations.

After installing on a phone with the method specified, I get the following error:

# /data/local/Inst/bin/valgrind
valgrind: failed to start tool 'memcheck' for platform 'arm-linux': Permission denied

On closer investigation, it is possible to find what it's trying to do:

# /data/local/Inst/bin/valgrind -d -v                         
--25068:1:debuglog DebugLog system started by Stage 1, level 1 logging requested
--25068:1:launcher no tool requested, defaulting to 'memcheck'
--25068:1:launcher no client specified, defaulting platform to 'arm-linux'
--25068:1:launcher launching /data/local/Inst/lib/valgrind/memcheck-arm-linux
valgrind: failed to start tool 'memcheck' for platform 'arm-linux': Permission denied

However, the executable is there and has the right permissions:

# ls -l /data/local/Inst/lib/valgrind/memcheck-arm-linux
-rwxrwxrwx root     root      9261240 2013-10-28 17:00 memcheck-arm-linux

Furthermore, trying to execute it yields no problem, which eliminates dynamic linking problems as well:

/data/local/Inst/lib/valgrind/memcheck-arm-linux              
valgrind: You cannot run '/data/local/Inst/lib/valgrind/memcheck-arm-linux' directly.
valgrind: You should use $prefix/bin/valgrind.

At this point, I'm mostly out of ideas, any help would be greatly appreciated.

I'm aware of this similar post, but I'm sure (based on the output with "-d") the prefix is right.

Potential clue: this worked a few "ROM"-s before, but unfortunately, this current one is the exact same on which it worked previously, with the exact same Valgrind build.

The minor alterations: since the build was done on a 64 bit system, _64 was appended to toolchain paths where appropriate. I can post the full script, but it should be irrelevant. Famous last words, potentially.

3条回答
爷的心禁止访问
2楼-- · 2019-06-26 07:32

I recently ran into the exact same problem. On my device /data/local/Inst and all of its content is owned by a user named "shell". Strange enough, when I try to execute valgrind with the root user, I get the above-mentioned error, but as soon as I log in with the unprivileged user, I can run valgrind without any issues.

From the information you posted, I take, that you installed valgrind as the root user, and I assume you also executed it as root.

So here are the steps that got it working for me:

  • /data/local/Inst is owned by an unprivileged user
  • Install valgrind with the same unprivileged user
  • Again, execute valgrind with the same user

Hope this helps.

查看更多
\"骚年 ilove
3楼-- · 2019-06-26 07:34

If you use Valgrind on Android, at least there are three way to solve the problem. (You must root your Android phone first.)

On your PC

cmd
adb shell
$su
#cp /data/local/Inst/bin/valgrind /system/bin/

Note: Remember to chmod. For example chmod 777 valgrind.

On your Android phone

Install an app "Root Explorer". Copy valgrind to /system/bin/ with the app.

Write a shell script

This is a example: Can't run a Java Android program with Valgrind

Chinese Comments: 我本人曾不止一次英语考试不及格。写英文回贴真的很不舒服。不过自我学Android开始,就从http://stackoverflow.com 这里得到过很多帮助。 知恩回报是中华民族的传统美德,所以 就硬首头皮写了这个E文回贴。

查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-06-26 07:41

Normally, this indicates some files (either lib or config files) lack the permission to you. Most likelihood is when you install the Valgrind with root, the umask may exclude the rx for others. It is easy to solve this by adding the rx permission for others:

find /usr/local -name "*valgrind*" -exec chmod o+rxt {} \;

查看更多
登录 后发表回答