title: Getting a valgrind for android. Problems with `valgrind`'s looking for `memcheck-arm-linux`
body: <p>Context is developing an android app that uses several static executable binaries through <code>sh</code> 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 <a href="http://embetek.blogspot.com.es/2011/10/valgrind-for-arm.html" rel="nofollow">http://embetek.blogspot.com.es/2011/10/valgrind-for-arm.html</a> with several custom modifications (CFLAGS='-static -march=armv7-a') end up getting a</p>
  
  <pre><code>$ 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.
  </code></pre>
  
  <p>Loaded on the target phone (versioned android 4.2.2 kernel 3.4...), <code>(context.getFilesDir() + File.separator + "valgrind").canExecute()</code> returns false.</p>
  
  <p>Running <code>sh -c PATH...valgrind</code> tells <code>valgrind: can't execute: Permission denied</code> and status 126 on exit.</p>
  
  <p>Emulator seems to run kernel 2.6... so there <code>adb shell</code> and executing <code>valgrind</code> there told something similar but more decorated telling about a kernel version mismatch: literally</p>
  
  <pre><code>llostatic/files/valgrind                                                       &lt;
  FATAL: kernel too old
  Segmentation fault
  </code></pre>
  
  <p><code>(context.getFilesDir() + File.separator + "valgrind").setExecute()</code> <strike>is failing by unknown reason</strike> was failing because it wasn't being done at all (was doing something like <code>dumpAssetToFile("valgrind"){/* Many things suppressed here. */ argument.setExecute() /* Done wrong without a files dir path ask */}</code>.</p>
  
  <p>Now <code>valgrind</code> seems to be correctly calling for a <code>memcheck-arm-linux</code>, but I didn't yet made it recognize it.</p>
  
  <p>Even a execution of <code>"sh -c \"PATH=$PATH:" + getFilesDir() + File.separator +  " " + getFilesDir() + File.separator + "busybox strace valgrind -v " + BINARY + " " + ARGS + " " + "2&gt;&amp;1\""</code> does not do what I expect. It is not exactly this what gets executed, but am outputting this to stderr.</p>
  
  <pre><code>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&gt;&amp;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).
  </code></pre>
  
  <p>My read of this is that <code>busybox</code> can not emulate <code>strace</code>, but is anyway executing as a command and args from what it thinks as <em>args[2]</em> to the end of its view of arguments. <code>valgrind</code> is loading well but can not find <code>memcheck</code>. A context here is <code>memcheck-arm-linux</code> is an asset' <em>ed</em> static binary dumped to the files directory together with those working <code>valgrind</code> and <code>busybox</code>. I can not be able to be sure <code>memcheck-arm-linux</code> is exactly what is asking for, if I can't get a system calls trace. IMHO <em>It would be a gotcha</em> not being <code>memcheck-arm-linux</code> what <code>valgrind</code> is calling here "'memcheck' for platform 'arm-linux'".</p>
  
  <p>Additional info (abstract the cwds please):</p>
  
  <pre><code>$ 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
  </code></pre>
  
  <p><strong>Does anybody see why <code>valgrind</code> seems no to be accepting <code>memcheck-arm-linux</code> as a valid <code>memcheck</code> tool?</strong></p>