Cannot start Java Android program using Valgrind

I am trying to run a Java program under Valgring like this (in adb shell):

valgrind am start -a android.intent.action.MAIN -n com.me.myapp/.MainActivity 

I get:

 ==2362== Memcheck, a memory error detector ==2362== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al. ==2362== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info ==2362== Command: am ==2362== /system/bin/sh: am: No such file or directory 
+11
android android-ndk valgrind
Nov 23
source share
3 answers

You need to create a script, let's call it start_valgrind.sh

 #!/system/bin/sh PACKAGE="com.example.hellojni" # Callgrind tool #VGPARAMS='-v --error-limit=no --trace-children=yes --log-file=/sdcard/valgrind.log.%p --tool=callgrind --callgrind-out-file=/sdcard/callgrind.out.%p' # Memcheck tool VGPARAMS='-v --error-limit=no --trace-children=yes --log-file=/sdcard/valgrind.log.%p --tool=memcheck --leak-check=full --show-reachable=yes' export TMPDIR=/data/data/$PACKAGE exec /data/local/Inst/bin/valgrind $VGPARAMS $* 

which must be copied to the device.

Once you have a script in the start_valgrind.sh file somewhere in the local file system, you can simply use the script below (lets call it bootstrap_valgrind.sh ) to do all the work (copy the start_valgrind.sh script to the phone, start it , launches your application through Valgrind).

 #!/usr/bin/env bash PACKAGE="com.example.hellojni" adb push start_valgrind.sh /data/local/ adb shell chmod 777 /data/local/start_valgrind.sh adb root adb shell setprop wrap.$PACKAGE "logwrapper /data/local/start_valgrind.sh" echo "wrap.$PACKAGE: $(adb shell getprop wrap.$PACKAGE)" adb shell am force-stop $PACKAGE adb shell am start -a android.intent.action.MAIN -n $PACKAGE/.HelloJni adb logcat -c adb logcat exit 0 

WARNING. Make sure that the property name specified with setprop ie (wrap.com.yourcompany.yourapp) is less than 31 characters long.
Otherwise, you will receive the error "cannot set the property" because you CANNOT set the property name with a length greater than 31, which is the number of maximum allowed characters in the property name.
Also, the value of the property must be <= 91 characters: https://stackoverflow.com/a/166778/




To create Valgrind for Android (ARM), see my script from here: https://stackoverflow.com/a/464829/

+17
Oct 07 '13 at
source share

1) I used the following script to create an Android Inst folder valgrind build does not work

2) The error I made was that I did not allow writing permission for all folders, while the MemCheck tool is under lib / valgrind.

My Finds Copy all the folders in the generated instance (bin, share, inclide, lib) Folder in / data / local / Inst Go through each folder and set the resolution to CHMOD 777 *

I ran into a problem How the Memcheck Tool was not found for arm-linux if I did not copy all the folders Folders 1 / Inst if you do not set permission to chmod 777 for all folders in Hirearchy

+1
Apr 19 '14 at 3:24
source share

I get permission errors for the start_valgrind.sh script.

Can I run it in an application that interacts with another Android library that actually makes JNI calls? And do I need to interact with him to see the results?

I'm sorry this is not an answer, but I do not have enough reputation to comment on bitek's answer.

0
Jan 23 '19 at 12:27
source share



All Articles